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