Change state timestamp to double precision.

This commit is contained in:
2022-12-19 14:55:15 +08:00
parent e55642cdeb
commit d7b0ca77e9
9 changed files with 40 additions and 40 deletions

View File

@@ -56,7 +56,7 @@ namespace Cryville.Crtr.Event {
private set;
}
public float Time {
public double Time {
get {
return Bus.Time;
}
@@ -225,7 +225,7 @@ namespace Cryville.Crtr.Event {
if (tr.Valid) return r;
#endif
float reltime = 0;
if (rootPrototype != null) reltime = Time - rootPrototype.Time;
if (rootPrototype != null) reltime = (float)(Time - rootPrototype.Time);
GetMotionValue(key).GetValue(reltime, ref r);
if (Parent != null) r.ApplyFrom(Parent.GetRawValue(key));
#if !DISABLE_CACHE
@@ -394,7 +394,7 @@ namespace Cryville.Crtr.Event {
}
}
else {
var scaledTime = (Time - m.Key.Time - ChartPlayer.actualRenderStep * tev.sumfix) / m.Key.Duration;
var scaledTime = (float)((Time - m.Key.Time - ChartPlayer.actualRenderStep * tev.sumfix) / m.Key.Duration);
var lerpedTime = MotionLerper.GetEaseTime(scaledTime, tev.transition, tev.rate);
if (tev.RelativeNode != null) {
var target = value.QueryRelativeNode(tev.RelativeNode.Id);

View File

@@ -4,7 +4,7 @@ using System.Collections.Generic;
namespace Cryville.Crtr.Event {
public class EventBatch : IComparable<EventBatch>, IEnumerable<StampedEvent> {
public float Time {
public double Time {
get;
private set;
}
@@ -14,7 +14,7 @@ namespace Cryville.Crtr.Event {
get { return queue.Count; }
}
public EventBatch(float time) {
public EventBatch(double time) {
Time = time;
}
@@ -32,7 +32,7 @@ namespace Cryville.Crtr.Event {
}
public int CompareTo(EventBatch other) {
return this.Time.CompareTo(other.Time);
return Time.CompareTo(other.Time);
}
public IEnumerator<StampedEvent> GetEnumerator() {

View File

@@ -17,8 +17,8 @@ namespace Cryville.Crtr.Event {
= new Dictionary<ChartEvent, ContainerState>();
public List<StampedEvent> stampedEvents = new List<StampedEvent>();
readonly List<EventBatch> batches = new List<EventBatch>();
float beat;
double beat;
float tempo;
public EventBatcher(Chart c) : base(c, new List<ChartEvent>()) {
@@ -56,12 +56,12 @@ namespace Cryville.Crtr.Event {
}
}
public override void ForwardOnceToTime(float toTime, Action<ChartEvent> callback) {
float toBeat = (float)Math.Round(beat + (toTime - Time) * tempo / 60f, 6);
public override void ForwardOnceToTime(double toTime, Action<ChartEvent> callback) {
double toBeat = Math.Round(beat + (toTime - Time) * tempo / 60f, 6);
if (EventId >= events.Count)
goto return_ahead;
float ebeat = events[EventId].BeatPosition;
float etime = (float)Math.Round((ebeat - beat) / tempo * 60f + Time, 6);
double ebeat = events[EventId].BeatPosition;
double etime = Math.Round((ebeat - beat) / tempo * 60f + Time, 6);
if (etime > toTime)
goto return_ahead;
var batch = GetEventBatch();

View File

@@ -114,7 +114,7 @@ namespace Cryville.Crtr.Event {
patch.Clear();
}
public override void ForwardOnceToTime(float toTime, Action<EventBatch> callback = null) {
public override void ForwardOnceToTime(double toTime, Action<EventBatch> callback = null) {
if (EventId < events.Count && events[EventId].Time <= toTime) {
Time = events[EventId].Time;
var batch = events[EventId];

View File

@@ -17,10 +17,10 @@ namespace Cryville.Crtr {
readonly Dictionary<Identifier, List<JudgeEvent>> activeEvs
= new Dictionary<Identifier, List<JudgeEvent>>();
struct JudgeEvent {
public float StartTime { get; set; }
public float EndTime { get; set; }
public float StartClip { get; set; }
public float EndClip { get; set; }
public double StartTime { get; set; }
public double EndTime { get; set; }
public double StartClip { get; set; }
public double EndClip { get; set; }
public JudgeDefinition Definition { get; set; }
public ContainerState State { get; set; }
}
@@ -35,7 +35,7 @@ namespace Cryville.Crtr {
_rs = rs;
InitScores();
}
public void Prepare(float st, float et, Identifier input, JudgeDefinition def, ContainerState container) {
public void Prepare(double st, double et, Identifier input, JudgeDefinition def, ContainerState container) {
List<JudgeEvent> list;
if (!evs.TryGetValue(input, out list)) {
ct.Add(input, 0);
@@ -105,8 +105,8 @@ namespace Cryville.Crtr {
var index = 0;
while (index >= 0 && index < actlist.Count) {
var ev = actlist[index];
LoadNum(_numbuf1, ev.StartTime); _etor.ContextCascadeUpdate(_var_fn, new PropSrc.Arbitrary(PdtInternalType.Number, _numbuf1));
LoadNum(_numbuf2, ev.EndTime); _etor.ContextCascadeUpdate(_var_tn, new PropSrc.Arbitrary(PdtInternalType.Number, _numbuf2));
LoadNum(_numbuf1, (float)ev.StartTime); _etor.ContextCascadeUpdate(_var_fn, new PropSrc.Arbitrary(PdtInternalType.Number, _numbuf1));
LoadNum(_numbuf2, (float)ev.EndTime); _etor.ContextCascadeUpdate(_var_tn, new PropSrc.Arbitrary(PdtInternalType.Number, _numbuf2));
var def = ev.Definition;
if (def.hit != null) _etor.Evaluate(_flagop, def.hit);
else _flag = true;
@@ -115,7 +115,7 @@ namespace Cryville.Crtr {
if (def.pass != null) Pass(def.pass);
actlist.RemoveAt(index);
if (def.prop != 0 && actlist.Count > 0) {
index = BinarySearchFirst(actlist, ev.StartClip, def.stack - def.prop);
index = BinarySearchFirst(actlist, (float)ev.StartClip, def.stack - def.prop);
if (index < 0) index = ~index;
}
else index++;
@@ -154,7 +154,7 @@ namespace Cryville.Crtr {
JudgeEvent ev;
while (list.Count > 0 && (ev = list[0]).StartClip <= tt) {
list.RemoveAt(0);
var index = BinarySearch(actlist, ev.StartClip, ev.Definition.stack);
var index = BinarySearch(actlist, (float)ev.StartClip, ev.Definition.stack);
if (index < 0) index = ~index;
actlist.Insert(index, ev);
}

View File

@@ -23,9 +23,9 @@ namespace Cryville.Crtr {
}
public static class MotionLerper {
public static void Lerp<T>(float time, float tt, T tv, float ft, T fv, TransitionType type, float rate, ref T result) where T : Vector {
public static void Lerp<T>(double time, double tt, T tv, double ft, T fv, TransitionType type, float rate, ref T result) where T : Vector {
if (fv == null) fv = (T)ReflectionHelper.InvokeEmptyConstructor(tv.GetType());
Lerp((time - ft) / (tt - ft), fv, tv, type, rate, ref result);
Lerp((float)((time - ft) / (tt - ft)), fv, tv, type, rate, ref result);
}
public static void Lerp<T>(float scaledTime, T from, T to, TransitionType type, float rate, ref T result) where T : Vector {
@@ -35,7 +35,7 @@ namespace Cryville.Crtr {
to.LerpWith(from, GetEaseTime(scaledTime, type, rate), ref r);
}
public static float Delerp<T>(T value, float tt, T tv, float ft, T fv, TransitionType type, float rate) where T : Vector {
public static double Delerp<T>(T value, double tt, T tv, double ft, T fv, TransitionType type, float rate) where T : Vector {
if (fv == null) fv = (T)ReflectionHelper.InvokeEmptyConstructor(tv.GetType());
var t = Delerp(value, fv, tv, type, rate);
return ft * (1 - t) + tt * t;

View File

@@ -4,7 +4,7 @@ using System.Linq;
namespace Cryville.Crtr {
public class StampedEvent : IComparable<StampedEvent> {
public float Time;
public double Time;
public ChartEvent Unstamped;
public EventContainer Container;
public StampedEvent Origin;
@@ -12,7 +12,7 @@ namespace Cryville.Crtr {
private StampedEvent attev = null;
private StampedEvent relev = null;
public float Duration {
public double Duration {
get {
if (Unstamped == null) return 0;
if (Unstamped.IsLong)

View File

@@ -4,7 +4,7 @@ using System.Collections.Generic;
namespace Cryville.Crtr {
public abstract class StateBase<T> {
public int EventId;
public float Time;
public double Time;
public Chart chart;
public List<T> events;
@@ -18,7 +18,7 @@ namespace Cryville.Crtr {
}
public virtual StateBase<T> Clone() {
return (StateBase<T>)base.MemberwiseClone();
return (StateBase<T>)MemberwiseClone();
}
public virtual void CopyTo(StateBase<T> dest) {
@@ -32,18 +32,18 @@ namespace Cryville.Crtr {
}
public void Forward(Action<T> callback = null) {
ForwardToTime(float.PositiveInfinity, callback);
ForwardToTime(double.PositiveInfinity, callback);
}
public void ForwardByTime(float time, Action<T> callback = null) {
public void ForwardByTime(double time, Action<T> callback = null) {
ForwardToTime(Time + time, callback);
}
public void ForwardOnceByTime(float time, Action<T> callback = null) {
public void ForwardOnceByTime(double time, Action<T> callback = null) {
ForwardOnceToTime(Time + time, callback);
}
public void ForwardToTime(float toTime, Action<T> callback = null) {
public void ForwardToTime(double toTime, Action<T> callback = null) {
breakflag = false;
ForwardOnceToTime(Time, callback);
while (Time < toTime) {
@@ -52,20 +52,20 @@ namespace Cryville.Crtr {
}
}
public void ForwardStepByTime(float time, float step, Action<T> callback = null) {
public void ForwardStepByTime(double time, double step, Action<T> callback = null) {
ForwardStepToTime(Time + time, step, callback);
}
public void ForwardStepToTime(float toTime, float step, Action<T> callback = null) {
public void ForwardStepToTime(double toTime, double step, Action<T> callback = null) {
breakflag = false;
ForwardOnceToTime(Time, callback);
while (Time < toTime) {
float next = Time + step;
double next = Time + step;
ForwardOnceToTime(next < toTime ? next : toTime, callback);
if (breakflag) break;
}
}
public abstract void ForwardOnceToTime(float toTime, Action<T> callback = null);
public abstract void ForwardOnceToTime(double toTime, Action<T> callback = null);
}
}

View File

@@ -57,7 +57,7 @@ namespace Cryville.Crtr {
Vector3 cpt; // Current point
Vector3 ppt = Vector3.zero; // Previous point
Vector3 pwp = Vector3.zero; // Previous world point
float ptime; // Previous time
double ptime; // Previous time
float length;
public override void Update(ContainerState s, StampedEvent ev) {
@@ -67,7 +67,7 @@ namespace Cryville.Crtr {
var tsv = s.ScrollVelocity;
Vector3 dpt = (Vector3)tpt - ppt; // Delta 2D point
dpt.z = (s.Time - ptime) * ChartPlayer.sv * tsv; // Delta Z
dpt.z = (float)((s.Time - ptime) * ChartPlayer.sv * tsv); // Delta Z
Quaternion rotq = Quaternion.Euler(s.Direction); // Rotation
var dwp = rotq * dpt; // Delta world point
var nl = length + dwp.magnitude; // New length
@@ -133,7 +133,7 @@ namespace Cryville.Crtr {
var tsv = s.ScrollVelocity;
Vector3 dpt = (Vector3)tpt - ppt;
dpt.z = (s.Time - ptime) * ChartPlayer.sv * tsv;
dpt.z = (float)((s.Time - ptime) * ChartPlayer.sv * tsv);
Quaternion rotq = Quaternion.Euler(s.Direction);
var dwp = rotq * dpt; // Delta world point
var nl = length + dwp.magnitude; // New length