Decompile 2 functions in Source/Contents/World/WorldSpatialInitialization.cpp, Source/Contents/World/WorldSpatialInitialization.h, ...
Batch #11543 by cremane: 0 byte-identical, 2 confirmed by peer review. - fn_17660 CWorld::InitializeSpatial: logic confirmed by peer review - fn_17684 CWorld::InitWorld: logic confirmed by peer review Peer-reviewed-by: Yommy, KWDev Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes).
This commit is contained in:
parent
ca0592e311
commit
f4e7bbfbb5
4 changed files with 26 additions and 26 deletions
|
|
@ -1,5 +1,6 @@
|
|||
#include "Contents/Ground/GroundGeometry.h"
|
||||
#include "Contents/Models/ModelActor.h"
|
||||
#include "Contents/World/World.h"
|
||||
#include "Contents/World/WorldSpatialInitialization.h"
|
||||
#include "Contents/World/WorldSpatialTree.h"
|
||||
#include "Resource/World/TerrainResource.h"
|
||||
|
|
@ -8,37 +9,39 @@
|
|||
|
||||
// OFFSET: 0x00AC79C0
|
||||
// FUNCTION: fn_17660
|
||||
void InitializeWorldSpatial(
|
||||
WorldSpatialTree& root, GroundGeometry& ground, C3dAttr& terrain, std::span<C3dActor* const> models, const WorldSpatialTree* serialized
|
||||
) {
|
||||
root.ClearChildren();
|
||||
const int halfWidth = ground.width / 2;
|
||||
const int halfHeight = ground.height / 2;
|
||||
root.minimum[0] = static_cast<float>(ground.width / -2) * ground.cellSize;
|
||||
root.maximum[0] = static_cast<float>(ground.width - halfWidth) * ground.cellSize - 1.0f;
|
||||
root.minimum[2] = static_cast<float>(ground.height / -2) * ground.cellSize;
|
||||
root.maximum[2] = static_cast<float>(ground.height - halfHeight) * ground.cellSize - 1.0f;
|
||||
root.halfSize[0] = 0;
|
||||
root.halfSize[2] = 0;
|
||||
root.Subdivide(0);
|
||||
void CWorld::InitializeSpatial() {
|
||||
this->spatial.ClearChildren();
|
||||
const int halfWidth = this->ground->width / 2;
|
||||
const int halfHeight = this->ground->height / 2;
|
||||
this->spatial.minimum[0] = static_cast<float>(-halfWidth) * this->ground->cellSize;
|
||||
this->spatial.maximum[0] = static_cast<float>(this->ground->width - halfWidth) * this->ground->cellSize - 1.0f;
|
||||
this->spatial.minimum[2] = static_cast<float>(-halfHeight) * this->ground->cellSize;
|
||||
this->spatial.maximum[2] = static_cast<float>(this->ground->height - halfHeight) * this->ground->cellSize - 1.0f;
|
||||
this->spatial.center[0] = 0;
|
||||
this->spatial.center[2] = 0;
|
||||
this->spatial.Subdivide(0);
|
||||
|
||||
for (C3dActor* model : models) {
|
||||
for (WorldSpatialTree* child : root.children) {
|
||||
for (auto it = this->models.begin(); it != this->models.end(); ++it) {
|
||||
C3dActor* model = *it;
|
||||
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
WorldSpatialTree* child = this->spatial.children[i];
|
||||
if (model->oriented.Intersects(child->minimum)) {
|
||||
child->InsertModel(*model, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
root.BindGround(ground, 0);
|
||||
root.BindTerrain(terrain, 0);
|
||||
this->spatial.BindGround(*this->ground, 0);
|
||||
this->spatial.BindTerrain(*this->terrain, 0);
|
||||
|
||||
if (serialized) {
|
||||
root.CopyBounds(0, *serialized);
|
||||
if (this->serializedSpatial) {
|
||||
this->spatial.CopyBounds(0, *this->serializedSpatial);
|
||||
} else {
|
||||
root.dirty = 0;
|
||||
this->spatial.dirty = 0;
|
||||
|
||||
for (WorldSpatialTree* child : root.children) {
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
WorldSpatialTree* child = this->spatial.children[i];
|
||||
if (child->dirty) {
|
||||
child->RefreshBounds(1);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue