From 93937c03942c284637c322485e861318d7872c90 Mon Sep 17 00:00:00 2001 From: hyzboy Date: Sun, 15 Jun 2025 21:58:07 +0800 Subject: [PATCH] =?UTF-8?q?CreateComponent=E5=87=BD=E6=95=B0=E8=BF=81?= =?UTF-8?q?=E7=A7=BB=E5=88=B0RenderFramework?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- inc/hgl/WorkObject.h | 62 +----------------------------- inc/hgl/graph/RenderFramework.h | 68 +++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 61 deletions(-) diff --git a/inc/hgl/WorkObject.h b/inc/hgl/WorkObject.h index 2262d3d5..4c6f883a 100644 --- a/inc/hgl/WorkObject.h +++ b/inc/hgl/WorkObject.h @@ -128,67 +128,7 @@ namespace hgl template inline C *CreateComponent(ARGS...args) { - auto manager=C::GetDefaultManager(); //取得默认管理器 - - if(!manager) - { - // LOG_ERROR(OS_TEXT("CreateComponent failed, no default manager!")); - return(nullptr); - } - - return manager->CreateComponent(args...); //创建组件 - } - - template - inline C *CreateComponent(graph::SceneNode *parent_node,ARGS...args) - { - if(!parent_node) - { - // LOG_ERROR(OS_TEXT("CreateComponent failed, parent node is null!")); - return(nullptr); - } - - C *c=this->CreateComponent(args...); //创建组件 - - if(!c) - { - // LOG_ERROR(OS_TEXT("CreateComponent failed, create component failed!")); - return(nullptr); - } - - /** - * 如果此处出现转换错误,请检查是否包含了对应的Component头文件。 - */ - parent_node->AttachComponent(c); //将组件附加到父节点 - - return c; - } - - template - inline C *CreateComponent(const graph::Matrix4f &mat,graph::SceneNode *parent_node,ARGS...args) - { - if(!parent_node) - { - // LOG_ERROR(OS_TEXT("CreateComponent failed, parent node is null!")); - return(nullptr); - } - - C *c=this->CreateComponent(args...); //创建组件 - - if(!c) - { - // LOG_ERROR(OS_TEXT("CreateComponent failed, create component failed!")); - return(nullptr); - } - - /** - * 如果此处出现转换错误,请检查是否包含了对应的Component头文件。 - */ - parent_node->AttachComponent(c); //将组件附加到父节点 - - c->graph::SceneOrient::SetLocalMatrix(mat); - - return c; + return render_framework?render_framework->CreateComponent(args...):nullptr; //创建组件 } };//class WorkObject diff --git a/inc/hgl/graph/RenderFramework.h b/inc/hgl/graph/RenderFramework.h index c305d7fd..eccd18f8 100644 --- a/inc/hgl/graph/RenderFramework.h +++ b/inc/hgl/graph/RenderFramework.h @@ -146,6 +146,74 @@ public: // ComponentManager { return light_component_manager; } + +public: //Component 相关 + + template + inline C *CreateComponent(ARGS...args) + { + auto manager=C::GetDefaultManager(); //取得默认管理器 + + if(!manager) + { + // LOG_ERROR(OS_TEXT("CreateComponent failed, no default manager!")); + return(nullptr); + } + + return manager->CreateComponent(args...); //创建组件 + } + + template + inline C *CreateComponent(graph::SceneNode *parent_node,ARGS...args) + { + if(!parent_node) + { + // LOG_ERROR(OS_TEXT("CreateComponent failed, parent node is null!")); + return(nullptr); + } + + C *c=this->CreateComponent(args...); //创建组件 + + if(!c) + { + // LOG_ERROR(OS_TEXT("CreateComponent failed, create component failed!")); + return(nullptr); + } + + /** + * 如果此处出现转换错误,请检查是否包含了对应的Component头文件。 + */ + parent_node->AttachComponent(c); //将组件附加到父节点 + + return c; + } + + template + inline C *CreateComponent(const graph::Matrix4f &mat,graph::SceneNode *parent_node,ARGS...args) + { + if(!parent_node) + { + // LOG_ERROR(OS_TEXT("CreateComponent failed, parent node is null!")); + return(nullptr); + } + + C *c=this->CreateComponent(args...); //创建组件 + + if(!c) + { + // LOG_ERROR(OS_TEXT("CreateComponent failed, create component failed!")); + return(nullptr); + } + + /** + * 如果此处出现转换错误,请检查是否包含了对应的Component头文件。 + */ + parent_node->AttachComponent(c); //将组件附加到父节点 + + c->graph::SceneOrient::SetLocalMatrix(mat); + + return c; + } };//class RenderFramework VK_NAMESPACE_END