public static NewHavokAnimation Clone(NewHavokAnimation anim)
 {
     if (anim is NewHavokAnimation_SplineCompressed spline)
     {
         return(new NewHavokAnimation_SplineCompressed(spline));
     }
     else if (anim is NewHavokAnimation_InterleavedUncompressed interleaved)
     {
         return(new NewHavokAnimation_InterleavedUncompressed(interleaved));
     }
     else
     {
         throw new NotImplementedException();
     }
 }
Example #2
0
 public static NewHavokAnimation Clone(NewHavokAnimation anim)
 {
     if (anim is NewHavokAnimation_SplineCompressed spline)
     {
         return(new NewHavokAnimation_SplineCompressed(spline));
     }
     else if (anim is NewHavokAnimation_InterleavedUncompressed interleaved)
     {
         return(new NewHavokAnimation_InterleavedUncompressed(interleaved));
     }
     else
     {
         return(new NewHavokAnimation(anim.data, anim.Skeleton, anim.ParentContainer));
     }
 }
Example #3
0
        public void AddNewAnimation(string name, NewHavokAnimation anim)
        {
            lock (_lock_animDict)
            {
                if (animHKXsToLoad.ContainsKey(name))
                {
                    animHKXsToLoad.Remove(name);
                }
            }

            lock (_lock_AdditiveOverlays)
            {
                var overlay = _additiveBlendOverlays.FirstOrDefault(a => a.Name == name);
                if (overlay != null)
                {
                    _additiveBlendOverlays.Remove(overlay);
                }

                if (_additiveBlendOverlayNames.Contains(name))
                {
                    _additiveBlendOverlayNames.Remove(name);
                }

                if (anim.IsAdditiveBlend)
                {
                    _additiveBlendOverlayNames.Add(anim.Name);
                    _additiveBlendOverlays.Add(NewHavokAnimation.Clone(anim));
                }
            }

            lock (_lock_animCache)
            {
                if (AnimationCache.ContainsKey(name))
                {
                    AnimationCache.Remove(name);
                }

                AnimationCache.Add(name, anim);
            }
        }
        private void PopulateAdditiveBlendOverlays()
        {
            //if (MODEL.IS_PLAYER)
            //    return; //todo

            lock (_lock_AdditiveOverlays)
            {
                _additiveBlendOverlays = new List <NewHavokAnimation>();
                List <string> allAnimNames = new List <string>();
                lock (_lock_animDict)
                {
                    foreach (var kvp in animHKXsToLoad)
                    {
                        allAnimNames.Add(kvp.Key);
                    }
                }

                LoadingTaskMan.DoLoadingTaskSynchronous("ScanningAllAnimations", "Loading animations...", prog =>
                {
                    for (int i = 0; i < allAnimNames.Count; i++)
                    {
                        prog?.Report(1.0 * i / allAnimNames.Count);
                        CurrentAnimationName = allAnimNames[i];
                        if (CurrentAnimation != null)
                        {
                            if (CurrentAnimation.IsAdditiveBlend)
                            {
                                var clone    = NewHavokAnimation.Clone(CurrentAnimation);
                                clone.Weight = -1;
                                _additiveBlendOverlays.Add(clone);
                            }
                        }
                    }
                    CurrentAnimationName = null;
                    prog?.Report(1.0);
                });
            }
        }