From c5921540064ee19cabd0707422274b9c3262f9b9 Mon Sep 17 00:00:00 2001 From: Marshall Hahn Date: Tue, 1 Oct 2013 11:21:36 -0400 Subject: [PATCH] using a custom compare function instead of a global aiVector3t less than operator --- code/ObjExporter.cpp | 4 ++-- code/ObjExporter.h | 17 ++++++++++++++++- include/assimp/vector3.h | 1 - include/assimp/vector3.inl | 10 ---------- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/code/ObjExporter.cpp b/code/ObjExporter.cpp index dce217d12..b680abb74 100644 --- a/code/ObjExporter.cpp +++ b/code/ObjExporter.cpp @@ -261,7 +261,7 @@ void ObjExporter :: WriteGeometryFile() int ObjExporter::vecIndexMap::getIndex(const aiVector3D& vec) { - std::map::iterator vertIt = vecMap.find(vec); + vecIndexMap::dataType::iterator vertIt = vecMap.find(vec); if(vertIt != vecMap.end()){// vertex already exists, so reference it return vertIt->second; } @@ -274,7 +274,7 @@ int ObjExporter::vecIndexMap::getIndex(const aiVector3D& vec) void ObjExporter::vecIndexMap::getVectors( std::vector& vecs ) { vecs.resize(vecMap.size()); - for(std::map::iterator it = vecMap.begin(); it != vecMap.end(); it++){ + for(vecIndexMap::dataType::iterator it = vecMap.begin(); it != vecMap.end(); it++){ vecs[it->second-1] = it->first; } } diff --git a/code/ObjExporter.h b/code/ObjExporter.h index 4f2f83240..4f6555aa5 100644 --- a/code/ObjExporter.h +++ b/code/ObjExporter.h @@ -113,10 +113,25 @@ private: std::vector vp, vn, vt; + + struct aiVectorCompare + { + bool operator() (const aiVector3D& a, const aiVector3D& b) const + { + if(a.x < b.x) return true; + if(a.x > b.x) return false; + if(a.y < b.y) return true; + if(a.y > b.y) return false; + if(a.z < b.z) return true; + return false; + } + }; + class vecIndexMap { int mNextIndex; - std::map vecMap; + typedef std::map dataType; + dataType vecMap; public: vecIndexMap():mNextIndex(1) diff --git a/include/assimp/vector3.h b/include/assimp/vector3.h index 5b3da297d..cbdee264d 100644 --- a/include/assimp/vector3.h +++ b/include/assimp/vector3.h @@ -85,7 +85,6 @@ public: // comparison bool operator== (const aiVector3t& other) const; bool operator!= (const aiVector3t& other) const; - bool operator< (const aiVector3t& other) const; template operator aiVector3t () const; diff --git a/include/assimp/vector3.inl b/include/assimp/vector3.inl index 90370fa07..c03437980 100644 --- a/include/assimp/vector3.inl +++ b/include/assimp/vector3.inl @@ -149,16 +149,6 @@ AI_FORCE_INLINE bool aiVector3t::operator!= (const aiVector3t& oth } // ------------------------------------------------------------------------------------------------ template -AI_FORCE_INLINE bool aiVector3t::operator< (const aiVector3t& other) const { - if(x < other.x) return true; - if(x > other.x) return false; - if(y < other.y) return true; - if(y > other.y) return false; - if(z < other.z) return true; - return false; -} -// ------------------------------------------------------------------------------------------------ -template AI_FORCE_INLINE const aiVector3t aiVector3t::SymMul(const aiVector3t& o) { return aiVector3t(x*o.x,y*o.y,z*o.z); }