]> git.tdb.fi Git - libs/gl.git/commitdiff
Trigger Mesh::check_buffers from MeshBuilder destructor
authorMikko Rasa <tdb@tdb.fi>
Mon, 25 Jan 2021 23:01:53 +0000 (01:01 +0200)
committerMikko Rasa <tdb@tdb.fi>
Mon, 25 Jan 2021 23:01:53 +0000 (01:01 +0200)
Doing it for every vertex wastes performance

source/meshbuilder.cpp
source/meshbuilder.h

index 9e71536a52a3ef121fafa5d7ab99ef73f64cc2bf..92e2ee06ce5bfb3f1922eb8ad9e4cb41f8982bbb 100644 (file)
@@ -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_()
index afc1450b0b490ee66e9a1ee7f369d19db7c4d390..5f4a9dc83ec1cceae9410468051caa86c6a36770 100644 (file)
@@ -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);