add comments

This commit is contained in:
hyzboy 2021-04-30 18:56:20 +08:00
parent f1fcfe5cd4
commit b0ec12112f
8 changed files with 78 additions and 65 deletions

View File

@ -32,5 +32,5 @@ namespace hgl
CompOperatorMemcmp(const MVPMatrix &); CompOperatorMemcmp(const MVPMatrix &);
};//struct MVPMatrix };//struct MVPMatrix
}//namespace graph }//namespace graph
//namespace hgl }//namespace hgl
#endif//HGL_GRAPH_MVP_MATRIX_INCLUDE #endif//HGL_GRAPH_MVP_MATRIX_INCLUDE

View File

@ -16,6 +16,10 @@ namespace hgl
using MVPArrayBuffer=GPUArrayBuffer<MVPMatrix>; using MVPArrayBuffer=GPUArrayBuffer<MVPMatrix>;
using MVPOffsetBuffer=List<uint32_t>; using MVPOffsetBuffer=List<uint32_t>;
/**
* <br>
* mvp用UBO/SSBO等数据RenderCommandBuffer
*/
class RenderList class RenderList
{ {
GPUDevice *device; GPUDevice *device;

View File

@ -10,7 +10,8 @@ namespace hgl
{ {
/** /**
* <br> * <br>
* (SceneOrient) * (SceneOrient)
* (/)
*/ */
class SceneNode:public SceneOrient ///场景节点类 class SceneNode:public SceneOrient ///场景节点类
{ {

View File

@ -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 #define HGL_GRAPH_SCENE_TREE_TO_RENDER_LIST_INCLUDE
#include<hgl/graph/RenderList.h> #include<hgl/graph/RenderList.h>
#include<hgl/graph/VKPipeline.h>
#include<hgl/graph/VKMaterial.h>
#include<hgl/graph/VKMaterialInstance.h>
namespace hgl namespace hgl
{ {
namespace graph namespace graph
{ {
struct RenderNode
{
SceneNode *node;
};//
class SceneTreeToRenderList class SceneTreeToRenderList
{ {
using PipelineSets=Sets<Pipeline *>; using PipelineSets=Sets<Pipeline *>;
@ -24,19 +32,19 @@ namespace hgl
protected: protected:
SceneNodeList * scene_node_list; ///<场景节点列表 SceneNodeList * scene_node_list; ///<场景节点列表
PipelineSets pipeline_sets; ///<管线合集 PipelineSets pipeline_sets; ///<管线合集
MaterialSets material_sets; ///<材质合集 MaterialSets material_sets; ///<材质合集
MatInstanceSets mat_instance_sets; ///<材质实例合集 MatInstanceSets mat_instance_sets; ///<材质实例合集
RenderList * render_list; RenderList * render_list;
protected: 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 Begin();
virtual bool Expend(SceneNode *); virtual bool Expend(SceneNode *);

View File

@ -15,14 +15,6 @@ namespace hgl
{ {
constexpr size_t MVPMatrixBytes=sizeof(MVPMatrix); 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) //bool FrustumClipFilter(const SceneNode *node,void *fc)
//{ //{

View File

@ -53,61 +53,61 @@ namespace hgl
LocalBoundingBox=local; LocalBoundingBox=local;
} }
/** ///**
* //* 从当前节点展开输出到一个渲染列表
* @param rl //* @param rl 渲染列表
* @param func //* @param func 过滤函数
* @param func_data //* @param func_data 过滤函数用辅助数据
* @return //* @return 成功与否
*/ //*/
bool SceneNode::ExpendToList(RenderList *rl,FilterSceneNodeFunc func,void *func_data) //bool SceneNode::ExpendToList(RenderList *rl,FilterSceneNodeFunc func,void *func_data)
{ //{
if(!rl)return(false); // if(!rl)return(false);
if(func) // if(func)
if(!func(this,func_data)) // if(!func(this,func_data))
return(false); // return(false);
{ // {
int count=renderable_instances.GetCount(); // int count=renderable_instances.GetCount();
if(count>0) // if(count>0)
rl->Add(this); // rl->Add(this);
} // }
{ // {
int count=SubNode.GetCount(); // int count=SubNode.GetCount();
SceneNode **sub=SubNode.GetData(); // SceneNode **sub=SubNode.GetData();
for(int i=0;i<count;i++) // for(int i=0;i<count;i++)
{ // {
(*sub)->ExpendToList(rl,func,func_data); //展开子节点 // (*sub)->ExpendToList(rl,func,func_data); //展开子节点
++sub; // ++sub;
} // }
} // }
return(true); // return(true);
} //}
/** ///**
* //* 从当前节点展开输出到一个渲染列表
* @param rl //* @param rl 渲染列表
* @param cam //* @param cam 摄像机
* @param comp_func //* @param comp_func 渲染列表远近比较函数
*/ //*/
bool SceneNode::ExpendToList(RenderList *rl,Camera *cam,RenderListCompFunc comp_func) //bool SceneNode::ExpendToList(RenderList *rl,Camera *cam,RenderListCompFunc comp_func)
{ //{
if(!rl||!cam)return(false); // if(!rl||!cam)return(false);
if(!ExpendToList(rl)) // if(!ExpendToList(rl))
return(false); // return(false);
if(comp_func) // if(comp_func)
{ // {
} // }
return(true); // return(true);
} //}
}//namespace graph }//namespace graph
}//namespace hgl }//namespace hgl

View File

@ -1,4 +1,4 @@
#include<hgl/graph/RenderList.h> #include<hgl/graph/SceneTreeToRenderList.h>
namespace hgl namespace hgl
{ {
@ -9,12 +9,19 @@ namespace hgl
SAFE_CLEAR(scene_node_list); 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 *) bool SceneTreeToRenderList::InFrustum(const SceneNode *,void *)
{ {
return(true);
} }
bool SceneTreeToRenderList::Begin() bool SceneTreeToRenderList::Begin()

View File

@ -1,6 +1,7 @@
#include<hgl/graph/VKRenderable.h> #include<hgl/graph/VKRenderable.h>
#include<hgl/graph/VKBuffer.h> #include<hgl/graph/VKBuffer.h>
#include<hgl/graph/VKShaderModule.h> #include<hgl/graph/VKShaderModule.h>
#include<hgl/graph/VKVertexAttribBuffer.h>
VK_NAMESPACE_BEGIN VK_NAMESPACE_BEGIN
//bool Renderable::Set(const int stage_input_binding,VAB *vab,VkDeviceSize offset) //bool Renderable::Set(const int stage_input_binding,VAB *vab,VkDeviceSize offset)