Compare commits
3 Commits
0.5.1
...
723ec937ad
Author | SHA1 | Date | |
---|---|---|---|
723ec937ad | |||
7c77ba83f8 | |||
6da4b96b24 |
@@ -152,6 +152,7 @@ namespace Cryville.Crtr.Components {
|
|||||||
List<Vector3> verts;
|
List<Vector3> verts;
|
||||||
List<Vector2> uvs;
|
List<Vector2> uvs;
|
||||||
List<int> trih = null, trib = null, trit = null;
|
List<int> trih = null, trib = null, trit = null;
|
||||||
|
static List<int> _emptyTris = new List<int>();
|
||||||
|
|
||||||
public override void Seal() {
|
public override void Seal() {
|
||||||
if (vertCount <= 1 || sumLength == 0) return;
|
if (vertCount <= 1 || sumLength == 0) return;
|
||||||
@@ -192,13 +193,13 @@ namespace Cryville.Crtr.Components {
|
|||||||
if (body.Frame != null) { m++; GenerateMeshTo(verts, uvs, out trib, body, ref i, ref t, ref l, headLength, sumLength - tailLength, vcpsec, hvc + bvc); }
|
if (body.Frame != null) { m++; GenerateMeshTo(verts, uvs, out trib, body, ref i, ref t, ref l, headLength, sumLength - tailLength, vcpsec, hvc + bvc); }
|
||||||
if (tail.Frame != null) { m++; GenerateMeshTo(verts, uvs, out trit, tail, ref i, ref t, ref l, sumLength - tailLength, sumLength, vcpsec, vc); }
|
if (tail.Frame != null) { m++; GenerateMeshTo(verts, uvs, out trit, tail, ref i, ref t, ref l, sumLength - tailLength, sumLength, vcpsec, vc); }
|
||||||
|
|
||||||
mesh.Mesh.subMeshCount = m;
|
mesh.Mesh.subMeshCount = 3;
|
||||||
m = 0;
|
m = 0;
|
||||||
mesh.Mesh.SetVertices(verts);
|
mesh.Mesh.SetVertices(verts);
|
||||||
mesh.Mesh.SetUVs(0, uvs);
|
mesh.Mesh.SetUVs(0, uvs);
|
||||||
if (head.Frame != null) mesh.Mesh.SetTriangles(trih, m++);
|
mesh.Mesh.SetTriangles(head.Frame == null ? _emptyTris : trih, m++);
|
||||||
if (body.Frame != null) mesh.Mesh.SetTriangles(trib, m++);
|
mesh.Mesh.SetTriangles(body.Frame == null ? _emptyTris : trib, m++);
|
||||||
if (tail.Frame != null) mesh.Mesh.SetTriangles(trit, m++);
|
mesh.Mesh.SetTriangles(tail.Frame == null ? _emptyTris : trit, m++);
|
||||||
mesh.Mesh.RecalculateNormals();
|
mesh.Mesh.RecalculateNormals();
|
||||||
|
|
||||||
_vertPool.Return(verts); verts = null;
|
_vertPool.Return(verts); verts = null;
|
||||||
|
@@ -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;
|
||||||
@@ -317,7 +312,7 @@ namespace Cryville.Crtr.Event {
|
|||||||
Working = false;
|
Working = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Handle(StampedEvent ev, Action<StampedEvent> callback = null) {
|
public void Handle(StampedEvent ev) {
|
||||||
if (breakflag) return;
|
if (breakflag) return;
|
||||||
if (ev != null) {
|
if (ev != null) {
|
||||||
if (ev.Unstamped is Chart.Motion) {
|
if (ev.Unstamped is Chart.Motion) {
|
||||||
@@ -326,7 +321,7 @@ namespace Cryville.Crtr.Event {
|
|||||||
mv.CloneTypeFlag = CloneType;
|
mv.CloneTypeFlag = CloneType;
|
||||||
GetMotionValue(tev.Name).CopyTo(mv);
|
GetMotionValue(tev.Name).CopyTo(mv);
|
||||||
PlayingMotions.Add(ev, mv);
|
PlayingMotions.Add(ev, mv);
|
||||||
Callback(ev, callback);
|
Update(ev);
|
||||||
if (!ev.Unstamped.IsLong) {
|
if (!ev.Unstamped.IsLong) {
|
||||||
PlayingMotions.Remove(ev);
|
PlayingMotions.Remove(ev);
|
||||||
RMVPool.Return(mv);
|
RMVPool.Return(mv);
|
||||||
@@ -349,7 +344,7 @@ namespace Cryville.Crtr.Event {
|
|||||||
if (tev.IsRelease) {
|
if (tev.IsRelease) {
|
||||||
var nev = tev.Original;
|
var nev = tev.Original;
|
||||||
if (nev is Chart.Motion) {
|
if (nev is Chart.Motion) {
|
||||||
Callback(ev, callback);
|
Update(ev);
|
||||||
var mv = PlayingMotions[ev.Origin];
|
var mv = PlayingMotions[ev.Origin];
|
||||||
if (mv.CloneTypeFlag == CloneType) RMVPool.Return(mv);
|
if (mv.CloneTypeFlag == CloneType) RMVPool.Return(mv);
|
||||||
PlayingMotions.Remove(ev.Origin);
|
PlayingMotions.Remove(ev.Origin);
|
||||||
@@ -364,15 +359,13 @@ namespace Cryville.Crtr.Event {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Callback(ev.Unstamped == null || ev.Unstamped.Priority >= 0 ? ev : null, callback);
|
Update(ev.Unstamped == null || ev.Unstamped.Priority >= 0 ? ev : null);
|
||||||
}
|
}
|
||||||
else Callback(null, callback);
|
else Update(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Callback(StampedEvent ev, Action<StampedEvent> callback) {
|
void Update(StampedEvent ev) {
|
||||||
UpdateMotions();
|
UpdateMotions();
|
||||||
if (callback != null)
|
|
||||||
callback(ev);
|
|
||||||
if (ev == null || ev.Unstamped != null) Handler.Update(this, ev);
|
if (ev == null || ev.Unstamped != null) Handler.Update(this, ev);
|
||||||
else Handler.ExUpdate(this, ev);
|
else Handler.ExUpdate(this, ev);
|
||||||
foreach (var m in PlayingMotions)
|
foreach (var m in PlayingMotions)
|
||||||
|
@@ -56,7 +56,7 @@ namespace Cryville.Crtr.Event {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ForwardOnceToTime(double toTime, Action<ChartEvent> callback) {
|
public override void ForwardOnceToTime(double toTime) {
|
||||||
double toBeat = Math.Round(beat + (toTime - Time) * tempo / 60f, 6);
|
double toBeat = Math.Round(beat + (toTime - Time) * tempo / 60f, 6);
|
||||||
if (EventId >= events.Count)
|
if (EventId >= events.Count)
|
||||||
goto return_ahead;
|
goto return_ahead;
|
||||||
@@ -84,7 +84,6 @@ namespace Cryville.Crtr.Event {
|
|||||||
}
|
}
|
||||||
stampedEvents.Add(sev);
|
stampedEvents.Add(sev);
|
||||||
if (ev.Priority >= 0) {
|
if (ev.Priority >= 0) {
|
||||||
if (callback != null) callback(ev);
|
|
||||||
flag = true;
|
flag = true;
|
||||||
}
|
}
|
||||||
if (ev is Chart.Signature) {
|
if (ev is Chart.Signature) {
|
||||||
@@ -93,12 +92,10 @@ namespace Cryville.Crtr.Event {
|
|||||||
}
|
}
|
||||||
EventId++;
|
EventId++;
|
||||||
}
|
}
|
||||||
if (callback != null && !flag) callback(batch.First());
|
|
||||||
return;
|
return;
|
||||||
return_ahead:
|
return_ahead:
|
||||||
Time = toTime;
|
Time = toTime;
|
||||||
beat = toBeat;
|
beat = toBeat;
|
||||||
if (callback != null) callback(null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IOrderedEnumerable<ChartEvent> GetEventBatch() {
|
IOrderedEnumerable<ChartEvent> GetEventBatch() {
|
||||||
|
@@ -107,7 +107,7 @@ namespace Cryville.Crtr.Event {
|
|||||||
tempEvents.Insert(index, ev);
|
tempEvents.Insert(index, ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ForwardOnceToTime(double toTime, Action<EventBatch> callback = null) {
|
public override void ForwardOnceToTime(double toTime) {
|
||||||
double time1 = EventId < events.Count ? events[EventId].Time : double.PositiveInfinity;
|
double time1 = EventId < events.Count ? events[EventId].Time : double.PositiveInfinity;
|
||||||
double time2 = tempEvents.Count > 0 ? tempEvents[0].Time : double.PositiveInfinity;
|
double time2 = tempEvents.Count > 0 ? tempEvents[0].Time : double.PositiveInfinity;
|
||||||
double time0 = Math.Min(time1, time2);
|
double time0 = Math.Min(time1, time2);
|
||||||
|
@@ -31,41 +31,41 @@ namespace Cryville.Crtr {
|
|||||||
breakflag = true;
|
breakflag = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Forward(Action<T> callback = null) {
|
public void Forward() {
|
||||||
ForwardToTime(double.PositiveInfinity, callback);
|
ForwardToTime(double.PositiveInfinity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ForwardByTime(double time, Action<T> callback = null) {
|
public void ForwardByTime(double time) {
|
||||||
ForwardToTime(Time + time, callback);
|
ForwardToTime(Time + time);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ForwardOnceByTime(double time, Action<T> callback = null) {
|
public void ForwardOnceByTime(double time) {
|
||||||
ForwardOnceToTime(Time + time, callback);
|
ForwardOnceToTime(Time + time);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ForwardToTime(double toTime, Action<T> callback = null) {
|
public void ForwardToTime(double toTime) {
|
||||||
breakflag = false;
|
breakflag = false;
|
||||||
ForwardOnceToTime(Time, callback);
|
ForwardOnceToTime(Time);
|
||||||
while (Time < toTime) {
|
while (Time < toTime) {
|
||||||
ForwardOnceToTime(toTime, callback);
|
ForwardOnceToTime(toTime);
|
||||||
if (breakflag) break;
|
if (breakflag) break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ForwardStepByTime(double time, double step, Action<T> callback = null) {
|
public void ForwardStepByTime(double time, double step) {
|
||||||
ForwardStepToTime(Time + time, step, callback);
|
ForwardStepToTime(Time + time, step);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ForwardStepToTime(double toTime, double step, Action<T> callback = null) {
|
public void ForwardStepToTime(double toTime, double step) {
|
||||||
breakflag = false;
|
breakflag = false;
|
||||||
ForwardOnceToTime(Time, callback);
|
ForwardOnceToTime(Time);
|
||||||
while (Time < toTime) {
|
while (Time < toTime) {
|
||||||
double next = Time + step;
|
double next = Time + step;
|
||||||
ForwardOnceToTime(next < toTime ? next : toTime, callback);
|
ForwardOnceToTime(next < toTime ? next : toTime);
|
||||||
if (breakflag) break;
|
if (breakflag) break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void ForwardOnceToTime(double toTime, Action<T> callback = null);
|
public abstract void ForwardOnceToTime(double toTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user