Decompile fn_19766 (CalculateVectorAngle)

Batch #1612 by eAthena: 0 byte-identical, 1 confirmed by peer review.

- fn_19766 CalculateVectorAngle: logic confirmed by peer review

Reviewed-by: ragnarok-clanker
This commit is contained in:
ragnarok-clanker 2026-10-28 19:44:33 +00:00
commit 9e88189238
2 changed files with 16 additions and 1 deletions

View file

@ -179,6 +179,21 @@ void EffectPrimitiveState::GetColorOverride(unsigned char* red, unsigned char* g
}
// OFFSET: 0x00BAE4B0
// FUNCTION: fn_19766
void __stdcall CalculateVectorAngle(float x, float y, std::int16_t* angle) {
const float length = SquareRoot(x * x + y * y);
const float normalY = y / length;
const float normalX = x / length;
for (std::int16_t index = 0; index <= 180; ++index) {
if (normalX >= ClientCosine(index)) {
*angle = normalY < 0.0f ? 360 - index : index;
return;
}
}
*angle = 180;
}
// OFFSET: 0x00BAE5D0
// FUNCTION: fn_19767

View file

@ -175,7 +175,7 @@ struct EffectPrimitiveObject {
bool AdvanceFrame();
};
void CalculateVectorAngle(float x, float y, std::int16_t* angle);
void __stdcall CalculateVectorAngle(float x, float y, std::int16_t* angle);
static_assert(sizeof(EffectVector3) == 12);
static_assert(sizeof(EffectPrimitiveRecord) == 140);