diff --git a/inc/hgl/graph/MVPMatrix.h b/inc/hgl/graph/MVPMatrix.h index db1e7405..b1024e16 100644 --- a/inc/hgl/graph/MVPMatrix.h +++ b/inc/hgl/graph/MVPMatrix.h @@ -32,5 +32,5 @@ namespace hgl CompOperatorMemcmp(const MVPMatrix &); };//struct MVPMatrix }//namespace graph -//namespace hgl +}//namespace hgl #endif//HGL_GRAPH_MVP_MATRIX_INCLUDE diff --git a/inc/hgl/graph/RenderList.h b/inc/hgl/graph/RenderList.h index 67d2d463..80aca4c5 100644 --- a/inc/hgl/graph/RenderList.h +++ b/inc/hgl/graph/RenderList.h @@ -16,6 +16,10 @@ namespace hgl using MVPArrayBuffer=GPUArrayBuffer; using MVPOffsetBuffer=List; + /** + * 渲染对象列表
+ * 已经展开的渲染对象列表,产生mvp用UBO/SSBO等数据,最终创建RenderCommandBuffer + */ class RenderList { GPUDevice *device; diff --git a/inc/hgl/graph/SceneNode.h b/inc/hgl/graph/SceneNode.h index e84bd36b..baa79380 100644 --- a/inc/hgl/graph/SceneNode.h +++ b/inc/hgl/graph/SceneNode.h @@ -10,7 +10,8 @@ namespace hgl { /** * 场景节点数据类
- * 从场景坐标变换(SceneOrient)类继承 + * 从场景坐标变换(SceneOrient)类继承, + * 每个场景节点中可能包括一个可渲染数据实例,或是完全不包含(用于坐标变换的父节点,或是灯光/摄像机之类)。 */ class SceneNode:public SceneOrient ///场景节点类 { diff --git a/inc/hgl/graph/SceneTreeToRenderList.h b/inc/hgl/graph/SceneTreeToRenderList.h index 6ed85e45..25904b9f 100644 --- a/inc/hgl/graph/SceneTreeToRenderList.h +++ b/inc/hgl/graph/SceneTreeToRenderList.h @@ -1,11 +1,19 @@ -#ifndef HGL_GRAPH_SCENE_TREE_TO_RENDER_LIST_INCLUDE +#ifndef HGL_GRAPH_SCENE_TREE_TO_RENDER_LIST_INCLUDE #define HGL_GRAPH_SCENE_TREE_TO_RENDER_LIST_INCLUDE #include +#include +#include +#include namespace hgl { namespace graph { + struct RenderNode + { + SceneNode *node; + };// + class SceneTreeToRenderList { using PipelineSets=Sets; @@ -24,19 +32,19 @@ namespace hgl protected: - SceneNodeList * scene_node_list; ///<ڵб + SceneNodeList * scene_node_list; ///<场景节点列表 - PipelineSets pipeline_sets; ///<ߺϼ - MaterialSets material_sets; ///<ʺϼ - MatInstanceSets mat_instance_sets; ///<ʵϼ + PipelineSets pipeline_sets; ///<管线合集 + MaterialSets material_sets; ///<材质合集 + MatInstanceSets mat_instance_sets; ///<材质实例合集 RenderList * render_list; protected: - virtual uint32 CameraLength(SceneNode *,SceneNode *); ///<ȽϺ + virtual float CameraLength(SceneNode *,SceneNode *); ///<摄像机距离比较函数 - virtual bool InFrustum(const SceneNode *,void *); ///<ƽͷؼ + virtual bool InFrustum(const SceneNode *,void *); ///<平截头截剪函数 virtual bool Begin(); virtual bool Expend(SceneNode *); @@ -57,7 +65,7 @@ namespace hgl virtual ~SceneTreeToRenderList(); virtual bool Expend(RenderList *,Camera *,SceneNode *); - };//class SceneTreeToRenderList + };//class SceneTreeToRenderList }//namespace graph }//namespace hgl #endif//HGL_GRAPH_SCENE_TREE_TO_RENDER_LIST_INCLUDE diff --git a/src/SceneGraph/RenderList.cpp b/src/SceneGraph/RenderList.cpp index 3182b9a8..0c1595ce 100644 --- a/src/SceneGraph/RenderList.cpp +++ b/src/SceneGraph/RenderList.cpp @@ -15,14 +15,6 @@ namespace hgl { constexpr size_t MVPMatrixBytes=sizeof(MVPMatrix); - float CameraLengthComp(Camera *cam,SceneNode *obj_one,SceneNode *obj_two) - { - if(!cam||!obj_one||!obj_two) - return(0); - - return( length_squared(obj_one->GetCenter(),cam->pos)- - length_squared(obj_two->GetCenter(),cam->pos)); - } //bool FrustumClipFilter(const SceneNode *node,void *fc) //{ diff --git a/src/SceneGraph/SceneNode.cpp b/src/SceneGraph/SceneNode.cpp index e14b61a0..c97563f2 100644 --- a/src/SceneGraph/SceneNode.cpp +++ b/src/SceneGraph/SceneNode.cpp @@ -53,61 +53,61 @@ namespace hgl LocalBoundingBox=local; } - /** - * 从当前节点展开输出到一个渲染列表 - * @param rl 渲染列表 - * @param func 过滤函数 - * @param func_data 过滤函数用辅助数据 - * @return 成功与否 - */ - bool SceneNode::ExpendToList(RenderList *rl,FilterSceneNodeFunc func,void *func_data) - { - if(!rl)return(false); + ///** + //* 从当前节点展开输出到一个渲染列表 + //* @param rl 渲染列表 + //* @param func 过滤函数 + //* @param func_data 过滤函数用辅助数据 + //* @return 成功与否 + //*/ + //bool SceneNode::ExpendToList(RenderList *rl,FilterSceneNodeFunc func,void *func_data) + //{ + // if(!rl)return(false); - if(func) - if(!func(this,func_data)) - return(false); + // if(func) + // if(!func(this,func_data)) + // return(false); - { - int count=renderable_instances.GetCount(); + // { + // int count=renderable_instances.GetCount(); - if(count>0) - rl->Add(this); - } + // if(count>0) + // rl->Add(this); + // } - { - int count=SubNode.GetCount(); - SceneNode **sub=SubNode.GetData(); + // { + // int count=SubNode.GetCount(); + // SceneNode **sub=SubNode.GetData(); - for(int i=0;iExpendToList(rl,func,func_data); //展开子节点 + // for(int i=0;iExpendToList(rl,func,func_data); //展开子节点 - ++sub; - } - } + // ++sub; + // } + // } - return(true); - } + // return(true); + //} - /** - * 从当前节点展开输出到一个渲染列表 - * @param rl 渲染列表 - * @param cam 摄像机 - * @param comp_func 渲染列表远近比较函数 - */ - bool SceneNode::ExpendToList(RenderList *rl,Camera *cam,RenderListCompFunc comp_func) - { - if(!rl||!cam)return(false); + ///** + //* 从当前节点展开输出到一个渲染列表 + //* @param rl 渲染列表 + //* @param cam 摄像机 + //* @param comp_func 渲染列表远近比较函数 + //*/ + //bool SceneNode::ExpendToList(RenderList *rl,Camera *cam,RenderListCompFunc comp_func) + //{ + // if(!rl||!cam)return(false); - if(!ExpendToList(rl)) - return(false); + // if(!ExpendToList(rl)) + // return(false); - if(comp_func) - { - } + // if(comp_func) + // { + // } - return(true); - } + // return(true); + //} }//namespace graph }//namespace hgl diff --git a/src/SceneGraph/SceneTreeToRenderList.cpp b/src/SceneGraph/SceneTreeToRenderList.cpp index 7eb17dec..bc21512c 100644 --- a/src/SceneGraph/SceneTreeToRenderList.cpp +++ b/src/SceneGraph/SceneTreeToRenderList.cpp @@ -1,4 +1,4 @@ -#include +#include namespace hgl { @@ -9,12 +9,19 @@ namespace hgl SAFE_CLEAR(scene_node_list); } - uint32 SceneTreeToRenderList::CameraLength(SceneNode *,SceneNode *) + float SceneTreeToRenderList::CameraLength(SceneNode *obj_one,SceneNode *obj_two) { + if(!camera||!obj_one||!obj_two) + return(0); + + return( length_squared(obj_one->GetCenter(),camera->pos)- + length_squared(obj_two->GetCenter(),camera->pos)); + } } bool SceneTreeToRenderList::InFrustum(const SceneNode *,void *) { + return(true); } bool SceneTreeToRenderList::Begin() diff --git a/src/SceneGraph/Vulkan/VKRenderable.cpp b/src/SceneGraph/Vulkan/VKRenderable.cpp index a6bae08a..64890a0a 100644 --- a/src/SceneGraph/Vulkan/VKRenderable.cpp +++ b/src/SceneGraph/Vulkan/VKRenderable.cpp @@ -1,6 +1,7 @@ #include #include #include +#include VK_NAMESPACE_BEGIN //bool Renderable::Set(const int stage_input_binding,VAB *vab,VkDeviceSize offset)