Layout codes of MaterialRenderList/SceneNode/SceneOrient
This commit is contained in:
parent
e778f64f00
commit
455cb0aa63
@ -1 +1 @@
|
|||||||
Subproject commit 9d9fad791d9c6569189bcc57dd4b219df62bc98a
|
Subproject commit 76aff5d55628a87baa35498520296d65ab70e995
|
@ -92,12 +92,12 @@ protected:
|
|||||||
|
|
||||||
VABList * vab_list;
|
VABList * vab_list;
|
||||||
|
|
||||||
const MeshDataBuffer * last_data_buffer;
|
const MeshDataBuffer * last_data_buffer;
|
||||||
const VDM * last_vdm;
|
const VDM * last_vdm;
|
||||||
const MeshRenderData * last_render_data;
|
const MeshRenderData * last_render_data;
|
||||||
|
|
||||||
int first_indirect_draw_index=-1;
|
int first_indirect_draw_index;
|
||||||
uint indirect_draw_count=0;
|
uint indirect_draw_count;
|
||||||
|
|
||||||
bool BindVAB(const MeshDataBuffer *,const uint);
|
bool BindVAB(const MeshDataBuffer *,const uint);
|
||||||
|
|
||||||
|
@ -6,123 +6,120 @@
|
|||||||
#include<hgl/graph/AABB.h>
|
#include<hgl/graph/AABB.h>
|
||||||
#include<hgl/component/Component.h>
|
#include<hgl/component/Component.h>
|
||||||
|
|
||||||
namespace hgl
|
namespace hgl::graph
|
||||||
{
|
{
|
||||||
namespace graph
|
using SceneNodeID =uint64;
|
||||||
|
using SceneNodeName =U16IDName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 场景节点数据类<br>
|
||||||
|
* 从场景坐标变换(SceneOrient)类继承,
|
||||||
|
* 每个场景节点中可能包括一个可渲染数据实例,或是完全不包含(用于坐标变换的父节点,或是灯光/摄像机之类)。
|
||||||
|
*/
|
||||||
|
class SceneNode:public SceneOrient ///场景节点类
|
||||||
{
|
{
|
||||||
using SceneNodeID =uint64;
|
SceneNode *ParentNode; ///<上级节点
|
||||||
using SceneNodeName =U16IDName;
|
|
||||||
|
|
||||||
/**
|
SceneNodeID NodeID; ///<节点ID
|
||||||
* 场景节点数据类<br>
|
SceneNodeName NodeName; ///<节点名称
|
||||||
* 从场景坐标变换(SceneOrient)类继承,
|
|
||||||
* 每个场景节点中可能包括一个可渲染数据实例,或是完全不包含(用于坐标变换的父节点,或是灯光/摄像机之类)。
|
protected:
|
||||||
*/
|
|
||||||
class SceneNode:public SceneOrient ///场景节点类
|
AABB BoundingBox; ///<绑定盒
|
||||||
|
AABB LocalBoundingBox; ///<本地坐标绑定盒
|
||||||
|
//AABB WorldBoundingBox; ///<世界坐标绑定盒
|
||||||
|
|
||||||
|
Mesh *render_obj=nullptr; ///<可渲染实例
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
ObjectList<SceneNode> ChildNode; ///<子节点
|
||||||
|
ObjectList<Component> ComponentList; ///<组件列表
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
const SceneNodeID & GetNodeID ()const { return NodeID; } ///<取得节点ID
|
||||||
|
const SceneNodeName & GetNodeName ()const { return NodeName; } ///<取得节点名称
|
||||||
|
|
||||||
|
const ObjectList<SceneNode> &GetChildNode()const { return ChildNode; } ///<取得子节点列表
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
SceneNode()=default;
|
||||||
|
SceneNode(const SceneNode &)=delete;
|
||||||
|
SceneNode(const SceneNode *)=delete;
|
||||||
|
SceneNode(const SceneOrient &so ):SceneOrient(so) {}
|
||||||
|
SceneNode( Mesh *ri ) {render_obj=ri;}
|
||||||
|
SceneNode(const Matrix4f &mat ):SceneOrient(mat) {}
|
||||||
|
SceneNode(const Matrix4f &mat, Mesh *ri ):SceneOrient(mat) {render_obj=ri;}
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
virtual ~SceneNode()=default;
|
||||||
|
|
||||||
|
void Clear() override
|
||||||
{
|
{
|
||||||
SceneNode *ParentNode; ///<上级节点
|
SceneOrient::Clear();
|
||||||
|
|
||||||
SceneNodeID NodeID; ///<节点ID
|
ParentNode=nullptr;
|
||||||
SceneNodeName NodeName; ///<节点名称
|
|
||||||
|
|
||||||
protected:
|
BoundingBox.SetZero();
|
||||||
|
LocalBoundingBox.SetZero();
|
||||||
|
|
||||||
AABB BoundingBox; ///<绑定盒
|
ChildNode.Clear();
|
||||||
AABB LocalBoundingBox; ///<本地坐标绑定盒
|
ComponentList.Clear();
|
||||||
//AABB WorldBoundingBox; ///<世界坐标绑定盒
|
render_obj=nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
Mesh *render_obj=nullptr; ///<可渲染实例
|
const bool ChildNodeIsEmpty()const
|
||||||
|
{
|
||||||
|
if(render_obj)return(false);
|
||||||
|
if(ChildNode.GetCount())return(false);
|
||||||
|
|
||||||
protected:
|
return(true);
|
||||||
|
}
|
||||||
|
|
||||||
ObjectList<SceneNode> ChildNode; ///<子节点
|
void SetParent(SceneNode *sn) {ParentNode=sn;}
|
||||||
ObjectList<Component> ComponentList; ///<组件列表
|
SceneNode * GetParent() noexcept{return ParentNode;}
|
||||||
|
const SceneNode * GetParent()const noexcept{return ParentNode;}
|
||||||
|
|
||||||
public:
|
void SetRenderable(Mesh *);
|
||||||
|
Mesh * GetRenderable() noexcept{return render_obj;}
|
||||||
|
const Mesh * GetRenderable()const noexcept{return render_obj;}
|
||||||
|
|
||||||
const SceneNodeID & GetNodeID ()const { return NodeID; } ///<取得节点ID
|
SceneNode *Add(SceneNode *sn)
|
||||||
const SceneNodeName & GetNodeName ()const { return NodeName; } ///<取得节点名称
|
{
|
||||||
|
if(!sn)
|
||||||
|
return(nullptr);
|
||||||
|
|
||||||
const ObjectList<SceneNode> &GetChildNode()const { return ChildNode; } ///<取得子节点列表
|
ChildNode.Add(sn);
|
||||||
|
sn->SetParent(this);
|
||||||
|
return sn;
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public: //坐标相关方法
|
||||||
|
|
||||||
SceneNode()=default;
|
virtual void SetBoundingBox (const AABB &bb){BoundingBox=bb;} ///<设置绑定盒
|
||||||
SceneNode(const SceneNode &)=delete;
|
|
||||||
SceneNode(const SceneNode *)=delete;
|
|
||||||
SceneNode(const SceneOrient &so ):SceneOrient(so) {}
|
|
||||||
SceneNode( Mesh *ri ) {render_obj=ri;}
|
|
||||||
SceneNode(const Matrix4f &mat ):SceneOrient(mat) {}
|
|
||||||
SceneNode(const Matrix4f &mat, Mesh *ri ):SceneOrient(mat) {render_obj=ri;}
|
|
||||||
|
|
||||||
public:
|
virtual void RefreshMatrix () override; ///<刷新世界变换
|
||||||
|
virtual void RefreshBoundingBox (); ///<刷新绑定盒
|
||||||
|
|
||||||
virtual ~SceneNode()=default;
|
virtual const AABB & GetBoundingBox ()const{return BoundingBox;} ///<取得绑定盒
|
||||||
|
virtual const AABB & GetLocalBoundingBox ()const{return LocalBoundingBox;} ///<取得本地坐标绑定盒
|
||||||
void Clear() override
|
|
||||||
{
|
|
||||||
SceneOrient::Clear();
|
|
||||||
|
|
||||||
ParentNode=nullptr;
|
|
||||||
|
|
||||||
BoundingBox.SetZero();
|
|
||||||
LocalBoundingBox.SetZero();
|
|
||||||
|
|
||||||
ChildNode.Clear();
|
|
||||||
ComponentList.Clear();
|
|
||||||
render_obj=nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
const bool ChildNodeIsEmpty()const
|
|
||||||
{
|
|
||||||
if(render_obj)return(false);
|
|
||||||
if(ChildNode.GetCount())return(false);
|
|
||||||
|
|
||||||
return(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetParent(SceneNode *sn) {ParentNode=sn;}
|
|
||||||
SceneNode * GetParent() noexcept{return ParentNode;}
|
|
||||||
const SceneNode * GetParent()const noexcept{return ParentNode;}
|
|
||||||
|
|
||||||
void SetRenderable(Mesh *);
|
|
||||||
Mesh * GetRenderable() noexcept{return render_obj;}
|
|
||||||
const Mesh * GetRenderable()const noexcept{return render_obj;}
|
|
||||||
|
|
||||||
SceneNode *Add(SceneNode *sn)
|
|
||||||
{
|
|
||||||
if(!sn)
|
|
||||||
return(nullptr);
|
|
||||||
|
|
||||||
ChildNode.Add(sn);
|
|
||||||
sn->SetParent(this);
|
|
||||||
return sn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public: //坐标相关方法
|
|
||||||
|
|
||||||
virtual void SetBoundingBox (const AABB &bb){BoundingBox=bb;} ///<设置绑定盒
|
|
||||||
|
|
||||||
virtual void RefreshMatrix () override; ///<刷新世界变换
|
|
||||||
virtual void RefreshBoundingBox (); ///<刷新绑定盒
|
|
||||||
|
|
||||||
virtual const AABB & GetBoundingBox ()const{return BoundingBox;} ///<取得绑定盒
|
|
||||||
virtual const AABB & GetLocalBoundingBox ()const{return LocalBoundingBox;} ///<取得本地坐标绑定盒
|
|
||||||
// virtual const AABB & GetWorldBoundingBox ()const{return WorldBoundingBox;} ///<取得世界坐标绑定盒
|
// virtual const AABB & GetWorldBoundingBox ()const{return WorldBoundingBox;} ///<取得世界坐标绑定盒
|
||||||
|
|
||||||
public: //组件相关方法
|
public: //组件相关方法
|
||||||
|
|
||||||
bool ComponentIsEmpty ()const {return ComponentList.GetCount()==0;} ///<是否没有组件
|
bool ComponentIsEmpty ()const {return ComponentList.GetCount()==0;} ///<是否没有组件
|
||||||
virtual int GetComponentCount ()const {return ComponentList.GetCount();} ///<取得组件数量
|
virtual int GetComponentCount ()const {return ComponentList.GetCount();} ///<取得组件数量
|
||||||
virtual void AddComponent (Component *comp) {ComponentList.Add(comp);} ///<添加一个组件
|
virtual void AddComponent (Component *comp) {ComponentList.Add(comp);} ///<添加一个组件
|
||||||
virtual void RemoveComponent (Component *comp) {ComponentList.DeleteByValue(comp);} ///<删除一个组件
|
virtual void RemoveComponent (Component *comp) {ComponentList.DeleteByValue(comp);} ///<删除一个组件
|
||||||
bool Contains (Component *comp) {return ComponentList.Contains(comp);} ///<是否包含指定组件
|
bool Contains (Component *comp) {return ComponentList.Contains(comp);} ///<是否包含指定组件
|
||||||
|
|
||||||
bool HasComponent (const ComponentManager *); ///<是否有指定组件管理器的组件
|
bool HasComponent (const ComponentManager *); ///<是否有指定组件管理器的组件
|
||||||
virtual int GetComponents (ArrayList<Component *> &comp_list,const ComponentManager *); ///<取得所有组件
|
virtual int GetComponents (ArrayList<Component *> &comp_list,const ComponentManager *); ///<取得所有组件
|
||||||
|
|
||||||
};//class SceneNode
|
};//class SceneNode
|
||||||
|
|
||||||
SceneNode *Duplication(SceneNode *); ///<复制一个场景节点
|
SceneNode *Duplication(SceneNode *); ///<复制一个场景节点
|
||||||
}//namespace graph
|
}//namespace hgl::graph
|
||||||
}//namespace hgl
|
|
||||||
|
@ -2,51 +2,48 @@
|
|||||||
|
|
||||||
#include<hgl/graph/VK.h>
|
#include<hgl/graph/VK.h>
|
||||||
#include<hgl/graph/SceneMatrix.h>
|
#include<hgl/graph/SceneMatrix.h>
|
||||||
namespace hgl
|
namespace hgl::graph
|
||||||
{
|
{
|
||||||
namespace graph
|
/**
|
||||||
|
* 方向定位数据基类<br>
|
||||||
|
*/
|
||||||
|
class SceneOrient ///场景定位类
|
||||||
{
|
{
|
||||||
/**
|
protected:
|
||||||
* 方向定位数据基类<br>
|
|
||||||
*/
|
SceneMatrix scene_matrix;
|
||||||
class SceneOrient ///场景定位类
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
SceneOrient()=default;
|
||||||
|
SceneOrient(const SceneOrient &);
|
||||||
|
SceneOrient(const Matrix4f &);
|
||||||
|
virtual ~SceneOrient()=default;
|
||||||
|
|
||||||
|
virtual void Clear()
|
||||||
{
|
{
|
||||||
protected:
|
scene_matrix.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
SceneMatrix scene_matrix;
|
void SetLocalNormal(const Vector3f &nor) {scene_matrix.SetLocalNormal(nor);} ///<设置本地法线
|
||||||
|
void SetLocalMatrix (const Matrix4f &mat){scene_matrix.SetLocalMatrix(mat);} ///<设置本地矩阵
|
||||||
|
void SetParentMatrix(const Matrix4f &mat){scene_matrix.SetParentMatrix(mat);} ///<设置上级到世界空间变换矩阵
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
SceneOrient()=default;
|
const uint32 GetLocalToWorldMatrixVersion()const {return scene_matrix.GetNewestVersion();} ///<取得版本号
|
||||||
SceneOrient(const SceneOrient &);
|
|
||||||
SceneOrient(const Matrix4f &);
|
|
||||||
virtual ~SceneOrient()=default;
|
|
||||||
|
|
||||||
virtual void Clear()
|
const Vector3f & GetWorldPosition() const {return scene_matrix.GetWorldPosition();} ///<取得世界坐标
|
||||||
{
|
const Matrix4f & GetLocalMatrix ()const {return scene_matrix.GetLocalMatrix();} ///<取得本地矩阵
|
||||||
scene_matrix.Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetLocalNormal(const Vector3f &nor) {scene_matrix.SetLocalNormal(nor);} ///<设置本地法线
|
TransformManager & GetTransform () {return scene_matrix.GetTransform();} ///<取得变换管理器
|
||||||
void SetLocalMatrix (const Matrix4f &mat){scene_matrix.SetLocalMatrix(mat);} ///<设置本地矩阵
|
|
||||||
void SetParentMatrix(const Matrix4f &mat){scene_matrix.SetParentMatrix(mat);} ///<设置上级到世界空间变换矩阵
|
|
||||||
|
|
||||||
public:
|
const Matrix4f & GetLocalToWorldMatrix () {return scene_matrix.GetLocalToWorldMatrix();} ///<取得本地到世界矩阵
|
||||||
|
const Matrix4f & GetInverseLocalToWorldMatrix () {return scene_matrix.GetInverseLocalToWorldMatrix();}
|
||||||
|
const Matrix4f & GetInverseTransposeLocalToWorldMatrix () {return scene_matrix.GetInverseTransposeLocalToWorldMatrix();}
|
||||||
|
|
||||||
const uint32 GetLocalToWorldMatrixVersion()const {return scene_matrix.GetNewestVersion();} ///<取得版本号
|
public:
|
||||||
|
|
||||||
const Vector3f & GetWorldPosition() const {return scene_matrix.GetWorldPosition();} ///<取得世界坐标
|
virtual void RefreshMatrix();
|
||||||
const Matrix4f & GetLocalMatrix ()const {return scene_matrix.GetLocalMatrix();} ///<取得本地矩阵
|
};//class SceneOrient
|
||||||
|
}//namespace hgl::graph
|
||||||
TransformManager & GetTransform () {return scene_matrix.GetTransform();} ///<取得变换管理器
|
|
||||||
|
|
||||||
const Matrix4f & GetLocalToWorldMatrix () {return scene_matrix.GetLocalToWorldMatrix();} ///<取得本地到世界矩阵
|
|
||||||
const Matrix4f & GetInverseLocalToWorldMatrix () {return scene_matrix.GetInverseLocalToWorldMatrix();}
|
|
||||||
const Matrix4f & GetInverseTransposeLocalToWorldMatrix () {return scene_matrix.GetInverseTransposeLocalToWorldMatrix();}
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void RefreshMatrix();
|
|
||||||
};//class SceneOrient
|
|
||||||
}//namespace graph
|
|
||||||
}//namespace hgl
|
|
||||||
|
@ -82,10 +82,19 @@ MaterialRenderList::MaterialRenderList(VulkanDevice *d,bool l2w,const RenderPipe
|
|||||||
|
|
||||||
assign_buffer=new RenderAssignBuffer(device,rp_index.material);
|
assign_buffer=new RenderAssignBuffer(device,rp_index.material);
|
||||||
|
|
||||||
vab_list=new VABList(rp_index.material->GetVertexInput()->GetCount());
|
|
||||||
|
|
||||||
icb_draw=nullptr;
|
icb_draw=nullptr;
|
||||||
icb_draw_indexed=nullptr;
|
icb_draw_indexed=nullptr;
|
||||||
|
|
||||||
|
ri_count=0;
|
||||||
|
|
||||||
|
vab_list=new VABList(rp_index.material->GetVertexInput()->GetCount());
|
||||||
|
|
||||||
|
last_data_buffer=nullptr;
|
||||||
|
last_vdm=nullptr;
|
||||||
|
last_render_data=nullptr;
|
||||||
|
|
||||||
|
first_indirect_draw_index=-1;
|
||||||
|
indirect_draw_count=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
MaterialRenderList::~MaterialRenderList()
|
MaterialRenderList::~MaterialRenderList()
|
||||||
@ -231,7 +240,7 @@ void MaterialRenderList::ReallocICB()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MaterialRenderList::WriteICB(VkDrawIndirectCommand *dicp,RenderItem *ri)
|
void MaterialRenderList::WriteICB(VkDrawIndirectCommand *dicp,RenderItem *ri)
|
||||||
{
|
{
|
||||||
dicp->vertexCount =ri->prd->vertex_count;
|
dicp->vertexCount =ri->prd->vertex_count;
|
||||||
dicp->instanceCount =ri->instance_count;
|
dicp->instanceCount =ri->instance_count;
|
||||||
dicp->firstVertex =ri->prd->vertex_offset;
|
dicp->firstVertex =ri->prd->vertex_offset;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user