From e88ea64835d97a4ead14ec0b8028e1ecff211471 Mon Sep 17 00:00:00 2001 From: Roman971 Date: Mon, 23 Mar 2020 21:19:54 +0100 Subject: Decompile Path_OrientAndGetDistSq --- src/code/z_path.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src/code') 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") -- cgit v1.2.3