Merge pull request #305 from dariomanesku/master

Geometryc now properly handles relative obj indices.
This commit is contained in:
Branimir Karadžić 2015-03-22 21:23:58 -07:00
commit b5dcce63e9

View file

@ -504,11 +504,14 @@ int main(int _argc, const char* _argv[])
Triangle triangle;
memset(&triangle, 0, sizeof(Triangle) );
const int numNormals = (int)normals.size();
const int numTexcoords = (int)texcoords.size();
const int numPositions = (int)positions.size();
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 +524,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+numNormals : nn-1;
}
index.m_texcoord = atoi(texcoord)-1;
const int tex = atoi(texcoord);
index.m_texcoord = (tex < 0) ? tex+numTexcoords : tex-1;
}
index.m_position = atoi(vertex)-1;
const int pos = atoi(vertex);
index.m_position = (pos < 0) ? pos+numPositions : pos-1;
uint64_t hash0 = index.m_position;
uint64_t hash1 = uint64_t(index.m_texcoord)<<20;
@ -710,8 +716,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() )