迁移到StaticMeshComponent渲染

This commit is contained in:
2025-06-14 21:05:36 +08:00
parent 92f612f675
commit f9675fc1e5
15 changed files with 140 additions and 141 deletions

View File

@@ -109,7 +109,7 @@ public:
MaterialRenderList(VulkanDevice *d,bool l2w,const RenderPipelineIndex &rpi);
~MaterialRenderList();
void Add(SceneNode *);
void Add(StaticMeshComponent *);
void SetCameraInfo(CameraInfo *ci){camera_info=ci;}
@@ -120,6 +120,6 @@ public:
void Render(RenderCmdBuffer *);
void UpdateLocalToWorld(); //刷新所有对象的LocalToWorld矩阵
void UpdateMaterialInstance(SceneNode *);
void UpdateMaterialInstance(StaticMeshComponent *);
};//class MaterialRenderList
VK_NAMESPACE_END

View File

@@ -46,7 +46,7 @@ namespace hgl
virtual bool Render(RenderCmdBuffer *); ///<渲染所有对象
virtual void UpdateLocalToWorld(); ///<更新所有对象的变换数据
virtual void UpdateMaterialInstance(SceneNode *); ///<有对象互换了材质实例
virtual void UpdateMaterialInstance(StaticMeshComponent *); ///<有对象互换了材质实例
virtual void Clear(); ///<彻底清理
};//class RenderList

View File

@@ -9,13 +9,13 @@ namespace hgl
{
class Mesh;
class MaterialInstance;
class SceneNode;
class StaticMeshComponent;
struct RenderNode:public Comparator<RenderNode>
{
uint index; ///<在MaterialRenderList中的索引
SceneNode * scene_node;
StaticMeshComponent *sm_component; ///<静态网格组件
uint32 l2w_version;
uint32 l2w_index;
@@ -27,6 +27,11 @@ namespace hgl
//该函数位于MaterialRenderList.cpp
const int compare(const RenderNode &)const override;
public:
Mesh *GetMesh()const;
MaterialInstance *GetMaterialInstance()const;
};
using RenderNodeList=ArrayList<RenderNode>;

View File

@@ -30,8 +30,6 @@ namespace hgl::graph
AABB LocalBoundingBox; ///<本地坐标绑定盒
//AABB WorldBoundingBox; ///<世界坐标绑定盒
Mesh *render_obj=nullptr; ///<可渲染实例
protected:
ObjectList<SceneNode> ChildNode; ///<子节点
@@ -55,9 +53,7 @@ namespace hgl::graph
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:
@@ -74,12 +70,10 @@ namespace hgl::graph
ChildNode.Clear();
ComponentSet.Clear();
render_obj=nullptr;
}
const bool ChildNodeIsEmpty()const
{
if(render_obj)return(false);
if(ChildNode.GetCount())return(false);
return(true);
@@ -89,10 +83,6 @@ namespace hgl::graph
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)
@@ -118,13 +108,32 @@ namespace hgl::graph
bool ComponentIsEmpty ()const{return ComponentSet.GetCount()==0;} ///<是否没有组件
virtual int GetComponentCount ()const{return ComponentSet.GetCount();} ///<取得组件数量
virtual void AttachComponent (Component *comp){ComponentSet.Add(comp);} ///<添加一个组件
virtual void DetachComponent (Component *comp){ComponentSet.Delete(comp);} ///<删除一个组件
virtual bool AttachComponent (Component *comp) ///<添加一个组件
{
if(!comp)return(false);
if(ComponentSet.Add(comp)<0)
return(false);
comp->OnAttach(this); //调用组件的OnAttach方法
return(true);
}
virtual void DetachComponent (Component *comp) ///<删除一个组件
{
if (!comp)return;
ComponentSet.Delete(comp);
comp->OnDetach(this); //调用组件的OnDetach方法
}
bool Contains (Component *comp){return ComponentSet.Contains(comp);} ///<是否包含指定组件
bool HasComponent (const ComponentManager *); ///<是否有指定组件管理器的组件
virtual int GetComponents (ArrayList<Component *> &comp_list,const ComponentManager *); ///<取得所有组件
const SortedSet<Component *> & GetComponents ()const{return ComponentSet;}
};//class SceneNode
SceneNode *Duplication(SceneNode *); ///<复制一个场景节点