mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-08-04 11:55:07 -04:00
The map worked out the player's zone from geometry alone: of the WorldMapArea boxes containing them, take the one they sit deepest inside. Those boxes are axis-aligned rectangles around irregular zones, so neighbours overlap heavily — the comment on that code already says as much — and the answer is a guess. It guessed wrong often enough to open on a zone the player was merely near. The server says which zone the player is in, in SMSG_INIT_WORLD_STATES, and the client has been tracking it as worldStateZoneId_ for other things all along. It is the same AreaTable id space WorldMapArea keys on, so it names a zone directly. Use it, and keep the geometry only for when the server has not said — before the first world-state packet, or for a zone that is not on the map currently displayed. Threaded to the exploration tracker and the player marker as well as the zone the map opens on. All three answered this question separately, so leaving any of them on the guess would show as a marker or a revealed area disagreeing with the zone in front of you. Tests cover the id winning over the geometry, the id winning even where the player's own zone box does not reach them, and the fallback for an id that names nothing on this map.
76 lines
2.6 KiB
C++
76 lines
2.6 KiB
C++
// overlay_renderer.hpp — ImGui overlay layer system for the world map.
|
|
// Extracted from WorldMap::renderImGuiOverlay (Phase 8 of refactoring plan).
|
|
// OCP — new marker types are added by implementing IOverlayLayer.
|
|
#pragma once
|
|
|
|
#include "rendering/world_map/world_map_types.hpp"
|
|
#include <glm/glm.hpp>
|
|
#include <vector>
|
|
#include <memory>
|
|
#include <unordered_set>
|
|
#include <unordered_map>
|
|
#include <array>
|
|
#include <cstdint>
|
|
#include <functional>
|
|
#include <imgui.h>
|
|
|
|
struct ImDrawList;
|
|
|
|
namespace wowee {
|
|
namespace rendering {
|
|
namespace world_map {
|
|
|
|
/// Context passed to each overlay layer during rendering.
|
|
struct LayerContext {
|
|
ImDrawList* drawList = nullptr;
|
|
ImVec2 imgMin; // top-left of map image in screen space
|
|
float displayW = 0, displayH = 0;
|
|
glm::vec3 playerRenderPos;
|
|
// The zone the server says the player is in; 0 when it has not said. Layers
|
|
// that need "which zone is the player in" must use this in preference to
|
|
// deriving it, so the marker agrees with the zone the map opened on.
|
|
uint32_t playerZoneId = 0;
|
|
float playerYawDeg = 0;
|
|
int currentZoneIdx = -1;
|
|
int continentIdx = -1;
|
|
int currentMapId = -1;
|
|
ViewLevel viewLevel = ViewLevel::ZONE;
|
|
const std::vector<Zone>* zones = nullptr;
|
|
const std::unordered_set<int>* exploredZones = nullptr;
|
|
const std::unordered_set<int>* exploredOverlays = nullptr;
|
|
const std::unordered_map<uint32_t, std::string>* areaNameByAreaId = nullptr;
|
|
// FBO dimensions for overlay coordinate math
|
|
int fboW = 1024;
|
|
int fboH = 768;
|
|
|
|
// ZMP pixel map for continent-view hover (128x128 grid of AreaTable IDs)
|
|
const std::array<uint32_t, 128 * 128>* zmpGrid = nullptr;
|
|
bool hasZmpData = false;
|
|
// Function to resolve AreaTable ID → zone index (from DataRepository)
|
|
int (*zmpResolveZoneIdx)(const void* repo, uint32_t areaId) = nullptr;
|
|
const void* zmpRepoPtr = nullptr; // opaque DataRepository pointer
|
|
// ZMP-derived zone bounding boxes (zone index → UV rect on display)
|
|
const std::unordered_map<int, ZmpRect>* zmpZoneBounds = nullptr;
|
|
};
|
|
|
|
/// Interface for an overlay layer rendered on top of the composite map.
|
|
class IOverlayLayer {
|
|
public:
|
|
virtual ~IOverlayLayer() = default;
|
|
virtual void render(const LayerContext& ctx) = 0;
|
|
};
|
|
|
|
/// Orchestrates rendering of all registered overlay layers.
|
|
class OverlayRenderer {
|
|
public:
|
|
void addLayer(std::unique_ptr<IOverlayLayer> layer);
|
|
void render(const LayerContext& ctx);
|
|
|
|
private:
|
|
std::vector<std::unique_ptr<IOverlayLayer>> layers_;
|
|
};
|
|
|
|
} // namespace world_map
|
|
} // namespace rendering
|
|
} // namespace wowee
|