增加新的StaticMeshComponent,并添加关于各Component关系的注释

This commit is contained in:
hyzboy 2025-03-25 23:15:38 +08:00
parent 87989a8e42
commit 964c17cf94
3 changed files with 79 additions and 3 deletions

View File

@ -4,6 +4,30 @@
#include<hgl/type/SortedSet.h> #include<hgl/type/SortedSet.h>
#include<hgl/type/List.h> #include<hgl/type/List.h>
/**
* Component/Data/Manager
*
* AMD FidelityFX
*
* AMD FidelityFX中Component存放于Entity下SceneNode
* Entity还是SceneNodeComponent的管理
*
* ComponentData是每个Component的数据Component或是其它模块提供数据
* ComponentManager是Component的管理器Component的创建
*
* Component是组件的基类
*
*
* RenderComponent是可渲染组件的基类Component
*
* PrimitiveComponent是图元组件的基类RenderComponent
* Component都必须是一个有3D空间的几何图元
* PrimitiveComponent提供数据进行计算
*
* StaticMeshComponent是静态网格组件PrimitiveComponent实现
*
*/
#define COMPONENT_NAMESPACE hgl::graph #define COMPONENT_NAMESPACE hgl::graph
#define COMPONENT_NAMESPACE_BEGIN namespace COMPONENT_NAMESPACE { #define COMPONENT_NAMESPACE_BEGIN namespace COMPONENT_NAMESPACE {
#define COMPONENT_NAMESPACE_END } #define COMPONENT_NAMESPACE_END }

View File

@ -1,18 +1,19 @@
#pragma once #pragma once
#include<hgl/component/RenderComponent.h> #include<hgl/component/RenderComponent.h>
#include<hgl/graph/VKRenderable.h>
COMPONENT_NAMESPACE_BEGIN COMPONENT_NAMESPACE_BEGIN
/**
* <br>
*
*/
class PrimitiveComponent:public RenderComponent class PrimitiveComponent:public RenderComponent
{ {
public: public:
PrimitiveComponent()=default; PrimitiveComponent()=default;
virtual ~PrimitiveComponent()=default; virtual ~PrimitiveComponent()=default;
Renderable *GetRenderable();
};//class PrimitiveComponent };//class PrimitiveComponent
COMPONENT_NAMESPACE_END COMPONENT_NAMESPACE_END

View File

@ -0,0 +1,51 @@
#pragma once
#include<hgl/component/PrimitiveComponent.h>
#include<hgl/graph/VKRenderable.h>
COMPONENT_NAMESPACE_BEGIN
struct StaticMeshComponentData:public ComponentData
{
Renderable *renderable;
};//struct StaticMeshComponentData
class StaticMeshComponent:public PrimitiveComponent;
class StaticMeshComponentManager:public ComponentManager
{
public:
StaticMeshComponentManager()=default;
StaticMeshComponent *CreateStaticMeshComponent(SceneNode *psn,StaticMeshComponentData *data);
virtual Component *CreateComponent(SceneNode *psn,ComponentData *data) override
{
return CreateStaticMeshComponent(psn,reinterpret_cast<StaticMeshComponentData *>(data));
}
};//class StaticMeshComponentManager
class StaticMeshComponent:public PrimitiveComponent
{
StaticMeshComponentData *sm_data;
public:
StaticMeshComponent(SceneNode *psn,ComponentData *cd,ComponentManager *cm)
:PrimitiveComponent(psn,cd,cm)
{
sm_data=reinterpret_cast<StaticMeshComponentData *>(cd);
}
virtual ~StaticMeshComponent()
{
SAFE_CLEAR(sm_Data);
}
StaticMeshComponentData &GetData() {return *sm_data;}
const StaticMeshComponentData &GetData()const {return *sm_data;}
};//class StaticMeshComponent
COMPONENT_NAMESPACE_END