From 70881ce2556cae8985225a16e65c74539d206b86 Mon Sep 17 00:00:00 2001 From: Marc Gilleron Date: Tue, 23 Apr 2019 23:38:15 +0100 Subject: [PATCH] Use Godot Map, std::map doesnt appear to have any advantage --- dmc/mesh_builder.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/dmc/mesh_builder.h b/dmc/mesh_builder.h index 25c159c..41e63e6 100644 --- a/dmc/mesh_builder.h +++ b/dmc/mesh_builder.h @@ -2,8 +2,8 @@ #define MESH_BUILDER_H #include "../utility.h" +#include #include -#include #include namespace dmc { @@ -18,15 +18,17 @@ public: int i = 0; - if (_position_to_index.find(position) != _position_to_index.end()) { + Map::Element *e = _position_to_index.find(position); - i = _position_to_index[position]; + if (e) { + + i = e->get(); ++_reused_vertices; } else { i = _positions.size(); - _position_to_index[position] = i; + _position_to_index.insert(position, i); _positions.push_back(position); _normals.push_back(normal); @@ -44,7 +46,7 @@ private: std::vector _positions; std::vector _normals; std::vector _indices; - std::map _position_to_index; + Map _position_to_index; int _reused_vertices; };