|
Unravel Engine C++ Reference
|
Class that contains core data for meshes. More...
#include <model_component.h>
Public Member Functions | |
| void | set_enabled (bool enabled) |
| Sets whether the model is enabled. | |
| void | set_casts_shadow (bool cast_shadow) |
| Sets whether the model casts shadows. | |
| void | set_static (bool is_static) |
| Sets whether the model is static. | |
| auto | is_enabled () const -> bool |
| Checks if the model is enabled. | |
| auto | casts_shadow () const -> bool |
| Checks if the model casts shadows. | |
| auto | is_static () const -> bool |
| Checks if the model is static. | |
| auto | get_model () const -> const model & |
| Gets the model. | |
| void | set_model (const model &model) |
| Sets the model. | |
| auto | get_bone_transforms () const -> const pose_mat4 & |
| Gets the bone transforms. | |
| auto | get_submesh_transforms () const -> const submesh_pose_mat4 & |
| Gets the submesh transforms. | |
| auto | get_armature_entities () const -> const std::vector< entt::handle > & |
| Gets the armature entities. | |
| auto | get_armature_by_index (size_t index) const -> entt::handle |
| 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 | get_skinning_transforms () const -> const std::vector< pose_mat4 > & |
| auto | init_armature (bool force) -> bool |
| Updates the armature of the model. | |
| auto | update_armature () -> bool |
| Refreshes pose-derived render data: submesh/bone poses, cached world-space render-proxy bounds, material overrides and skinning palettes. | |
| void | mark_pose_dirty () noexcept |
| Forces the next update_armature call to run a full refresh even when no armature transform is dirty (armature rebuilds, submesh entry settings edits). | |
| void | set_armature_entities (const std::vector< entt::handle > &submesh_entities) |
| Sets the armature entities. | |
| auto | get_world_bounds () const -> const math::bbox & |
| Gets the pose-aware world-space bounding box for this model. | |
| auto | get_world_bounds_transform () const -> const math::transform & |
| void | update_world_bounds (const math::transform &world_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_render_proxies () const -> const submesh_render_proxies & |
| Retained render proxies: cached world-space per-submesh bounds (including animated bounds for skinned submeshes) refreshed alongside the pose data. | |
| 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 submesh_component entries on the armature node entities. | |
| auto | get_submit_extras (bool shadow_pass=false) const -> model_submit_extras |
| Convenience: builds the submit extras referencing the retained proxy data. | |
| void | set_last_render_frame (uint64_t frame) |
| auto | is_newly_created () const noexcept -> bool |
| auto | get_last_render_frame () const noexcept -> uint64_t |
| auto | was_used_last_frame () const noexcept -> bool |
| auto | is_skinned () const -> bool |
| auto | get_bind_pose () const -> const animation_pose & |
| auto | get_armature_root_entity () const -> entt::handle |
| Armature root entity (first node of the imported skeleton hierarchy). | |
| auto | get_facing_adjustment_rotation () const -> math::quat |
| Local rotation of the armature root (used for root motion / IK remapping). | |
| 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 access from this view. | |
| 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 (e.g., once per frame) to prevent unbounded growth. | |
Public Member Functions inherited from unravel::owned_component | |
| auto | operator= (const owned_component &other) -> owned_component &=default |
| void | set_owner (entt::handle owner) |
| Sets the owner of the component. | |
| auto | get_owner () const noexcept -> entt::const_handle |
| Gets the owner of the component. | |
| auto | get_owner () noexcept -> entt::handle |
| Gets the owner of the component. | |
Public Member Functions inherited from unravel::basic_component | |
| void | touch () |
| Marks the component as 'touched'. | |
Static Public Member Functions | |
| static void | on_create_component (entt::registry &r, entt::entity e) |
| Called when the component is created. | |
| static void | on_destroy_component (entt::registry &r, entt::entity e) |
| Called when the component is destroyed. | |
Static Public Member Functions inherited from unravel::owned_component | |
| template<typename T > | |
| static void | on_create_component (entt::registry &r, entt::entity e) |
| template<typename T > | |
| static void | on_destroy_component (entt::registry &r, entt::entity e) |
Additional Inherited Members | |
Public Types inherited from unravel::component_crtp< model_component, owned_component > | |
| using | base |
Public Attributes inherited from unravel::basic_component | |
| bool | eto {} |
| Disable empty type optimizations. | |
Static Public Attributes inherited from unravel::component_crtp< model_component, owned_component > | |
| static constexpr bool | in_place_delete |
| Indicates if the component can be deleted in place. | |
Class that contains core data for meshes.
Definition at line 15 of file model_component.h.
| auto unravel::model_component::casts_shadow | ( | ) | const -> bool |
Checks if the model casts shadows.
Definition at line 818 of file model_component.cpp.
| void unravel::model_component::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 (e.g., once per frame) to prevent unbounded growth.
| current_frame | Current render frame number. |
| max_frames_inactive | Maximum frames since last access before cleanup (default: 120 = ~2 seconds at 60fps). |
Definition at line 975 of file model_component.cpp.
| auto unravel::model_component::get_armature_by_index | ( | size_t | index | ) | const -> entt::handle |
Definition at line 948 of file model_component.cpp.
| auto unravel::model_component::get_armature_entities | ( | ) | const -> const std::vector<entt::handle>& |
Gets the armature entities.
Definition at line 943 of file model_component.cpp.
| auto unravel::model_component::get_armature_index_by_name_cached | ( | const std::string & | node_name | ) | const -> int |
Gets armature index by name using cached lookup (O(1)).
| node_name | The name of the node to find. |
Definition at line 933 of file model_component.cpp.
| auto unravel::model_component::get_armature_root_entity | ( | ) | const -> entt::handle |
Armature root entity (first node of the imported skeleton hierarchy).
Definition at line 717 of file model_component.cpp.
| auto unravel::model_component::get_bind_pose | ( | ) | const -> const animation_pose& |
Definition at line 712 of file model_component.cpp.
| auto unravel::model_component::get_bone_transforms | ( | ) | const -> const pose_mat4& |
Gets the bone transforms.
Definition at line 847 of file model_component.cpp.
| auto unravel::model_component::get_facing_adjustment_rotation | ( | ) | const -> math::quat |
Local rotation of the armature root (used for root motion / IK remapping).
Definition at line 748 of file model_component.cpp.
|
noexcept |
Definition at line 677 of file model_component.cpp.
| auto unravel::model_component::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.
NEVER use this for culling: it does not track node or bone animation. It is only meaningful for editor tooling (placement helpers, bounds gizmos).
Definition at line 655 of file model_component.cpp.
| auto unravel::model_component::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 access from this view.
| view_id | Unique identifier for the view (typically camera pointer as uintptr_t). |
| current_frame | Current render frame number for tracking access. |
Definition at line 958 of file model_component.cpp.
| auto unravel::model_component::get_model | ( | ) | const -> const model& |
Gets the model.
Definition at line 828 of file model_component.cpp.
| auto unravel::model_component::get_render_proxies | ( | ) | const -> const submesh_render_proxies& |
Retained render proxies: cached world-space per-submesh bounds (including animated bounds for skinned submeshes) refreshed alongside the pose data.
Definition at line 862 of file model_component.cpp.
| auto unravel::model_component::get_skinning_transforms | ( | ) | const -> const std::vector<pose_mat4>& |
Definition at line 852 of file model_component.cpp.
| auto unravel::model_component::get_submesh_material_overrides | ( | ) | const -> const std::vector<material::sptr>& |
Per-submesh material overrides (indexed by submesh index; null = model material), resolved from the submesh_component entries on the armature node entities.
Definition at line 867 of file model_component.cpp.
| auto unravel::model_component::get_submesh_transforms | ( | ) | const -> const submesh_pose_mat4& |
Gets the submesh transforms.
Definition at line 857 of file model_component.cpp.
| auto unravel::model_component::get_submit_extras | ( | bool | shadow_pass = false | ) | const -> model_submit_extras |
Convenience: builds the submit extras referencing the retained proxy data.
| shadow_pass | True when the submit target is a shadow pass. |
Definition at line 872 of file model_component.cpp.
| auto unravel::model_component::get_world_bounds | ( | ) | const -> const math::bbox& |
Gets the pose-aware world-space bounding box for this model.
Static mesh bounds transformed to world space, unioned with the cached pose bounds (node-attached submesh placements and skinned geometry). Refreshed every frame by model_system::on_frame_before_render, before any render path runs. This is the ONLY box that is valid for culling.
Definition at line 645 of file model_component.cpp.
| auto unravel::model_component::get_world_bounds_transform | ( | ) | const -> const math::transform& |
Definition at line 650 of file model_component.cpp.
| auto unravel::model_component::init_armature | ( | bool | force | ) | -> bool |
Updates the armature of the model.
Definition at line 504 of file model_component.cpp.
| auto unravel::model_component::is_enabled | ( | ) | const -> bool |
Checks if the model is enabled.
Definition at line 813 of file model_component.cpp.
|
noexcept |
Definition at line 682 of file model_component.cpp.
| auto unravel::model_component::is_skinned | ( | ) | const -> bool |
Definition at line 695 of file model_component.cpp.
| auto unravel::model_component::is_static | ( | ) | const -> bool |
Checks if the model is static.
Definition at line 823 of file model_component.cpp.
|
noexcept |
Forces the next update_armature call to run a full refresh even when no armature transform is dirty (armature rebuilds, submesh entry settings edits).
Definition at line 912 of file model_component.cpp.
|
static |
Called when the component is created.
| r | The registry containing the component. |
| e | The entity associated with the component. |
Definition at line 763 of file model_component.cpp.
|
static |
Called when the component is destroyed.
| r | The registry containing the component. |
| e | The entity associated with the component. |
Definition at line 773 of file model_component.cpp.
| void unravel::model_component::set_armature_entities | ( | const std::vector< entt::handle > & | submesh_entities | ) |
Sets the armature entities.
| submesh_entities | A vector of handles to the armature entities. |
Definition at line 885 of file model_component.cpp.
| void unravel::model_component::set_casts_shadow | ( | bool | cast_shadow | ) |
Sets whether the model casts shadows.
| cast_shadow | True if the model casts shadows, false otherwise. |
Definition at line 789 of file model_component.cpp.
| void unravel::model_component::set_enabled | ( | bool | enabled | ) |
Sets whether the model is enabled.
| enabled | True if the model is enabled, false otherwise. |
Definition at line 777 of file model_component.cpp.
| void unravel::model_component::set_last_render_frame | ( | uint64_t | frame | ) |
Definition at line 672 of file model_component.cpp.
| void unravel::model_component::set_model | ( | const model & | model | ) |
Sets the model.
| model | The model to set. |
Definition at line 833 of file model_component.cpp.
| void unravel::model_component::set_static | ( | bool | is_static | ) |
Sets whether the model is static.
| is_static | True if the model is static, false otherwise. |
Definition at line 801 of file model_component.cpp.
| auto unravel::model_component::update_armature | ( | ) | -> bool |
Refreshes pose-derived render data: submesh/bone poses, cached world-space render-proxy bounds, material overrides and skinning palettes.
Two gates keep this cheap:
Definition at line 381 of file model_component.cpp.
| void unravel::model_component::update_world_bounds | ( | const math::transform & | world_transform | ) |
Definition at line 531 of file model_component.cpp.
|
noexcept |
Definition at line 687 of file model_component.cpp.