Commit 21efe402 authored by hybrid's avatar hybrid

Fix relative indices in obj files.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@826 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 00cab3e6
...@@ -201,7 +201,7 @@ IAnimatedMesh* COBJMeshFileLoader::createMesh(io::IReadFile* file) ...@@ -201,7 +201,7 @@ IAnimatedMesh* COBJMeshFileLoader::createMesh(io::IReadFile* file)
// read in next vertex's data // read in next vertex's data
u32 wlength = copyWord(vertexWord, pLinePtr, WORD_BUFFER_LENGTH, pBufEnd); u32 wlength = copyWord(vertexWord, pLinePtr, WORD_BUFFER_LENGTH, pBufEnd);
// this function will also convert obj's 1-based index to c++'s 0-based index // this function will also convert obj's 1-based index to c++'s 0-based index
retrieveVertexIndices(vertexWord, Idx, vertexWord+wlength+1); retrieveVertexIndices(vertexWord, Idx, vertexWord+wlength+1, vertexBuffer.size());
if ( -1 != Idx[0] ) if ( -1 != Idx[0] )
{ {
v.Pos = vertexBuffer[Idx[0]]; v.Pos = vertexBuffer[Idx[0]];
...@@ -720,7 +720,7 @@ const c8* COBJMeshFileLoader::goAndCopyNextWord(c8* outBuf, const c8* inBuf, u32 ...@@ -720,7 +720,7 @@ const c8* COBJMeshFileLoader::goAndCopyNextWord(c8* outBuf, const c8* inBuf, u32
} }
bool COBJMeshFileLoader::retrieveVertexIndices(c8* pVertexData, s32* pIdx, const c8* pBufEnd) bool COBJMeshFileLoader::retrieveVertexIndices(c8* pVertexData, s32* pIdx, const c8* pBufEnd, u32 bufferSize)
{ {
c8 word[16] = ""; c8 word[16] = "";
const c8* pChar = goFirstWord(pVertexData, pBufEnd); const c8* pChar = goFirstWord(pVertexData, pBufEnd);
...@@ -742,7 +742,7 @@ bool COBJMeshFileLoader::retrieveVertexIndices(c8* pVertexData, s32* pIdx, const ...@@ -742,7 +742,7 @@ bool COBJMeshFileLoader::retrieveVertexIndices(c8* pVertexData, s32* pIdx, const
// if no number was found index will become 0 and later on -1 by decrement // if no number was found index will become 0 and later on -1 by decrement
index = atoi( word ); index = atoi( word );
if (index<0) if (index<0)
index += pIdx[idxType]; index += bufferSize;
else else
--index; --index;
pIdx[idxType] = index; pIdx[idxType] = index;
......
...@@ -96,7 +96,7 @@ private: ...@@ -96,7 +96,7 @@ private:
// reads and convert to integer the vertex indices in a line of obj file's face statement // reads and convert to integer the vertex indices in a line of obj file's face statement
// -1 for the index if it doesn't exist // -1 for the index if it doesn't exist
// indices are changed to 0-based index instead of 1-based from the obj file // indices are changed to 0-based index instead of 1-based from the obj file
bool retrieveVertexIndices(c8* pVertexData, s32* Idx, const c8* pBufEnd); bool retrieveVertexIndices(c8* pVertexData, s32* Idx, const c8* pBufEnd, u32 bufferSize);
void cleanUp(); void cleanUp();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment