diff --git a/Assets/Cryville/Crtr/ChartPlayer.cs b/Assets/Cryville/Crtr/ChartPlayer.cs index a322f25..00b7020 100644 --- a/Assets/Cryville/Crtr/ChartPlayer.cs +++ b/Assets/Cryville/Crtr/ChartPlayer.cs @@ -253,8 +253,8 @@ namespace Cryville.Crtr { if (ContainerState.RMVPool != null) { statusbuf.AppendFormat( "\nPools: RMV {0}, MC {1}", - ContainerState.RMVPool.RentedCount, - ContainerState.MCPool.RentedCount + RMVPool.Shared.RentedCount, + MotionCachePool.Shared.RentedCount ); } if (loadThread != null) { @@ -671,8 +671,8 @@ namespace Cryville.Crtr { pruleset = ruleset.Root; pruleset.Optimize(etor); } - ContainerState.RMVPool = new RMVPool(); - ContainerState.MCPool = new MotionCachePool(); + RMVPool.Shared = new RMVPool(); + MotionCachePool.Shared = new MotionCachePool(); } void LoadSkin(FileInfo file) { diff --git a/Assets/Cryville/Crtr/Event/ContainerState.cs b/Assets/Cryville/Crtr/Event/ContainerState.cs index 3bd7219..11087d4 100644 --- a/Assets/Cryville/Crtr/Event/ContainerState.cs +++ b/Assets/Cryville/Crtr/Event/ContainerState.cs @@ -95,8 +95,8 @@ namespace Cryville.Crtr.Event { Parent = parent; } - _rmvpa = new CategorizedPoolAccessor(RMVPool); - _mcpa = new CategorizedPoolAccessor(MCPool); + _rmvpa = new CategorizedPoolAccessor(RMVPool.Shared); + _mcpa = new CategorizedPoolAccessor(MotionCachePool.Shared); Values = new IntKeyedDictionary(ChartPlayer.motionRegistry.Count); CachedValues = new IntKeyedDictionary(ChartPlayer.motionRegistry.Count); @@ -151,7 +151,7 @@ namespace Cryville.Crtr.Event { return r; } - public void CopyTo(byte ct, ContainerState dest) { + public void CopyTo(ContainerState dest) { dest.m_lActive = m_lActive; dest.m_pActive = m_pActive; dest.m_active = m_active; @@ -174,12 +174,12 @@ namespace Cryville.Crtr.Event { foreach (var cev in dest.ActiveChildren) { if (!ActiveChildren.Contains(cev)) - Children[cev].CopyTo(ct, dest.Children[cev]); + Children[cev].CopyTo(dest.Children[cev]); } dest.ActiveChildren.Clear(); foreach (var cev in ActiveChildren) { dest.ActiveChildren.Add(cev); - Children[cev].CopyTo(ct, dest.Children[cev]); + Children[cev].CopyTo(dest.Children[cev]); } dest.PlayingMotions.Clear(); @@ -221,8 +221,6 @@ namespace Cryville.Crtr.Event { #endregion #region Motion - internal static RMVPool RMVPool; - internal static MotionCachePool MCPool; readonly CategorizedPoolAccessor _rmvpa; readonly CategorizedPoolAccessor _mcpa; Dictionary PlayingMotions = new Dictionary(4); diff --git a/Assets/Cryville/Crtr/Event/EventBus.cs b/Assets/Cryville/Crtr/Event/EventBus.cs index e282afb..2cb48b3 100644 --- a/Assets/Cryville/Crtr/Event/EventBus.cs +++ b/Assets/Cryville/Crtr/Event/EventBus.cs @@ -38,11 +38,11 @@ namespace Cryville.Crtr.Event { return r; } - public void CopyTo(byte ct, EventBus dest) { + public void CopyTo(EventBus dest) { base.CopyTo(dest); dest.activeStates.Clear(); dest.invalidatedStates.Clear(); - RootState.CopyTo(ct, dest.RootState); + RootState.CopyTo(dest.RootState); dest.ValidateStates(); } @@ -150,10 +150,10 @@ namespace Cryville.Crtr.Event { [MethodImpl(MethodImplOptions.AggressiveInlining)] void HandleTempEvents(double time, int maxPriority = int.MaxValue) { while (tempEvents.Count > 0) { - var ev2 = tempEvents[0]; - if (ev2.Time != time || ev2.Priority >= maxPriority) break; - if (ev2.Container != null) { - states[ev2.Container].Handle(ev2); + var ev = tempEvents[0]; + if (ev.Time != time || ev.Priority >= maxPriority) break; + if (ev.Container != null) { + states[ev.Container].Handle(ev); } tempEvents.RemoveAt(0); } @@ -178,6 +178,10 @@ namespace Cryville.Crtr.Event { } public void EndGraphicalUpdate() { RootState.EndGraphicalUpdate(); + ClearTempEvents(); + } + + void ClearTempEvents() { foreach (var ev in tempEvents) { if (ev.Container != null) { states[ev.Container].Discard(ev); diff --git a/Assets/Cryville/Crtr/Event/MotionCache.cs b/Assets/Cryville/Crtr/Event/MotionCache.cs index c8940bf..d672504 100644 --- a/Assets/Cryville/Crtr/Event/MotionCache.cs +++ b/Assets/Cryville/Crtr/Event/MotionCache.cs @@ -14,6 +14,7 @@ namespace Cryville.Crtr.Event { } } internal class MotionCachePool : CategorizedPool { + public static MotionCachePool Shared; private class Bucket : ObjectPool { readonly MotionRegistry _reg; public Bucket(Identifier name, int capacity) : base(capacity) { diff --git a/Assets/Cryville/Crtr/Event/RMVPool.cs b/Assets/Cryville/Crtr/Event/RMVPool.cs index 62075ed..de57e21 100644 --- a/Assets/Cryville/Crtr/Event/RMVPool.cs +++ b/Assets/Cryville/Crtr/Event/RMVPool.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; namespace Cryville.Crtr.Event { internal class RMVPool : CategorizedPool { + public static RMVPool Shared; private class Bucket : ObjectPool { readonly MotionRegistry _reg; public Bucket(Identifier name, int capacity) : base(capacity) { diff --git a/Assets/Cryville/Crtr/Motion.cs b/Assets/Cryville/Crtr/Motion.cs index eeebd50..2a2561a 100644 --- a/Assets/Cryville/Crtr/Motion.cs +++ b/Assets/Cryville/Crtr/Motion.cs @@ -304,12 +304,7 @@ namespace Cryville.Crtr { } public abstract void CopyTo(Vector dest); - static readonly Type[] stringTypeArray = new Type[] { typeof(string) }; static readonly Type[] floatArrayTypeArray = new Type[] { typeof(float[]) }; - public static Vector Construct(Type type, string s) { - if (!typeof(Vector).IsAssignableFrom(type)) throw new ArgumentException("Type is not vector"); - return (Vector)type.GetConstructor(stringTypeArray).Invoke(new object[] { s }); - } public static Vector Construct(Type type, float[] values) { if (!typeof(Vector).IsAssignableFrom(type)) throw new ArgumentException("Type is not vector"); return (Vector)type.GetConstructor(floatArrayTypeArray).Invoke(new object[] { values }); diff --git a/Assets/Cryville/Crtr/PdtEvaluator.cs b/Assets/Cryville/Crtr/PdtEvaluator.cs index 73a152c..7ca773f 100644 --- a/Assets/Cryville/Crtr/PdtEvaluator.cs +++ b/Assets/Cryville/Crtr/PdtEvaluator.cs @@ -37,7 +37,7 @@ namespace Cryville.Crtr { prop.Get(out type, out value); } else if (ContextState != null && ChartPlayer.motionRegistry.ContainsKey(new Identifier(name))) { - _vec = ContextState.GetRawValue(name); + _vec = ContextState.GetComputedValue(name); _vecsrc.Invalidate(); _vecsrc.Get(out type, out value); } diff --git a/Assets/Cryville/Crtr/StampedEvent.cs b/Assets/Cryville/Crtr/StampedEvent.cs index f6465f0..f970a1f 100644 --- a/Assets/Cryville/Crtr/StampedEvent.cs +++ b/Assets/Cryville/Crtr/StampedEvent.cs @@ -12,8 +12,7 @@ namespace Cryville.Crtr { public double Duration { get { - if (Unstamped == null) return 0; - if (Unstamped.IsLong) + if (ReleaseEvent != null) return ReleaseEvent.Time - Time; else return 0; } diff --git a/Assets/Cryville/Crtr/TrackHandler.cs b/Assets/Cryville/Crtr/TrackHandler.cs index 56fa922..8f35bc2 100644 --- a/Assets/Cryville/Crtr/TrackHandler.cs +++ b/Assets/Cryville/Crtr/TrackHandler.cs @@ -29,7 +29,10 @@ namespace Cryville.Crtr { } protected override void StartPreGraphicalUpdate(ContainerState s) { base.StartPreGraphicalUpdate(s); + spos = Vector3.zero; TransformAwake(s); + bpos = Position; + brot = Rotation; } protected override void StartGraphicalUpdate(ContainerState s) { base.StartGraphicalUpdate(s); @@ -46,11 +49,6 @@ namespace Cryville.Crtr { pwp = Vector3.zero; cpt = s.ScreenPoint; ptime = s.Time; - if (s.CloneType == 3) { - spos = Vector3.zero; - bpos = cpt; - brot = Quaternion.Euler(s.Direction); - } Position = pwp + cpt + spos; Rotation = Quaternion.Euler(s.Direction); } @@ -112,7 +110,7 @@ namespace Cryville.Crtr { protected override void EndGraphicalUpdate(ContainerState s) { base.EndGraphicalUpdate(s); EndUpdatePosition(s); - var p = pwp + cpt + spos; + var p = Position; foreach (var i in sgos) { i.AppendPoint(p, s.QuatDir); i.Seal();