Quellcode durchsuchen

using a custom compare function instead of a global aiVector3t less than operator

Marshall Hahn vor 12 Jahren
Ursprung
Commit
c592154006
4 geänderte Dateien mit 18 neuen und 14 gelöschten Zeilen
  1. 2 2
      code/ObjExporter.cpp
  2. 16 1
      code/ObjExporter.h
  3. 0 1
      include/assimp/vector3.h
  4. 0 10
      include/assimp/vector3.inl

+ 2 - 2
code/ObjExporter.cpp

@@ -261,7 +261,7 @@ void ObjExporter :: WriteGeometryFile()
 
 int ObjExporter::vecIndexMap::getIndex(const aiVector3D& vec)
 {
-	std::map<aiVector3D, int>::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<aiVector3D>& vecs )
 {
 	vecs.resize(vecMap.size());
-	for(std::map<aiVector3D, int>::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;
 	}
 }

+ 16 - 1
code/ObjExporter.h

@@ -113,10 +113,25 @@ private:
 
 	std::vector<aiVector3D> 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<aiVector3D, int> vecMap;
+		typedef std::map<aiVector3D, int, aiVectorCompare> dataType;
+		dataType vecMap;
 	public:
 
 		vecIndexMap():mNextIndex(1)

+ 0 - 1
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 <typename TOther>
 	operator aiVector3t<TOther> () const;

+ 0 - 10
include/assimp/vector3.inl

@@ -149,16 +149,6 @@ AI_FORCE_INLINE bool aiVector3t<TReal>::operator!= (const aiVector3t<TReal>& oth
 }
 // ------------------------------------------------------------------------------------------------
 template <typename TReal>
-AI_FORCE_INLINE bool aiVector3t<TReal>::operator< (const aiVector3t<TReal>& 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 <typename TReal>
 AI_FORCE_INLINE const aiVector3t<TReal> aiVector3t<TReal>::SymMul(const aiVector3t<TReal>& o) {
 	return aiVector3t<TReal>(x*o.x,y*o.y,z*o.z);
 }