建立最基础的SceneWorldManager

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

2
CMCore

Submodule CMCore updated: 511dd86c56...f1a6f0b90e

2
CMUtil

Submodule CMUtil updated: 6173c16bf1...48383e5f63

View File

@@ -1,26 +1,28 @@
#pragma once
#include<hgl/graph/SceneNode.h>
#include<hgl/type/Pool.h>
namespace hgl::graph
{
class CameraData
{
};
class CameraManager
{
public:
};
/**
* 世界场景管理器<Br>
* 管理一个世界场景中的所有资源与场景节点
*/
class SceneWorld
{
U8String WorldName; ///<世界名称
ObjectList<SceneNode> SceneNodePool; ///<场景节点池
SceneNode *root_node; ///<世界根节点
public:
const U8String & GetWorldName()const{return WorldName;} ///<获取世界名称
SceneNode * GetRootNode (){return root_node;} ///<获取世界根节点
public:
SceneWorld()
@@ -32,7 +34,17 @@ namespace hgl::graph
{
SAFE_CLEAR(root_node);
}
SceneNode *GetRootNode(){return root_node;}
};//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

View File

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

View File

@@ -27,7 +27,7 @@ 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>
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