Fix position and rotation of track anchors not set.

This commit is contained in:
2023-04-14 14:39:48 +08:00
parent f7bfe07660
commit 07babcb0ff
2 changed files with 13 additions and 11 deletions

View File

@@ -133,7 +133,7 @@ namespace Cryville.Crtr {
}
Vector3 GetFramePoint(ContainerState state, float track) {
return GetFrame(state, track, th => ((TrackHandler)th.Handler).GetCurrentWorldPoint());
return GetFrame(state, track, th => th.Handler.Position);
}
Quaternion GetFrameRotation(ContainerState state, float track) {

View File

@@ -35,7 +35,7 @@ namespace Cryville.Crtr {
base.StartGraphicalUpdate(s);
if (RootTransform) {
TransformAwake(s);
var p = GetCurrentWorldPoint();
var p = Position;
foreach (var i in sgos) {
i.Reset();
i.AppendPoint(p, s.QuatDir);
@@ -51,6 +51,8 @@ namespace Cryville.Crtr {
bpos = cpt;
brot = Quaternion.Euler(s.Direction);
}
Position = pwp + cpt + spos;
Rotation = Quaternion.Euler(s.Direction);
}
Vector3 cpt; // Current point
@@ -81,11 +83,12 @@ namespace Cryville.Crtr {
ppt += dpt;
ptime = s.Time;
Position = pwp + cpt + spos;
Rotation = Quaternion.Euler(s.Direction);
if (!RootTransform || s.CloneType == 3) return;
var p = GetCurrentWorldPoint();
foreach (var i in sgos)
i.AppendPoint(p, s.QuatDir);
i.AppendPoint(Position, s.QuatDir);
}
else UpdatePosition(s);
}
@@ -96,19 +99,20 @@ namespace Cryville.Crtr {
pwp = Vector3.zero;
ptime = s.Time;
length = 0;
// Logger.LogFormat("main", 0, "Debug", "SV: {0}", cs.GetRawValue<Vec1m>("svm").Value);
Position = pwp + cpt + spos;
Rotation = Quaternion.Euler(s.Direction);
}
// TODO Fix anchor rotation
public override void Anchor() {
base.Anchor();
spos = bpos - GetCurrentWorldPoint();
spos = bpos - Position;
}
protected override void EndGraphicalUpdate(ContainerState s) {
base.EndGraphicalUpdate(s);
EndUpdatePosition(s);
var p = GetCurrentWorldPoint();
var p = pwp + cpt + spos;
foreach (var i in sgos) {
i.AppendPoint(p, s.QuatDir);
i.Seal();
@@ -131,10 +135,8 @@ namespace Cryville.Crtr {
var wp = pwp + dwp; // World point
pwp = wp;
ppt += dpt;
}
public Vector3 GetCurrentWorldPoint() {
return pwp + cpt + spos;
Position = pwp + cpt + spos;
Rotation = Quaternion.Euler(s.Direction);
}
}
}