I have a rather large scene where a few objects have animation. I export using FCollada with sampled animation. The converted animation file is 25MB so I guess every node has animation stored even if the node doesn't actually move.
I changed the code in Converter::processNode to check the node actually animates and clear the frame vector if not. The anim file is then 70KB.
Code:
// Animation (assume sampled data)
DaeSampler *sampler = doc.libAnimations.findAnimForTarget( node.id, node.transMat.sid );
std::vector< Matrix4f > frame_matrices;
if( sampler != 0x0 && sampler->output->floatArray.size() == _frameCount * 16 )
{
// create all the matrices adn see if they actually animate
for( unsigned int i = 0; i < _frameCount; ++i )
{
Matrix4f mat = animTransAccum[i] * makeMatrix4f( &sampler->output->floatArray[i * 16], doc.y_up );
if( oNode != 0x0 )
{
frame_matrices.push_back( mat );
animTransAccum[i] = Matrix4f();
}
else animTransAccum[i] = mat;
}
}
else
{
for( unsigned int i = 0; i < _frameCount; ++i )
{
if( oNode != 0x0 )
{
frame_matrices.push_back( relMat );
animTransAccum[i] = Matrix4f();
}
else animTransAccum[i] = relMat;
}
if( sampler != 0x0 && sampler->output->floatArray.size() != _frameCount * 16 )
log( "Warning: Use animation sampling for export!" );
}
// see if the frame matrices are actually animating, if not, clear the frame matrix array
if( frame_matrices.size()>0 )
{
bool is_animating = false;
Matrix4f ref_tm = frame_matrices[0];
for( size_t i=1; i<frame_matrices.size(); ++i )
{
if( memcmp(ref_tm.x,frame_matrices[i].x,sizeof(ref_tm.x))!=0 )
{
is_animating = true;
break;
}
}
if( !is_animating )
{
frame_matrices.clear();
}
}
// copy the frame matrices to the node
for( size_t i=0; i<frame_matrices.size(); ++i )
{
oNode->frames.push_back(frame_matrices[i]);
}
// Process children