diff --git a/Source/Contents/Actors/RenderObject.cpp b/Source/Contents/Actors/RenderObject.cpp index d81d4e9f..0022d168 100644 --- a/Source/Contents/Actors/RenderObject.cpp +++ b/Source/Contents/Actors/RenderObject.cpp @@ -12,6 +12,7 @@ #include "Utility/Math/ScalarConversion.h" #include +#include #include #include #include @@ -390,3 +391,30 @@ void CGameActor::Slot21(int) { // FUNCTION: fn_21152 void CGameActor::Slot23(int, int) { } + +// OFFSET: 0x00CAA1F0 +// FUNCTION: fn_21015 +void CRenderObject::JitterBounds(float* output, const int* input, float offset, int spread, int base) { + if ((this->render.flags & 0x2000) == 0) { + return; + } + + float jitter[4]; + for (int index = 0; index < 4; ++index) { + int value = 0; + if (spread != 0) { + const int remainder = rand() % spread; + if (remainder >= 0) { + value = remainder; + } + } + + CGameMode* mode = static_cast(g_world.ActiveGameMode()); + jitter[index] = 400.0f / mode->camera->camera.desiredDistance * static_cast(value - base); + } + + output[0] = static_cast(input[1]) + jitter[0]; + output[2] = static_cast(input[3]) + jitter[1]; + output[1] = static_cast(input[0]) + offset + jitter[2]; + output[3] = static_cast(input[2]) + offset + jitter[3]; +} diff --git a/Source/Contents/Actors/RenderObject.h b/Source/Contents/Actors/RenderObject.h index f7d8e9f5..dc2439db 100644 --- a/Source/Contents/Actors/RenderObject.h +++ b/Source/Contents/Actors/RenderObject.h @@ -34,6 +34,7 @@ public: ); int HoverHeight(); void ScaleByPulse(float& scale) const; + void JitterBounds(float* output, const int* input, float offset, int spread, int base); void ApplySwing(int mode, int& x, int& y, int& outX, int& outY) const; void SetInstantValue(int key, std::int64_t value); std::int64_t GetInstant(int key) const;