diff options
Diffstat (limited to '3rdparty/bgfx/tools/geometryc/geometryc.cpp')
-rw-r--r-- | 3rdparty/bgfx/tools/geometryc/geometryc.cpp | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/3rdparty/bgfx/tools/geometryc/geometryc.cpp b/3rdparty/bgfx/tools/geometryc/geometryc.cpp index ccf6a580b80..0314455b413 100644 --- a/3rdparty/bgfx/tools/geometryc/geometryc.cpp +++ b/3rdparty/bgfx/tools/geometryc/geometryc.cpp @@ -10,7 +10,7 @@ #include <stdlib.h> #include <string.h> -#include <bgfx.h> +#include <bgfx/bgfx.h> #include "../../src/vertexdecl.h" #include <tinystl/allocator.h> @@ -510,11 +510,11 @@ int main(int _argc, const char* _argv[]) for (uint32_t edge = 0, numEdges = argc-1; edge < numEdges; ++edge) { Index3 index; - index.m_texcoord = 0; - index.m_normal = 0; + index.m_texcoord = -1; + index.m_normal = -1; index.m_vertexIndex = -1; - char* vertex = argv[edge+1]; + char* vertex = argv[edge+1]; char* texcoord = strchr(vertex, '/'); if (NULL != texcoord) { @@ -528,8 +528,12 @@ int main(int _argc, const char* _argv[]) index.m_normal = (nn < 0) ? nn+numNormals : nn-1; } - const int tex = atoi(texcoord); - index.m_texcoord = (tex < 0) ? tex+numTexcoords : tex-1; + // https://en.wikipedia.org/wiki/Wavefront_.obj_file#Vertex_Normal_Indices_Without_Texture_Coordinate_Indices + if(*texcoord != '\0') + { + const int tex = atoi(texcoord); + index.m_texcoord = (tex < 0) ? tex+numTexcoords : tex-1; + } } const int pos = atoi(vertex); @@ -716,8 +720,8 @@ int main(int _argc, const char* _argv[]) bool hasTexcoord; { Index3Map::const_iterator it = indexMap.begin(); - hasNormal = 0 != it->second.m_normal; - hasTexcoord = 0 != it->second.m_texcoord; + hasNormal = -1 != it->second.m_normal; + hasTexcoord = -1 != it->second.m_texcoord; if (!hasTexcoord && texcoords.size() == positions.size() ) @@ -938,14 +942,14 @@ int main(int _argc, const char* _argv[]) } } - if (0 < numVertices) + prim.m_numVertices = numVertices - prim.m_startVertex; + if (0 < prim.m_numVertices) { - prim.m_numVertices = numVertices - prim.m_startVertex; prim.m_numIndices = numIndices - prim.m_startIndex; prim.m_name = groupIt->m_name; primitives.push_back(prim); prim.m_startVertex = numVertices; - prim.m_startIndex = numIndices; + prim.m_startIndex = numIndices; } BX_TRACE("%3d: s %5d, n %5d, %s\n" |