- Bugfix: XFileLoader does not generate dummy bone arrays anymore. Had screwed HasBones()-Test in the viewer, making bone-less objects vanish from view
- made HasFooBar()-checks more precise on the way - cleared up everyone's destructors to also delete arrays if the corresponding mNumFoo member was zero. This hopefully does not break all too much - Bugfix: meshes without bones now properly show up with DisableMaterials enabled git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@230 67173fc5-114c-0410-ac8e-9d2fd5bffc1fpull/1/head
parent
562050cf6d
commit
195d9a9cb1
|
@ -371,9 +371,11 @@ void XFileImporter::CreateMeshes( aiScene* pScene, aiNode* pNode, const std::vec
|
||||||
|
|
||||||
// store the bones in the mesh
|
// store the bones in the mesh
|
||||||
mesh->mNumBones = (unsigned int)newBones.size();
|
mesh->mNumBones = (unsigned int)newBones.size();
|
||||||
|
if( newBones.size() > 0)
|
||||||
|
{
|
||||||
mesh->mBones = new aiBone*[mesh->mNumBones];
|
mesh->mBones = new aiBone*[mesh->mNumBones];
|
||||||
for( unsigned int c = 0; c < newBones.size(); c++)
|
std::copy( newBones.begin(), newBones.end(), mesh->mBones);
|
||||||
mesh->mBones[c] = newBones[c];
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -184,11 +184,8 @@ struct aiNodeAnim
|
||||||
|
|
||||||
~aiNodeAnim()
|
~aiNodeAnim()
|
||||||
{
|
{
|
||||||
if (mNumPositionKeys)
|
|
||||||
delete [] mPositionKeys;
|
delete [] mPositionKeys;
|
||||||
if (mNumRotationKeys)
|
|
||||||
delete [] mRotationKeys;
|
delete [] mRotationKeys;
|
||||||
if (mNumScalingKeys)
|
|
||||||
delete [] mScalingKeys;
|
delete [] mScalingKeys;
|
||||||
}
|
}
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
|
@ -234,12 +231,11 @@ struct aiAnimation
|
||||||
~aiAnimation()
|
~aiAnimation()
|
||||||
{
|
{
|
||||||
if (mNumChannels)
|
if (mNumChannels)
|
||||||
{
|
|
||||||
for( unsigned int a = 0; a < mNumChannels; a++)
|
for( unsigned int a = 0; a < mNumChannels; a++)
|
||||||
delete mChannels[a];
|
delete mChannels[a];
|
||||||
|
|
||||||
delete [] mChannels;
|
delete [] mChannels;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,6 @@ struct aiFace
|
||||||
//! Default destructor. Delete the index array
|
//! Default destructor. Delete the index array
|
||||||
~aiFace()
|
~aiFace()
|
||||||
{
|
{
|
||||||
if (mNumIndices)
|
|
||||||
delete [] mIndices;
|
delete [] mIndices;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,7 +197,7 @@ struct aiBone
|
||||||
//! Destructor - deletes the array of vertex weights
|
//! Destructor - deletes the array of vertex weights
|
||||||
~aiBone()
|
~aiBone()
|
||||||
{
|
{
|
||||||
if (mNumWeights)delete [] mWeights;
|
delete [] mWeights;
|
||||||
}
|
}
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
};
|
};
|
||||||
|
@ -438,8 +437,6 @@ struct aiMesh
|
||||||
|
|
||||||
//! Deletes all storage allocated for the mesh
|
//! Deletes all storage allocated for the mesh
|
||||||
~aiMesh()
|
~aiMesh()
|
||||||
{
|
|
||||||
if ( mNumVertices ) // fix to make this work for invalid scenes, too
|
|
||||||
{
|
{
|
||||||
delete [] mVertices;
|
delete [] mVertices;
|
||||||
delete [] mNormals;
|
delete [] mNormals;
|
||||||
|
@ -449,40 +446,33 @@ struct aiMesh
|
||||||
delete [] mTextureCoords[a];
|
delete [] mTextureCoords[a];
|
||||||
for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS; a++)
|
for( unsigned int a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS; a++)
|
||||||
delete [] mColors[a];
|
delete [] mColors[a];
|
||||||
}
|
|
||||||
if ( mNumBones && mBones) // fix to make this work for invalid scenes, too
|
|
||||||
{
|
|
||||||
for( unsigned int a = 0; a < mNumBones; a++)
|
for( unsigned int a = 0; a < mNumBones; a++)
|
||||||
delete mBones[a];
|
delete mBones[a];
|
||||||
delete [] mBones;
|
delete [] mBones;
|
||||||
}
|
|
||||||
if ( mNumFaces) // fix to make this work for invalid scenes, too
|
|
||||||
{
|
|
||||||
delete [] mFaces;
|
delete [] mFaces;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//! Check whether the mesh contains positions. If no special scene flags
|
//! Check whether the mesh contains positions. If no special scene flags
|
||||||
//! (such as AI_SCENE_FLAGS_ANIM_SKELETON_ONLY) are set this MUST
|
//! (such as AI_SCENE_FLAGS_ANIM_SKELETON_ONLY) are set this MUST
|
||||||
//! always return true
|
//! always return true
|
||||||
inline bool HasPositions() const
|
inline bool HasPositions() const
|
||||||
{ return mVertices != NULL; }
|
{ return mVertices != NULL && mNumVertices > 0; }
|
||||||
|
|
||||||
//! Check whether the mesh contains faces. If no special scene flags
|
//! Check whether the mesh contains faces. If no special scene flags
|
||||||
//! are set this should always return true
|
//! are set this should always return true
|
||||||
inline bool HasFaces() const
|
inline bool HasFaces() const
|
||||||
{ return mFaces != NULL; }
|
{ return mFaces != NULL && mNumFaces > 0; }
|
||||||
|
|
||||||
//! Check whether the mesh contains normal vectors
|
//! Check whether the mesh contains normal vectors
|
||||||
inline bool HasNormals() const
|
inline bool HasNormals() const
|
||||||
{ return mNormals != NULL; }
|
{ return mNormals != NULL && mNumVertices > 0; }
|
||||||
|
|
||||||
//! Check whether the mesh contains tangent and bitangent vectors
|
//! Check whether the mesh contains tangent and bitangent vectors
|
||||||
//! It is not possible that it contains tangents and no bitangents
|
//! It is not possible that it contains tangents and no bitangents
|
||||||
//! (or the other way round). The existence of one of them
|
//! (or the other way round). The existence of one of them
|
||||||
//! implies that the second is there, too.
|
//! implies that the second is there, too.
|
||||||
inline bool HasTangentsAndBitangents() const
|
inline bool HasTangentsAndBitangents() const
|
||||||
{ return mTangents != NULL && mBitangents != NULL; }
|
{ return mTangents != NULL && mBitangents != NULL && mNumVertices > 0; }
|
||||||
|
|
||||||
//! Check whether the mesh contains a vertex color set
|
//! Check whether the mesh contains a vertex color set
|
||||||
//! \param pIndex Index of the vertex color set
|
//! \param pIndex Index of the vertex color set
|
||||||
|
@ -491,7 +481,7 @@ struct aiMesh
|
||||||
if( pIndex >= AI_MAX_NUMBER_OF_COLOR_SETS)
|
if( pIndex >= AI_MAX_NUMBER_OF_COLOR_SETS)
|
||||||
return false;
|
return false;
|
||||||
else
|
else
|
||||||
return mColors[pIndex] != NULL;
|
return mColors[pIndex] != NULL && mNumVertices > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Check whether the mesh contains a texture coordinate set
|
//! Check whether the mesh contains a texture coordinate set
|
||||||
|
@ -501,11 +491,11 @@ struct aiMesh
|
||||||
if( pIndex >= AI_MAX_NUMBER_OF_TEXTURECOORDS)
|
if( pIndex >= AI_MAX_NUMBER_OF_TEXTURECOORDS)
|
||||||
return false;
|
return false;
|
||||||
else
|
else
|
||||||
return mTextureCoords[pIndex] != NULL;
|
return mTextureCoords[pIndex] != NULL && mNumVertices > 0;
|
||||||
}
|
}
|
||||||
//! Check whether the mesh contains bones
|
//! Check whether the mesh contains bones
|
||||||
inline bool HasBones() const
|
inline bool HasBones() const
|
||||||
{ return mBones != NULL; }
|
{ return mBones != NULL && mNumBones > 0; }
|
||||||
|
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
};
|
};
|
||||||
|
|
|
@ -121,8 +121,8 @@ struct aiNode
|
||||||
{
|
{
|
||||||
for( unsigned int a = 0; a < mNumChildren; a++)
|
for( unsigned int a = 0; a < mNumChildren; a++)
|
||||||
delete mChildren[a];
|
delete mChildren[a];
|
||||||
delete [] mChildren;
|
|
||||||
}
|
}
|
||||||
|
delete [] mChildren;
|
||||||
delete [] mMeshes;
|
delete [] mMeshes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -317,68 +317,61 @@ struct aiScene
|
||||||
// mich better to check whether both mNumXXX and mXXX are
|
// mich better to check whether both mNumXXX and mXXX are
|
||||||
// valid instead of relying on just one of them.
|
// valid instead of relying on just one of them.
|
||||||
if (mNumMeshes && mMeshes)
|
if (mNumMeshes && mMeshes)
|
||||||
{
|
|
||||||
for( unsigned int a = 0; a < mNumMeshes; a++)
|
for( unsigned int a = 0; a < mNumMeshes; a++)
|
||||||
delete mMeshes[a];
|
delete mMeshes[a];
|
||||||
delete [] mMeshes;
|
delete [] mMeshes;
|
||||||
}
|
|
||||||
if (mNumMaterials && mMaterials)
|
if (mNumMaterials && mMaterials)
|
||||||
{
|
|
||||||
for( unsigned int a = 0; a < mNumMaterials; a++)
|
for( unsigned int a = 0; a < mNumMaterials; a++)
|
||||||
delete mMaterials[a];
|
delete mMaterials[a];
|
||||||
delete [] mMaterials;
|
delete [] mMaterials;
|
||||||
}
|
|
||||||
if (mNumAnimations && mAnimations)
|
if (mNumAnimations && mAnimations)
|
||||||
{
|
|
||||||
for( unsigned int a = 0; a < mNumAnimations; a++)
|
for( unsigned int a = 0; a < mNumAnimations; a++)
|
||||||
delete mAnimations[a];
|
delete mAnimations[a];
|
||||||
delete [] mAnimations;
|
delete [] mAnimations;
|
||||||
}
|
|
||||||
if (mNumTextures && mTextures)
|
if (mNumTextures && mTextures)
|
||||||
{
|
|
||||||
for( unsigned int a = 0; a < mNumTextures; a++)
|
for( unsigned int a = 0; a < mNumTextures; a++)
|
||||||
delete mTextures[a];
|
delete mTextures[a];
|
||||||
delete [] mTextures;
|
delete [] mTextures;
|
||||||
}
|
|
||||||
if (mNumLights && mLights)
|
if (mNumLights && mLights)
|
||||||
{
|
|
||||||
for( unsigned int a = 0; a < mNumLights; a++)
|
for( unsigned int a = 0; a < mNumLights; a++)
|
||||||
delete mLights[a];
|
delete mLights[a];
|
||||||
delete [] mLights;
|
delete [] mLights;
|
||||||
}
|
|
||||||
if (mNumCameras && mCameras)
|
if (mNumCameras && mCameras)
|
||||||
{
|
|
||||||
for( unsigned int a = 0; a < mNumCameras; a++)
|
for( unsigned int a = 0; a < mNumCameras; a++)
|
||||||
delete mCameras[a];
|
delete mCameras[a];
|
||||||
delete [] mCameras;
|
delete [] mCameras;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//! Check whether the scene contains meshes
|
//! Check whether the scene contains meshes
|
||||||
//! Unless no special scene flags are set this will always be true.
|
//! Unless no special scene flags are set this will always be true.
|
||||||
inline bool HasMeshes() const
|
inline bool HasMeshes() const
|
||||||
{ return mMeshes != NULL; }
|
{ return mMeshes != NULL && mNumMeshes > 0; }
|
||||||
|
|
||||||
//! Check whether the scene contains materials
|
//! Check whether the scene contains materials
|
||||||
//! Unless no special scene flags are set this will always be true.
|
//! Unless no special scene flags are set this will always be true.
|
||||||
inline bool HasMaterials() const
|
inline bool HasMaterials() const
|
||||||
{ return mMaterials != NULL; }
|
{ return mMaterials != NULL && mNumMaterials > 0; }
|
||||||
|
|
||||||
//! Check whether the scene contains lights
|
//! Check whether the scene contains lights
|
||||||
inline bool HasLights() const
|
inline bool HasLights() const
|
||||||
{ return mLights != NULL; }
|
{ return mLights != NULL && mNumLights > 0; }
|
||||||
|
|
||||||
//! Check whether the scene contains textures
|
//! Check whether the scene contains textures
|
||||||
inline bool HasTextures() const
|
inline bool HasTextures() const
|
||||||
{ return mTextures != NULL; }
|
{ return mTextures != NULL && mNumTextures > 0; }
|
||||||
|
|
||||||
//! Check whether the scene contains cameras
|
//! Check whether the scene contains cameras
|
||||||
inline bool HasCameras() const
|
inline bool HasCameras() const
|
||||||
{ return mCameras != NULL; }
|
{ return mCameras != NULL && mNumCameras > 0; }
|
||||||
|
|
||||||
//! Check whether the scene contains animations
|
//! Check whether the scene contains animations
|
||||||
inline bool HasAnimations() const
|
inline bool HasAnimations() const
|
||||||
{ return mAnimations != NULL; }
|
{ return mAnimations != NULL && mNumAnimations > 0; }
|
||||||
|
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
};
|
};
|
||||||
|
|
|
@ -1972,7 +1972,9 @@ int CDisplay::RenderNode (aiNode* piNode,const aiMatrix4x4& piMatrix,
|
||||||
else if (bAlpha)continue;
|
else if (bAlpha)continue;
|
||||||
|
|
||||||
// Upload bone matrices. This maybe is the wrong place to do it, but for the heck of it I don't understand this code flow
|
// Upload bone matrices. This maybe is the wrong place to do it, but for the heck of it I don't understand this code flow
|
||||||
if( mesh->HasBones() && helper->piEffect)
|
if( mesh->HasBones())
|
||||||
|
{
|
||||||
|
if( helper->piEffect)
|
||||||
{
|
{
|
||||||
static float matrices[4*4*60];
|
static float matrices[4*4*60];
|
||||||
float* tempmat = matrices;
|
float* tempmat = matrices;
|
||||||
|
@ -1998,6 +2000,16 @@ int CDisplay::RenderNode (aiNode* piNode,const aiMatrix4x4& piMatrix,
|
||||||
g_piDefaultEffect->CommitChanges();
|
g_piDefaultEffect->CommitChanges();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
// upload identity matrices instead. Only the first is ever going to be used in meshes without bones
|
||||||
|
if( !g_sOptions.bRenderMats)
|
||||||
|
{
|
||||||
|
D3DXMATRIX identity( 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
|
||||||
|
g_piDefaultEffect->SetMatrixTransposeArray( "gBoneMatrix", &identity, 1);
|
||||||
|
g_piDefaultEffect->CommitChanges();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// now setup the material
|
// now setup the material
|
||||||
if (g_sOptions.bRenderMats)
|
if (g_sOptions.bRenderMats)
|
||||||
|
|
Loading…
Reference in New Issue