Obj-Stream-Handling: fix readin of linewise import.
parent
a54e42cb5a
commit
33e370a8b7
|
@ -92,8 +92,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
bool readNextBlock() {
|
bool readNextBlock() {
|
||||||
std::cout << "readNextBlock()\n";
|
m_stream->Seek( m_filePos, aiOrigin_SET );
|
||||||
m_stream->Seek( m_filePos, aiOrigin_CUR );
|
|
||||||
size_t readLen = m_stream->Read( &m_cache[ 0 ], sizeof( T ), m_cacheSize );
|
size_t readLen = m_stream->Read( &m_cache[ 0 ], sizeof( T ), m_cacheSize );
|
||||||
if ( readLen == 0 ) {
|
if ( readLen == 0 ) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -108,7 +107,9 @@ public:
|
||||||
::memset( &buffer[ 0 ], ' ', m_cacheSize );
|
::memset( &buffer[ 0 ], ' ', m_cacheSize );
|
||||||
|
|
||||||
if ( m_cachePos == m_cacheSize || 0 == m_filePos ) {
|
if ( m_cachePos == m_cacheSize || 0 == m_filePos ) {
|
||||||
readNextBlock();
|
if ( !readNextBlock() ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
while ( !IsLineEnd( m_cache[ m_cachePos ] ) ) {
|
while ( !IsLineEnd( m_cache[ m_cachePos ] ) ) {
|
||||||
|
@ -116,12 +117,13 @@ public:
|
||||||
m_cachePos++;
|
m_cachePos++;
|
||||||
i++;
|
i++;
|
||||||
if ( m_cachePos >= m_cacheSize ) {
|
if ( m_cachePos >= m_cacheSize ) {
|
||||||
readNextBlock();
|
if ( !readNextBlock() ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
buffer[ i ]='\n';
|
buffer[ i ]='\n';
|
||||||
m_cachePos++;
|
m_cachePos++;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -297,9 +297,7 @@ aiNode *ObjFileImporter::createNodes(const ObjFile::Model* pModel, const ObjFile
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Create topology data
|
// Create topology data
|
||||||
aiMesh *ObjFileImporter::createTopology( const ObjFile::Model* pModel, const ObjFile::Object* pData,
|
aiMesh *ObjFileImporter::createTopology( const ObjFile::Model* pModel, const ObjFile::Object* pData, unsigned int meshIndex ) {
|
||||||
unsigned int meshIndex )
|
|
||||||
{
|
|
||||||
// Checking preconditions
|
// Checking preconditions
|
||||||
ai_assert( NULL != pModel );
|
ai_assert( NULL != pModel );
|
||||||
|
|
||||||
|
@ -483,19 +481,15 @@ void ObjFileImporter::createVertexArray(const ObjFile::Model* pModel,
|
||||||
aiFace *pDestFace = &pMesh->mFaces[ outIndex ];
|
aiFace *pDestFace = &pMesh->mFaces[ outIndex ];
|
||||||
|
|
||||||
const bool last = ( vertexIndex == pSourceFace->m_pVertices->size() - 1 );
|
const bool last = ( vertexIndex == pSourceFace->m_pVertices->size() - 1 );
|
||||||
if (pSourceFace->m_PrimitiveType != aiPrimitiveType_LINE || !last)
|
if (pSourceFace->m_PrimitiveType != aiPrimitiveType_LINE || !last) {
|
||||||
{
|
|
||||||
pDestFace->mIndices[ outVertexIndex ] = newIndex;
|
pDestFace->mIndices[ outVertexIndex ] = newIndex;
|
||||||
outVertexIndex++;
|
outVertexIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pSourceFace->m_PrimitiveType == aiPrimitiveType_POINT)
|
if (pSourceFace->m_PrimitiveType == aiPrimitiveType_POINT) {
|
||||||
{
|
|
||||||
outIndex++;
|
outIndex++;
|
||||||
outVertexIndex = 0;
|
outVertexIndex = 0;
|
||||||
}
|
} else if (pSourceFace->m_PrimitiveType == aiPrimitiveType_LINE) {
|
||||||
else if (pSourceFace->m_PrimitiveType == aiPrimitiveType_LINE)
|
|
||||||
{
|
|
||||||
outVertexIndex = 0;
|
outVertexIndex = 0;
|
||||||
|
|
||||||
if(!last)
|
if(!last)
|
||||||
|
|
Loading…
Reference in New Issue