mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-04-26 21:13:51 +00:00
refactor: decompose world map into modular component architecture
Break the monolithic 1360-line world_map.cpp into 16 focused modules under src/rendering/world_map/: Architecture: - world_map_facade: public API composing all components (PIMPL) - world_map_types: Vulkan-free domain types (Zone, ViewLevel, etc.) - data_repository: DBC zone loading, ZMP pixel map, POI/overlay storage - coordinate_projection: UV projection, zone/continent lookups - composite_renderer: Vulkan tile pipeline + off-screen compositing - exploration_state: server mask + local exploration tracking - view_state_machine: COSMIC→WORLD→CONTINENT→ZONE navigation - input_handler: keyboard/mouse input → InputAction mapping - overlay_renderer: layer-based ImGui overlay system (OCP) - map_resolver: cross-map navigation (Outland, Northrend, etc.) - zone_metadata: level ranges and faction data Overlay layers (each an IOverlayLayer): - player_marker, party_dot, taxi_node, poi_marker, quest_poi, corpse_marker, zone_highlight, coordinate_display, subzone_tooltip Fixes: - Player marker no longer bleeds across continents (only shown when player is in a zone belonging to the displayed continent) - Zone hover uses DBC-projected AABB rectangles (restored from original working behavior) - Exploration overlay rendering for zone view subzones Tests: - 6 new test files covering coordinate projection, exploration state, map resolver, view state machine, zone metadata, and integration Signed-off-by: Pavel Okhlopkov <pavel.okhlopkov@flant.com>
This commit is contained in:
parent
db3f65a87e
commit
fff06fc932
55 changed files with 6335 additions and 1542 deletions
95
include/rendering/world_map/data_repository.hpp
Normal file
95
include/rendering/world_map/data_repository.hpp
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
// data_repository.hpp — DBC data loading, ZMP pixel map, and zone/POI/overlay storage.
|
||||
// Extracted from WorldMap::loadZonesFromDBC, loadPOIData, buildCosmicView
|
||||
// (Phase 5 of refactoring plan). SRP — all DBC parsing lives here.
|
||||
#pragma once
|
||||
|
||||
#include "rendering/world_map/world_map_types.hpp"
|
||||
#include <unordered_map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
|
||||
namespace wowee {
|
||||
namespace pipeline { class AssetManager; }
|
||||
namespace rendering {
|
||||
namespace world_map {
|
||||
|
||||
class DataRepository {
|
||||
public:
|
||||
/// Load all zone data from DBC files for the given map name.
|
||||
void loadZones(const std::string& mapName, pipeline::AssetManager& assetManager);
|
||||
|
||||
/// Load area POI markers from AreaPOI.dbc.
|
||||
void loadPOIs(pipeline::AssetManager& assetManager);
|
||||
|
||||
/// Build cosmic view entries for the active expansion (uses isActiveExpansion).
|
||||
void buildCosmicView(int expansionLevel = 0);
|
||||
|
||||
/// Build Azeroth world-view continent regions for the active expansion.
|
||||
void buildAzerothView(int expansionLevel = 0);
|
||||
|
||||
/// Load ZMP pixel map for the given continent name (e.g. "Azeroth").
|
||||
/// The ZMP is a 128x128 grid of uint32 AreaTable IDs.
|
||||
void loadZmpPixelMap(const std::string& continentName,
|
||||
pipeline::AssetManager& assetManager);
|
||||
|
||||
/// Determine expansion level from the active expansion profile.
|
||||
static int getExpansionLevel();
|
||||
|
||||
// --- Accessors ---
|
||||
std::vector<Zone>& zones() { return zones_; }
|
||||
const std::vector<Zone>& zones() const { return zones_; }
|
||||
int cosmicIdx() const { return cosmicIdx_; }
|
||||
int worldIdx() const { return worldIdx_; }
|
||||
int currentMapId() const { return currentMapId_; }
|
||||
const std::vector<CosmicMapEntry>& cosmicMaps() const { return cosmicMaps_; }
|
||||
const std::vector<CosmicMapEntry>& azerothRegions() const { return azerothRegions_; }
|
||||
bool cosmicEnabled() const { return cosmicEnabled_; }
|
||||
const std::vector<POI>& poiMarkers() const { return poiMarkers_; }
|
||||
|
||||
const std::unordered_map<uint32_t, uint32_t>& exploreFlagByAreaId() const { return exploreFlagByAreaId_; }
|
||||
const std::unordered_map<uint32_t, std::string>& areaNameByAreaId() const { return areaNameByAreaId_; }
|
||||
|
||||
/// ZMP pixel map accessors.
|
||||
static constexpr int ZMP_SIZE = 128;
|
||||
const std::array<uint32_t, 128 * 128>& zmpGrid() const { return zmpGrid_; }
|
||||
bool hasZmpData() const { return zmpLoaded_; }
|
||||
|
||||
/// Look up zone index from an AreaTable ID (from ZMP). Returns -1 if not found.
|
||||
int zoneIndexForAreaId(uint32_t areaId) const;
|
||||
|
||||
/// ZMP-derived bounding rectangles per zone index (UV [0,1] on display).
|
||||
const std::unordered_map<int, ZmpRect>& zmpZoneBounds() const { return zmpZoneBounds_; }
|
||||
|
||||
/// Reset all data (called on map change).
|
||||
void clear();
|
||||
|
||||
private:
|
||||
std::vector<Zone> zones_;
|
||||
std::vector<POI> poiMarkers_;
|
||||
std::vector<CosmicMapEntry> cosmicMaps_;
|
||||
std::vector<CosmicMapEntry> azerothRegions_;
|
||||
std::unordered_map<uint32_t, uint32_t> exploreFlagByAreaId_;
|
||||
std::unordered_map<uint32_t, std::string> areaNameByAreaId_;
|
||||
int cosmicIdx_ = -1;
|
||||
int worldIdx_ = -1;
|
||||
int currentMapId_ = -1;
|
||||
bool cosmicEnabled_ = true;
|
||||
bool poisLoaded_ = false;
|
||||
|
||||
// ZMP pixel map: 128x128 grid of AreaTable IDs for continent-level hover
|
||||
std::array<uint32_t, 128 * 128> zmpGrid_{};
|
||||
bool zmpLoaded_ = false;
|
||||
// AreaID → zone index (zones_ vector) for quick resolution
|
||||
std::unordered_map<uint32_t, int> areaIdToZoneIdx_;
|
||||
// ZMP-derived bounding boxes per zone index (UV coords on display)
|
||||
std::unordered_map<int, ZmpRect> zmpZoneBounds_;
|
||||
|
||||
/// Scan ZMP grid and build bounding boxes for each zone.
|
||||
void buildZmpZoneBounds();
|
||||
};
|
||||
|
||||
} // namespace world_map
|
||||
} // namespace rendering
|
||||
} // namespace wowee
|
||||
Loading…
Add table
Add a link
Reference in a new issue