Optimize motion invalidation performance.
This commit is contained in:
@@ -81,14 +81,7 @@ namespace Cryville.Crtr.Event {
|
|||||||
/// <param name="clone">Returns a cloned motion value instead.</param>
|
/// <param name="clone">Returns a cloned motion value instead.</param>
|
||||||
/// <returns>A motion value.</returns>
|
/// <returns>A motion value.</returns>
|
||||||
RealtimeMotionValue GetMotionValue(Identifier name, bool clone = false) {
|
RealtimeMotionValue GetMotionValue(Identifier name, bool clone = false) {
|
||||||
RealtimeMotionValue value;
|
RealtimeMotionValue value = Values[name];
|
||||||
if (!Values.TryGetValue(name, out value)) {
|
|
||||||
value = new RealtimeMotionValue().Init(Parent == null
|
|
||||||
? ChartPlayer.motionRegistry[name].GlobalInitValue
|
|
||||||
: ChartPlayer.motionRegistry[name].InitValue
|
|
||||||
);
|
|
||||||
Values.Add(name, value);
|
|
||||||
}
|
|
||||||
if (clone) return value.Clone();
|
if (clone) return value.Clone();
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
@@ -98,8 +91,9 @@ namespace Cryville.Crtr.Event {
|
|||||||
if (!CachedValues.TryGetValue(name, out cache))
|
if (!CachedValues.TryGetValue(name, out cache))
|
||||||
CachedValues.Add(name, cache = new CacheEntry());
|
CachedValues.Add(name, cache = new CacheEntry());
|
||||||
cache.Valid = false;
|
cache.Valid = false;
|
||||||
foreach (var c in Children)
|
ValidateChildren();
|
||||||
c.Value.InvalidateMotion(name);
|
foreach (var c in WorkingChildren)
|
||||||
|
Children[c].InvalidateMotion(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ContainerState(Chart c, EventContainer _ev, ContainerState parent = null) {
|
public ContainerState(Chart c, EventContainer _ev, ContainerState parent = null) {
|
||||||
@@ -171,6 +165,7 @@ namespace Cryville.Crtr.Event {
|
|||||||
else dest.Values.Add(mv.Key, mv.Value.Clone());
|
else dest.Values.Add(mv.Key, mv.Value.Clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach (var cv in dest.CachedValues) cv.Value.Valid = false;
|
||||||
foreach (var cv in CachedValues) {
|
foreach (var cv in CachedValues) {
|
||||||
CacheEntry dv;
|
CacheEntry dv;
|
||||||
if (dest.CachedValues.TryGetValue(cv.Key, out dv)) {
|
if (dest.CachedValues.TryGetValue(cv.Key, out dv)) {
|
||||||
@@ -184,7 +179,7 @@ namespace Cryville.Crtr.Event {
|
|||||||
Children[cev].CopyTo(ct, dest.Children[cev]);
|
Children[cev].CopyTo(ct, dest.Children[cev]);
|
||||||
else foreach (var child in Children)
|
else foreach (var child in Children)
|
||||||
child.Value.CopyTo(ct, dest.Children[child.Key]);
|
child.Value.CopyTo(ct, dest.Children[child.Key]);
|
||||||
ValidateChildren();
|
dest.ValidateChildren();
|
||||||
|
|
||||||
dest.PlayingMotions.Clear();
|
dest.PlayingMotions.Clear();
|
||||||
foreach (var m in PlayingMotions) dest.PlayingMotions.Add(m.Key, m.Value);
|
foreach (var m in PlayingMotions) dest.PlayingMotions.Add(m.Key, m.Value);
|
||||||
@@ -217,7 +212,7 @@ namespace Cryville.Crtr.Event {
|
|||||||
public Vector GetRawValue(Identifier key) {
|
public Vector GetRawValue(Identifier key) {
|
||||||
CacheEntry tr;
|
CacheEntry tr;
|
||||||
if (!CachedValues.TryGetValue(key, out tr))
|
if (!CachedValues.TryGetValue(key, out tr))
|
||||||
CachedValues.Add(key, tr = new CacheEntry { Valid = false });
|
CachedValues.Add(key, tr = new CacheEntry { });
|
||||||
if (tr.Value == null)
|
if (tr.Value == null)
|
||||||
tr.Value = RMVPool.Rent(key).AbsoluteValue;
|
tr.Value = RMVPool.Rent(key).AbsoluteValue;
|
||||||
Vector r = tr.Value;
|
Vector r = tr.Value;
|
||||||
|
|||||||
Reference in New Issue
Block a user