From 4d87b344261c4ff393a0b9d9fd59fd9b0c902b6b Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Tue, 26 Jan 2021 01:01:53 +0200 Subject: [PATCH] Trigger Mesh::check_buffers from MeshBuilder destructor Doing it for every vertex wastes performance --- source/meshbuilder.cpp | 9 ++++----- source/meshbuilder.h | 3 ++- 2 files changed, 6 insertions(+), 6 deletions(-) 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); -- 2.45.2