Files
wowdecomp/Engine/Source/Tempest/C3Vector.cpp
T
SatyandClaude Opus 5.5 860511ea4d Gxu: port the font and light TUs
GxuFontMain.cpp (0x6BCD60-0x6BF370), GxuFontUtil.cpp, GxuFontFont.cpp,
GxuFontFace.cpp, GxuFontString.cpp, GxuFontMiscClasses.cpp,
GxuFontTextureCache.cpp and IGxuFontGlyph.cpp, named after the 12340 and
Mac 13682 source file strings; CGxFont moves from Gx to Gxu.
GxuLight.cpp (0x6BB510-0x6BCD60): the light grid behind the GxuLight*
function-pointer table at 0xAD9834.

Gxu links FreeType 2.0.1. Shared additions: GxBufDestroy, GxFormatColor,
CGxVertexPC/PCT, CMath fint_n/fuint_pi/CeilToInt64, C3Vector::SquaredMag,
HASHKEY_DWORD and the template instances in stpl.h.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
2026-09-27 00:15:42 +02:00

200 lines
4.5 KiB
C++

#include <cmath>
#include "Engine/Source/Tempest/C3Vector.h"
#include "Engine/Source/Tempest/C4Vector.h"
#include "Engine/Source/Tempest/CImVector.h"
// VERIFY: 237e1aa1 auto
// OFFSET: 0x00407990
C3Vector operator+(const C3Vector& l, const C3Vector& r) {
C3Vector result;
result.x = l.x + r.x;
result.y = l.y + r.y;
result.z = l.z + r.z;
return result;
}
// VERIFY: 1e8771a4 manual
// OFFSET: 0x00408260
void C3Vector::Zero() {
this->x = 0.0f;
this->y = 0.0f;
this->z = 0.0f;
}
// VERIFY: a755af8a auto
// OFFSET: 0x00482970
C3Vector& C3Vector::operator+=(const C3Vector& v) {
this->x = v.x + this->x;
this->y = v.y + this->y;
this->z = v.z + this->z;
return *this;
}
// VERIFY: a9b58487 auto
// OFFSET: 0x004829A0
C3Vector operator-(const C3Vector& l, const C3Vector& r) {
C3Vector result;
result.x = l.x - r.x;
result.y = l.y - r.y;
result.z = l.z - r.z;
return result;
}
// VERIFY: 023d5589 manual
// OFFSET: 0x004BF500
bool operator==(const C3Vector& l, const C3Vector& r) {
return r.x == l.x && r.y == l.y && r.z == l.z;
}
// VERIFY: 935caed1 manual
// OFFSET: 0x004BF540
bool operator!=(const C3Vector& l, const C3Vector& r) {
return r.x != l.x || r.y != l.y || r.z != l.z;
}
// VERIFY: c262d6dc auto
// OFFSET: 0x004C1D20
C3Vector C3Vector::operator-() const {
C3Vector result;
result.x = -this->x;
result.y = -this->y;
result.z = -this->z;
return result;
}
// VERIFY: 681282c6 manual
// OFFSET: 0x004C3420
void C3Vector::Normalize() {
float scale = 1.0f / sqrt(this->z * this->z + this->y * this->y + this->x * this->x);
this->x = this->x * scale;
this->y = this->y * scale;
this->z = scale * this->z;
}
// VERIFY: a70c3daa auto
// OFFSET: 0x004C35A0
C3Vector& C3Vector::operator*=(float s) {
this->x = this->x * s;
this->y = this->y * s;
this->z = s * this->z;
return *this;
}
// VERIFY: 2eb2846f auto
// OFFSET: 0x004C35D0
C3Vector& C3Vector::operator/=(float s) {
float scale = 1.0f / s;
this->x = this->x * scale;
this->y = scale * this->y;
this->z = scale * this->z;
return *this;
}
// VERIFY: 460f2c58 manual
// OFFSET: 0x004C3600
void C3Vector::NormalizeSafe() {
float length = this->z * this->z + this->y * this->y + this->x * this->x;
if (length > 0.00000023841858f) {
float scale = 1.0f / sqrt(length);
this->x = this->x * scale;
this->y = scale * this->y;
this->z = scale * this->z;
}
}
// VERIFY: 5d5f694d auto
// OFFSET: 0x005FEC70
C3Vector C3Vector::Cross(const C3Vector& a, const C3Vector& b) {
C3Vector result;
result.x = b.z * a.y - a.z * b.y;
result.y = a.z * b.x - b.z * a.x;
result.z = b.y * a.x - b.x * a.y;
return result;
}
// VERIFY: 8d879f2a manual
// OFFSET: 0x00714D10
C3Vector C3Vector::Min(const C3Vector& a, const C3Vector& b) {
C3Vector result;
float z = b.z <= a.z ? b.z : a.z;
float y = b.y <= a.y ? b.y : a.y;
result.x = b.x <= a.x ? b.x : a.x;
result.y = y;
result.z = z;
return result;
}
// VERIFY: 552b0392 manual
// OFFSET: 0x00714D70
C3Vector C3Vector::Max(const C3Vector& a, const C3Vector& b) {
C3Vector result;
float z = b.z >= a.z ? b.z : a.z;
float y = b.y >= a.y ? b.y : a.y;
result.x = b.x >= a.x ? b.x : a.x;
result.y = y;
result.z = z;
return result;
}
// VERIFY: 0c1cd6c4 manual
// OFFSET: 0x00982950
C3Vector::C3Vector(const C4Vector& v) {
this->x = v.x;
this->y = v.y;
this->z = v.z;
}
// VERIFY: 6a482f8d manual
// OFFSET: 0x00982970
C3Vector::C3Vector(const CImVector& color) {
this->x = color.r * 0.0039215689f;
this->y = color.g * 0.0039215689f;
this->z = 0.0039215689f * color.b;
}
// VERIFY: 6cb56de3 manual
// OFFSET: 0x009829B0
C3Vector::EAxis C3Vector::MajorAxis() const {
float y = fabs(this->y);
float x = fabs(this->x);
float z = fabs(this->z);
if (x <= y) {
if (y > z) {
return AXIS_Y;
}
} else if (x > z) {
return AXIS_X;
}
return AXIS_Z;
}
// VERIFY: 8564aa4a manual
// OFFSET: 0x009829F0
C3Vector::EAxis C3Vector::MinorAxis() const {
float y = fabs(this->y);
float x = fabs(this->x);
float z = fabs(this->z);
if (x >= y) {
if (y <= z) {
return AXIS_Y;
}
return AXIS_Z;
}
if (x >= z) {
return AXIS_Z;
}
return AXIS_X;
}
// INLINED
float C3Vector::SquaredMag() const {
return this->y * this->y + this->x * this->x + this->z * this->z;
}