Vulkan Schnee 0.0.1
High-performance rendering engine
Loading...
Searching...
No Matches
EngineCore::MeshComponent Class Reference

A component which can be attached as many times to an actor as one wants. It makes it possible to render a mesh attached to an object. More...

#include <MeshComponent.h>

Inheritance diagram for EngineCore::MeshComponent:
Collaboration diagram for EngineCore::MeshComponent:

Public Member Functions

 MeshComponent (Scene *owningScene, entt::entity &actor, Asset::Path asset, std::shared_ptr< SceneNode > sceneNode, bool isVisible_=true, const std::string &name_="game object")
 Production constructor - uses EngineManager singleton to get RenderingDataManager.
 MeshComponent (Scene *owningScene, entt::entity &actor, Asset::Path asset, std::shared_ptr< SceneNode > sceneNode, RenderingDataManager *renderingDataManager, bool isVisible_=true, const std::string &name_="game object")
 Testable constructor - allows injecting RenderingDataManager for testing.
 ~MeshComponent () 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 isVisible () const
 If this mesh component should be considered for rendering.
MeshAssetgetMeshAsset () 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.
PipelineNames getMaterialNames () const
 Gets the material name of this mesh component.
Public Member Functions inherited from EngineCore::LogicComponent
 LogicComponent (Scene *owningScene)
virtual ~LogicComponent ()=default
virtual void tick (double deltaTime)
 Called every frame if ticking is enabled.
bool canTick () const
 Checks if the component is currently set to tick.
void setCanTick (bool enable)
 Enables or disables ticking for this component.
EntitygetOwningEntity () const
 Gets the entity this component belongs to.

Private Attributes

std::string name = "game object"
bool visible = true
entt::entity componentEntity = entt::null
std::optional< std::shared_ptr< SceneNode > > sceneNode
Ecs::StaticMeshDatastaticMeshData = nullptr
RenderingDataManagerrenderingDataManager_ = nullptr

Additional Inherited Members

Static Public Attributes inherited from EngineCore::LogicComponent
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.
Protected Member Functions inherited from EngineCore::LogicComponent
ScenegetScene () const
 Gets the scene this component belongs to.
SceneManagergetSceneManager () const
 Helper to get the SceneManager from the owning scene.

Detailed Description

A component which can be attached as many times to an actor as one wants. It makes it possible to render a mesh attached to an object.

Definition at line 27 of file MeshComponent.h.

Constructor & Destructor Documentation

◆ MeshComponent() [1/2]

EngineCore::MeshComponent::MeshComponent ( Scene * owningScene,
entt::entity & actor,
Asset::Path asset,
std::shared_ptr< SceneNode > sceneNode,
bool isVisible_ = true,
const std::string & name_ = "game object" )

Production constructor - uses EngineManager singleton to get RenderingDataManager.

Definition at line 9 of file MeshComponent.cpp.

References MeshComponent(), and sceneNode.

Referenced by MeshComponent().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MeshComponent() [2/2]

EngineCore::MeshComponent::MeshComponent ( Scene * owningScene,
entt::entity & actor,
Asset::Path asset,
std::shared_ptr< SceneNode > sceneNode,
RenderingDataManager * renderingDataManager,
bool isVisible_ = true,
const std::string & name_ = "game object" )

Testable constructor - allows injecting RenderingDataManager for testing.

Definition at line 21 of file MeshComponent.cpp.

References componentEntity, Ecs::RegistryManager::get(), EngineCore::Scene::getAssetManager(), EngineCore::AssetManager::getMeshAsset(), EngineCore::LogicComponent::LogicComponent(), name, Ecs::Parent::parent, renderingDataManager_, sceneNode, staticMeshData, and visible.

Here is the call graph for this function:

◆ ~MeshComponent()

EngineCore::MeshComponent::~MeshComponent ( )
overridedefault

Member Function Documentation

◆ beginPlay()

void EngineCore::MeshComponent::beginPlay ( )
overridevirtual

Called when the component is added to the scene or the game starts.

Reimplemented from EngineCore::LogicComponent.

Definition at line 57 of file MeshComponent.cpp.

References EngineCore::LogicComponent::beginPlay(), Ecs::RegistryManager::get(), EngineCore::EngineManager::getEngineModule(), EngineCore::EngineManager::getInstance(), EngineCore::Engine::getRenderer(), EngineCore::Renderer::getRenderingDataManager(), renderingDataManager_, and sceneNode.

