Optimize GC for frame calculation.

This commit is contained in:
2023-02-09 18:07:06 +08:00
parent 16b1d323dc
commit 041c1e374e
4 changed files with 21 additions and 24 deletions

View File

@@ -50,6 +50,7 @@ namespace Cryville.Crtr {
public override void PreInit() {
base.PreInit();
coeffs = new ColumnVector<float>(gh.TrackCount);
foreach (var j in Event.judges) {
judges.Add(j, new JudgeState(this, j.Id.Key));
}
@@ -132,6 +133,7 @@ namespace Cryville.Crtr {
}
readonly List<Vector3> ctrl = new List<Vector3>(2);
ColumnVector<float> coeffs;
Vector3 GetFrame(ContainerState state, float track, Func<ContainerState, Vector3> func) {
// TODO
int id = Mathf.FloorToInt(track);
@@ -160,12 +162,8 @@ namespace Cryville.Crtr {
}
if (ctrl.Count == 0) {
var frame = gh.GetCurrentFrame(func);
return frame.Dot(
ColumnVector<float>.WithPolynomialCoefficients(
frame.Size, track
),
Vector3Operator.Instance
);
ColumnVector<float>.FillWithPolynomialCoefficients(coeffs, track);
return frame.Dot(coeffs, Vector3Operator.Instance);
}
else if (ctrl.Count == 1) {
return nt * (nt * p1 + t * (ctrl[0] + p1)) + t * t * p2;