Fix WMO visibility culling and renderer initialization guards

This commit is contained in:
Kelsi 2026-02-18 22:41:05 -08:00
parent ff8ffc3bfb
commit a30525d7c9
5 changed files with 17 additions and 10 deletions

View file

@ -322,6 +322,7 @@ public:
uint32_t getQueryCallCount() const { return queryCallCount; }
// Stats
bool isInitialized() const { return initialized_; }
uint32_t getModelCount() const { return static_cast<uint32_t>(models.size()); }
uint32_t getInstanceCount() const { return static_cast<uint32_t>(instances.size()); }
uint32_t getTotalTriangleCount() const;
@ -347,6 +348,7 @@ public:
void setOnTaxi(bool onTaxi) { onTaxi_ = onTaxi; }
private:
bool initialized_ = false;
bool insideInterior = false;
bool onTaxi_ = false;
pipeline::AssetManager* assetManager = nullptr;

View file

@ -142,6 +142,7 @@ public:
/**
* Get number of loaded models
*/
bool isInitialized() const { return initialized_; }
uint32_t getModelCount() const { return loadedModels.size(); }
/**
@ -573,6 +574,8 @@ private:
std::vector<WMOInstance> instances;
uint32_t nextInstanceId = 1;
bool initialized_ = false;
// Rendering state
bool wireframeMode = false;
bool frustumCulling = true;

View file

@ -61,6 +61,7 @@ void Logger::log(LogLevel level, const std::string& message) {
std::cout << line.str() << '\n';
if (fileStream.is_open()) {
fileStream << line.str() << '\n';
fileStream.flush();
}
}

View file

@ -261,6 +261,7 @@ M2Renderer::~M2Renderer() {
}
bool M2Renderer::initialize(pipeline::AssetManager* assets) {
if (initialized_) { assetManager = assets; return true; }
assetManager = assets;
numAnimThreads_ = std::min(4u, std::max(1u, std::thread::hardware_concurrency() - 1));
@ -635,6 +636,7 @@ bool M2Renderer::initialize(pipeline::AssetManager* assets) {
}
LOG_INFO("M2 renderer initialized");
initialized_ = true;
return true;
}

View file

@ -37,6 +37,7 @@ WMORenderer::~WMORenderer() {
}
bool WMORenderer::initialize(pipeline::AssetManager* assets) {
if (initialized_) { assetManager = assets; return true; }
core::Logger::getInstance().info("Initializing WMO renderer...");
assetManager = assets;
@ -204,6 +205,7 @@ bool WMORenderer::initialize(pipeline::AssetManager* assets) {
initOcclusionResources();
core::Logger::getInstance().info("WMO renderer initialized");
initialized_ = true;
return true;
}
@ -1205,19 +1207,16 @@ void WMORenderer::render(const Camera& camera, const glm::mat4& view, const glm:
for (uint32_t gi : dl.visibleGroups) {
const auto& group = model.groups[gi];
// Skip non-renderable groups:
// 0x20000 = SHOW_SKYBOX (transparent sky windows)
// 0x4000000 = ANTIPORTAL (occlusion planes, not visible geometry)
// 0x8000000 = disables batch rendering
if (group.groupFlags & (0x20000 | 0x4000000 | 0x8000000)) {
// Skip truly non-visible groups:
// 0x20000 = SHOW_SKYBOX (window/skybox planes)
// 0x4000000 = ANTIPORTAL (occlusion planes, not render geometry)
// Note: 0x8000000 is *not* a safe global skip; some valid world WMOs use it.
if (group.groupFlags & (0x20000 | 0x4000000)) {
continue;
}
// Skip groups where ALL batches use the fallback white texture —
// these are collision/placeholder/LOD shell groups with no visual data
if (group.allUntextured) {
continue;
}
// Do not globally cull untextured groups: some valid world WMOs can
// temporarily resolve to fallback textures. Render geometry anyway.
// STORMWIND.WMO specific fix: LOD shell visibility control