15#include <glm/vec3.hpp>
17#include <unordered_map>
53 int add(
const std::string& name,
54 const std::string& filename =
"",
56 glm::vec3 renderScale = glm::vec3{1.0f},
57 glm::vec3 renderTranslation = glm::vec3{0.0f},
58 glm::vec3 renderRotationDegrees = glm::vec3{0.0f})
60 const int id =
static_cast<int>(
entries_.size());
64 .renderScale = renderScale,
65 .renderTranslation = renderTranslation,
66 .renderRotationDegrees = renderRotationDegrees});
74 if (assetId >= 0 && assetId <
static_cast<int>(
entries_.size()))
81 if (assetId >= 0 && assetId <
static_cast<int>(
entries_.size()))
82 entries_[
static_cast<size_t>(assetId)].hasCollision = v;
86 [[nodiscard]] int32_t
modelIndex(
const std::string& name)
const
97 if (assetId < 0 || assetId >=
static_cast<int>(
entries_.size()))
103 [[nodiscard]]
int id(
const std::string& name)
const
106 return (it !=
nameToId_.end()) ? it->second : -1;
113 [[nodiscard]]
int count()
const {
return static_cast<int>(
entries_.size()); }
AssetRole
Describes how a registered asset should be used.
Definition AssetRegistry.hpp:22
@ Entity
Dynamic entity model (player, weapon) — drawn via EntityRenderCmd only.
Definition AssetRegistry.hpp:25
@ Map
Static world geometry — rendered in scene pass, has collision.
Definition AssetRegistry.hpp:23
@ Prop
Static placed object — rendered in scene pass, optionally has collision.
Definition AssetRegistry.hpp:24
@ Effect
Procedural effect (glow sphere, beam) — drawn via EntityRenderCmd only.
Definition AssetRegistry.hpp:26
Central asset registry — maps names to renderer model indices.
Definition AssetRegistry.hpp:50
void setHasCollision(int assetId, bool v=true)
Mark an asset as having collision data.
Definition AssetRegistry.hpp:79
std::vector< AssetEntry > entries_
Definition AssetRegistry.hpp:119
std::unordered_map< std::string, int > nameToId_
Definition AssetRegistry.hpp:120
int32_t modelIndex(const std::string &name) const
Look up the renderer model index by asset name. Returns -1 if not found.
Definition AssetRegistry.hpp:86
const AssetEntry & entry(int assetId) const
Get a read-only reference to an entry.
Definition AssetRegistry.hpp:110
int count() const
Number of registered assets.
Definition AssetRegistry.hpp:113
int add(const std::string &name, const std::string &filename="", AssetRole role=AssetRole::Entity, glm::vec3 renderScale=glm::vec3{1.0f}, glm::vec3 renderTranslation=glm::vec3{0.0f}, glm::vec3 renderRotationDegrees=glm::vec3{0.0f})
Register a new asset. Returns its asset ID (index into entries_).
Definition AssetRegistry.hpp:53
void setModelIndex(int assetId, int32_t modelIndex)
Set the renderer model index for a registered asset.
Definition AssetRegistry.hpp:72
int32_t modelIndex(int assetId) const
Look up the renderer model index by asset ID. Returns -1 if out of range.
Definition AssetRegistry.hpp:95
const std::vector< AssetEntry > & entries() const
All entries (for debug UI / logging).
Definition AssetRegistry.hpp:116
int id(const std::string &name) const
Look up asset ID by name. Returns -1 if not found.
Definition AssetRegistry.hpp:103
One entry in the asset registry.
Definition AssetRegistry.hpp:31
glm::vec3 renderScale
Default per-entity render scale for this asset.
Definition AssetRegistry.hpp:35
AssetRole role
Definition AssetRegistry.hpp:34
glm::vec3 renderRotationDegrees
Default per-entity local Euler rotation in degrees.
Definition AssetRegistry.hpp:37
glm::vec3 renderTranslation
Default per-entity local translation for this asset.
Definition AssetRegistry.hpp:36
std::string name
Human-readable name (e.g. "porsche", "wraith", "map1").
Definition AssetRegistry.hpp:32
bool hasCollision
True if collision was generated for this asset.
Definition AssetRegistry.hpp:39
std::string filename
GLB filename relative to assets/ (empty for procedural).
Definition AssetRegistry.hpp:33
int32_t modelIndex
Renderer model index (-1 = not uploaded to GPU yet).
Definition AssetRegistry.hpp:38