From: Mikko Rasa Date: Mon, 25 Jan 2021 23:01:53 +0000 (+0200) Subject: Trigger Mesh::check_buffers from MeshBuilder destructor X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=4d87b344261c4ff393a0b9d9fd59fd9b0c902b6b;p=libs%2Fgl.git Trigger Mesh::check_buffers from MeshBuilder destructor Doing it for every vertex wastes performance --- diff --git a/source/meshbuilder.cpp b/source/meshbuilder.cpp index 9e71536a..92e2ee06 100644 --- a/source/meshbuilder.cpp +++ b/source/meshbuilder.cpp @@ -10,15 +10,14 @@ MeshBuilder::MeshBuilder(Mesh &m): batch(0) { } -void MeshBuilder::auto_offset() +MeshBuilder::~MeshBuilder() { - offset(mesh.get_vertices().size()); + mesh.check_buffers(Mesh::VERTEX_BUFFER); } -void MeshBuilder::vertex_(const Vector4 &v) +void MeshBuilder::auto_offset() { - PrimitiveBuilder::vertex_(v); - mesh.check_buffers(Mesh::VERTEX_BUFFER); + offset(mesh.get_vertices().size()); } void MeshBuilder::begin_() diff --git a/source/meshbuilder.h b/source/meshbuilder.h index afc1450b..5f4a9dc8 100644 --- a/source/meshbuilder.h +++ b/source/meshbuilder.h @@ -17,9 +17,10 @@ private: public: MeshBuilder(Mesh &); + ~MeshBuilder(); + void auto_offset(); private: - virtual void vertex_(const Vector4 &); virtual void begin_(); virtual void end_(); virtual void element_(unsigned);