From 73027ffd9a7ba9ff0158c24137d01baf430883e4 Mon Sep 17 00:00:00 2001 From: hyzboy Date: Tue, 10 Jun 2025 23:46:19 +0800 Subject: [PATCH] =?UTF-8?q?WorkObject=E5=A2=9E=E5=8A=A0GetPrimitiveCreater?= =?UTF-8?q?=E5=87=BD=E6=95=B0=EF=BC=8C=E5=B9=B6=E8=BF=9E=E5=B8=A6=E6=9B=B4?= =?UTF-8?q?=E6=96=B0BillboardTest/PlaneGrid3D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/Basic/BillboardTest.cpp | 12 ++++++------ example/Gizmo/PlaneGrid3D.cpp | 4 ++-- inc/hgl/WorkObject.h | 8 ++++++++ 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/example/Basic/BillboardTest.cpp b/example/Basic/BillboardTest.cpp index e39ec6e1..9df4a2b6 100644 --- a/example/Basic/BillboardTest.cpp +++ b/example/Basic/BillboardTest.cpp @@ -130,7 +130,7 @@ private: using namespace inline_geometry; { - PrimitiveCreater pc(GetDevice(),mi_plane_grid->GetVIL()); + auto pc=GetPrimitiveCreater(mi_plane_grid); struct PlaneGridCreateInfo pgci; @@ -140,18 +140,18 @@ private: pgci.lum=128; pgci.sub_lum=192; - prim_plane_grid=CreatePlaneGrid2D(&pc,&pgci); + prim_plane_grid=CreatePlaneGrid2D(pc,&pgci); } { - PrimitiveCreater pc(GetDevice(),mi_billboard->GetVIL()); + auto pc=GetPrimitiveCreater(mi_billboard); - pc.Init("Billboard",1); + pc->Init("Billboard",1); - if(!pc.WriteVAB(VAN::Position,VF_V3F,position_data)) + if(!pc->WriteVAB(VAN::Position,VF_V3F,position_data)) return(false); - ro_billboard=db->CreateMesh(&pc,mi_billboard,pipeline_billboard); + ro_billboard=db->CreateMesh(pc,mi_billboard,pipeline_billboard); if(!ro_billboard) return(false); diff --git a/example/Gizmo/PlaneGrid3D.cpp b/example/Gizmo/PlaneGrid3D.cpp index 357f795f..5c7a3f81 100644 --- a/example/Gizmo/PlaneGrid3D.cpp +++ b/example/Gizmo/PlaneGrid3D.cpp @@ -69,9 +69,9 @@ private: pgci.lum=180; pgci.sub_lum=255; - PrimitiveCreater pc(GetDevice(),material_instance[0]->GetVIL()); + auto pc=GetPrimitiveCreater(material_instance[0]); - prim_plane_grid=CreatePlaneGrid2D(&pc,&pgci); + prim_plane_grid=CreatePlaneGrid2D(pc,&pgci); return prim_plane_grid; } diff --git a/inc/hgl/WorkObject.h b/inc/hgl/WorkObject.h index 4309d0fd..28844532 100644 --- a/inc/hgl/WorkObject.h +++ b/inc/hgl/WorkObject.h @@ -94,6 +94,14 @@ namespace hgl return db->CreateMaterialInstance(mtl_name,mci,vil_cfg); } + AutoDelete GetPrimitiveCreater(graph::MaterialInstance *mi) + { + if(!mi) + return(nullptr); + + return(new graph::PrimitiveCreater(GetDevice(),mi->GetVIL())); + } + graph::Primitive *CreatePrimitive( const AnsiString &name, const uint32_t vertices_count, const graph::VIL *vil,