add comments
This commit is contained in:
parent
f1fcfe5cd4
commit
b0ec12112f
@ -32,5 +32,5 @@ namespace hgl
|
||||
CompOperatorMemcmp(const MVPMatrix &);
|
||||
};//struct MVPMatrix
|
||||
}//namespace graph
|
||||
//namespace hgl
|
||||
}//namespace hgl
|
||||
#endif//HGL_GRAPH_MVP_MATRIX_INCLUDE
|
||||
|
@ -16,6 +16,10 @@ namespace hgl
|
||||
using MVPArrayBuffer=GPUArrayBuffer<MVPMatrix>;
|
||||
using MVPOffsetBuffer=List<uint32_t>;
|
||||
|
||||
/**
|
||||
* 渲染对象列表<br>
|
||||
* 已经展开的渲染对象列表,产生mvp用UBO/SSBO等数据,最终创建RenderCommandBuffer
|
||||
*/
|
||||
class RenderList
|
||||
{
|
||||
GPUDevice *device;
|
||||
|
@ -10,7 +10,8 @@ namespace hgl
|
||||
{
|
||||
/**
|
||||
* 场景节点数据类<br>
|
||||
* 从场景坐标变换(SceneOrient)类继承
|
||||
* 从场景坐标变换(SceneOrient)类继承,
|
||||
* 每个场景节点中可能包括一个可渲染数据实例,或是完全不包含(用于坐标变换的父节点,或是灯光/摄像机之类)。
|
||||
*/
|
||||
class SceneNode:public SceneOrient ///场景节点类
|
||||
{
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
//{
|
||||
|
@ -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
|
||||
|
@ -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()
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user