From f5ffefce4c32acf8d067a9672e62350ecf97e42a Mon Sep 17 00:00:00 2001 From: Nico de Poel Date: Wed, 8 Feb 2023 10:55:40 +0100 Subject: [PATCH] Additional debugging output --- lighting.cpp | 7 ++++++- main.cpp | 9 +++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lighting.cpp b/lighting.cpp index 0ebccb8..1019ed8 100644 --- a/lighting.cpp +++ b/lighting.cpp @@ -399,7 +399,12 @@ unsigned char compute_faceVertex_light5(const world_t* world, const face_t* refF } if (!numSamples) - return 0; // Shouldn't happen + { + // This really shouldn't happen. At the very least we should get a sample from the reference face, which this point originates from. + // The most common cause of issues here are floating point rounding errors in world->facesWithPoint + printf("Couldn't get any light samples for point (%.2f, %.2f, %.2f)! This is definitely a bug and should be looked at!\n", point.x, point.y, point.z); + return 0; + } // We should always end up with at least one sample (that from refFace itself), so if we divide by zero here something is very much wrong return (unsigned char)(light / numSamples); diff --git a/main.cpp b/main.cpp index 695cd02..eb61223 100644 --- a/main.cpp +++ b/main.cpp @@ -430,6 +430,15 @@ int process_faces(const world_t* world, const TextureList& textures) int process_bsp(const world_t *world) { + FILE* fents; + sprintf_s(path, _MAX_PATH, "%s.ents", world->name); + fopen_s(&fents, path, "w"); + if (fents) + { + fwrite(world->entities, sizeof(char), world->entitiesLength, fents); + fclose(fents); + } + // Test exporting texture data TextureList textures; if (!process_textures(world, textures))