diff --git a/inc/hgl/graph/PrimitiveCreater.h b/inc/hgl/graph/PrimitiveCreater.h index 24248c41..f85a09f5 100644 --- a/inc/hgl/graph/PrimitiveCreater.h +++ b/inc/hgl/graph/PrimitiveCreater.h @@ -8,6 +8,8 @@ namespace hgl { namespace graph { + class VertexDataManager; + /** * 可绘制图元创建器 */ @@ -23,6 +25,7 @@ namespace hgl protected: + VertexDataManager *vdm; RenderResource *db; const VIL *vil; @@ -43,6 +46,7 @@ namespace hgl public: PrimitiveCreater(RenderResource *sdb,const VIL *); + PrimitiveCreater(VertexDataManager *); virtual ~PrimitiveCreater()=default; virtual bool Init(const uint32 vertices_count); ///<初始化,参数为顶点数量 diff --git a/inc/hgl/graph/VertexDataManager.h b/inc/hgl/graph/VertexDataManager.h index a5cedca9..e486e250 100644 --- a/inc/hgl/graph/VertexDataManager.h +++ b/inc/hgl/graph/VertexDataManager.h @@ -14,6 +14,7 @@ namespace hgl protected: + VIL * vil; ///<顶点输入格式列表 uint vi_count; ///<顶点输入流数量 const VIF * vif_list; ///<顶点输入格式列表 @@ -34,6 +35,8 @@ namespace hgl VertexDataManager(GPUDevice *dev,const VIL *_vil); ~VertexDataManager(); + const VIL * GetVIL ()const{return vil;} ///<取得顶点输入格式列表 + const VkDeviceSize GetVBOMaxCount ()const{return vbo_max_size;} ///<取得顶点缓冲区分配的空间最大数量 const VkDeviceSize GetVBOCurCount ()const{return vbo_cur_size;} ///<取得顶点缓冲区当前数量 diff --git a/src/SceneGraph/PrimitiveCreater.cpp b/src/SceneGraph/PrimitiveCreater.cpp index d4d8e830..8ca07e4d 100644 --- a/src/SceneGraph/PrimitiveCreater.cpp +++ b/src/SceneGraph/PrimitiveCreater.cpp @@ -1,6 +1,7 @@ #include #include #include +#include namespace hgl { @@ -15,6 +16,15 @@ namespace hgl ibo =nullptr; } + PrimitiveCreater::PrimitiveCreater(VertexDataManager *_vdm) + { + vdm=_vdm; + vil=vdm->GetVIL(); + + vertices_number =0; + ibo =nullptr; + } + bool PrimitiveCreater::Init(const uint32 count) { if(count<=0)return(false); diff --git a/src/SceneGraph/VertexDataManager.cpp b/src/SceneGraph/VertexDataManager.cpp index 3527cb95..d09a6ba1 100644 --- a/src/SceneGraph/VertexDataManager.cpp +++ b/src/SceneGraph/VertexDataManager.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -12,8 +12,9 @@ namespace hgl { device=dev; + vil=_vil; vi_count=_vil->GetCount(); - vif_list=_vil->GetVIFList(); //MaterialᱻͷţָЧ + vif_list=_vil->GetVIFList(); //来自于Material,不会被释放,所以指针有效 vbo_max_size=0; vbo_cur_size=0; @@ -30,14 +31,14 @@ namespace hgl } /** - * ʼݹ - * @param vbo_size VBOС - * @param ibo_size IBOС - * @param index_type + * 初始化顶点数据管理器 + * @param vbo_size VBO大小 + * @param ibo_size IBO大小 + * @param index_type 索引类型 */ bool VertexDataManager::Init(const VkDeviceSize vbo_size,const VkDeviceSize ibo_size,const IndexType index_type) { - if(vbo[0]||ibo) //Ѿʼ + if(vbo[0]||ibo) //已经初始化过了 return(false); if(vbo_size<=0)