Files
wowdecomp/Engine/Source/Tempest/CAaBox.cpp
T
SatyandClaude Opus 5.5 597201ec6a Gx pass 1: device-free leaves, C3Vector ctors, Gx enums into Gx/Types.h
- CGxFormat(), CGxMatrixStack() + Identity, CGxLight(), CGxApiLight::operator= (moved to CGxLight.h),
  CGxPool::Invalidate/Discard, CGxGammaRamp::Set
- Gx.h/Gx.cpp: GxApiSupported, GxVertexSize, GxVertexAttribOffset, GxCalcTexelStrideInBytes + tables
- C3Vector() zero-inits and C3Vector(x, y, z) exists (inline only); CAaBox/C3Ray/CFrustum/Intersect rely on it
- EGxApi/EGxTexFormat/EGxVertexBufferFormat moved to Engine/Source/Gx/Types.h
- struct/class forward declaration mismatches fixed in CGxDevice.h and CGxPool.h

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
2026-09-24 22:05:14 +02:00

160 lines
3.6 KiB
C++

#include <cstdint>
#include "Engine/Source/Tempest/C44Matrix.h"
#include "Engine/Source/Tempest/CAaBox.h"
// VERIFY: 1bea3dca manual
// OFFSET: 0x0070BCF0
bool CAaBox::IsValid() const {
return this->t.x > this->b.x && this->t.y > this->b.y && this->t.z > this->b.z;
}
// VERIFY: 040a12ae manual
// OFFSET: 0x0070BD20
bool CAaBox::IsEmpty() const {
return this->t.x <= this->b.x || this->t.y <= this->b.y || this->t.z <= this->b.z;
}
// VERIFY: 0f1d380e manual
// OFFSET: 0x007150D0
CAaBox operator|(const CAaBox& l, const CAaBox& r) {
C3Vector t = C3Vector::Max(l.t, r.t);
C3Vector b = C3Vector::Min(l.b, r.b);
CAaBox result;
result.b = b;
result.t = t;
return result;
}
// VERIFY: 724307ab manual
// OFFSET: 0x00715130
CAaBox CAaBox::operator|=(const CAaBox& box) {
*this = *this | box;
return *this;
}
// VERIFY: 417ec50b manual
// OFFSET: 0x0075B5B0
bool CAaBox::ContainsPoint(const C3Vector& point) const {
return this->b.x <= point.x && this->b.y <= point.y && this->b.z <= point.z && this->t.x >= point.x && this->t.y >= point.y && this->t.z >= point.z;
}
// VERIFY: 195b7d66 manual
// OFFSET: 0x0078F370
bool CAaBox::Intersects(const CAaBox& box) const {
return this->t.x >= box.b.x && this->t.y >= box.b.y && this->t.z >= box.b.z && this->b.x <= box.t.x && this->b.y <= box.t.y && this->b.z <= box.t.z;
}
// VERIFY: 77b1dfb8 auto
// OFFSET: 0x0078F480
CAaBox::CAaBox(const C3Vector& b, const C3Vector& t) {
this->b = b;
this->t = t;
}
// VERIFY: 4ac67881 manual
// OFFSET: 0x007AE2B0
bool CAaBox::IntersectsXY(const CAaBox& box) const {
return this->t.x >= box.b.x && this->t.y >= box.b.y && this->b.x <= box.t.x && this->b.y <= box.t.y;
}
// VERIFY: 2895a20e manual
// OFFSET: 0x00984860
CAaBox CAaBox::Transform(const CAaBox& box, const C44Matrix& m) {
CAaBox result;
result.b.x = m.d0;
result.b.y = m.d1;
result.b.z = m.d2;
result.t.x = m.d0;
result.t.y = m.d1;
result.t.z = m.d2;
const float* rows = &m.a0;
for (uint32_t i = 0; i < 3; i++) {
float* lo = &result.b.x + i;
float* hi = &result.t.x + i;
float e = box.b.x * rows[0 + i];
float f = rows[0 + i] * box.t.x;
if (f <= e) {
*lo = f + *lo;
} else {
*lo = e + *lo;
e = f;
}
*hi = e + *hi;
e = box.b.y * rows[4 + i];
f = box.t.y * rows[4 + i];
if (f <= e) {
*lo = f + *lo;
} else {
*lo = e + *lo;
e = f;
}
*hi = e + *hi;
e = rows[8 + i] * box.b.z;
f = rows[8 + i] * box.t.z;
if (f <= e) {
*lo = f + *lo;
} else {
*lo = e + *lo;
e = f;
}
*hi = e + *hi;
}
return result;
}
// VERIFY: d22b3ba3 manual
// OFFSET: 0x00984930
CAaBox CAaBox::Bounding(const C3Vector* points, uint32_t count) {
CAaBox result;
if (!count) {
return result;
}
result.b = points[0];
result.t = points[0];
for (uint32_t i = 1; i < count; i++) {
const C3Vector& point = points[i];
if (result.b.x > point.x) {
result.b.x = point.x;
}
if (result.b.y > point.y) {
result.b.y = point.y;
}
if (result.b.z > point.z) {
result.b.z = point.z;
}
if (result.t.x < point.x) {
result.t.x = point.x;
}
if (result.t.y < point.y) {
result.t.y = point.y;
}
if (result.t.z < point.z) {
result.t.z = point.z;
}
}
return result;
}