Files
tp/include/SSystem/SComponent/c_xyz.h
T
LagoLunatic 4dc0cd9d09 Debug version now builds OK and all_source compiles (#2343)
* Fix missing arg to JUT_ASSERT

* Fix some MWCC version diff errors

* Compile m_Do_ext, d_demo, actor_mng

* Add VSCode task to quickly switch between versions

* Unlink magLift for debug

* Update the hash of the debug dol

The old cbea5fa... hash here was for the dol generated by the alf2dol.py script, which produces incorrect alignment.

The dol with the new hash can be obtained by using `dtk elf2dol` to convert the debug .alf file to a dol.

The DOL now builds OK.

* Fix all debug REL dtor splits

All RELs now also build OK, meaning `ninja build/ShieldD/ok` now succeeds.

* Add genMessage declarations to all HIO subclasses

* Fixing more compilation errors

* m_Do_mtx 100% on debug

Cannot be linked due to weak function name mangling?

* Improve various matches

* Fix all remaining compilation errors

* Fix new compilation errors from main

* Fix retail regression

* Link f_pc_profile_lst
2025-03-22 18:00:51 -07:00

136 lines
4.0 KiB
C

#ifndef C_XYZ_H
#define C_XYZ_H
#include "dolphin/mtx.h"
#include "math.h"
struct cXyz : Vec {
static const cXyz Zero;
static const cXyz BaseX;
static const cXyz BaseY;
static const cXyz BaseZ;
static const cXyz BaseXY;
static const cXyz BaseXZ;
static const cXyz BaseYZ;
static const cXyz BaseXYZ;
/* 80009184 */ ~cXyz() {}
/* inlined */ cXyz() {}
cXyz(f32 x, f32 y, f32 z) {
this->x = x;
this->y = y;
this->z = z;
}
cXyz(const cXyz& vec) {
this->x = vec.x;
this->y = vec.y;
this->z = vec.z;
}
cXyz(const Vec& vec) {
this->x = vec.x;
this->y = vec.y;
this->z = vec.z;
}
void operator=(const Vec& vec) {
this->x = vec.x;
this->y = vec.y;
this->z = vec.z;
}
/* 80266AE4 */ cXyz operator+(Vec const&) const;
/* 80266B34 */ cXyz operator-(Vec const&) const;
/* 80266B84 */ cXyz operator*(f32) const;
/* 80266BD0 */ cXyz operator*(Vec const&) const;
/* 80266C18 */ cXyz operator/(f32) const;
void operator+=(f32 f) {
x += f;
y += f;
z += f;
}
void operator-=(f32 f) {
x -= f;
y -= f;
z -= f;
}
void operator*=(const Vec& other) {
x *= other.x;
y *= other.y;
z *= other.z;
}
void operator-=(const Vec& other) { VECSubtract(this, &other, this); }
cXyz* operator+=(const Vec& other) {
VECAdd(this, &other, this);
return this;
}
void operator*=(f32 scale) { VECScale(this, this, scale); }
void operator/=(f32 scale) { VECScale(this, this, 1.0f / scale); }
/* 80266C6C */ cXyz getCrossProduct(Vec const&) const;
/* 80266CBC */ cXyz outprod(Vec const&) const;
/* 80266CE4 */ cXyz norm() const;
/* 80266D30 */ cXyz normZP() const;
/* 80266DC4 */ cXyz normZC() const;
/* 80266EF4 */ cXyz normalize();
/* 80266F48 */ cXyz normalizeZP();
/* 80266FDC */ bool normalizeRS();
/* 8026702C */ bool operator==(Vec const&) const;
/* 8026706C */ bool operator!=(Vec const&) const;
/* 802670AC */ bool isZero() const;
/* 80267128 */ s16 atan2sX_Z() const;
/* 80267150 */ s16 atan2sY_XZ() const;
void set(f32 pX, f32 pY, f32 pZ) {
x = pX;
y = pY;
z = pZ;
}
void set(const Vec& other) {
x = other.x;
y = other.y;
z = other.z;
}
f32 getXDiff(const Vec* other) const { return x - other->x; }
f32 getYDiff(const Vec* other) const { return y - other->y; }
f32 getZDiff(const Vec* other) const { return z - other->z; }
void setall(f32 f) { set(f, f, f); }
void zero() { set(0.0f, 0.0f, 0.0f); }
f32 getSquareMag() const { return VECSquareMag(this); }
f32 getSquareDistance(const Vec& other) const { return VECSquareDistance(this, &other); }
static f32 getNearZeroValue() { return 8e-11f; }
bool isNearZeroSquare() const { return (this->getSquareMag() < getNearZeroValue()); }
bool isNearZeroSquare(const cXyz& other) const { return (PSVECSquareMag(&other) < getNearZeroValue()); }
f32 abs2() const { return this->getSquareMag(); }
f32 abs2(const Vec& other) const { return this->getSquareDistance(other); }
f32 abs2XZ() const {
cXyz tmp(this->x, 0, this->z);
return tmp.abs2();
}
f32 abs2XZ(const Vec& other) const {
cXyz tmp(this->x, 0, this->z);
cXyz tmp2(other.x, 0, other.z);
return tmp.abs2(tmp2);
}
f32 abs() const { return sqrtf(this->abs2()); }
f32 abs(const Vec& other) const { return sqrtf(this->abs2(other)); }
f32 absXZ() const { return sqrtf(this->abs2XZ()); }
f32 absXZ(const Vec& other) const { return sqrtf(this->abs2XZ(other)); }
f32 getMagXZ() const { return cXyz(this->x, 0, this->z).getSquareMag(); }
f32 getDotProduct(const Vec& other) const { return PSVECDotProduct(this, &other); }
f32 inprod(const Vec& other) const { return getDotProduct(other); }
f32 inprodXZ(const Vec& other) const { return x * other.x + z * other.z; }
};
#endif /* C_XYZ_H */