mirror of
https://github.com/zeldaret/tww.git
synced 2026-08-21 14:07:29 -04:00
clean up c_xyz to not use fake inlines
This commit is contained in:
@@ -119,6 +119,7 @@ struct cXyz : Vec {
|
||||
static f32 getNearZeroValue() { return 8e-11f; }
|
||||
|
||||
bool isNearZeroSquare() const { return (this->getSquareMag() < getNearZeroValue()); }
|
||||
bool isNearZeroSquare(const cXyz& other) const { return (VECSquareMag(&other) < getNearZeroValue()); }
|
||||
f32 abs2() const { return this->getSquareMag(); }
|
||||
f32 abs2(const Vec& other) const { return this->getSquareDistance(other); }
|
||||
f32 abs2XZ() const {
|
||||
@@ -141,8 +142,6 @@ struct cXyz : Vec {
|
||||
f32 inprodXZ(const Vec& other) const { return x * other.x + z * other.z; }
|
||||
|
||||
// TODO
|
||||
// void inprodXZ(const Vec&) const {}
|
||||
// void isNearZeroSquare(const cXyz&) const {}
|
||||
// void operator*=(const Vec&) {}
|
||||
// void operator/=(f32) {}
|
||||
// void operator=(const cXyz&) {}
|
||||
|
||||
@@ -38,16 +38,12 @@ cXyz cXyz::operator*(f32 scale) const {
|
||||
return cXyz(ret);
|
||||
}
|
||||
|
||||
inline void vecMul(const Vec* src1, const Vec* src2, Vec* dst) {
|
||||
dst->x = src1->x * src2->x;
|
||||
dst->y = src1->y * src2->y;
|
||||
dst->z = src1->z * src2->z;
|
||||
}
|
||||
|
||||
/* 80245760-802457A8 .text __ml__4cXyzCFRC3Vec */
|
||||
cXyz cXyz::operator*(const Vec& vec) const {
|
||||
cXyz ret;
|
||||
vecMul(this, &vec, &ret);
|
||||
ret.x = this->x * vec.x;
|
||||
ret.y = this->y * vec.y;
|
||||
ret.z = this->z * vec.z;
|
||||
return cXyz(ret);
|
||||
}
|
||||
|
||||
@@ -89,16 +85,6 @@ cXyz cXyz::normZP(void) const {
|
||||
return cXyz(vec);
|
||||
}
|
||||
|
||||
inline void normToUpZIfNearZero(Vec& vec) {
|
||||
if (cXyz(vec).isNearZeroSquare()) {
|
||||
vec.x = 0.0f;
|
||||
vec.y = 0.0f;
|
||||
vec.z = 1.0f;
|
||||
const Vec v = {0, 0, 1};
|
||||
vec = v;
|
||||
}
|
||||
}
|
||||
|
||||
/* 802459AC-80245ADC .text normZC__4cXyzCFv */
|
||||
cXyz cXyz::normZC(void) const {
|
||||
Vec outVec;
|
||||
@@ -106,7 +92,12 @@ cXyz cXyz::normZC(void) const {
|
||||
VECNormalize(this, &outVec);
|
||||
} else {
|
||||
outVec = (*this * 1.25f * 1000000.0f).normZP();
|
||||
normToUpZIfNearZero(outVec);
|
||||
if (this->isNearZeroSquare(cXyz(outVec))) {
|
||||
outVec.x = 0.0f;
|
||||
outVec.y = 0.0f;
|
||||
outVec.z = 1.0f;
|
||||
outVec = (Vec){0, 0, 1};
|
||||
}
|
||||
}
|
||||
return outVec;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user