We found this bug when migrated our engine and tools to Visual Studio 2012.
Our geo files are 50%-200% larger after converting with the new ColladaConv.
The vertices are duplicated for each index. The problem is with Vec3f operator==
Code:
bool operator==( const Vec3f &v ) const
{
return (x > v.x - Math::Epsilon && x < v.x + Math::Epsilon &&
y > v.y - Math::Epsilon && y < v.y + Math::Epsilon &&
z > v.z - Math::Epsilon && z < v.z + Math::Epsilon);
}
For sufficiently large numbers "x - Math::Epsilon" or "x + Math::Epsilon" has exactly the same bit representation as "x" because the mantissa/significand is not large enough to represent the small change. In this case this function returns false even if this' value was exactly the same as v's value.
The difference between VS2008 and VS2012 is that the new version uses sse instructions while the old used standard floating point instructions.
I think the correct version should be:
Code:
bool operator==( const Vec3f &v ) const
{
return (x >= v.x - Math::Epsilon && x <= v.x + Math::Epsilon &&
y >= v.y - Math::Epsilon && y <= v.y + Math::Epsilon &&
z >= v.z - Math::Epsilon && z <= v.z + Math::Epsilon);
}
It also makes sense as the operator== and operator!= should satisfy that !(a==b) == (a!=b).