6#include <unordered_map>
219 auto create_armature(
bool force) -> bool;
225 void rebuild_armature_cache();
230 bool enabled_ =
true;
240 bool casts_shadow_ =
true;
250 std::vector<entt::handle> armature_entities_;
256 std::unordered_map<std::string, size_t> armature_name_to_index_;
275 std::vector<pose_mat4> skinning_pose_;
286 std::vector<material::sptr> submesh_material_overrides_;
321 entt::handle bounds_anchor_;
327 uint64_t captured_proxies_version_{~0ULL};
334 bool render_proxies_stale_{
false};
339 uint64_t last_render_frame_{};
345 bool pose_dirty_{
true};
353 std::unordered_map<uintptr_t, per_camera_lod_state> per_camera_lod_data_;
398 if(!
entries.empty() || legacy_indices.empty())
403 entries.reserve(legacy_indices.size());
404 for(uint32_t
index : legacy_indices)
Class representing a camera. Contains functionality for manipulating and updating a camera....
Class that contains core data for meshes.
static void on_create_component(entt::registry &r, entt::entity e)
Called when the component is created.
auto get_facing_adjustment_rotation() const -> math::quat
Local rotation of the armature root (used for root motion / IK remapping).
auto was_used_last_frame() const noexcept -> bool
auto get_submesh_material_overrides() const -> const std::vector< material::sptr > &
Per-submesh material overrides (indexed by submesh index; null = model material), resolved from the s...
auto get_armature_by_index(size_t index) const -> entt::handle
auto get_last_render_frame() const noexcept -> uint64_t
auto get_submesh_transforms() const -> const submesh_pose_mat4 &
Gets the submesh transforms.
auto get_bone_transforms() const -> const pose_mat4 &
Gets the bone transforms.
void set_enabled(bool enabled)
Sets whether the model is enabled.
auto get_submit_extras(bool shadow_pass=false) const -> model_submit_extras
Convenience: builds the submit extras referencing the retained proxy data.
auto is_static() const -> bool
Checks if the model is static.
auto get_lod_data_for_camera(const camera *cam, uint64_t current_frame) -> lod_data &
Gets the per-view LOD data for a specific camera/view. Creates a new entry if this is the first acces...
auto is_newly_created() const noexcept -> bool
auto get_bind_pose() const -> const animation_pose &
auto casts_shadow() const -> bool
Checks if the model casts shadows.
auto init_armature(bool force) -> bool
Updates the armature of the model.
static void on_destroy_component(entt::registry &r, entt::entity e)
Called when the component is destroyed.
auto get_model() const -> const model &
Gets the model.
void cleanup_stale_lod_data(uint64_t current_frame, uint64_t max_frames_inactive=120)
Cleans up stale per-view LOD data entries that haven't been accessed recently. Call this periodically...
auto get_armature_index_by_name_cached(const std::string &node_name) const -> int
Gets armature index by name using cached lookup (O(1)).
auto is_enabled() const -> bool
Checks if the model is enabled.
void mark_pose_dirty() noexcept
Forces the next update_armature call to run a full refresh even when no armature transform is dirty (...
auto get_render_proxies() const -> const submesh_render_proxies &
Retained render proxies: cached world-space per-submesh bounds (including animated bounds for skinned...
auto is_skinned() const -> bool
auto get_skinning_transforms() const -> const std::vector< pose_mat4 > &
void set_model(const model &model)
Sets the model.
auto get_world_bounds_transform() const -> const math::transform &
auto get_local_bounds(uint32_t lod_index) const -> const math::bbox &
Gets the bind-pose local bounding box of the mesh asset for a given LOD.
auto get_armature_root_entity() const -> entt::handle
Armature root entity (first node of the imported skeleton hierarchy).
auto get_armature_entities() const -> const std::vector< entt::handle > &
Gets the armature entities.
void set_static(bool is_static)
Sets whether the model is static.
auto get_world_bounds() const -> const math::bbox &
Gets the pose-aware world-space bounding box for this model.
void update_world_bounds(const math::transform &world_transform)
void set_armature_entities(const std::vector< entt::handle > &submesh_entities)
Sets the armature entities.
auto update_armature() -> bool
Refreshes pose-derived render data: submesh/bone poses, cached world-space render-proxy bounds,...
void set_last_render_frame(uint64_t frame)
void set_casts_shadow(bool cast_shadow)
Sets whether the model casts shadows.
Structure describing a LOD group (set of meshes), LOD transitions, and their materials.
Thread-safe handle to an asset.
Storage for box vector values and wraps up common functionality.
CRTP (Curiously Recurring Template Pattern) base structure for components.
Contains level of detail (LOD) data for an entity per view. Uses distance-based hysteresis for stable...
std::vector< submesh_entry > entries
void migrate_legacy_indices(const std::vector< uint32_t > &legacy_indices)
Migrates legacy serialized data that only stored bare submesh indices. Creates default-valued entries...
Per-submesh render settings authored on the armature node entity that owns the submesh.
bool casts_shadow
Whether this submesh instance casts shadows.
asset_handle< material > material_override
Optional material override for this submesh instance (null = model material).
bool enabled
Whether this submesh instance is rendered at all.
Retained per-model render proxy data used by the culling/LOD code.