Files
wowdecomp/Engine/Source/Tempest/CFrustum.cpp
T
SatyandClaude Opus 5.5 095603ff2b Client bring-up: login, realm list, world auth, character select
- Grunt login ported end to end (SRP6 challenge/proof, version checksum,
  realm list) and tested against a live server: authenticates, connects to
  the world server (auth session with proof-of-work, header crypt), receives
  the character list and shows character select
- Glue: realm list UI, character select (list, models, scripts), character
  create screen + name generator, delete/rename/decline, Enter World up to
  the loading screen; loading screen drawing and progress
- AccountData (times, update, upload/download), BannedAddOns, addon scan and
  addon info, client cache version, tutorial flags
- Shutdown path at login state: world/map/liquid/weather teardown, NetClient,
  ComSat, streaming stop; Logitech LCD no-device path in Ui/UILCD/Windows
- PCRE 5.0 vendored (core stock; chartables and the posix layer from 12340),
  ValidateName
- Fixes: TSGrowableArray::CalcChunkSize clamps to >= 8 (crash on char list),
  CWorldScene liquid renderer allocation, CMapFootprintTexture element ctor,
  pointer render states on x64, CFrustum/CWFrustum layout, M2 draw callback
  arguments, 37 class/struct forward-declaration mismatches
- IDB name sync (1217 names), verify aliases, harness large-element
  instantiation

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

210 lines
5.9 KiB
C++

