Decompile 11 functions in Source/Contents/Models/ModelLighting.cpp, Source/Contents/Models/ModelNode.cpp, ...

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
This commit is contained in:
ragnarok-clanker 2026-10-27 16:31:29 +00:00
commit eb3e3b8b08
11 changed files with 249 additions and 132 deletions

View file

@ -121,19 +121,17 @@ inline void C3dModelResV2::ReadNode(ResourceByteReader& input, unsigned minor, c
input.Read(node->transform, sizeof(node->transform));
ModelMesh& mesh = *node->mesh;
unsigned vertexCount = 0;
input.Read(&vertexCount, 4);
mesh.vertices.resize(vertexCount);
input.Read(mesh.vertices.data(), vertexCount * 12u);
unsigned textureVertexCount = 0;
input.Read(&textureVertexCount, 4);
mesh.textureVertices.resize(textureVertexCount);
input.Read(mesh.textureVertices.data(), textureVertexCount * 12u);
int faceCount = 0;
input.Read(&faceCount, 4);
mesh.faces.resize(static_cast<unsigned>(faceCount));
input.Read(&mesh.vertexCount, 4);
mesh.vertices = new std::array<float, 3>[mesh.vertexCount]{};
input.Read(mesh.vertices, static_cast<unsigned>(mesh.vertexCount) * 12u);
input.Read(&mesh.textureVertexCount, 4);
mesh.textureVertices = new ModelTextureVertex[mesh.textureVertexCount];
input.Read(mesh.textureVertices, static_cast<unsigned>(mesh.textureVertexCount) * 12u);
input.Read(&mesh.faceCount, 4);
mesh.faces = new ModelFace[mesh.faceCount];
for (ModelFace& face : mesh.faces) {
for (int index = 0; index < mesh.faceCount; ++index) {
ModelFace& face = mesh.faces[index];
std::vector<unsigned char> bytes;
unsigned char fixed[24];
const unsigned char* record;
@ -161,7 +159,7 @@ inline void C3dModelResV2::ReadNode(ResourceByteReader& input, unsigned minor, c
}
// INLINED
std::sort(mesh.faces.begin(), mesh.faces.end(), [](const ModelFace& a, const ModelFace& b) { return a.texture < b.texture; });
std::sort(mesh.faces, mesh.faces + mesh.faceCount, [](const ModelFace& a, const ModelFace& b) { return a.texture < b.texture; });
mesh.CalculateNormals();
ReadKeys(input, node->scaleKeys, false);
ReadKeys(input, node->rotationKeys, true);