diff options
| author | KrimtonZ <krimtonz@gmail.com> | 2020-03-24 11:56:37 -0500 |
|---|---|---|
| committer | KrimtonZ <krimtonz@gmail.com> | 2020-03-24 11:56:37 -0500 |
| commit | 8bbac143cd9a101b2cdd2c80f3531d5cc104ca8a (patch) | |
| tree | 3b9aae76ff4e5200884f593d2db69254d9709c3f /src/code/z_path.c | |
| parent | ac4a51bf8fdc93221d4ba674351b683d0eedfd9b (diff) | |
| parent | 4eb7f023f348151fb73f4a0850a6f348280d7805 (diff) | |
Merge branch 'master' into skelanime
Diffstat (limited to 'src/code/z_path.c')
| -rw-r--r-- | src/code/z_path.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/code/z_path.c b/src/code/z_path.c new file mode 100644 index 000000000..03dc6d6f6 --- /dev/null +++ b/src/code/z_path.c @@ -0,0 +1,46 @@ +#include <ultra64.h> +#include <global.h> + +Path* Path_GetByIndex(GlobalContext* globalCtx, s16 index, s16 max) { + Path* path; + + if (index != max) { + path = &globalCtx->setupPathList[index]; + } else { + path = NULL; + } + + return path; +} + +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); +} + +void Path_CopyLastPoint(Path* path, Vec3f* dest) { + Vec3s* pointPos; + + if (path != NULL) { + pointPos = &((Vec3s*)SEGMENTED_TO_VIRTUAL(path->points))[path->count - 1]; + + dest->x = pointPos->x; + dest->y = pointPos->y; + dest->z = pointPos->z; + } +} |
