开启写Component,参考AMD FidelityFX Framework
This commit is contained in:
parent
ada6a41fc6
commit
b05538b501
@ -1,21 +1,76 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include<hgl/type/DataType.h>
|
#include<hgl/type/DataType.h>
|
||||||
|
#include<hgl/type/SortedSet.h>
|
||||||
|
|
||||||
namespace hgl::graph
|
namespace hgl::graph
|
||||||
{
|
{
|
||||||
|
class ComponentManager;
|
||||||
|
class SceneNode;
|
||||||
|
|
||||||
|
struct ComponentData{};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 基础组件<br>
|
* 基础组件<br>
|
||||||
* 是一切组件的基类
|
* 是一切组件的基类
|
||||||
*/
|
*/
|
||||||
class BaseComponent
|
class Component
|
||||||
{
|
{
|
||||||
|
SceneNode * OwnerNode;
|
||||||
|
ComponentManager * Manager;
|
||||||
|
ComponentData * Data;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual ~BaseComponent()=default;
|
Component()=delete;
|
||||||
|
Component(SceneNode *sn,ComponentData *cd,ComponentManager *cm)
|
||||||
|
{
|
||||||
|
OwnerNode=sn;
|
||||||
|
Data=cd;
|
||||||
|
Manager=cm;
|
||||||
|
}
|
||||||
|
virtual ~Component()=default;
|
||||||
|
|
||||||
public: //序列化
|
public:
|
||||||
|
|
||||||
|
virtual void Update(const double delta_time)=0;
|
||||||
|
|
||||||
};//class BaseComponent
|
virtual void OnFocusLost(){} ///<焦点丢失事件
|
||||||
|
virtual void OnFocusGained(){} ///<焦点获得事件
|
||||||
|
};//class Component
|
||||||
|
|
||||||
|
//Component *CreateComponent(const ObjectBaseInfo &,ComponentData *);
|
||||||
|
|
||||||
|
//template<typename T,typename ...ARGS> inline T *NewComponentSCL(const SourceCodeLocation &scl,ARGS...args)
|
||||||
|
//{
|
||||||
|
// static size_t new_count=0;
|
||||||
|
// ObjectBaseInfo obi;
|
||||||
|
|
||||||
|
// obi.hash_code =GetTypeHash<T>();
|
||||||
|
// obi.unique_id =new_count;
|
||||||
|
// obi.scl =scl;
|
||||||
|
|
||||||
|
// ++new_count;
|
||||||
|
// T *obj=new T(obi);
|
||||||
|
// return obj;
|
||||||
|
//}
|
||||||
|
|
||||||
|
//#define NewComponent(T,...) NewComponentSCL<T>(HGL_SOURCE_LOCATION __VA_OPT__(,) __VA_ARGS__)
|
||||||
|
|
||||||
|
class ComponentManager
|
||||||
|
{
|
||||||
|
SortedSet<Component *> ComponentSet;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
virtual ~ComponentManager()=default;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
virtual size_t ComponentHashCode()const=0;
|
||||||
|
|
||||||
|
virtual Component * CreateComponent(SceneNode *,ComponentData *)=0;
|
||||||
|
|
||||||
|
virtual int GetComponentCount()const=0;
|
||||||
|
};//class ComponentManager
|
||||||
}//namespace hgl::graph
|
}//namespace hgl::graph
|
||||||
|
@ -7,7 +7,7 @@ namespace hgl::graph
|
|||||||
/**
|
/**
|
||||||
* 可渲染组件
|
* 可渲染组件
|
||||||
*/
|
*/
|
||||||
class RenderComponent: public BaseComponent
|
class RenderComponent: public Component
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#ifndef HGL_GRAPH_RENDER_NODE_INCLUDE
|
#pragma once
|
||||||
#define HGL_GRAPH_RENDER_NODE_INCLUDE
|
|
||||||
|
|
||||||
#include<hgl/graph/VK.h>
|
#include<hgl/graph/VK.h>
|
||||||
#include<hgl/type/SortedSet.h>
|
#include<hgl/type/SortedSet.h>
|
||||||
|
|
||||||
namespace hgl
|
namespace hgl
|
||||||
{
|
{
|
||||||
namespace graph
|
namespace graph
|
||||||
@ -40,4 +40,3 @@ namespace hgl
|
|||||||
return a.compare(b);
|
return a.compare(b);
|
||||||
}
|
}
|
||||||
}//namespace hgl
|
}//namespace hgl
|
||||||
#endif//HGL_GRAPH_RENDER_NODE_INCLUDE
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user