Geometryc now properly handles relative obj indices.

This commit is contained in:
Dario Manesku 2015-03-23 01:54:52 +01:00
parent 5d0b8c1f75
commit 7c472b4ca5

View file

@ -507,8 +507,8 @@ int main(int _argc, const char* _argv[])
for (uint32_t edge = 0, numEdges = argc-1; edge < numEdges; ++edge)
{
Index3 index;
index.m_texcoord = -1;
index.m_normal = -1;
index.m_texcoord = 0;
index.m_normal = 0;
index.m_vertexIndex = -1;
char* vertex = argv[edge+1];
@ -521,13 +521,16 @@ int main(int _argc, const char* _argv[])
if (NULL != normal)
{
*normal++ = '\0';
index.m_normal = atoi(normal)-1;
const int nn = atoi(normal);
index.m_normal = (nn < 0) ? nn+(int)normals.size() : nn-1;
}
index.m_texcoord = atoi(texcoord)-1;
const int tex = atoi(texcoord);
index.m_texcoord = (tex < 0) ? tex+(int)texcoords.size() : tex-1;
}
index.m_position = atoi(vertex)-1;
const int pos = atoi(vertex);
index.m_position = (pos < 0) ? pos+(int)positions.size() : pos-1;
uint64_t hash0 = index.m_position;
uint64_t hash1 = uint64_t(index.m_texcoord)<<20;
@ -710,8 +713,8 @@ int main(int _argc, const char* _argv[])
bool hasTexcoord;
{
Index3Map::const_iterator it = indexMap.begin();
hasNormal = -1 != it->second.m_normal;
hasTexcoord = -1 != it->second.m_texcoord;
hasNormal = 0 != it->second.m_normal;
hasTexcoord = 0 != it->second.m_texcoord;
if (!hasTexcoord
&& texcoords.size() == positions.size() )