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