Here is the call graph for this function:

◆ endPlay()

void EngineCore::MeshComponent::endPlay ( )
overridevirtual

Called when the component is removed or the game ends.

Reimplemented from EngineCore::LogicComponent.

Definition at line 86 of file MeshComponent.cpp.

References EngineCore::LogicComponent::endPlay(), Ecs::RegistryManager::get(), renderingDataManager_, and sceneNode.

Here is the call graph for this function:

◆ getLocalTransform()

glm::mat4 EngineCore::MeshComponent::getLocalTransform ( ) const
nodiscard

Gets the local model matrix which isn't affected by its parent.

Returns
glm local model matrix

Definition at line 123 of file MeshComponent.cpp.

References sceneNode.

◆ getMaterialNames()

PipelineNames EngineCore::MeshComponent::getMaterialNames ( ) const
nodiscard

Gets the material name of this mesh component.

Returns
name of the material used or defaults ot normals if none is used

Definition at line 128 of file MeshComponent.cpp.

References EngineCore::NORMALS_SHADER.

◆ getMeshAsset()

MeshAsset * EngineCore::MeshComponent::getMeshAsset ( ) const
nodiscard

Gets the asset used by this mesh rendering component.

Returns
Pointer to the mesh asset used by this mesh renderer

Definition at line 112 of file MeshComponent.cpp.

References staticMeshData.

Referenced by EngineCore::RenderingDataManager::snapshotRenderableMeshes(), EngineCore::RenderingDataManager::updatePrimitiveData(), EngineCore::RenderingDataManager::updatePrimitiveDataInstanced(), and EngineCore::RenderingDataManager::updateTransforms().

Here is the caller graph for this function:

◆ getWorldTransform()

glm::mat4 EngineCore::MeshComponent::getWorldTransform ( ) const
nodiscard

Getter for the world transform of the mesh component.

Returns
model matrix which is affected by the scene graph hierarchy

Definition at line 118 of file MeshComponent.cpp.

References sceneNode.

Referenced by EngineCore::RenderingDataManager::updatePrimitiveData(), EngineCore::RenderingDataManager::updatePrimitiveDataInstanced(), and EngineCore::RenderingDataManager::updateTransforms().

Here is the caller graph for this function:

◆ isVisible()

bool EngineCore::MeshComponent::isVisible ( ) const
nodiscard

If this mesh component should be considered for rendering.

Returns
visible = true

Definition at line 107 of file MeshComponent.cpp.

References visible.

Referenced by EngineCore::RenderingDataManager::snapshotRenderableMeshes(), EngineCore::RenderingDataManager::updatePrimitiveData(), EngineCore::RenderingDataManager::updatePrimitiveDataInstanced(), and EngineCore::RenderingDataManager::updateTransforms().

Here is the caller graph for this function:

Member Data Documentation

◆ componentEntity

entt::entity EngineCore::MeshComponent::componentEntity = entt::null
private

Definition at line 93 of file MeshComponent.h.

Referenced by MeshComponent().

◆ name

std::string EngineCore::MeshComponent::name = "game object"
private

Definition at line 29 of file MeshComponent.h.

Referenced by MeshComponent().

◆ renderingDataManager_

RenderingDataManager* EngineCore::MeshComponent::renderingDataManager_ = nullptr
private

Definition at line 97 of file MeshComponent.h.

Referenced by beginPlay(), endPlay(), and MeshComponent().

◆ sceneNode

std::optional<std::shared_ptr<SceneNode> > EngineCore::MeshComponent::sceneNode
private

◆ staticMeshData

Ecs::StaticMeshData* EngineCore::MeshComponent::staticMeshData = nullptr
private

Definition at line 96 of file MeshComponent.h.

Referenced by getMeshAsset(), and MeshComponent().

◆ visible

bool EngineCore::MeshComponent::visible = true
private

Definition at line 30 of file MeshComponent.h.

Referenced by isVisible(), and MeshComponent().


The documentation for this class was generated from the following files:
  • /home/magerbeton/Documents/gl3-vulkan/Engine/include/Engine/Component/MeshComponent.h
  • /home/magerbeton/Documents/gl3-vulkan/Engine/src/Engine/Component/MeshComponent.cpp