mirror of
https://github.com/zeldaret/oot.git
synced 2025-01-15 21:07:15 +00:00
fed9ac3e20
* Move binang utility macros out of angle conversion macros block
* `BINANG_TO_DEGF` -> `BINANG_TO_DEG_ALT` (it may even be warranted to name it _approx instead of _alt, unsure)
* Add `BINANG_TO_DEG` (unused by oot) (for completeness)
* `DEGF_TO_BINANG` -> `DEG_TO_BINANG_ALT` (again may even be _approx, or maybe _cam)
* Add `DEG_TO_BINANG` (unused by oot) (for completeness)
* `RADF_TO_BINANG` -> `RAD_TO_BINANG`
* `RADF_TO_DEGF` -> `RAD_TO_DEG`
* Cleanup argument names in angle conversion macros
* Format for angle macros changes
* Run formatter
* Move `DEG_TO_BINANG_ALT`, `BINANG_TO_DEG_ALT` to z64camera.h
* Remove `DEG_TO_BINANG`, `BINANG_TO_DEG`
* Remove `_ALT` from `DEG_TO_BINANG`, `BINANG_TO_DEG`
* Add comment about inaccuracy near `DEG_TO_BINANG`, `BINANG_TO_DEG`
* run formatter
* `CAM_` prefix on `DEG_TO_BINANG`, `BINANG_TO_DEG` macros
* Revert "Remove `DEG_TO_BINANG`, `BINANG_TO_DEG`"
This reverts commit 5321647e5b
.
45 lines
957 B
C
45 lines
957 B
C
#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 = RAD_TO_BINANG(Math_FAtan2F(dx, dz));
|
|
|
|
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;
|
|
}
|
|
}
|