feat: Raw reading on zone load and scene tools#1910
feat: Raw reading on zone load and scene tools#1910aronwk-aaron wants to merge 32 commits intomainfrom
Conversation
added option to automatically write the raw obj file Added scene colors to the obj use proper scene colors from hf
…lameUniverse/DarkflameServer into raw-parsing-for-scene-data
There was a problem hiding this comment.
Pull Request Overview
This PR implements raw terrain file reading on zone load to enable scene identification from player positions. Key changes include parsing .raw terrain files, building a scene adjacency graph from scene transitions, and adding developer commands for scene debugging and visualization.
- Adds comprehensive RAW terrain file parsing with scene map support
- Implements scene ID lookup from world positions and scene adjacency graph construction
- Adds developer commands for scene debugging and visualization with OBJ export capability
Reviewed Changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 17 comments.
Show a summary per file
| File | Description |
|---|---|
| resources/worldconfig.ini | Adds config option to export terrain meshes to OBJ files for debugging |
| dZoneManager/dZoneManager.h | Declares scene position lookup, adjacency list access, and scene graph building methods |
| dZoneManager/dZoneManager.cpp | Implements scene position queries, scene graph construction from transitions, and global scene connectivity |
| dZoneManager/Zone.h | Adds Raw terrain data storage and scene lookup methods |
| dZoneManager/Zone.cpp | Implements zone file version checking, Raw file loading, and optional OBJ export |
| dZoneManager/Raw.h | Defines complete terrain chunk structures, scene vertex data, and mesh generation/export functions |
| dZoneManager/Raw.cpp | Implements RAW file parsing, terrain mesh generation with scene IDs, and OBJ export with scene colors |
| dZoneManager/CMakeLists.txt | Adds Raw.cpp to build and includes SceneColor.h path |
| dNavigation/dTerrain/* | Removes old unused terrain parsing code |
| dNavigation/dNavMesh.cpp | Removes unused RawFile.h include |
| dNavigation/CMakeLists.txt | Removes dTerrain subdirectory from build |
| dGame/dUtilities/SlashCommands/DEVGMCommands.h | Declares four new scene debugging commands |
| dGame/dUtilities/SlashCommands/DEVGMCommands.cpp | Implements GetScene, GetAdjacentScenes, SpawnScenePoints, and SpawnAllScenePoints commands |
| dGame/dUtilities/SlashCommandHandler.cpp | Registers the four new scene debugging commands |
| dCommon/dClient/SceneColor.h | Defines color palette for visualizing scene IDs in OBJ exports |
| dCommon/NiColor.h | Adds RGB color structure with grayscale conversion |
Comments suppressed due to low confidence (1)
dZoneManager/Raw.cpp:1
- Potential division by zero in GetSceneIDFromPosition if chunk dimensions are 1. Similar to the issue in GenerateTerrainMesh, if chunk.width or chunk.height equals 1, this will cause division by zero. Add validation before these calculations.
#include "Raw.h"
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 23 out of 23 changed files in this pull request and generated 7 comments.
Comments suppressed due to low confidence (1)
dZoneManager/dZoneManager.cpp:18
- This file uses
std::clamp,std::min, andstd::findbut doesn’t include<algorithm>directly. Relying on transitive includes can break builds when include order changes; add the proper standard header and drop unused<cmath>if it’s no longer needed.
#include "WorldConfig.h"
#include "CDZoneTableTable.h"
#include <chrono>
#include <cmath>
#include "eObjectBits.h"
#include "CDZoneTableTable.h"
#include "AssetManager.h"
#include <ranges>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Agent-Logs-Url: https://github.com/DarkflameUniverse/DarkflameServer/sessions/8e30d854-e439-4b25-bb15-891ba389f0fd Co-authored-by: aronwk-aaron <26027722+aronwk-aaron@users.noreply.github.com>
…D in BuildSceneGraph Agent-Logs-Url: https://github.com/DarkflameUniverse/DarkflameServer/sessions/5cf247c9-7028-4f94-9ab9-8dfd8e6101fa Co-authored-by: aronwk-aaron <26027722+aronwk-aaron@users.noreply.github.com>
…FromPosition Agent-Logs-Url: https://github.com/DarkflameUniverse/DarkflameServer/sessions/e331a9a3-fb6b-4574-9456-2a94e4ecdd33 Co-authored-by: aronwk-aaron <26027722+aronwk-aaron@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 23 out of 23 changed files in this pull request and generated 10 comments.
Comments suppressed due to low confidence (1)
dZoneManager/dZoneManager.cpp:18
- This file now uses std::clamp/std::min/std::find and std::set, but the includes only add . Please add the required standard headers (at least for clamp/min/find and for std::set) to avoid relying on transitive includes and potential build breaks on other toolchains.
#include "WorldConfig.h"
#include "CDZoneTableTable.h"
#include <chrono>
#include <cmath>
#include "eObjectBits.h"
#include "CDZoneTableTable.h"
#include "AssetManager.h"
#include <ranges>
dZoneManager/Raw.cpp
Outdated
| return; // No scene data available | ||
| } | ||
|
|
||
| LOG("GenerateTerrainMesh: Processing %u chunks", raw.chunks.size()); |
There was a problem hiding this comment.
LOG uses printf-style formatting. raw.chunks.size() is size_t but is logged with %u here, which is undefined behavior on platforms where size_t isn't 32-bit. Use %zu (preferred) or cast to uint32_t after validating it fits.
| LOG("GenerateTerrainMesh: Processing %u chunks", raw.chunks.size()); | |
| LOG("GenerateTerrainMesh: Processing %zu chunks", raw.chunks.size()); |
| struct FlairAttributes { | ||
| uint32_t id; | ||
| float scaleFactor; | ||
| NiPoint3 position; | ||
| NiPoint3 rotation; | ||
| uint8_t colorR; | ||
| uint8_t colorG; | ||
| uint8_t colorB; | ||
| uint8_t colorA; |
There was a problem hiding this comment.
These structs introduce many fundamental fields that are not default-initialized (e.g., FlairAttributes::id, MeshTri::meshTriListSize, Chunk::id/width/height/offsetX/offsetZ/shaderId/scaleFactor, Raw::version/dev). This is inconsistent with other structs in this module (which use {} initialization) and can lead to use of indeterminate values if a partial read fails or an instance is constructed before being fully populated. Prefer brace/"=" initialization for all scalar members.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
… OOM from malformed raws Agent-Logs-Url: https://github.com/DarkflameUniverse/DarkflameServer/sessions/39d7ce79-bc9a-4960-8259-f11bcb5947f8 Co-authored-by: aronwk-aaron <26027722+aronwk-aaron@users.noreply.github.com>
…nt division by zero Agent-Logs-Url: https://github.com/DarkflameUniverse/DarkflameServer/sessions/386caefa-6a0f-4445-b3a5-3534ca2a5a93 Co-authored-by: aronwk-aaron <26027722+aronwk-aaron@users.noreply.github.com>
Agent-Logs-Url: https://github.com/DarkflameUniverse/DarkflameServer/sessions/804e2235-77e8-458f-9a0b-519c496ba3b3 Co-authored-by: aronwk-aaron <26027722+aronwk-aaron@users.noreply.github.com>
…%zu format specifier Agent-Logs-Url: https://github.com/DarkflameUniverse/DarkflameServer/sessions/43d6190e-34b2-4d7f-8aaf-dd16bd77cc25 Co-authored-by: aronwk-aaron <26027722+aronwk-aaron@users.noreply.github.com>
Uh oh!
There was an error while loading. Please reload this page.