#include <cstdint>
#include "Engine/Source/Tempest/C44Matrix.h"
#include "Engine/Source/Tempest/CAaBox.h"
#include "Engine/Source/Tempest/CAaSphere.h"
#include "Engine/Source/Tempest/CFrustum.h"
// VERIFY: e0dd73d2 auto
// OFFSET: 0x00983990
void CFrustum::Extents(CAaBox& box) {
box = CAaBox::Bounding(this->corners, 8);
}
// VERIFY: 835d8937 auto
// OFFSET: 0x009839E0
uint32_t CFrustum::Cull(const CAaBox& box) {
const C3Vector* extremes[2] = { &box.t, &box.b };
for (uint32_t i = 0; i < 6; i++) {
const C4Plane& plane = this->planes[i];
const C3Vector* x = extremes[*reinterpret_cast<const uint32_t*>(&plane.n.x) >> 31];
const C3Vector* y = extremes[*reinterpret_cast<const uint32_t*>(&plane.n.y) >> 31];
const C3Vector* z = extremes[*reinterpret_cast<const uint32_t*>(&plane.n.z) >> 31];
if (z->z * plane.n.z + y->y * plane.n.y + x->x * plane.n.x + plane.d < -0.019444443f) {
return 0;
}
}
return 3;
}
// VERIFY: 93cc8ec1 auto
// OFFSET: 0x00983A60
uint32_t CFrustum::CullInv(const CAaBox& box) {
const C3Vector* extremes[2] = { &box.t, &box.b };
for (uint32_t i = 0; i < 6; i++) {
const C4Plane& plane = this->planes[i];
const C3Vector* x = extremes[*reinterpret_cast<const uint32_t*>(&plane.n.x) >> 31];
const C3Vector* y = extremes[*reinterpret_cast<const uint32_t*>(&plane.n.y) >> 31];
const C3Vector* z = extremes[*reinterpret_cast<const uint32_t*>(&plane.n.z) >> 31];
if (z->z * plane.n.z + y->y * plane.n.y + x->x * plane.n.x + plane.d > 0.019444443f) {
return 0;
}
}
return 3;
}
// VERIFY: 2f6339ef manual
// OFFSET: 0x00983AE0
void CFrustum::Translate(const C3Vector& v) {
for (uint32_t i = 0; i < 8; i++) {
this->corners[i] += v;
}
for (uint32_t i = 0; i < 6; i++) {
this->planes[i].d = this->planes[i].d - (this->planes[i].n.z * v.z + this->planes[i].n.y * v.y + v.x * this->planes[i].n.x);
}
this->lookPos += v;
this->lookAt += v;
}
// VERIFY: b3982b68 manual
// OFFSET: 0x00983D20
uint32_t CFrustum::Cull(const CAaSphere& sphere) {
float limit = -sphere.r;
for (uint32_t i = 0; i < 6; i++) {
const C4Plane& plane = this->planes[i];
if (plane.n.x * sphere.c.x + plane.n.z * sphere.c.z + plane.n.y * sphere.c.y + plane.d < limit) {
return 0;
}
}
return 3;
}
// VERIFY: 5fea8dd6 manual
// OFFSET: 0x00983D70
void CFrustum::Cull(const C3Vector& point, uint8_t& outside) {
outside = 0;
for (uint32_t i = 0; i < 6; i++) {
const C4Plane& plane = this->planes[i];
if (plane.n.z * point.z + plane.n.y * point.y + point.x * plane.n.x + plane.d < -0.019444443f) {
outside |= 1 << i;
}
}
}
// VERIFY: ccfad69b manual
// OFFSET: 0x00983E70
void CFrustum::CalcPlanesFromCorners() {
this->planes[0].From3Pos(this->corners[1], this->corners[5], this->corners[6]);
this->planes[1].From3Pos(this->corners[0], this->corners[7], this->corners[4]);
this->planes[2].From3Pos(this->corners[0], this->corners[4], this->corners[5]);
this->planes[3].From3Pos(this->corners[3], this->corners[6], this->corners[7]);
this->planes[4].From3Pos(this->corners[5], this->corners[4], this->corners[6]);
this->planes[5].n.x = -this->planes[4].n.x;
this->planes[5].n.y = -this->planes[4].n.y;
this->planes[5].n.z = -this->planes[4].n.z;
this->planes[5].d = -(this->planes[5].n.z * this->corners[2].z + this->planes[5].n.y * this->corners[2].y + this->planes[5].n.x * this->corners[2].x);
}
// VERIFY: 88718e38 auto
// OFFSET: 0x00983F40
void CFrustum::Transform(const C44Matrix& m) {
for (uint32_t i = 0; i < 8; i++) {
this->corners[i] *= m;
}
this->CalcPlanesFromCorners();
this->lookPos *= m;
this->lookAt *= m;
}
// VERIFY: 75e79820 auto
// OFFSET: 0x00983FB0
uint32_t CFrustum::Cull(const C3Vector& center, float radius) {
CAaSphere sphere;
sphere.c = center;
sphere.r = radius;
return this->Cull(sphere);
}
// VERIFY: 0ece7724 manual
// OFFSET: 0x00601650
CFrustum::CFrustum() {
for (uint32_t i = 0; i < 6; i++) {
this->planes[i].n.x = 0.0f;
this->planes[i].n.y = 0.0f;
this->planes[i].d = 0.0f;
this->planes[i].n.z = 1.0f;
}
for (uint32_t i = 0; i < 8; i++) {
this->corners[i].x = 0.0f;
this->corners[i].y = 0.0f;
this->corners[i].z = 0.0f;
}
this->lookPos.x = 0.0f;
this->lookPos.y = 0.0f;
this->lookPos.z = 0.0f;
this->lookAt.x = 0.0f;
this->lookAt.y = 0.0f;
this->lookAt.z = 0.0f;
this->lookUp.x = 0.0f;
this->lookUp.y = 0.0f;
this->lookUp.z = 0.0f;
}
// VERIFY: 6f48db85 manual
// OFFSET: 0x00983FE0
CFrustum::CFrustum(const C3Vector* corners) {
for (uint32_t i = 0; i < 6; i++) {
this->planes[i].n.x = 0.0f;
this->planes[i].n.y = 0.0f;
this->planes[i].n.z = 1.0f;
this->planes[i].d = 0.0f;
}
for (uint32_t i = 0; i < 8; i++) {
this->corners[i] = corners[i];
}
this->CalcPlanesFromCorners();
}
// VERIFY: 6d9a59ac manual
// OFFSET: 0x00984240
void CFrustum::CalcPlanesFromCorners(const C3Vector* corners) {
for (uint32_t i = 0; i < 8; i++) {
this->corners[i] = corners[i];
}
this->CalcPlanesFromCorners();
}
// VERIFY: 1bd5200d auto
// OFFSET: 0x00790020
CFrustum& CFrustum::operator=(const CFrustum& source) {
if (this != &source) {
for (uint32_t i = 0; i < 6; i++) {
this->planes[i] = source.planes[i];
}
for (uint32_t i = 0; i < 8; i++) {
this->corners[i] = source.corners[i];
}
this->lookPos = source.lookPos;
this->lookAt = source.lookAt;
this->lookUp = source.lookUp;
this->fovy = source.fovy;
this->aspect = source.aspect;
this->minz = source.minz;
this->maxz = source.maxz;
}
return *this;
}