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

pull/136/head
Marshall Hahn 2013-10-01 11:21:36 -04:00
parent b72b16c90b
commit c592154006
4 changed files with 18 additions and 14 deletions

View File

@ -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;
}
}

View File

@ -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)

View File

@ -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;

View File

@ -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);
}