Owner-authorized source migration: 31 helper-only translation units were merged into their callers or existing inline headers; both build manifests updated. Includes the preserved source payload, Lua configuration matching wowdecomp, and exact malloca expansion without diagnostic pragmas. 449 native units compiled locally and 449 staged units compiled by the pinned server toolchain. No previously byte-matched function regressed. Compiler mapping diagnostics remain recorded as needs_cleanup, not accepted or peer-confirmed. Existing independent review records are preserved. README.md is intentionally unchanged.
97 lines
2.4 KiB
C++
97 lines
2.4 KiB
C++
#include "Contents/World/WorldModelView.h"
|
|
#include "Contents/World/WorldSpatialTree.h"
|
|
|
|
#include <bit>
|
|
|
|
namespace {
|
|
// INLINED
|
|
float Horizontal(float x, const float* row) {
|
|
return (x * row[0] + row[1] * 0.0f) + row[2];
|
|
}
|
|
}
|
|
|
|
// OFFSET: 0x00ADADE0
|
|
// FUNCTION: fn_17913
|
|
WorldViewSpatial::WorldViewSpatial() {
|
|
for (auto& normal : this->planes.normals) {
|
|
normal[0] = 0;
|
|
normal[1] = 0;
|
|
normal[2] = 0;
|
|
}
|
|
}
|
|
|
|
// OFFSET: 0x00ADAF20
|
|
// FUNCTION: fn_17914
|
|
WorldViewSpatial::~WorldViewSpatial() = default;
|
|
|
|
// OFFSET: 0x00ADB0D0
|
|
// FUNCTION: fn_17919
|
|
void WorldViewSpatial::Collect(float horizontal, float vertical, const float* matrix, WorldSpatialTree& root) {
|
|
const float negativeX = -horizontal;
|
|
const float negativeY = -vertical;
|
|
|
|
for (unsigned plane = 0; plane < 6; ++plane) {
|
|
for (unsigned axis = 0; axis < 4; ++axis) {
|
|
const float* row = matrix + axis * 3;
|
|
float value;
|
|
|
|
if (plane == 0 || plane == 1) {
|
|
const float x = plane == 0 ? negativeX : horizontal;
|
|
value = Horizontal(x, row);
|
|
|
|
if (axis == 3) {
|
|
value = value + 0.0f;
|
|
}
|
|
} else if (plane == 2 || plane == 3) {
|
|
const float y = plane == 2 ? negativeY : vertical;
|
|
value = (y * row[1] + row[0] * 0.0f) + row[2];
|
|
|
|
if (axis == 3) {
|
|
value = value + 0.0f;
|
|
}
|
|
} else if (plane == 4) {
|
|
value = (row[0] * 0.0f + row[1] * 0.0f) + row[2];
|
|
|
|
if (axis == 3) {
|
|
value = value - 10.0f;
|
|
}
|
|
} else {
|
|
value = (row[0] * 0.0f + row[1] * 0.0f) - row[2] * 1.0f;
|
|
|
|
if (axis == 3) {
|
|
value = value + 1500.0f;
|
|
}
|
|
}
|
|
|
|
this->planes.planes[plane][axis] = value;
|
|
}
|
|
|
|
for (unsigned axis = 0; axis < 3; ++axis) {
|
|
this->planes.normals[plane][axis] = this->planes.planes[plane][axis];
|
|
}
|
|
}
|
|
|
|
this->CollectNode(root, 0, false);
|
|
}
|
|
|
|
// OFFSET: 0x00ADB910
|
|
// FUNCTION: fn_17923
|
|
void WorldViewSpatial::CollectNode(WorldSpatialTree& node, int depth, bool fullyInside) {
|
|
if (depth == 5) {
|
|
(fullyInside ? this->inside : this->clipped).push_back(&node);
|
|
return;
|
|
}
|
|
|
|
for (WorldSpatialTree* child : node.children) {
|
|
if (fullyInside) {
|
|
this->CollectNode(*child, depth + 1, true);
|
|
continue;
|
|
}
|
|
|
|
const int visibility = this->planes.ClassifyAxisAligned(*child);
|
|
|
|
if (visibility != 0) {
|
|
this->CollectNode(*child, depth + 1, visibility == 1);
|
|
}
|
|
}
|
|
}
|