supported new Comparator<> and ItemComparator<>

This commit is contained in:
2024-12-12 13:30:11 +08:00
parent dd5a78cbaa
commit 6c160f5c53
8 changed files with 41 additions and 40 deletions

View File

@@ -8,14 +8,14 @@ class RenderAssignBuffer;
class SceneNode;
struct CameraInfo;
struct RenderPipelineIndex
struct RenderPipelineIndex:public Comparator<RenderPipelineIndex>
{
Material *material;
Pipeline *pipeline;
public:
const int Comp(const RenderPipelineIndex &rli)const
const int compare(const RenderPipelineIndex &rli)const override
{
if(material<rli.material)return(-1);
if(material>rli.material)return(1);
@@ -26,8 +26,6 @@ public:
return(0);
}
CompOperator(const RenderPipelineIndex &,Comp)
public:
RenderPipelineIndex()

View File

@@ -11,7 +11,7 @@ namespace hgl
class MaterialInstance;
class SceneNode;
struct RenderNode
struct RenderNode:public Comparator<RenderNode>
{
uint index; ///<在MaterialRenderList中的索引
@@ -22,6 +22,11 @@ namespace hgl
Vector3f world_position;
float to_camera_distance;
public:
//该函数位于MaterialRenderList.cpp
const int compare(const RenderNode &)const override;
};
using RenderNodeList=List<RenderNode>;

View File

@@ -12,7 +12,7 @@ VK_NAMESPACE_BEGIN
* 原始图元数据缓冲区<Br>
* 提供在渲染之前的数据绑定信息
*/
struct PrimitiveDataBuffer
struct PrimitiveDataBuffer:public Comparator<PrimitiveDataBuffer>
{
uint32_t vab_count;
VkBuffer * vab_list;
@@ -32,14 +32,14 @@ public:
PrimitiveDataBuffer(const uint32_t,IndexBuffer *,VertexDataManager *_v=nullptr);
~PrimitiveDataBuffer();
const bool Comp(const PrimitiveDataBuffer *pdb)const;
const int compare(const PrimitiveDataBuffer &pdb)const override;
};//struct PrimitiveDataBuffer
/**
* 原始图元渲染数据<Br>
* 提供在渲染时的数据
*/
struct PrimitiveRenderData
struct PrimitiveRenderData:public ComparatorData<PrimitiveRenderData>
{
//因为要VAB是流式访问所以我们这个结构会被用做排序依据
//也因此把vertex_offset放在最前面
@@ -59,9 +59,6 @@ public:
vertex_offset =vo;
first_index =fi;
}
CompOperatorMemcmp(const PrimitiveRenderData &);
CompOperatorMemcmpPointer(PrimitiveRenderData);
};
/**

View File

@@ -12,7 +12,7 @@ namespace hgl
/**
* 字体信息
*/
struct Font
struct Font:public ComparatorData<Font>
{
os_char name[MAX_FONT_NAME_LENGTH]; ///<字体名称
@@ -28,8 +28,6 @@ namespace hgl
Font();
Font(const os_char *,int,int,bool b=false,bool i=false,bool=true);
CompOperatorMemcmp(const Font &); ///<比较操作符重载
};//struct Font
}//namespace graph
}//namespace hgl