|
Vulkan Schnee 0.0.1
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") | |
| 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") | |
| 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") | |
| 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") | |
| 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 | 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") | |
| 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") | |
| 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") | |
| 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") | |
| ~Mesh () override=default | |
| 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. | |
| 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. | |
| Rendering::PipelineNames | getMaterialNames () const |
| Gets the material name of this mesh component. | |
| void | setMaterialOverride (Assets::MaterialHandle material) |
| void | clearMaterialOverride () |
| std::optional< Assets::MaterialHandle > | getMaterialOverride () const |
| std::string | getAssetName () const |
| Gets the asset name of this mesh component (e.g. "rat") | |
| void | attachCollisionChild (Collision *collision) |
| void | attachCollisionChildren (const std::vector< Collision * > &collisions) |
| void | detachCollisionChild (const Collision *collision) |
| const std::vector< Collision * > & | getCollisionChildren () const |
| bool | ownsCollisionChild (const Logic *component) const |
| Public Member Functions inherited from Engine::Components::Logic | |
| Logic (Entities::Scene *owningScene) | |
| Logic (const Entities::SpawnContext &context) | |
| virtual | ~Logic ()=default |
| 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 |
| 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" |
| Static Public Attributes inherited from Engine::Components::Mesh | |
| static constexpr const char * | ComponentName = "Mesh" |
| 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 | collisionStatic_ = false |
Additional Inherited Members | |
| Protected Member Functions inherited from Engine::Components::Mesh | |
| std::shared_ptr< Entities::SceneNode > | getSceneNode () const |
| Ecs::StaticMeshData * | getStaticMeshData () const |
| 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 |
| std::optional< std::shared_ptr< Entities::SceneNode > > | sceneNode |
| Ecs::StaticMeshData * | staticMeshData = nullptr |
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 156 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" ) |
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" ) |
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" ) |
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" ) |
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.
|
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 190 of file CollidableMeshComponent.h.
|
private |
Definition at line 192 of file CollidableMeshComponent.h.
|
private |
Definition at line 193 of file CollidableMeshComponent.h.
|
staticconstexpr |
Definition at line 23 of file CollidableMeshComponent.h.
|
private |
Definition at line 191 of file CollidableMeshComponent.h.