guillaumeblanc / ozz-animation

Open source c++ skeletal animation library and toolset
http://guillaumeblanc.github.io/ozz-animation/
Other
2.46k stars 302 forks source link

AnimationOptimizer too eager to early out ? #176

Open jankrassnigg opened 8 months ago

jankrassnigg commented 8 months ago

I quickly gave AnimationOptimizer a try to see how it would optimize my animation clips, but it doesn't do anything.

It does an early out here:

  // Validates the skeleton matches the animation.
  if (num_tracks != _skeleton.num_joints()) {
    return false;
  }

My skeleton has 20 joints. The animation clip only has 18 tracks. All my animation playback etc works fine, so this data shouldn't be a problem, could it be that the AnimationOptimizer has an invalid assumption that these numbers must match?

I've attached the file that I use for testing.

Pete.zip

guillaumeblanc commented 7 months ago

Hi,

From ozz pipeline point a view, the number of tracks of an animation must be the same as the number of joints of the skeleton. The number of joints and tracks is the only thing allowing to "validate" that the animation matches with the skeleton.

Let's consider number of joints differs (less animation tracks than skeleton joint):

The reason you don't see playback or other operations failing is that runtime operations check "soa" numbers of joints, aka multiple of 4. It seems I need to reinforce these tests.

In your case, the 2 missing tracks are set to identity by the animation sampler. So you have 2 arbitrary non-animated joints. I'd recommend investigating how/why you end up with this 2 more tracks.

ozz import pipeline does not let this happen (unless there's a bug):

Hope it helps, Guillaume