Fix position anchoring.

This commit is contained in:
2023-04-20 00:21:39 +08:00
parent 93d9fdd4b8
commit d6208f19fb

View File

@@ -19,7 +19,6 @@ namespace Cryville.Crtr {
sgos = RootTransform.GetComponentsInChildren<SectionalGameObject>();
}
SectionalGameObject[] sgos;
Vector3 bpos; Quaternion brot;
Vector3 spos;
public override void StartPhysicalUpdate(ContainerState s) {
base.StartPhysicalUpdate(s);
@@ -31,8 +30,6 @@ namespace Cryville.Crtr {
base.StartPreGraphicalUpdate(s);
spos = Vector3.zero;
TransformAwake(s);
bpos = Position;
brot = Rotation;
}
protected override void StartGraphicalUpdate(ContainerState s) {
base.StartGraphicalUpdate(s);
@@ -46,14 +43,13 @@ namespace Cryville.Crtr {
}
}
void TransformAwake(ContainerState s) {
ppt = s.ScreenPoint;
pwp = Vector3.zero;
cpt = s.ScreenPoint;
ptime = s.Time;
Position = pwp + cpt + spos;
Position = spos;
Rotation = s.QuatDir;
}
Vector3 cpt; // Current point
Vector3 ppt = Vector3.zero; // Previous point
Vector3 pwp = Vector3.zero; // Previous world point
double ptime; // Previous time
@@ -81,7 +77,7 @@ namespace Cryville.Crtr {
ppt += dpt;
ptime = s.Time;
Position = pwp + cpt + spos;
Position = pwp + spos;
Rotation = s.QuatDir;
if (!RootTransform || s.CloneType == 3) return;
@@ -92,19 +88,18 @@ namespace Cryville.Crtr {
}
void UpdatePosition(ContainerState s) {
cpt = s.ScreenPoint;
ppt = cpt;
ppt = s.ScreenPoint;
pwp = Vector3.zero;
ptime = s.Time;
length = 0;
Position = pwp + cpt + spos;
Position = pwp + spos;
Rotation = s.QuatDir;
}
// TODO Fix anchor rotation
public override void Anchor() {
base.Anchor();
spos = bpos - Position;
spos = (Vector3)cs.ScreenPoint - Position;
}
protected override void EndGraphicalUpdate(ContainerState s) {
@@ -133,7 +128,7 @@ namespace Cryville.Crtr {
var wp = pwp + dwp; // World point
pwp = wp;
ppt += dpt;
Position = pwp + cpt + spos;
Position = pwp + spos;
Rotation = s.QuatDir;
}
}