diff options
| author | Roman971 <romanlasnier@hotmail.com> | 2020-03-23 21:19:54 +0100 |
|---|---|---|
| committer | Roman971 <romanlasnier@hotmail.com> | 2020-03-23 21:19:54 +0100 |
| commit | e88ea64835d97a4ead14ec0b8028e1ecff211471 (patch) | |
| tree | 0e59f2f70ecd3851ebca3739003c45e7ba40685c /src/code | |
| parent | a9d4fec1134990b3df70fe82e68013af07927d84 (diff) | |
Decompile Path_OrientAndGetDistSq
Diffstat (limited to 'src/code')
| -rw-r--r-- | src/code/z_path.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/code/z_path.c b/src/code/z_path.c index 011421bd6..d1d81286d 100644 --- a/src/code/z_path.c +++ b/src/code/z_path.c @@ -13,6 +13,24 @@ Path* Path_GetByIndex(GlobalContext* globalCtx, s16 index, s16 max) { return path; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_path/Path_OrientAndGetDistSq.s") +f32 Path_OrientAndGetDistSq(Actor* actor, Path* path, s16 waypoint, s16* yaw) { + f32 dx; + f32 dz; + Vec3s* pointPos; + + if (path == NULL) { + return -1.0; + } + + pointPos = SEGMENTED_TO_VIRTUAL(path->points); + pointPos = &pointPos[waypoint]; + + dx = pointPos->x - actor->posRot.pos.x; + dz = pointPos->z - actor->posRot.pos.z; + + *yaw = Math_atan2f(dx, dz) * (32768 / M_PI); + + return SQ(dx) + SQ(dz); +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_path/Path_CopyLastPoint.s") |
