|
@@ -230,16 +230,10 @@ aiNode *ObjFileImporter::createNodes(const ObjFile::Model* pModel, const ObjFile
|
|
|
for ( unsigned int i=0; i< pObject->m_Meshes.size(); i++ )
|
|
|
{
|
|
|
unsigned int meshId = pObject->m_Meshes[ i ];
|
|
|
- aiMesh *pMesh = new aiMesh;
|
|
|
- createTopology( pModel, pObject, meshId, pMesh );
|
|
|
- if ( pMesh->mNumVertices > 0 )
|
|
|
- {
|
|
|
+ aiMesh *pMesh = createTopology( pModel, pObject, meshId );
|
|
|
+ if( pMesh && pMesh->mNumFaces > 0 ) {
|
|
|
MeshArray.push_back( pMesh );
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- delete pMesh;
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
// Create all nodes from the sub-objects stored in the current object
|
|
@@ -272,22 +266,22 @@ aiNode *ObjFileImporter::createNodes(const ObjFile::Model* pModel, const ObjFile
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
// Create topology data
|
|
|
-void ObjFileImporter::createTopology(const ObjFile::Model* pModel,
|
|
|
- const ObjFile::Object* pData,
|
|
|
- unsigned int uiMeshIndex,
|
|
|
- aiMesh* pMesh )
|
|
|
+aiMesh *ObjFileImporter::createTopology( const ObjFile::Model* pModel, const ObjFile::Object* pData,
|
|
|
+ unsigned int uiMeshIndex )
|
|
|
{
|
|
|
// Checking preconditions
|
|
|
ai_assert( NULL != pModel );
|
|
|
if( NULL == pData ) {
|
|
|
- return;
|
|
|
+ return NULL;
|
|
|
}
|
|
|
|
|
|
// Create faces
|
|
|
ObjFile::Mesh *pObjMesh = pModel->m_Meshes[ uiMeshIndex ];
|
|
|
- ai_assert( NULL != pObjMesh );
|
|
|
-
|
|
|
- pMesh->mNumFaces = 0;
|
|
|
+ if( !pObjMesh ) {
|
|
|
+ return NULL;
|
|
|
+ }
|
|
|
+ ai_assert( NULL != pObjMesh );
|
|
|
+ aiMesh* pMesh = new aiMesh;
|
|
|
for (size_t index = 0; index < pObjMesh->m_Faces.size(); index++)
|
|
|
{
|
|
|
ObjFile::Face* const inp = pObjMesh->m_Faces[ index ];
|
|
@@ -295,16 +289,14 @@ void ObjFileImporter::createTopology(const ObjFile::Model* pModel,
|
|
|
if (inp->m_PrimitiveType == aiPrimitiveType_LINE) {
|
|
|
pMesh->mNumFaces += inp->m_pVertices->size() - 1;
|
|
|
pMesh->mPrimitiveTypes |= aiPrimitiveType_LINE;
|
|
|
- }
|
|
|
- else if (inp->m_PrimitiveType == aiPrimitiveType_POINT) {
|
|
|
+ } else if (inp->m_PrimitiveType == aiPrimitiveType_POINT) {
|
|
|
pMesh->mNumFaces += inp->m_pVertices->size();
|
|
|
pMesh->mPrimitiveTypes |= aiPrimitiveType_POINT;
|
|
|
} else {
|
|
|
++pMesh->mNumFaces;
|
|
|
if (inp->m_pVertices->size() > 3) {
|
|
|
pMesh->mPrimitiveTypes |= aiPrimitiveType_POLYGON;
|
|
|
- }
|
|
|
- else {
|
|
|
+ } else {
|
|
|
pMesh->mPrimitiveTypes |= aiPrimitiveType_TRIANGLE;
|
|
|
}
|
|
|
}
|
|
@@ -353,6 +345,8 @@ void ObjFileImporter::createTopology(const ObjFile::Model* pModel,
|
|
|
|
|
|
// Create mesh vertices
|
|
|
createVertexArray(pModel, pData, uiMeshIndex, pMesh, uiIdxCount);
|
|
|
+
|
|
|
+ return pMesh;
|
|
|
}
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|