ComponentManager增加自动释放功能
This commit is contained in:
@@ -58,10 +58,24 @@ public:
|
||||
*/
|
||||
class Component
|
||||
{
|
||||
static uint unique_id_count;
|
||||
|
||||
uint unique_id;
|
||||
|
||||
SceneNode * OwnerNode;
|
||||
ComponentManager * Manager;
|
||||
ComponentData * Data;
|
||||
|
||||
protected:
|
||||
|
||||
friend class ComponentManager;
|
||||
|
||||
virtual void OnDetachManager(ComponentManager *cm)
|
||||
{
|
||||
if(cm==Manager)
|
||||
Manager=nullptr;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
Component()=delete;
|
||||
@@ -72,6 +86,8 @@ public:
|
||||
|
||||
public:
|
||||
|
||||
uint GetUniqueID ()const{return unique_id;}
|
||||
|
||||
SceneNode * GetOwnerNode()const{return OwnerNode;}
|
||||
ComponentManager * GetManager ()const{return Manager;}
|
||||
ComponentData * GetData ()const{return Data;}
|
||||
@@ -83,7 +99,7 @@ public:
|
||||
public: //事件
|
||||
|
||||
virtual void OnAttach(SceneNode *node){if(node)OwnerNode=node;} ///<附加到节点事件
|
||||
virtual void OnDetach(SceneNode *node){OwnerNode=nullptr;} ///<从节点分离事件
|
||||
virtual void OnDetach(SceneNode *){OwnerNode=nullptr;} ///<从节点分离事件
|
||||
|
||||
virtual void OnFocusLost(){} ///<焦点丢失事件
|
||||
virtual void OnFocusGained(){} ///<焦点获得事件
|
||||
@@ -108,17 +124,17 @@ public:
|
||||
virtual const size_t GetComponentHashCode()const=0;
|
||||
virtual const size_t GetHashCode()const=0;
|
||||
|
||||
virtual ~ComponentManager()=default;
|
||||
virtual ~ComponentManager();
|
||||
|
||||
public:
|
||||
|
||||
virtual Component * CreateComponent(ComponentData *)=0;
|
||||
|
||||
int GetComponentCount()const{return component_set.GetCount();}
|
||||
const size_t GetComponentCount()const{return component_set.GetCount();}
|
||||
|
||||
ComponentSet & GetComponents(){return component_set;}
|
||||
|
||||
int GetComponents(ArrayList<Component *> &comp_list,SceneNode *);
|
||||
int GetComponents(ComponentList &comp_list,SceneNode *);
|
||||
|
||||
virtual void UpdateComponents(const double delta_time);
|
||||
|
||||
|
@@ -57,7 +57,7 @@ namespace hgl::graph
|
||||
|
||||
public:
|
||||
|
||||
virtual ~SceneNode()=default;
|
||||
virtual ~SceneNode();
|
||||
|
||||
void Clear() override
|
||||
{
|
||||
@@ -106,8 +106,8 @@ namespace hgl::graph
|
||||
|
||||
public: //组件相关方法
|
||||
|
||||
bool ComponentIsEmpty ()const{return component_set.GetCount()==0;} ///<是否没有组件
|
||||
virtual int GetComponentCount ()const{return component_set.GetCount();} ///<取得组件数量
|
||||
bool ComponentIsEmpty ()const{return component_set.IsEmpty();} ///<是否没有组件
|
||||
virtual const int64 GetComponentCount ()const{return component_set.GetCount();} ///<取得组件数量
|
||||
virtual bool AttachComponent (Component *comp) ///<添加一个组件
|
||||
{
|
||||
if(!comp)return(false);
|
||||
|
@@ -1,8 +1,8 @@
|
||||
#ifndef HGL_GRAPH_VULKAN_MATERIAL_INCLUDE
|
||||
#define HGL_GRAPH_VULKAN_MATERIAL_INCLUDE
|
||||
#pragma once
|
||||
|
||||
#include<hgl/graph/VK.h>
|
||||
#include<hgl/type/Map.h>
|
||||
#include<hgl/type/SortedSet.h>
|
||||
#include<hgl/type/String.h>
|
||||
#include<hgl/graph/VKShaderModuleMap.h>
|
||||
#include<hgl/graph/mtl/ShaderBufferSource.h>
|
||||
@@ -106,6 +106,5 @@ public:
|
||||
MaterialInstance *CreateMI(const VILConfig *vil_cfg=nullptr);
|
||||
};//class Material
|
||||
|
||||
using MaterialSets=SortedSet<Material *>;
|
||||
using MaterialSet=SortedSet<Material *>;
|
||||
VK_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_VULKAN_MATERIAL_INCLUDE
|
||||
|
@@ -2,7 +2,6 @@
|
||||
|
||||
#include<hgl/graph/VK.h>
|
||||
#include<hgl/type/String.h>
|
||||
#include<hgl/type/SortedSet.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
class VulkanPhyDevice
|
||||
|
@@ -1,9 +1,7 @@
|
||||
#ifndef HGL_GRAPH_VULKAN_SHADER_MODULE_INCLUDE
|
||||
#define HGL_GRAPH_VULKAN_SHADER_MODULE_INCLUDE
|
||||
#pragma once
|
||||
|
||||
#include<hgl/graph/VK.h>
|
||||
#include<hgl/graph/VKVertexInputLayout.h>
|
||||
#include<hgl/type/SortedSet.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
|
||||
@@ -46,4 +44,3 @@ public:
|
||||
operator VkShaderModule ()const{return stage_create_info->module;}
|
||||
};//class ShaderModule
|
||||
VK_NAMESPACE_END
|
||||
#endif//HGL_GRAPH_VULKAN_SHADER_MODULE_INCLUDE
|
||||
|
Reference in New Issue
Block a user