2019-05-25 00:50:04 +08:00
|
|
|
|
#include<hgl/graph/RenderList.h>
|
2019-05-21 21:28:33 +08:00
|
|
|
|
#include<hgl/graph/SceneNode.h>
|
2021-04-26 20:36:56 +08:00
|
|
|
|
#include<hgl/graph/VKBuffer.h>
|
2022-06-24 17:51:05 +08:00
|
|
|
|
#include<hgl/graph/VKPrimitive.h>
|
2020-10-21 11:43:18 +08:00
|
|
|
|
#include<hgl/graph/VKCommandBuffer.h>
|
2020-07-16 20:36:54 +08:00
|
|
|
|
#include<hgl/graph/VertexAttribDataAccess.h>
|
2021-06-16 11:43:19 +08:00
|
|
|
|
#include<hgl/graph/VKMaterialParameters.h>
|
2022-06-24 21:06:38 +08:00
|
|
|
|
#include<hgl/graph/VKRenderable.h>
|
2021-06-19 20:31:07 +08:00
|
|
|
|
#include<hgl/util/sort/Sort.h>
|
|
|
|
|
|
2019-05-21 21:28:33 +08:00
|
|
|
|
namespace hgl
|
|
|
|
|
{
|
|
|
|
|
namespace graph
|
|
|
|
|
{
|
2021-06-19 20:31:07 +08:00
|
|
|
|
RenderList::RenderList(GPUDevice *dev)
|
2020-11-26 17:51:59 +08:00
|
|
|
|
{
|
2021-06-19 20:31:07 +08:00
|
|
|
|
device =dev;
|
2023-05-07 01:07:26 +08:00
|
|
|
|
renderable_count=0;
|
2020-11-26 17:51:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-06-19 20:31:07 +08:00
|
|
|
|
RenderList::~RenderList()
|
2020-11-26 17:51:59 +08:00
|
|
|
|
{
|
2023-03-23 21:43:10 +08:00
|
|
|
|
}
|
2021-06-19 20:31:07 +08:00
|
|
|
|
|
2023-05-07 01:07:26 +08:00
|
|
|
|
bool RenderList::ExpendNode(SceneNode *sn)
|
2021-06-19 20:31:07 +08:00
|
|
|
|
{
|
|
|
|
|
if(!sn)return(false);
|
|
|
|
|
|
2022-06-24 21:06:38 +08:00
|
|
|
|
Renderable *ri=sn->GetRenderable();
|
2021-06-19 20:31:07 +08:00
|
|
|
|
|
|
|
|
|
if(ri)
|
|
|
|
|
{
|
2023-05-07 01:07:26 +08:00
|
|
|
|
Material *mtl=ri->GetMaterial();
|
|
|
|
|
MaterialRenderList *mrl;
|
2021-06-19 20:31:07 +08:00
|
|
|
|
|
2023-05-07 01:07:26 +08:00
|
|
|
|
if(!mrl_map.Get(mtl,mrl))
|
|
|
|
|
{
|
|
|
|
|
mrl=new MaterialRenderList(device,mtl);
|
2021-06-19 20:31:07 +08:00
|
|
|
|
|
2023-05-07 01:07:26 +08:00
|
|
|
|
mrl_map.Add(mtl,mrl);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mrl->Add(ri,sn->GetLocalToWorldMatrix());
|
2021-06-19 20:31:07 +08:00
|
|
|
|
|
2023-05-07 01:07:26 +08:00
|
|
|
|
++renderable_count;
|
2021-06-19 20:31:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(SceneNode *sub:sn->SubNode)
|
2023-05-07 01:07:26 +08:00
|
|
|
|
ExpendNode(sub);
|
2021-06-19 20:31:07 +08:00
|
|
|
|
|
|
|
|
|
return(true);
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-07 01:07:26 +08:00
|
|
|
|
bool RenderList::Expend(SceneNode *sn)
|
2021-06-19 20:31:07 +08:00
|
|
|
|
{
|
|
|
|
|
if(!device|!sn)return(false);
|
|
|
|
|
|
2023-05-07 01:07:26 +08:00
|
|
|
|
mrl_map.Begin();
|
|
|
|
|
ExpendNode(sn);
|
|
|
|
|
mrl_map.End();
|
2021-06-19 20:31:07 +08:00
|
|
|
|
|
|
|
|
|
return(true);
|
2020-11-26 17:51:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-11-09 15:37:00 +08:00
|
|
|
|
bool RenderList::Render(RenderCmdBuffer *cb)
|
2019-05-27 16:54:08 +08:00
|
|
|
|
{
|
|
|
|
|
if(!cb)
|
2019-05-21 21:28:33 +08:00
|
|
|
|
return(false);
|
|
|
|
|
|
2023-05-07 01:07:26 +08:00
|
|
|
|
if(renderable_count<=0)
|
2021-06-15 15:36:30 +08:00
|
|
|
|
return(true);
|
|
|
|
|
|
2023-05-07 01:07:26 +08:00
|
|
|
|
mrl_map.Render(cb);
|
2019-05-21 21:28:33 +08:00
|
|
|
|
|
|
|
|
|
return(true);
|
|
|
|
|
}
|
2023-05-07 01:07:26 +08:00
|
|
|
|
|
|
|
|
|
void RenderList::Clear()
|
|
|
|
|
{
|
|
|
|
|
mrl_map.Clear();
|
|
|
|
|
}
|
2019-05-21 21:28:33 +08:00
|
|
|
|
}//namespace graph
|
|
|
|
|
}//namespace hgl
|