|
Vulkan Schnee 0.0.1 (22840dc8)
High-performance rendering engine
|
Mesh component that can create and own collision shapes for its actor. More...
#include <CollidableMeshComponent.h>
Public Member Functions | |
| CollidableMesh (Entities::Scene *owningScene, entt::entity &actor, Asset::MeshPath asset, std::shared_ptr< Entities::SceneNode > sceneNode, bool isVisible_=true, const std::string &name_="game object") | |
| Constructs a collidable mesh using the engine rendering data manager. | |
| CollidableMesh (Entities::Scene *owningScene, entt::entity &actor, Assets::GltfRenderableHandle renderable, std::shared_ptr< Entities::SceneNode > sceneNode, bool isVisible_=true, const std::string &name_="game object") | |
| Constructs a collidable mesh from a glTF renderable handle using the engine rendering data manager. | |
| CollidableMesh (Entities::Scene *owningScene, entt::entity &actor, Assets::GeometryMeshHandle mesh, std::shared_ptr< Entities::SceneNode > sceneNode, bool isVisible_=true, const std::string &name_="game object") | |
| Constructs a collidable mesh from a geometry mesh handle using the engine rendering data manager. | |
| CollidableMesh (Entities::Scene *owningScene, entt::entity &actor, Asset::MeshPath asset, std::shared_ptr< Entities::SceneNode > sceneNode, Core::RenderingDataManager *renderingDataManager, bool isVisible_=true, const std::string &name_="game object") | |
| Constructs a collidable mesh with an explicit rendering data manager. | |
| CollidableMesh (Entities::Scene *owningScene, entt::entity &actor, Assets::GltfRenderableHandle renderable, std::shared_ptr< Entities::SceneNode > sceneNode, Core::RenderingDataManager *renderingDataManager, bool isVisible_=true, const std::string &name_="game object") | |
| Constructs a collidable mesh from a glTF renderable handle with an explicit rendering data manager. | |
| CollidableMesh (Entities::Scene *owningScene, entt::entity &actor, Assets::GeometryMeshHandle mesh, std::shared_ptr< Entities::SceneNode > sceneNode, Core::RenderingDataManager *renderingDataManager, bool isVisible_=true, const std::string &name_="game object") | |
| Constructs a collidable mesh from a geometry mesh handle with an explicit rendering data manager. | |
| void | endPlay () override |
| Removes collision owned by this component, then ends mesh playback. | |
| void | enableCollision (bool enabled) |
| Enables or disables generated collision for this mesh. | |
| bool | isCollisionEnabled () const |
| Returns whether collision generation has been requested. | |
| void | setCollisionProperties (const Assets::Loaders::GltfLoader::VulkanSchneeExtension::CollisionProperties &properties) |
| Sets imported collision properties used to build collision components. | |
| void | markCollisionPropertiesResolved () |
| Marks authored collision metadata as already inspected for this mesh. | |
| void | clearCollisionProperties () |
| Clears imported collision properties and falls back to mesh bounds when collision is enabled. | |
| void | setCollisionStatic (bool isStatic) |
| Sets whether the generated PhysicsBody should be static. | |
| void | onMeshAssetResolved (Assets::MeshAssetRef meshAsset) override |
| Handles mesh asset resolution and builds deferred fallback collision when requested. | |
| Public Member Functions inherited from Engine::Components::Mesh | |
| Mesh (Entities::Scene *owningScene, entt::entity &actor, Asset::MeshPath asset, std::shared_ptr< Entities::SceneNode > sceneNode, bool isVisible_=true, const std::string &name_="game object") | |
| Production constructor - uses EngineManager singleton to get RenderingDataManager. | |
| Mesh (Entities::Scene *owningScene, entt::entity &actor, Assets::GltfRenderableHandle renderable, std::shared_ptr< Entities::SceneNode > sceneNode, bool isVisible_=true, const std::string &name_="game object") | |
| Production constructor for a GLTF renderable handle. | |
| Mesh (Entities::Scene *owningScene, entt::entity &actor, Assets::GeometryMeshHandle mesh, std::shared_ptr< Entities::SceneNode > sceneNode, bool isVisible_=true, const std::string &name_="game object") | |
| Production constructor for a geometry mesh handle. | |
| Mesh (Entities::Scene *owningScene, entt::entity &actor, Asset::MeshPath asset, std::shared_ptr< Entities::SceneNode > sceneNode, Core::RenderingDataManager *renderingDataManager, bool isVisible_=true, const std::string &name_="game object") | |
| Testable constructor - allows injecting RenderingDataManager for testing. | |
| Mesh (Entities::Scene *owningScene, entt::entity &actor, Assets::GltfRenderableHandle renderable, std::shared_ptr< Entities::SceneNode > sceneNode, Core::RenderingDataManager *renderingDataManager, bool isVisible_=true, const std::string &name_="game object") | |
| Testable constructor for a GLTF renderable handle. | |
| Mesh (Entities::Scene *owningScene, entt::entity &actor, Assets::GeometryMeshHandle mesh, std::shared_ptr< Entities::SceneNode > sceneNode, Core::RenderingDataManager *renderingDataManager, bool isVisible_=true, const std::string &name_="game object") | |
| Testable constructor for a geometry mesh handle. | |
| ~Mesh () override=default | |
| Destroys the mesh component. | |
| void | beginPlay () override |
| Called when the component is added to the scene or the game starts. | |
| void | endPlay () override |
| Called when the component is removed or the game ends. | |
| bool | drawImGui () override |
| Draw the debug UI. | |
| bool | isVisible () const |
| If this mesh component should be considered for rendering. | |
| void | setVisible (bool isVisible) |
| Sets whether this mesh component should be rendered. | |
| Assets::MeshAssetRef | getMeshAsset () const |
| Gets the asset used by this mesh rendering component. | |
| glm::mat4 | getWorldTransform () const |
| Getter for the world transform of the mesh component. | |
| glm::mat4 | getLocalTransform () const |
| Gets the local model matrix which isn't affected by its parent. | |
| std::optional< Core::AnchorPoint > | anchorPoint (std::string_view name) const |
| Looks up an AnchorPoint on this renderable-backed mesh. | |
| std::vector< std::string > | anchorPointNames () const |
| Lists this renderable's AnchorPoint names. | |
| Rendering::PipelineNames | getMaterialNames () const |
| Gets the material name of this mesh component. | |
| void | setMaterialOverride (Assets::MaterialHandle material) |
| Overrides the material used for rendering this mesh. | |
| void | clearMaterialOverride () |
| Clears the material override and returns to the mesh material. | |
| std::optional< Assets::MaterialHandle > | getMaterialOverride () const |
| Gets the current material override. | |
| std::string | getAssetName () const |
| Gets the asset name of this mesh component (e.g. "rat") | |
| void | attachCollisionChild (Collision *collision) |
| Records a collision component owned by this mesh. | |
| void | attachCollisionChildren (const std::vector< Collision * > &collisions) |
| Records multiple collision components owned by this mesh. | |
| void | detachCollisionChild (const Collision *collision) |
| Removes a collision component from this mesh's child list. | |
| const std::vector< Collision * > & | getCollisionChildren () const |
| Gets collision components owned by this mesh. | |
| bool | ownsCollisionChild (const Logic *component) const |
| Checks whether a logic component is one of this mesh's collision children. | |
| Public Member Functions inherited from Engine::Components::Logic | |
| Logic (Entities::Scene *owningScene) | |
| Constructs a logic component owned by a scene. | |
| Logic (const Entities::SpawnContext &context) | |
| Constructs a logic component from spawn context data. | |
| virtual | ~Logic ()=default |
| Destroys the logic component. | |
| virtual std::string | getComponentName () const |
| Gets the component type name for debugging/UI. | |
| virtual bool | drawImGuiName () |
| Used to alter the name of the entity in the outliner. | |
| virtual void | tick (double deltaTime) |
| Called every frame if ticking is enabled. | |
| bool | hasBegunPlay () const |
| Checks whether beginPlay() has been called without a matching endPlay(). | |
| bool | canTick () const |
| Checks if the component is currently set to tick. | |
| void | setCanTick (bool enable) |
| Enables or disables ticking for this component. | |
| Entities::Entity * | getOwningEntity () const |
| Gets the entity this component belongs to. | |
Static Public Attributes | |
| static constexpr const char * | ComponentName = "CollidableMesh" |
| Component registry name. | |
| Static Public Attributes inherited from Engine::Components::Mesh | |
| static constexpr const char * | ComponentName = "Mesh" |
| Component type name. | |
| Static Public Attributes inherited from Engine::Components::Logic | |
| static constexpr bool | IsUnique = false |
| Defines whether multiple instances of this component can exist on the same entity. Defaults to false (multiple allowed). Override in derived classes with static constexpr bool IsUnique =
true; if needed. | |
| static constexpr const char * | ComponentName = "Logic" |
| Fallback component type name. Derived classes may override getComponentName() for custom labels. | |
Private Types | |
| using | CollisionProperties = Assets::Loaders::GltfLoader::VulkanSchneeExtension::CollisionProperties |
Private Member Functions | |
| void | rebuildOwnedCollision () |
| Rebuilds all collision owned by this component from imported properties or fallback bounds. | |
| void | loadCollisionPropertiesFromAsset () |
| Loads authored glTF collision properties for this mesh asset when available. | |
| bool | createCollisionFromProperties () |
| Creates collision components from imported glTF collision properties. | |
| bool | createFallbackBoxCollision () |
| Creates a BoxCollision from the resolved mesh asset's local vertex bounds. | |
| void | ensurePhysicsBody () |
| Adds a PhysicsBody to the owning actor if needed and applies the static flag. | |
| void | removeOwnedCollision () |
| Removes collision components created and owned by this component. | |
Private Attributes | |
| std::optional< CollisionProperties > | collisionProperties_ |
| std::vector< Collision * > | ownedCollisionChildren_ |
| bool | collisionRequested_ = false |
| bool | collisionPropertiesResolved_ = false |
| bool | collisionStatic_ = false |
Additional Inherited Members | |
| Protected Member Functions inherited from Engine::Components::Mesh | |
| std::shared_ptr< Entities::SceneNode > | getSceneNode () const |
| Gets the scene node used for mesh transforms. | |
| Ecs::StaticMeshData * | getStaticMeshData () const |
| Gets the ECS static mesh data for derived components. | |
| Protected Member Functions inherited from Engine::Components::Logic | |
| Entities::Scene * | getScene () const |
| Gets the scene this component belongs to. | |
| Core::SceneManager * | getSceneManager () const |
| Helper to get the SceneManager from the owning scene. | |
| Protected Attributes inherited from Engine::Components::Mesh | |
| entt::entity | componentEntity = entt::null |
| ECS entity that stores this mesh component data. | |
| std::optional< std::shared_ptr< Entities::SceneNode > > | sceneNode |
| Scene node used for transforms. | |
Mesh component that can create and own collision shapes for its actor.
CollidableMesh renders the same mesh data as Engine::Components::Mesh and can optionally add collision components to the owning actor. Imported collision properties are used when available; otherwise the component builds a fallback box from the resolved mesh's local vertex bounds.
Enabling collision also ensures that the owning actor has a PhysicsBody component. Collision created by this component is removed when collision is disabled or when the component ends play.
Definition at line 20 of file CollidableMeshComponent.h.
|
private |
Definition at line 202 of file CollidableMeshComponent.h.
| Engine::Components::CollidableMesh::CollidableMesh | ( | Entities::Scene * | owningScene, |
| entt::entity & | actor, | ||
| Asset::MeshPath | asset, | ||
| std::shared_ptr< Entities::SceneNode > | sceneNode, | ||
| bool | isVisible_ = true, | ||
| const std::string & | name_ = "game object" ) |
Constructs a collidable mesh using the engine rendering data manager.
| owningScene | Scene that owns the actor and component. |
| actor | ECS entity associated with the owning actor. |
| asset | Mesh asset path to render and use for fallback collision bounds. |
| sceneNode | Scene graph node used for the mesh transform and generated PhysicsBody. |
| isVisible_ | True when the mesh should be submitted for rendering. |
| name_ | Display name for the mesh component. |
References Engine::Components::Mesh::sceneNode.
| Engine::Components::CollidableMesh::CollidableMesh | ( | Entities::Scene * | owningScene, |
| entt::entity & | actor, | ||
| Assets::GltfRenderableHandle | renderable, | ||
| std::shared_ptr< Entities::SceneNode > | sceneNode, | ||
| bool | isVisible_ = true, | ||
| const std::string & | name_ = "game object" ) |
Constructs a collidable mesh from a glTF renderable handle using the engine rendering data manager.
| owningScene | Scene that owns the actor and component. |
| actor | ECS entity associated with the owning actor. |
| renderable | Renderable handle to render. |
| sceneNode | Scene graph node used for the mesh transform and generated PhysicsBody. |
| isVisible_ | True when the mesh should be submitted for rendering. |
| name_ | Display name for the mesh component. |
References Engine::Components::Mesh::sceneNode.
| Engine::Components::CollidableMesh::CollidableMesh | ( | Entities::Scene * | owningScene, |
| entt::entity & | actor, | ||
| Assets::GeometryMeshHandle | mesh, | ||
| std::shared_ptr< Entities::SceneNode > | sceneNode, | ||
| bool | isVisible_ = true, | ||
| const std::string & | name_ = "game object" ) |
Constructs a collidable mesh from a geometry mesh handle using the engine rendering data manager.
| owningScene | Scene that owns the actor and component. |
| actor | ECS entity associated with the owning actor. |
| mesh | Geometry mesh handle to render. |
| sceneNode | Scene graph node used for the mesh transform and generated PhysicsBody. |
| isVisible_ | True when the mesh should be submitted for rendering. |
| name_ | Display name for the mesh component. |
References Engine::Components::Mesh::sceneNode.
| Engine::Components::CollidableMesh::CollidableMesh | ( | Entities::Scene * | owningScene, |
| entt::entity & | actor, | ||
| Asset::MeshPath | asset, | ||
| std::shared_ptr< Entities::SceneNode > | sceneNode, | ||
| Core::RenderingDataManager * | renderingDataManager, | ||
| bool | isVisible_ = true, | ||
| const std::string & | name_ = "game object" ) |
Constructs a collidable mesh with an explicit rendering data manager.
| owningScene | Scene that owns the actor and component. |
| actor | ECS entity associated with the owning actor. |
| asset | Mesh asset path to render and use for fallback collision bounds. |
| sceneNode | Scene graph node used for the mesh transform and generated PhysicsBody. |
| renderingDataManager | Rendering data manager used by the base Mesh component. |
| isVisible_ | True when the mesh should be submitted for rendering. |
| name_ | Display name for the mesh component. |
References Engine::Components::Mesh::sceneNode.
| Engine::Components::CollidableMesh::CollidableMesh | ( | Entities::Scene * | owningScene, |
| entt::entity & | actor, | ||
| Assets::GltfRenderableHandle | renderable, | ||
| std::shared_ptr< Entities::SceneNode > | sceneNode, | ||
| Core::RenderingDataManager * | renderingDataManager, | ||
| bool | isVisible_ = true, | ||
| const std::string & | name_ = "game object" ) |
Constructs a collidable mesh from a glTF renderable handle with an explicit rendering data manager.
| owningScene | Scene that owns the actor and component. |
| actor | ECS entity associated with the owning actor. |
| renderable | Renderable handle to render. |
| sceneNode | Scene graph node used for the mesh transform and generated PhysicsBody. |
| renderingDataManager | Rendering data manager used by the base Mesh component. |
| isVisible_ | True when the mesh should be submitted for rendering. |
| name_ | Display name for the mesh component. |
References Engine::Components::Mesh::sceneNode.
| Engine::Components::CollidableMesh::CollidableMesh | ( | Entities::Scene * | owningScene, |
| entt::entity & | actor, | ||
| Assets::GeometryMeshHandle | mesh, | ||
| std::shared_ptr< Entities::SceneNode > | sceneNode, | ||
| Core::RenderingDataManager * | renderingDataManager, | ||
| bool | isVisible_ = true, | ||
| const std::string & | name_ = "game object" ) |
Constructs a collidable mesh from a geometry mesh handle with an explicit rendering data manager.
| owningScene | Scene that owns the actor and component. |
| actor | ECS entity associated with the owning actor. |
| mesh | Geometry mesh handle to render. |
| sceneNode | Scene graph node used for the mesh transform and generated PhysicsBody. |
| renderingDataManager | Rendering data manager used by the base Mesh component. |
| isVisible_ | True when the mesh should be submitted for rendering. |
| name_ | Display name for the mesh component. |
References Engine::Components::Mesh::sceneNode.
| void Engine::Components::CollidableMesh::clearCollisionProperties | ( | ) |
Clears imported collision properties and falls back to mesh bounds when collision is enabled.
|
private |
Creates collision components from imported glTF collision properties.
|
private |
Creates a BoxCollision from the resolved mesh asset's local vertex bounds.
| void Engine::Components::CollidableMesh::enableCollision | ( | bool | enabled | ) |
Enables or disables generated collision for this mesh.
| enabled | True to create collision, false to remove collision owned by this component. |
Enabling collision uses imported collision properties first. If no usable imported collision exists, the component creates a fallback BoxCollision from the mesh asset's local-space bounds after the asset is available.
|
overridevirtual |
Removes collision owned by this component, then ends mesh playback.
Reimplemented from Engine::Components::Logic.
|
private |
Adds a PhysicsBody to the owning actor if needed and applies the static flag.
|
nodiscard |
Returns whether collision generation has been requested.
This reports the requested state, not whether collision components currently exist. Collision can be requested before the mesh asset has resolved.
|
private |
Loads authored glTF collision properties for this mesh asset when available.
| void Engine::Components::CollidableMesh::markCollisionPropertiesResolved | ( | ) |
Marks authored collision metadata as already inspected for this mesh.
Used by GLTF spawning when the node extension was parsed as part of the spawn plan. This keeps fallback collision generation from reparsing the whole GLTF file for every spawned mesh node.
|
overridevirtual |
Handles mesh asset resolution and builds deferred fallback collision when requested.
| meshAsset | Resolved mesh asset passed through to Mesh::onMeshAssetResolved(). |
Reimplemented from Engine::Components::Mesh.
|
private |
Rebuilds all collision owned by this component from imported properties or fallback bounds.
|
private |
Removes collision components created and owned by this component.
| void Engine::Components::CollidableMesh::setCollisionProperties | ( | const Assets::Loaders::GltfLoader::VulkanSchneeExtension::CollisionProperties & | properties | ) |
Sets imported collision properties used to build collision components.
| properties | Collision shape data parsed from the VulkanSchnee glTF extension. |
If collision is already enabled, existing collision owned by this component is rebuilt immediately.
| void Engine::Components::CollidableMesh::setCollisionStatic | ( | bool | isStatic | ) |
Sets whether the generated PhysicsBody should be static.
| isStatic | True for a static rigid body, false for a dynamic rigid body. |
The value is applied to an existing PhysicsBody immediately and to any PhysicsBody created later by enableCollision(true).
|
private |
Definition at line 236 of file CollidableMeshComponent.h.
|
private |
Definition at line 239 of file CollidableMeshComponent.h.
|
private |
Definition at line 238 of file CollidableMeshComponent.h.
|
private |
Definition at line 240 of file CollidableMeshComponent.h.
|
staticconstexpr |
Component registry name.
Definition at line 23 of file CollidableMeshComponent.h.
|
private |
Definition at line 237 of file CollidableMeshComponent.h.