Vulkan Schnee 0.0.1 (22840dc8)
High-performance rendering engine
Loading...
Searching...
No Matches
CollidableMeshComponent.h
1#pragma once
2
3#include "Engine/Component/MeshComponent.h"
4#include "Engine/Mesh/GltfLoader.h"
5
6#include <optional>
7
8namespace Engine::Components
9{
20 class CollidableMesh : public Mesh
21 {
22 public:
23 static constexpr const char* ComponentName = "CollidableMesh";
24
35 Entities::Scene * owningScene,
36 entt::entity & actor,
37 Asset::MeshPath asset,
38 std::shared_ptr<Entities::SceneNode> sceneNode,
39 bool isVisible_ = true,
40 const std::string & name_ = "game object"
41 );
42
53 Entities::Scene * owningScene,
54 entt::entity & actor,
56 std::shared_ptr<Entities::SceneNode> sceneNode,
57 bool isVisible_ = true,
58 const std::string & name_ = "game object"
59 );
60
71 Entities::Scene * owningScene,
72 entt::entity & actor,
74 std::shared_ptr<Entities::SceneNode> sceneNode,
75 bool isVisible_ = true,
76 const std::string & name_ = "game object"
77 );
78
90 Entities::Scene * owningScene,
91 entt::entity & actor,
92 Asset::MeshPath asset,
93 std::shared_ptr<Entities::SceneNode> sceneNode,
94 Core::RenderingDataManager * renderingDataManager,
95 bool isVisible_ = true,
96 const std::string & name_ = "game object"
97 );
98
110 Entities::Scene * owningScene,
111 entt::entity & actor,
113 std::shared_ptr<Entities::SceneNode> sceneNode,
114 Core::RenderingDataManager * renderingDataManager,
115 bool isVisible_ = true,
116 const std::string & name_ = "game object"
117 );
118
130 Entities::Scene * owningScene,
131 entt::entity & actor,
133 std::shared_ptr<Entities::SceneNode> sceneNode,
134 Core::RenderingDataManager * renderingDataManager,
135 bool isVisible_ = true,
136 const std::string & name_ = "game object"
137 );
138
142 void endPlay() override;
143
152 void enableCollision(bool enabled);
153
161 [[nodiscard]] bool isCollisionEnabled() const;
162
171 );
172
180
185
193 void setCollisionStatic(bool isStatic);
194
200
201 private:
203
208
213
219
225
230
235
236 std::optional<CollisionProperties> collisionProperties_;
237 std::vector<Collision *> ownedCollisionChildren_;
240 bool collisionStatic_ = false;
241 };
242} // namespace Engine::Components
bool isCollisionEnabled() const
Returns whether collision generation has been requested.
static constexpr const char * ComponentName
Component registry name.
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.
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, 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.
bool createCollisionFromProperties()
Creates collision components from imported glTF collision properties.
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, bool isVisible_=true, const std::string &name_="game object")
Constructs a collidable mesh using the engine rendering data manager.
void rebuildOwnedCollision()
Rebuilds all collision owned by this component from imported properties or fallback bounds.
void setCollisionProperties(const Assets::Loaders::GltfLoader::VulkanSchneeExtension::CollisionProperties &properties)
Sets imported collision properties used to build collision components.
bool createFallbackBoxCollision()
Creates a BoxCollision from the resolved mesh asset's local vertex bounds.
void loadCollisionPropertiesFromAsset()
Loads authored glTF collision properties for this mesh asset when available.
Assets::Loaders::GltfLoader::VulkanSchneeExtension::CollisionProperties CollisionProperties
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.
void clearCollisionProperties()
Clears imported collision properties and falls back to mesh bounds when collision is enabled.
void endPlay() override
Removes collision owned by this component, then ends mesh playback.
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.
void onMeshAssetResolved(Assets::MeshAssetRef meshAsset) override
Handles mesh asset resolution and builds deferred fallback collision when requested.
void enableCollision(bool enabled)
Enables or disables generated collision for this mesh.
void setCollisionStatic(bool isStatic)
Sets whether the generated PhysicsBody should be static.
std::optional< CollisionProperties > collisionProperties_
std::vector< Collision * > ownedCollisionChildren_
void markCollisionPropertiesResolved()
Marks authored collision metadata as already inspected for this mesh.
std::optional< std::shared_ptr< Entities::SceneNode > > sceneNode
Scene node used for transforms.
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.
Owns scene entities, actor lifetime, and the scene graph root.
Definition Scene.h:84
AssetHandle< GltfRenderableHandleTag > GltfRenderableHandle
Handle to one mesh-bearing node inside a glTF file.
Asset::Ref< Asset::MeshPath, Mesh > MeshAssetRef
Asset reference to mesh geometry loaded from a mesh asset path.
AssetHandle< GeometryMeshHandleTag > GeometryMeshHandle
Handle to non-skinned mesh geometry.
Identifies a named mesh-like asset inside an asset file.
Definition AssetPath.h:89