Пример #1
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);
                });
            }
        }