建立最基础的SceneWorldManager

This commit is contained in:
hyzboy 2025-05-22 01:42:16 +08:00
parent 8a99a331c0
commit 75da8cabef
6 changed files with 68 additions and 17 deletions

2
CMCore

@ -1 +1 @@
Subproject commit 511dd86c56383bc14078602f5e5baab1a3109ae5 Subproject commit f1a6f0b90eb7766be90afb7e62ec539dfa30f746

2
CMUtil

@ -1 +1 @@
Subproject commit 6173c16bf1744eb15472aa198d3a2a5c4513e78e Subproject commit 48383e5f63928bab43320c406219365850507246

View File

@ -1,26 +1,28 @@
#pragma once #pragma once
#include<hgl/graph/SceneNode.h> #include<hgl/graph/SceneNode.h>
#include<hgl/type/Pool.h>
namespace hgl::graph namespace hgl::graph
{ {
class CameraData
{
};
class CameraManager
{
public:
};
/** /**
* <Br> * <Br>
* *
*/ */
class SceneWorld class SceneWorld
{ {
U8String WorldName; ///<世界名称
ObjectList<SceneNode> SceneNodePool; ///<场景节点池
SceneNode *root_node; ///<世界根节点 SceneNode *root_node; ///<世界根节点
public:
const U8String & GetWorldName()const{return WorldName;} ///<获取世界名称
SceneNode * GetRootNode (){return root_node;} ///<获取世界根节点
public: public:
SceneWorld() SceneWorld()
@ -32,7 +34,17 @@ namespace hgl::graph
{ {
SAFE_CLEAR(root_node); SAFE_CLEAR(root_node);
} }
SceneNode *GetRootNode(){return root_node;}
};//class SceneWorld };//class SceneWorld
bool RegistrySceneWorld(SceneWorld *sw); ///<注册场景世界
bool UnregistrySceneWorld(const U8String &world_name); ///<注销场景世界
inline bool UnregistrySceneWorld(SceneWorld *sw) ///<注销场景世界
{
if(!sw)return(false);
return UnregistrySceneWorld(sw->GetWorldName());
}
SceneWorld *GetSceneWorld(const U8String &world_name); ///<获取指定名称的场景世界
}//namespace hgl::graph }//namespace hgl::graph

View File

@ -43,7 +43,7 @@ public:
{ {
if(name.IsEmpty())return(nullptr); if(name.IsEmpty())return(nullptr);
return GetObjectFromList(ubo_map,name); return GetObjectFromMap(ubo_map,name);
} }
void RemoveUBO(DeviceBuffer *buf) void RemoveUBO(DeviceBuffer *buf)
@ -65,7 +65,7 @@ public:
{ {
if(name.IsEmpty())return(nullptr); if(name.IsEmpty())return(nullptr);
return GetObjectFromList(ssbo_map,name); return GetObjectFromMap(ssbo_map,name);
} }
void RemoveSSBO(DeviceBuffer *buf) void RemoveSSBO(DeviceBuffer *buf)
@ -87,7 +87,7 @@ public:
{ {
if(name.IsEmpty())return(nullptr); if(name.IsEmpty())return(nullptr);
return GetObjectFromList(texture_map,name); return GetObjectFromMap(texture_map,name);
} }
void RemoveTexture(Texture *tex) void RemoveTexture(Texture *tex)

View File

@ -27,7 +27,7 @@ public:
public: public:
GraphModule * Get(const size_t type_hash) {return GetObjectFromList(module_map,type_hash);} ///<取得指定类型的模块 GraphModule * Get(const size_t type_hash) {return GetObjectFromMap(module_map,type_hash);} ///<取得指定类型的模块
template<typename T> template<typename T>
T * Get() {return((T *)Get(typeid(T).hash_code()));} ///<取得指定类型的模块 T * Get() {return((T *)Get(typeid(T).hash_code()));} ///<取得指定类型的模块

View File

@ -0,0 +1,39 @@
#include<hgl/graph/SceneWorld.h>
#include<hgl/type/Map.h>
namespace hgl::graph
{
namespace
{
Map<U8String,SceneWorld *> scene_world_map;///<场景世界列表
}//namespace
bool RegistrySceneWorld(SceneWorld *sw)
{
if(!sw)return(false);
const U8String &world_name=sw->GetWorldName();
if(scene_world_map.Find(world_name))
return false;///<已经注册过了
scene_world_map.Add(world_name,sw);
return true;
}
SceneWorld *GetSceneWorld(const U8String &world_name)
{
if(world_name.IsEmpty())
return(nullptr);
return GetObjectFromMap(scene_world_map,world_name);
}
bool UnregistrySceneWorld(const U8String &world_name)
{
if(world_name.IsEmpty())
return(false);
return scene_world_map.DeleteByKey(world_name);
}
}//namespace hgl::graph