Decompile fn_21015 (CRenderObject::JitterBounds)

Batch #1460 by ragnarok-clanker: 0 byte-identical, 1 confirmed by peer review.

- fn_21015 CRenderObject::JitterBounds: logic confirmed by peer review

Reviewed-by: ragnarok-clanker
This commit is contained in:
ragnarok-clanker 2026-10-28 15:37:50 +00:00
commit 3b469b8970
2 changed files with 29 additions and 0 deletions

View file

@ -12,6 +12,7 @@
#include "Utility/Math/ScalarConversion.h"
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <windows.h>
#include <timeapi.h>
@ -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<CGameMode*>(g_world.ActiveGameMode());
jitter[index] = 400.0f / mode->camera->camera.desiredDistance * static_cast<float>(value - base);
}
output[0] = static_cast<float>(input[1]) + jitter[0];
output[2] = static_cast<float>(input[3]) + jitter[1];
output[1] = static_cast<float>(input[0]) + offset + jitter[2];
output[3] = static_cast<float>(input[2]) + offset + jitter[3];
}

View file

@ -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;