void UpdateAnimationStatesWeights()
{
float totalWeight = 0;
{
for( int n = 0; n < activeItems.Count; n++ )
{
AnimationItem item = activeItems[ n ];
totalWeight += item.Weight * item.blendingWeightCoefficient;
}
for( int n = 0; n < removedItemsForBlending.Count; n++ )
{
AnimationItem item = removedItemsForBlending[ n ];
totalWeight += item.Weight * item.blendingWeightCoefficient;
}
}
float multiplier = 1;
if( totalWeight > 0 && totalWeight < 1 )
multiplier = 1.0f / totalWeight;
//update animation states
{
for( int n = 0; n < activeItems.Count; n++ )
{
AnimationItem item = activeItems[ n ];
item.animationState.Weight = item.Weight * item.blendingWeightCoefficient *
multiplier;
}
for( int n = 0; n < removedItemsForBlending.Count; n++ )
{
AnimationItem item = removedItemsForBlending[ n ];
item.animationState.Weight = item.Weight * item.blendingWeightCoefficient *
multiplier;
}
}
}