2020-10-03 15:22:44 +00:00
|
|
|
#include "global.h"
|
2020-03-23 20:18:53 +00:00
|
|
|
|
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:18:53 +00:00
|
|
|
|
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];
|
|
|
|
|
2021-01-18 21:04:04 +00:00
|
|
|
dx = pointPos->x - actor->world.pos.x;
|
|
|
|
dz = pointPos->z - actor->world.pos.z;
|
2020-03-23 20:19:54 +00:00
|
|
|
|
2022-04-24 14:23:49 +00:00
|
|
|
*yaw = RAD_TO_BINANG(Math_FAtan2F(dx, dz));
|
2020-03-23 20:19:54 +00:00
|
|
|
|
|
|
|
return SQ(dx) + SQ(dz);
|
|
|
|
}
|
2020-03-23 20:18:53 +00:00
|
|
|
|
2020-03-23 20:20:30 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|