Implement new transition.

This commit is contained in:
2023-04-20 00:18:49 +08:00
parent d2b71e41c9
commit 8670482c04
8 changed files with 175 additions and 28 deletions

View File

@@ -1,6 +1,7 @@
using Cryville.Common;
using Cryville.Common.Buffers;
using Cryville.Common.Collections.Specialized;
using Cryville.Common.Pdt;
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
@@ -424,7 +425,8 @@ namespace Cryville.Crtr.Event {
}
else {
var scaledTime = (float)((Time - tev.Time) / tev.Duration);
tev.Node.Value.LerpWith(m.Value.RelativeValue, scaledTime, ref value.RelativeValue);
var transition = GetTransition(scaledTime, tev.Node.Transition);
tev.Node.Value.LerpWith(m.Value.RelativeValue, transition, ref value.RelativeValue);
}
}
else {
@@ -442,6 +444,7 @@ namespace Cryville.Crtr.Event {
}
else {
var scaledTime = (float)((Time - m.Key.Time - ChartPlayer.actualRenderStep * tev.sumfix) / m.Key.Duration);
var transition = GetTransition(scaledTime, tev.transition);
if (tev.Node.Id >= 0) {
var start = m.Value.GetRelativeNode(tev.Node.Id);
if (start == null) {
@@ -450,16 +453,30 @@ namespace Cryville.Crtr.Event {
else {
var target = value.GetRelativeNode(tev.Node.Id);
if (target == null) value.SetRelativeNode(tev.Node);
else tev.Node.LerpWith(m.Value.GetRelativeNode(tev.Node.Id), scaledTime, ref target);
else tev.Node.LerpWith(m.Value.GetRelativeNode(tev.Node.Id), transition, ref target);
}
}
else {
tev.Node.Value.LerpWith(m.Value.AbsoluteValue, scaledTime, ref value.AbsoluteValue);
tev.Node.Value.LerpWith(m.Value.AbsoluteValue, transition, ref value.AbsoluteValue);
}
}
}
}
}
static float _ttime;
static Vector4 _trans;
static readonly PropSrc _ttimesrc = new PropSrc.Float(() => _ttime);
static readonly PropOp _transop = new PropOp.Vector4(v => _trans = v);
Vector4 GetTransition(float time, PdtExpression transition) {
if (time >= 1 || transition == null)
return new Vector4(time, time, time, time);
_ttime = time;
_ttimesrc.Invalidate();
ChartPlayer.etor.ContextSelfValue = _ttimesrc;
ChartPlayer.etor.Evaluate(_transop, transition);
ChartPlayer.etor.ContextSelfValue = null;
return _trans;
}
public void BroadcastPreInit() {
Handler.PreInit();