Reconstruct readable C++ and organize cohesive source subsystems
Administrative source import: native x86 compilation passed for 423 authored units. Source placement and submission states are migrated separately; this commit does not imply peer acceptance.
Previous head: 35d2a8cb36
Payload SHA256: 592f016d2730c5593bb653aa054c1e5f76a6df72c8f5a09e66f74876e2e33dee
This commit is contained in:
parent
35d2a8cb36
commit
a47d20f8be
890 changed files with 11796 additions and 16664 deletions
71
Source/Contents/World/WorldSpatialInitialization.cpp
Normal file
71
Source/Contents/World/WorldSpatialInitialization.cpp
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
#include "Contents/Ground/GroundSpatial.h"
|
||||
#include "Contents/Models/ModelActor.h"
|
||||
#include "Contents/World/WorldSpatialInitialization.h"
|
||||
#include "Contents/World/WorldSpatialTree.h"
|
||||
#include "Resource/World/TerrainResource.h"
|
||||
|
||||
#include <atomic>
|
||||
|
||||
// OFFSET: 0x00AC79C0
|
||||
// FUNCTION: fn_17660
|
||||
void InitializeWorldSpatial(
|
||||
WorldSpatialTree& root, GroundSpatial& 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);
|
||||
|
||||
for (C3dActor* model : models) {
|
||||
for (WorldSpatialTree* child : root.children) {
|
||||
if (model->oriented.Intersects(child->minimum)) {
|
||||
child->InsertModel(*model, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
root.BindGround(ground, 0);
|
||||
root.BindTerrain(terrain, 0);
|
||||
|
||||
if (serialized) {
|
||||
root.CopyBounds(0, *serialized);
|
||||
} else {
|
||||
root.dirty = 0;
|
||||
|
||||
for (WorldSpatialTree* child : root.children) {
|
||||
if (child->dirty) {
|
||||
child->RefreshBounds(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PublishWorldModels(WorldSpatialTree& root, C3dActor* const* models, int& published, int& pending) {
|
||||
std::atomic_ref<int> count(pending);
|
||||
const int ready = count.load(std::memory_order_acquire);
|
||||
|
||||
if (ready == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const int end = published + ready;
|
||||
|
||||
while (published < end) {
|
||||
C3dActor& model = *models[published];
|
||||
|
||||
for (WorldSpatialTree* child : root.children) {
|
||||
if (model.oriented.Intersects(child->minimum)) {
|
||||
child->InsertModel(model, 1);
|
||||
}
|
||||
}
|
||||
|
||||
count.fetch_sub(1, std::memory_order_seq_cst);
|
||||
++published;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue