removed PushConstants at SceneNode/RenderList
This commit is contained in:
parent
f57a7afb74
commit
4bd4a9b898
@ -9,15 +9,44 @@ namespace hgl
|
|||||||
{
|
{
|
||||||
namespace graph
|
namespace graph
|
||||||
{
|
{
|
||||||
|
template<typename T> struct GPUArray
|
||||||
|
{
|
||||||
|
List<T> list;
|
||||||
|
GPUBuffer *buffer;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
GPUArray()
|
||||||
|
{
|
||||||
|
buffer=nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
~GPUArray()
|
||||||
|
{
|
||||||
|
SAFE_CLEAR(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Clear()
|
||||||
|
{
|
||||||
|
list.ClearData();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Add(const T &data)
|
||||||
|
{
|
||||||
|
list.Add(data);
|
||||||
|
}
|
||||||
|
};//
|
||||||
|
|
||||||
class RenderList
|
class RenderList
|
||||||
{
|
{
|
||||||
RenderCmdBuffer *cmd_buf;
|
RenderCmdBuffer *cmd_buf;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
GPUArray<Matrix4f> LocalToWorld;
|
||||||
|
|
||||||
List<SceneNode *> scene_node_list;
|
List<SceneNode *> scene_node_list;
|
||||||
|
|
||||||
PushConstant * last_pc;
|
|
||||||
Pipeline * last_pipeline;
|
Pipeline * last_pipeline;
|
||||||
MaterialInstance * last_mat_inst;
|
MaterialInstance * last_mat_inst;
|
||||||
RenderableInstance *last_ri;
|
RenderableInstance *last_ri;
|
||||||
@ -27,19 +56,12 @@ namespace hgl
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
RenderList()
|
RenderList();
|
||||||
{
|
|
||||||
cmd_buf=nullptr;
|
|
||||||
last_pc=nullptr;
|
|
||||||
last_pipeline=nullptr;
|
|
||||||
last_mat_inst=nullptr;
|
|
||||||
last_ri=nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
~RenderList()=default;
|
~RenderList()=default;
|
||||||
|
|
||||||
void Add (SceneNode *node) {if(node)scene_node_list.Add(node);}
|
void Begin ();
|
||||||
void Clear () {scene_node_list.ClearData();}
|
void Add (SceneNode *);
|
||||||
|
void End ();
|
||||||
|
|
||||||
bool Render (RenderCmdBuffer *);
|
bool Render (RenderCmdBuffer *);
|
||||||
};//class RenderList
|
};//class RenderList
|
||||||
|
@ -18,7 +18,7 @@ namespace hgl
|
|||||||
|
|
||||||
using FilterSceneNodeFunc=bool (*)(const SceneNode *,void *); ///<场景节点过滤函数重定义
|
using FilterSceneNodeFunc=bool (*)(const SceneNode *,void *); ///<场景节点过滤函数重定义
|
||||||
|
|
||||||
bool FrustumClipFilter(const SceneNode *,void *); ///<平截头截减过滤函数
|
bool FrustumClipFilter(const SceneNode *,void *); ///<平截头截剪函数
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 场景节点数据类<br>
|
* 场景节点数据类<br>
|
||||||
|
@ -24,15 +24,11 @@ namespace hgl
|
|||||||
Matrix4f InverseLocalMatrix; ///<反向当前矩阵
|
Matrix4f InverseLocalMatrix; ///<反向当前矩阵
|
||||||
Matrix4f InverseLocalToWorldMatrix; ///<反向当前到世界矩阵
|
Matrix4f InverseLocalToWorldMatrix; ///<反向当前到世界矩阵
|
||||||
|
|
||||||
PushConstant pc;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
SceneOrient();
|
SceneOrient();
|
||||||
virtual ~SceneOrient()=default;
|
virtual ~SceneOrient()=default;
|
||||||
|
|
||||||
PushConstant *GetPushConstant(){return &pc;}
|
|
||||||
|
|
||||||
Matrix4f & SetLocalMatrix (const Matrix4f &); ///<设定当前节点矩阵
|
Matrix4f & SetLocalMatrix (const Matrix4f &); ///<设定当前节点矩阵
|
||||||
Matrix4f & SetLocalToWorldMatrix (const Matrix4f &); ///<设定当前节点到世界矩阵
|
Matrix4f & SetLocalToWorldMatrix (const Matrix4f &); ///<设定当前节点到世界矩阵
|
||||||
|
|
||||||
@ -42,7 +38,9 @@ namespace hgl
|
|||||||
const Matrix4f & GetInverseLocalMatrix ()const {return InverseLocalMatrix;}
|
const Matrix4f & GetInverseLocalMatrix ()const {return InverseLocalMatrix;}
|
||||||
const Matrix4f & GetInverseLocalToWorldMatrix()const {return InverseLocalToWorldMatrix;}
|
const Matrix4f & GetInverseLocalToWorldMatrix()const {return InverseLocalToWorldMatrix;}
|
||||||
|
|
||||||
void RefreshLocalToWorldMatrix (const Matrix4f *); ///<刷新到世界空间矩阵
|
public:
|
||||||
|
|
||||||
|
virtual void RefreshLocalToWorldMatrix (const Matrix4f *); ///<刷新到世界空间矩阵
|
||||||
};//class SceneOrient
|
};//class SceneOrient
|
||||||
}//namespace graph
|
}//namespace graph
|
||||||
}//namespace hgl
|
}//namespace hgl
|
||||||
|
@ -27,6 +27,38 @@ namespace hgl
|
|||||||
// return (((Frustum *)fc)->BoxIn(node->GetWorldBoundingBox())!=Frustum::OUTSIDE);
|
// return (((Frustum *)fc)->BoxIn(node->GetWorldBoundingBox())!=Frustum::OUTSIDE);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
RenderList::RenderList()
|
||||||
|
{
|
||||||
|
cmd_buf =nullptr;
|
||||||
|
|
||||||
|
last_pipeline =nullptr;
|
||||||
|
last_mat_inst =nullptr;
|
||||||
|
last_ri =nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderList::Begin()
|
||||||
|
{
|
||||||
|
LocalToWorld.Clear();
|
||||||
|
scene_node_list.ClearData();
|
||||||
|
|
||||||
|
last_pipeline =nullptr;
|
||||||
|
last_mat_inst =nullptr;
|
||||||
|
last_ri =nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderList::Add(SceneNode *node)
|
||||||
|
{
|
||||||
|
if(!node)return;
|
||||||
|
|
||||||
|
LocalToWorld.Add(node->GetLocalToWorldMatrix());
|
||||||
|
|
||||||
|
scene_node_list.Add(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderList::End()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void RenderList::Render(SceneNode *node,RenderableInstance *ri)
|
void RenderList::Render(SceneNode *node,RenderableInstance *ri)
|
||||||
{
|
{
|
||||||
if(last_pipeline!=ri->GetPipeline())
|
if(last_pipeline!=ri->GetPipeline())
|
||||||
@ -45,13 +77,6 @@ namespace hgl
|
|||||||
cmd_buf->BindDescriptorSets(last_mat_inst->GetDescriptorSets());
|
cmd_buf->BindDescriptorSets(last_mat_inst->GetDescriptorSets());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(last_pc!=node->GetPushConstant())
|
|
||||||
{
|
|
||||||
last_pc=node->GetPushConstant();
|
|
||||||
|
|
||||||
cmd_buf->PushConstants(last_pc,sizeof(PushConstant));
|
|
||||||
}
|
|
||||||
|
|
||||||
//更新fin_mvp
|
//更新fin_mvp
|
||||||
|
|
||||||
if(ri!=last_ri)
|
if(ri!=last_ri)
|
||||||
@ -95,7 +120,6 @@ namespace hgl
|
|||||||
last_pipeline=nullptr;
|
last_pipeline=nullptr;
|
||||||
last_mat_inst=nullptr;
|
last_mat_inst=nullptr;
|
||||||
last_ri=nullptr;
|
last_ri=nullptr;
|
||||||
last_pc=nullptr;
|
|
||||||
|
|
||||||
const int count=scene_node_list.GetCount();
|
const int count=scene_node_list.GetCount();
|
||||||
SceneNode **node=scene_node_list.GetData();
|
SceneNode **node=scene_node_list.GetData();
|
||||||
|
@ -7,7 +7,6 @@ namespace hgl
|
|||||||
|
|
||||||
SceneOrient::SceneOrient()
|
SceneOrient::SceneOrient()
|
||||||
{
|
{
|
||||||
pc.local_to_world =Matrix4f::identity;
|
|
||||||
LocalMatrix =Matrix4f::identity;
|
LocalMatrix =Matrix4f::identity;
|
||||||
LocalToWorldMatrix =Matrix4f::identity;
|
LocalToWorldMatrix =Matrix4f::identity;
|
||||||
InverseLocalMatrix =Matrix4f::identity;
|
InverseLocalMatrix =Matrix4f::identity;
|
||||||
@ -29,9 +28,6 @@ namespace hgl
|
|||||||
|
|
||||||
InverseLocalToWorldMatrix=inverse(LocalToWorldMatrix);
|
InverseLocalToWorldMatrix=inverse(LocalToWorldMatrix);
|
||||||
|
|
||||||
pc.local_to_world =LocalToWorldMatrix;
|
|
||||||
pc.normal =InverseLocalToWorldMatrix.Transposed();
|
|
||||||
|
|
||||||
return LocalToWorldMatrix;
|
return LocalToWorldMatrix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user