Batch #12484 by cremane: 0 byte-identical, 5 confirmed by peer review. - fn_17921 WorldViewSpatial::ClassifyAxisAligned: logic confirmed by peer review - fn_17922 WorldViewSpatial::ClassifyOriented: logic confirmed by peer review - fn_17930 CView::Render: logic confirmed by peer review - fn_17923 WorldViewSpatial::CollectNode: logic confirmed by peer review - fn_17919 WorldViewSpatial::Collect: logic confirmed by peer review (already on main) Peer-reviewed-by: Yommy, dori, codeplay Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes).
69 lines
1.9 KiB
C++
69 lines
1.9 KiB
C++
#include "Contents/World/WorldModelView.h"
|
|
#include "Contents/World/WorldSpatialTree.h"
|
|
|
|
#include <bit>
|
|
|
|
// 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) {
|
|
float viewPlanes[6][4] = {
|
|
{-horizontal, 0.0f, 1.0f, 0.0f},
|
|
{horizontal, 0.0f, 1.0f, 0.0f},
|
|
{0.0f, -vertical, 1.0f, 0.0f},
|
|
{0.0f, vertical, 1.0f, 0.0f},
|
|
{0.0f, 0.0f, 1.0f, -10.0f},
|
|
{0.0f, 0.0f, -1.0f, 1500.0f},
|
|
};
|
|
|
|
for (int i = 0; i < 6; ++i) {
|
|
const float* plane = viewPlanes[i];
|
|
float* out = this->planes.planes[i];
|
|
|
|
out[0] = plane[0] * matrix[0] + plane[1] * matrix[1] + plane[2] * matrix[2];
|
|
out[1] = plane[0] * matrix[3] + plane[1] * matrix[4] + plane[2] * matrix[5];
|
|
out[2] = plane[0] * matrix[6] + plane[1] * matrix[7] + plane[2] * matrix[8];
|
|
out[3] = plane[0] * matrix[9] + plane[1] * matrix[10] + plane[2] * matrix[11] + plane[3];
|
|
|
|
this->planes.normals[i][0] = out[0];
|
|
this->planes.normals[i][1] = out[1];
|
|
this->planes.normals[i][2] = out[2];
|
|
}
|
|
|
|
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->ClassifyAxisAligned(*child);
|
|
|
|
if (visibility != 0) {
|
|
this->CollectNode(*child, depth + 1, visibility == 1);
|
|
}
|
|
}
|
|
}
|