Batch #1082 by ragnarok-clanker: 0 byte-identical, 11 confirmed by peer review. - fn_02007 ModelMesh::ModelMesh: logic confirmed by peer review - fn_02009 ModelMesh::~ModelMesh: logic confirmed by peer review - fn_02011 ModelMesh::CalculateNormals: logic confirmed by peer review - fn_07958 C3dAnimModelRes::Load: logic confirmed by peer review - fn_07997 AnimatedModelRecord::~AnimatedModelRecord: logic confirmed by peer review - fn_08023 C3dAnimModelRes::Unload: logic confirmed by peer review - fn_17482 C3dNodeV1::Initialize: logic confirmed by peer review - fn_17484 C3dNodeV2::Initialize: logic confirmed by peer review - fn_17514 C3dNode::AccumulateBounds: logic confirmed by peer review - fn_17515 C3dNode::SampleGroundColors: logic confirmed by peer review - fn_17521 C3dNode::Prepare: logic confirmed by peer review Reviewed-by: ragnarok-clanker
47 lines
1.3 KiB
C++
47 lines
1.3 KiB
C++
#include "Contents/Models/ModelNode.h"
|
|
|
|
#include <cstring>
|
|
|
|
// OFFSET: 0x00ABB300
|
|
// FUNCTION: fn_17514
|
|
void C3dNode::AccumulateBounds(float* bounds, const float* matrix) {
|
|
AffineMatrix parentMatrix;
|
|
std::memcpy(parentMatrix.values, matrix, sizeof(parentMatrix.values));
|
|
AffineMatrix combined;
|
|
combined.Compose(this->transform, parentMatrix);
|
|
|
|
for (int index = 0; index < this->mesh->vertexCount; ++index) {
|
|
const auto& vertex = this->mesh->vertices[index];
|
|
const float x = ((vertex[0] * combined.values[0] + vertex[1] * combined.values[3]) + vertex[2] * combined.values[6]) + combined.values[9];
|
|
const float y = ((vertex[1] * combined.values[4] + vertex[0] * combined.values[1]) + vertex[2] * combined.values[7]) + combined.values[10];
|
|
const float z = ((vertex[0] * combined.values[2] + vertex[1] * combined.values[5]) + vertex[2] * combined.values[8]) + combined.values[11];
|
|
|
|
if (bounds[0] > x) {
|
|
bounds[0] = x;
|
|
}
|
|
|
|
if (x > bounds[3]) {
|
|
bounds[3] = x;
|
|
}
|
|
|
|
if (bounds[1] > y) {
|
|
bounds[1] = y;
|
|
}
|
|
|
|
if (y > bounds[4]) {
|
|
bounds[4] = y;
|
|
}
|
|
|
|
if (bounds[2] > z) {
|
|
bounds[2] = z;
|
|
}
|
|
|
|
if (z > bounds[5]) {
|
|
bounds[5] = z;
|
|
}
|
|
}
|
|
|
|
for (C3dNode* child : this->children) {
|
|
child->AccumulateBounds(bounds, combined.values);
|
|
}
|
|
}
|