mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-07-29 19:18:58 -07:00
git subrepo clone https://github.com/HarbourMasters/soh.git
subrepo: subdir: "soh" merged: "ba904bbd0" upstream: origin: "https://github.com/HarbourMasters/soh.git" branch: "master" commit: "ba904bbd0" git-subrepo: version: "0.4.1" origin: "???" commit: "???"
This commit is contained in:
parent
0bb0e7b53b
commit
39cc86c260
2466 changed files with 451557 additions and 0 deletions
45
soh/src/code/z_path.c
Normal file
45
soh/src/code/z_path.c
Normal file
|
@ -0,0 +1,45 @@
|
|||
#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->world.pos.x;
|
||||
dz = pointPos->z - actor->world.pos.z;
|
||||
|
||||
*yaw = Math_FAtan2F(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;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue