1#include <game/cLib/c_lib.hpp>
2#include <lib/egg/math/eggMath.h>
3#include <lib/revolution/MTX/vec.h>
10 return EGG::Mathf::sqrt(dx * dx + dy * dy + dz * dz);
15void memSet(
void *dst,
int val, ulong size) {
16 memset(dst, val, size);
20 if (*currPos != targetPos) {
22 stepVector = *currPos - targetPos;
23 float distance = PSVECMag(stepVector);
24 if (distance < minStep) {
28 float step = distance * ratio;
31 stepVector *= maxStep / step;
32 }
else if (step < minStep) {
33 stepVector *= minStep / step;
35 *currPos -= stepVector;
42 return calcDistance(*currPos, targetPos);
47 mVec3_c offset = *currentPos - targetPos;
48 float distance = PSVECMag(offset);
49 if (
isZero(distance) || distance <= step) {
50 *currentPos = targetPos;
53 *currentPos -= (step / distance) * offset;
54 }
else if (*currentPos == targetPos) {
61 return cM::atan2s(vec2.x - vec1.x, vec2.z - vec1.z);
A three-dimensional floating point vector.
Provides common utilities.
float addCalcPos(mVec3_c *currPos, const mVec3_c &targetPos, float ratio, float maxStep, float minStep)
Smoothly moves currentPos towards targetPos using proportional scaling.
bool isZero(float val)
Checks if a floating-point value is effectively zero within epsilon tolerance.
void memSet(void *dst, int val, ulong size)
See memset.
bool chasePos(mVec3_c *currentPos, const mVec3_c &targetPos, float step)
Moves currentPos towards targetPos by a fixed step amount.
s16 targetAngleY(const mVec3_c &vec1, const mVec3_c &vec2)
Calculates the yaw (Y-axis) orientation angle from an origin position to a target position.
s16 targetAngleX(const mVec3_c &vec1, const mVec3_c &vec2)
Calculates the pitch (X-axis) orientation angle from an origin position to a target position.
s16 atan2s(float sin, float cos)
Converts a sine and a cosine to an angle in units.