2026-02-02 12:24:50 -08:00
|
|
|
#pragma once
|
|
|
|
|
|
2026-02-21 19:41:21 -08:00
|
|
|
#include <vulkan/vulkan.h>
|
|
|
|
|
#include <vk_mem_alloc.h>
|
2026-02-02 12:24:50 -08:00
|
|
|
#include <glm/glm.hpp>
|
2026-02-03 17:21:04 -08:00
|
|
|
#include <chrono>
|
2026-02-02 12:24:50 -08:00
|
|
|
#include <memory>
|
2026-02-04 20:06:27 -08:00
|
|
|
#include <string>
|
|
|
|
|
#include <unordered_map>
|
2026-02-09 17:39:21 -08:00
|
|
|
#include <algorithm>
|
2026-02-02 12:24:50 -08:00
|
|
|
|
|
|
|
|
namespace wowee {
|
2026-02-04 20:06:27 -08:00
|
|
|
namespace pipeline { class AssetManager; }
|
2026-02-02 12:24:50 -08:00
|
|
|
namespace rendering {
|
|
|
|
|
|
|
|
|
|
class Camera;
|
2026-02-21 19:41:21 -08:00
|
|
|
class VkContext;
|
|
|
|
|
class VkTexture;
|
|
|
|
|
class VkRenderTarget;
|
2026-02-02 12:24:50 -08:00
|
|
|
|
|
|
|
|
class Minimap {
|
|
|
|
|
public:
|
|
|
|
|
Minimap();
|
|
|
|
|
~Minimap();
|
|
|
|
|
|
2026-02-21 19:41:21 -08:00
|
|
|
bool initialize(VkContext* ctx, VkDescriptorSetLayout perFrameLayout, int size = 200);
|
2026-02-02 12:24:50 -08:00
|
|
|
void shutdown();
|
2026-02-22 03:49:44 -08:00
|
|
|
void recreatePipelines();
|
2026-02-02 12:24:50 -08:00
|
|
|
|
2026-02-04 20:06:27 -08:00
|
|
|
void setAssetManager(pipeline::AssetManager* am) { assetManager = am; }
|
|
|
|
|
void setMapName(const std::string& name);
|
2026-02-02 12:24:50 -08:00
|
|
|
|
2026-02-21 19:41:21 -08:00
|
|
|
/// Off-screen composite pass — call BEFORE the main render pass begins.
|
|
|
|
|
void compositePass(VkCommandBuffer cmd, const glm::vec3& centerWorldPos);
|
|
|
|
|
|
|
|
|
|
/// Display quad — call INSIDE the main render pass.
|
|
|
|
|
void render(VkCommandBuffer cmd, const Camera& playerCamera,
|
2026-02-22 08:44:16 -08:00
|
|
|
const glm::vec3& centerWorldPos, int screenWidth, int screenHeight,
|
|
|
|
|
float playerOrientation = 0.0f, bool hasPlayerOrientation = false);
|
2026-02-02 12:24:50 -08:00
|
|
|
|
|
|
|
|
void setEnabled(bool enabled) { this->enabled = enabled; }
|
|
|
|
|
bool isEnabled() const { return enabled; }
|
|
|
|
|
void toggle() { enabled = !enabled; }
|
|
|
|
|
|
|
|
|
|
void setViewRadius(float radius) { viewRadius = radius; }
|
2026-02-07 20:51:53 -08:00
|
|
|
void setRotateWithCamera(bool rotate) { rotateWithCamera = rotate; }
|
|
|
|
|
bool isRotateWithCamera() const { return rotateWithCamera; }
|
2026-02-02 12:24:50 -08:00
|
|
|
|
2026-02-09 17:39:21 -08:00
|
|
|
void setSquareShape(bool square) { squareShape = square; }
|
|
|
|
|
bool isSquareShape() const { return squareShape; }
|
2026-02-20 16:27:21 -08:00
|
|
|
float getViewRadius() const { return viewRadius; }
|
2026-02-09 17:39:21 -08:00
|
|
|
|
|
|
|
|
void zoomIn() { viewRadius = std::max(100.0f, viewRadius - 50.0f); }
|
|
|
|
|
void zoomOut() { viewRadius = std::min(800.0f, viewRadius + 50.0f); }
|
|
|
|
|
|
2026-02-04 22:27:45 -08:00
|
|
|
// Public accessors for WorldMap
|
2026-02-21 19:41:21 -08:00
|
|
|
VkTexture* getOrLoadTileTexture(int tileX, int tileY);
|
2026-02-04 22:27:45 -08:00
|
|
|
void ensureTRSParsed() { if (!trsParsed) parseTRS(); }
|
|
|
|
|
const std::string& getMapName() const { return mapName; }
|
|
|
|
|
|
2026-02-02 12:24:50 -08:00
|
|
|
private:
|
2026-02-04 20:06:27 -08:00
|
|
|
void parseTRS();
|
2026-02-21 19:41:21 -08:00
|
|
|
void updateTileDescriptors(uint32_t frameIdx, int centerTileX, int centerTileY);
|
2026-02-02 12:24:50 -08:00
|
|
|
|
2026-02-21 19:41:21 -08:00
|
|
|
VkContext* vkCtx = nullptr;
|
2026-02-04 20:06:27 -08:00
|
|
|
pipeline::AssetManager* assetManager = nullptr;
|
|
|
|
|
std::string mapName = "Azeroth";
|
2026-02-02 12:24:50 -08:00
|
|
|
|
2026-02-04 20:06:27 -08:00
|
|
|
// TRS lookup: "Azeroth\map32_49" → "e7f0dea73ee6baca78231aaf4b7e772a"
|
|
|
|
|
std::unordered_map<std::string, std::string> trsLookup;
|
|
|
|
|
bool trsParsed = false;
|
|
|
|
|
|
2026-02-21 19:41:21 -08:00
|
|
|
// Tile texture cache: hash → VkTexture
|
|
|
|
|
std::unordered_map<std::string, std::unique_ptr<VkTexture>> tileTextureCache;
|
|
|
|
|
std::unique_ptr<VkTexture> noDataTexture;
|
2026-02-04 20:06:27 -08:00
|
|
|
|
2026-02-21 19:41:21 -08:00
|
|
|
// Composite render target (3x3 tiles = 768x768)
|
|
|
|
|
std::unique_ptr<VkRenderTarget> compositeTarget;
|
2026-02-04 20:06:27 -08:00
|
|
|
static constexpr int TILE_PX = 256;
|
|
|
|
|
static constexpr int COMPOSITE_PX = TILE_PX * 3; // 768
|
|
|
|
|
|
2026-02-21 19:41:21 -08:00
|
|
|
// Shared quad vertex buffer (6 verts, pos2 + uv2 = 16 bytes/vert)
|
|
|
|
|
::VkBuffer quadVB = VK_NULL_HANDLE;
|
|
|
|
|
VmaAllocation quadVBAlloc = VK_NULL_HANDLE;
|
|
|
|
|
|
|
|
|
|
// Descriptor resources (shared layout: 1 combined image sampler at binding 0)
|
|
|
|
|
VkDescriptorSetLayout samplerSetLayout = VK_NULL_HANDLE;
|
|
|
|
|
VkDescriptorPool descPool = VK_NULL_HANDLE;
|
|
|
|
|
static constexpr uint32_t MAX_DESC_SETS = 24;
|
|
|
|
|
|
|
|
|
|
// Tile composite pipeline (renders into VkRenderTarget)
|
|
|
|
|
VkPipeline tilePipeline = VK_NULL_HANDLE;
|
|
|
|
|
VkPipelineLayout tilePipelineLayout = VK_NULL_HANDLE;
|
|
|
|
|
VkDescriptorSet tileDescSets[2][9] = {}; // [frameInFlight][tileSlot]
|
2026-02-02 12:24:50 -08:00
|
|
|
|
2026-02-21 19:41:21 -08:00
|
|
|
// Display pipeline (renders into main render pass)
|
|
|
|
|
VkPipeline displayPipeline = VK_NULL_HANDLE;
|
|
|
|
|
VkPipelineLayout displayPipelineLayout = VK_NULL_HANDLE;
|
|
|
|
|
VkDescriptorSet displayDescSet = VK_NULL_HANDLE;
|
2026-02-02 12:24:50 -08:00
|
|
|
|
|
|
|
|
int mapSize = 200;
|
2026-02-21 19:41:21 -08:00
|
|
|
float viewRadius = 400.0f;
|
2026-02-04 20:06:27 -08:00
|
|
|
bool enabled = true;
|
2026-02-09 01:13:56 -08:00
|
|
|
bool rotateWithCamera = false;
|
2026-02-09 17:39:21 -08:00
|
|
|
bool squareShape = false;
|
2026-02-04 20:06:27 -08:00
|
|
|
|
|
|
|
|
// Throttling
|
2026-02-03 17:21:04 -08:00
|
|
|
float updateIntervalSec = 0.25f;
|
|
|
|
|
float updateDistance = 6.0f;
|
2026-02-04 20:06:27 -08:00
|
|
|
std::chrono::steady_clock::time_point lastUpdateTime{};
|
|
|
|
|
glm::vec3 lastUpdatePos{0.0f};
|
2026-02-03 17:21:04 -08:00
|
|
|
bool hasCachedFrame = false;
|
2026-02-04 20:06:27 -08:00
|
|
|
|
|
|
|
|
// Tile tracking
|
|
|
|
|
int lastCenterTileX = -1;
|
|
|
|
|
int lastCenterTileY = -1;
|
2026-02-02 12:24:50 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace rendering
|
|
|
|
|
} // namespace wowee
|