1
0
mirror of https://github.com/zeldaret/oot.git synced 2024-09-22 21:35:27 +00:00
oot/src/code/z_path.c

37 lines
772 B
C
Raw Normal View History

#include <ultra64.h>
#include <global.h>
2020-03-23 20:19:24 +00:00
Path* Path_GetByIndex(GlobalContext* globalCtx, s16 index, s16 max) {
Path* path;
if (index != max) {
path = &globalCtx->setupPathList[index];
} else {
path = NULL;
}
return path;
}
2020-03-23 20:19:54 +00:00
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")