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 &);
};//struct MVPMatrix
}//namespace graph
//namespace hgl
}//namespace hgl
#endif//HGL_GRAPH_MVP_MATRIX_INCLUDE

View File

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

View File

@ -10,7 +10,8 @@ namespace hgl
{
/**
* <br>
* (SceneOrient)
* (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
#include<hgl/graph/RenderList.h>
#include<hgl/graph/VKPipeline.h>
#include<hgl/graph/VKMaterial.h>
#include<hgl/graph/VKMaterialInstance.h>
namespace hgl
{
namespace graph
{
struct RenderNode
{
SceneNode *node;
};//
class SceneTreeToRenderList
{
using PipelineSets=Sets<Pipeline *>;
@ -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

View File

@ -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)
//{

View File

@ -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;i<count;i++)
{
(*sub)->ExpendToList(rl,func,func_data); //展开子节点
// for(int i=0;i<count;i++)
// {
// (*sub)->ExpendToList(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

View File

@ -1,4 +1,4 @@
#include<hgl/graph/RenderList.h>
#include<hgl/graph/SceneTreeToRenderList.h>
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()

View File

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