From 7788459109fa16f247026e611f3631b02b123b20 Mon Sep 17 00:00:00 2001 From: "HuYingzhuo(hugo/hyzboy)" Date: Fri, 13 Oct 2023 19:21:04 +0800 Subject: [PATCH] improved and fixed CreatePlane --- inc/hgl/graph/InlineGeometry.h | 15 +-------------- src/SceneGraph/InlineGeometry.cpp | 11 +++-------- 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/inc/hgl/graph/InlineGeometry.h b/inc/hgl/graph/InlineGeometry.h index 70d9ce85..f52cebb7 100644 --- a/inc/hgl/graph/InlineGeometry.h +++ b/inc/hgl/graph/InlineGeometry.h @@ -78,23 +78,10 @@ namespace hgl */ Primitive *CreatePlaneGrid(RenderResource *db,const VIL *vil,const PlaneGridCreateInfo *pgci); - struct PlaneCreateInfo - { - Vector2f tile; - - public: - - PlaneCreateInfo() - { - tile.x=1.0f; - tile.y=1.0f; - } - };//struct PlaneCreateInfo - /** * 创建一个平面(三角形) */ - Primitive *CreatePlane(RenderResource *db,const VIL *vil,const PlaneCreateInfo *pci); + Primitive *CreatePlane(RenderResource *db,const VIL *vil); struct CubeCreateInfo { diff --git a/src/SceneGraph/InlineGeometry.cpp b/src/SceneGraph/InlineGeometry.cpp index be74876b..dfae2bbb 100644 --- a/src/SceneGraph/InlineGeometry.cpp +++ b/src/SceneGraph/InlineGeometry.cpp @@ -212,7 +212,7 @@ namespace hgl return rc.Finish("PlaneGrid"); } - Primitive *CreatePlane(RenderResource *db,const VIL *vil,const PlaneCreateInfo *pci) + Primitive *CreatePlane(RenderResource *db,const VIL *vil) { const float xy_vertices [] = { -0.5f,-0.5f,0.0f, +0.5f,-0.5f,0.0f, +0.5f,+0.5f,0.0f, -0.5f,+0.5f,0.0f }; float xy_tex_coord[] = { 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f }; @@ -235,19 +235,14 @@ namespace hgl { AutoDelete tangent=rc.AccessVAD(VAN::Tangent); - tangent->RepeatWrite(xy_tangent,4); + if(tangent)tangent->RepeatWrite(xy_tangent,4); } { AutoDelete tex_coord=rc.AccessVAD(VAN::TexCoord); if(tex_coord) - { - xy_tex_coord[2]=xy_tex_coord[4]=pci->tile.x; - xy_tex_coord[5]=xy_tex_coord[7]=pci->tile.y; - - tex_coord->Write(xy_tex_coord); - } + tex_coord->Write(xy_tex_coord,4); } return rc.Finish("Plane");