3#include "Engine/Component/LogicComponent.h"
4#include "Engine/Asset/AssetRegistry.h"
5#include "Engine/Asset/AssetHandles.h"
6#include "Engine/Core/Asset.h"
7#include "Engine/Ecs/EcsData.h"
8#include "Engine/Material/MaterialTypes.h"
9#include "Engine/Mesh/MeshAssetRef.h"
16#include <tracy/Tracy.hpp>
34 class RenderingDataManager;
52 std::string
name =
"game object";
63 std::shared_ptr<Entities::SceneNode>
sceneNode,
64 bool isVisible_ =
true,
65 const std::string & name_ =
"game object"
75 std::shared_ptr<Entities::SceneNode>
sceneNode,
76 bool isVisible_ =
true,
77 const std::string & name_ =
"game object"
87 std::shared_ptr<Entities::SceneNode>
sceneNode,
88 bool isVisible_ =
true,
89 const std::string & name_ =
"game object"
99 std::shared_ptr<Entities::SceneNode>
sceneNode,
100 Core::RenderingDataManager * renderingDataManager,
101 bool isVisible_ =
true,
102 const std::string & name_ =
"game object"
110 entt::entity & actor,
112 std::shared_ptr<Entities::SceneNode>
sceneNode,
113 Core::RenderingDataManager * renderingDataManager,
114 bool isVisible_ =
true,
115 const std::string & name_ =
"game object"
123 entt::entity & actor,
125 std::shared_ptr<Entities::SceneNode>
sceneNode,
126 Core::RenderingDataManager * renderingDataManager,
127 bool isVisible_ =
true,
128 const std::string & name_ =
"game object"
177 [[nodiscard]] std::optional<Core::AnchorPoint>
anchorPoint( std::string_view
name )
const;
256 [[nodiscard]] std::shared_ptr<Entities::SceneNode>
getSceneNode()
const;
265 std::optional<std::shared_ptr<Entities::SceneNode>>
sceneNode;
270 entt::entity & actor,
272 std::optional<Assets::GltfRenderableHandle> renderable,
The mesh asset stores geometry data and.
Base class for collision shape components.
Logic(Entities::Scene *owningScene)
Constructs a logic component owned by a scene.
std::vector< Collision * > collisionChildren_
void initializeMeshData(Entities::Scene *owningScene, entt::entity &actor, Asset::MeshPath asset, std::optional< Assets::GltfRenderableHandle > renderable, Assets::GeometryMeshHandle mesh)
Assets::MeshAssetRef getMeshAsset() const
Gets the asset used by this mesh rendering component.
void setMaterialOverride(Assets::MaterialHandle material)
Overrides the material used for rendering this mesh.
bool ownsCollisionChild(const Logic *component) const
Checks whether a logic component is one of this mesh's collision children.
std::optional< Core::AnchorPoint > anchorPoint(std::string_view name) const
Looks up an AnchorPoint on this renderable-backed mesh.
void setVisible(bool isVisible)
Sets whether this mesh component should be rendered.
void beginPlay() override
Called when the component is added to the scene or the game starts.
void attachCollisionChild(Collision *collision)
Records a collision component owned by this mesh.
std::optional< std::shared_ptr< Entities::SceneNode > > sceneNode
Scene node used for transforms.
static constexpr const char * ComponentName
Component type name.
void attachCollisionChildren(const std::vector< Collision * > &collisions)
Records multiple collision components owned by this mesh.
glm::mat4 getWorldTransform() const
Getter for the world transform of the mesh component.
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.
std::string getAssetName() const
Gets the asset name of this mesh component (e.g. "rat")
~Mesh() override=default
Destroys the mesh component.
const std::vector< Collision * > & getCollisionChildren() const
Gets collision components owned by this mesh.
bool isVisible() const
If this mesh component should be considered for rendering.
std::optional< Assets::MaterialHandle > materialOverride_
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.
Rendering::PipelineNames getMaterialNames() const
Gets the material name of this mesh component.
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.
bool drawImGui() override
Draw the debug UI.
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.
Ecs::StaticMeshData * getStaticMeshData() const
Gets the ECS static mesh data for derived components.
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.
entt::entity componentEntity
ECS entity that stores this mesh component data.
virtual void onMeshAssetResolved(Assets::MeshAssetRef meshAsset)
Called when the mesh asset reference has resolved.
void clearMaterialOverride()
Clears the material override and returns to the mesh material.
Core::RenderingDataManager * renderingDataManager_
std::vector< std::string > anchorPointNames() const
Lists this renderable's AnchorPoint names.
std::optional< Assets::MaterialHandle > getMaterialOverride() const
Gets the current material override.
glm::mat4 getLocalTransform() const
Gets the local model matrix which isn't affected by its parent.
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.
void detachCollisionChild(const Collision *collision)
Removes a collision component from this mesh's child list.
void endPlay() override
Called when the component is removed or the game ends.
std::shared_ptr< Entities::SceneNode > getSceneNode() const
Gets the scene node used for mesh transforms.
Represents a node in the scene graph, containing information about its position, rotation,...
Owns scene entities, actor lifetime, and the scene graph root.
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.
AssetHandle< MaterialHandleTag > MaterialHandle
Handle to a material payload.
PipelineNames
Named graphics pipelines used by material selection and shader lookup.
Identifies a named mesh-like asset inside an asset file.
Mesh component state for one static mesh reference.