Remove debug logging and add negative texture cache to fix lag spikes

Remove PPM composite dumps, MODEL1_BOUNDS vertex analysis, TEX_REGION
logging, FOUNTAIN_PARTICLES debug output, and verbose chat/warden gate
logging. Add negative cache for failed texture loads to prevent repeated
file I/O for missing textures like deathknighteyeglow.blp.
This commit is contained in:
Kelsi 2026-02-16 00:45:47 -08:00
parent 4190cb796f
commit d87a86e35c
8 changed files with 19 additions and 106 deletions

View file

@ -357,11 +357,15 @@ GLuint CharacterRenderer::loadTexture(const std::string& path) {
return whiteTexture;
}
// Check negative cache to avoid repeated file I/O for textures that don't exist
if (failedTextureCache_.count(key)) {
return whiteTexture;
}
auto blpImage = assetManager->loadTexture(key);
if (!blpImage.isValid()) {
core::Logger::getInstance().warning("Failed to load texture: ", path);
// Do not cache failures as white. Some asset reads can fail transiently and
// we want later retries (e.g., mount skins loaded shortly after model spawn).
failedTextureCache_.insert(key);
return whiteTexture;
}
@ -553,11 +557,6 @@ GLuint CharacterRenderer::compositeTextures(const std::vector<std::string>& laye
}
}
// Debug dump removed: it was always-on and could stall badly under load.
// Debug: dump first composite to /tmp for visual inspection
// Upload composite to GPU
GLuint texId;
glGenTextures(1, &texId);
@ -765,26 +764,6 @@ GLuint CharacterRenderer::compositeWithRegions(const std::string& basePath,
" at (", dstX, ",", dstY, ") ", overlay.width, "x", overlay.height, " from ", rl.second);
}
// Debug: dump composite to /tmp for visual inspection
{
static int dumpCount = 0;
if (dumpCount < 6) {
dumpCount++;
std::string dumpPath = "/tmp/wowee_composite_" + std::to_string(dumpCount) + ".ppm";
FILE* f = fopen(dumpPath.c_str(), "wb");
if (f) {
fprintf(f, "P6\n%d %d\n255\n", width, height);
for (int i = 0; i < width * height; i++) {
fputc(composite[i * 4 + 0], f);
fputc(composite[i * 4 + 1], f);
fputc(composite[i * 4 + 2], f);
}
fclose(f);
core::Logger::getInstance().info("compositeWithRegions: dumped to ", dumpPath);
}
}
}
// Upload to GPU
GLuint texId;
glGenTextures(1, &texId);
@ -874,37 +853,6 @@ bool CharacterRenderer::loadModel(const pipeline::M2Model& model, uint32_t id) {
" verts, ", model.bones.size(), " bones, ", model.sequences.size(),
" anims, ", model.textures.size(), " textures)");
// Debug: dump vertex bounding boxes per submesh group for player model
if (id == 1) {
core::Logger::getInstance().info("MODEL1_VERSION: ", model.version);
std::map<uint16_t, std::array<float,6>> groupBounds; // group -> minX,minY,minZ,maxX,maxY,maxZ
for (const auto& b : model.batches) {
uint16_t grp = b.submeshId;
for (uint32_t idx = b.indexStart; idx < b.indexStart + b.indexCount && idx < model.indices.size(); idx++) {
uint16_t vi = model.indices[idx];
if (vi >= model.vertices.size()) continue;
const auto& v = model.vertices[vi];
auto it = groupBounds.find(grp);
if (it == groupBounds.end()) {
groupBounds[grp] = {v.position.x, v.position.y, v.position.z,
v.position.x, v.position.y, v.position.z};
} else {
auto& bb = it->second;
bb[0] = std::min(bb[0], v.position.x);
bb[1] = std::min(bb[1], v.position.y);
bb[2] = std::min(bb[2], v.position.z);
bb[3] = std::max(bb[3], v.position.x);
bb[4] = std::max(bb[4], v.position.y);
bb[5] = std::max(bb[5], v.position.z);
}
}
}
for (const auto& [grp, bb] : groupBounds) {
core::Logger::getInstance().info("MODEL1_BOUNDS: submesh=", grp,
" X[", bb[0], "..", bb[3], "] Y[", bb[1], "..", bb[4], "] Z[", bb[2], "..", bb[5], "]");
}
}
return true;
}

View file

@ -2352,14 +2352,8 @@ void M2Renderer::renderM2Particles(const glm::mat4& view, const glm::mat4& proj)
float alpha = interpFBlockFloat(em.particleAlpha, lifeRatio);
float scale = interpFBlockFloat(em.particleScale, lifeRatio);
// Some waterfall/spray emitters become overly dark after channel-correct decoding.
// Apply a small correction only for strongly blue-dominant particle colors.
if (color.b > color.r * 1.4f && color.b > color.g * 1.15f) {
float luma = color.r * 0.2126f + color.g * 0.7152f + color.b * 0.0722f;
color = glm::mix(color, glm::vec3(luma), 0.35f);
color *= 1.35f;
color = glm::clamp(color, glm::vec3(0.28f, 0.35f, 0.45f), glm::vec3(1.0f));
}
// Note: blue-dominant color correction removed — it was over-brightening
// water/fountain particles, making them look like spell effects.
GLuint tex = whiteTexture;
if (p.emitterIndex < static_cast<int>(gpu.particleTextures.size())) {
@ -2421,18 +2415,9 @@ void M2Renderer::renderM2Particles(const glm::mat4& view, const glm::mat4& proj)
for (auto& [key, group] : groups) {
if (group.vertexData.empty()) continue;
// Set blend mode. Many classic glow textures use a black background with no alpha,
// and expect additive blending so black contributes nothing.
bool texHasAlpha = true;
if (auto it = textureHasAlphaById_.find(group.texture); it != textureHasAlphaById_.end()) {
texHasAlpha = it->second;
}
// Use blend mode as specified by the emitter — don't override based on texture alpha.
// BlendType: 0=opaque, 1=alphaKey, 2=alpha, 3=add, 4=mod
uint8_t blendType = group.blendType;
if ((blendType == 1 || blendType == 2) && !texHasAlpha) {
blendType = 4; // Treat as additive fallback
}
if (blendType == 3 || blendType == 4) {
glBlendFunc(GL_SRC_ALPHA, GL_ONE); // Additive
} else {

View file

@ -1189,7 +1189,6 @@ void WMORenderer::render(const Camera& camera, const glm::mat4& view, const glm:
const auto& group = model.groups[gi];
glm::vec3 groupCenter = (group.boundingBoxMin + group.boundingBoxMax) * 0.5f;
glm::vec4 worldCenter = instance.modelMatrix * glm::vec4(groupCenter, 1.0f);
float distToGroup = glm::length(cameraPos - glm::vec3(worldCenter));
// Log bounding box to identify groups that are positioned HIGH (floating shell)
glm::vec3 size = group.boundingBoxMax - group.boundingBoxMin;
@ -1233,8 +1232,8 @@ void WMORenderer::render(const Camera& camera, const glm::mat4& view, const glm:
float distToGroup = glm::length(cameraPos - glm::vec3(worldCenter));
static int logCounter = 0;
if (logCounter++ % 300 == 0) {
LOG_INFO("LOD Shell Group ", gi, ": worldZ=", worldCenter.z, " sizeZ=", size.z,
if (logCounter++ % 10000 == 0) {
LOG_DEBUG("LOD Shell Group ", gi, ": worldZ=", worldCenter.z, " sizeZ=", size.z,
" distToGroup=", distToGroup, " (hiding if < 185)");
}