Class Scene#

Class Documentation#

class Scene#

Public Functions

Scene()#
void update_model_matrix(glm::mat4 model_matrix, uint32_t model_id)#
inline Model *findModel(uint32_t model_index) const#
inline Mesh *findMesh(uint32_t model_index, uint32_t mesh_index) const#

findModel() chained through Model::getMesh(), which is already nullptr out of range - so the mesh half of the rule is one null test, not a second bounds check.

inline std::vector<Texture> &getTextures(uint32_t model_index)#
inline std::vector<vk::Sampler> &getTextureSampler(uint32_t model_index)#
inline uint32_t getTextureCount(uint32_t model_index) const#
inline uint32_t getModelCount() const#
inline glm::mat4 getModelMatrix(uint32_t model_index) const#
inline uint32_t getMeshCount(uint32_t model_index) const#
inline std::vector<uint32_t> getTextureCountPerModel() const#
inline std::vector<uint32_t> getMeshCountPerModel() const#
inline vk::Buffer getVertexBuffer(uint32_t model_index, uint32_t mesh_index) const#
inline vk::Buffer getIndexBuffer(uint32_t model_index, uint32_t mesh_index) const#
inline uint32_t getIndexCount(uint32_t model_index, uint32_t mesh_index) const#
inline bool isMeshDoubleSided(uint32_t model_index, uint32_t mesh_index) const#

glTF material.doubleSided for a mesh, so the raster pass can disable back-face culling for it. Out-of-range defaults to single-sided.

inline const AABB &getMeshBounds(uint32_t model_index, uint32_t mesh_index) const#

Object-space bounds of a mesh, for frustum culling. An invalid box is returned for an out-of-range index, which isVisible() treats as visible - a missing bound must never be a reason to skip a draw.

inline std::vector<ObjectDescription> getObjectDescriptions() const#
inline std::vector<std::shared_ptr<Model>> const &get_model_list() const#
void loadModel(const std::shared_ptr<VulkanDevice> &device, vk::CommandPool commandPool)#
void beginModelLoadAsync()#

Starts parsing the configured model on a worker thread and returns immediately. The scene has NO model until pollModelLoad() reports one.

The parse is ~2800 ms of the ~2815 ms load (measured on the bundled 27 MB model), and the window froze for all of it.

bool isModelLoadPending() const#

True between beginModelLoadAsync() and the model being installed.

bool pollModelLoad(const std::shared_ptr<VulkanDevice> &device, vk::CommandPool commandPool)#

Finishes a completed async load: uploads on THIS thread (the one that owns the device) and adds the model. Returns true on the frame the model becomes available, so the caller can rebuild whatever depends on scene contents. Cheap to call every frame.

void cancelPendingModelLoad()#

Joins and discards a still-running beginModelLoadAsync() parse. A no-op when no parse is pending. reloadModel() calls this first so a reload issued mid-parse cannot let the startup load land in the scene alongside the reloaded model.

void reloadModel(const std::shared_ptr<VulkanDevice> &device, vk::CommandPool commandPool, const std::string &modelPath)#

Replaces the scene with a single model. modelPath is relative to Resources/ and is resolved here, like loadAdditionalModel()’s contract. The previous scene is torn down before the new load is attempted, so a failed reload leaves the scene empty by design.

std::optional<uint32_t> loadAdditionalModel(const std::shared_ptr<VulkanDevice> &device, vk::CommandPool commandPool, const std::string &modelPath, const glm::mat4 &modelMatrix)#

Loads an ADDITIONAL model, leaving existing ones in place, and returns its model index (the value the raster paths push as objectIndex) or std::nullopt if loading failed.

loadModel() deliberately loads exactly one model from SceneConfig and reloadModel() replaces the scene, so until now nothing could produce a scene with two models - which meant the per-draw objectIndex could not be exercised even though the shaders index with it.

std::optional<uint32_t> add_model(const std::shared_ptr<Model> &model)#

Appends model to the scene and returns the index it landed at, or std::nullopt for the null-model guard (a failed load upstream) - the caller no longer has to re-derive “which model did I just add”.

void cleanUp()#
~Scene()#