TASable now saves linear and angular velocities
This commit is contained in:
parent
0bac49d257
commit
d3324ad81f
|
@ -12,18 +12,24 @@ public partial class TASable : Node
|
||||||
get { return this._assignedRigidBody3D; }
|
get { return this._assignedRigidBody3D; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Frame data
|
||||||
public Dictionary<int, Vector3> framePositions = new Dictionary<int, Vector3>();
|
public Dictionary<int, Vector3> framePositions = new Dictionary<int, Vector3>();
|
||||||
|
public Dictionary<int, Vector3> frameLinearVelocities = new Dictionary<int, Vector3>();
|
||||||
|
public Dictionary<int, Vector3> frameAngularVelocities = new Dictionary<int, Vector3>();
|
||||||
|
|
||||||
|
|
||||||
public virtual void SaveState(int frame)
|
public virtual void SaveState(int frame)
|
||||||
{
|
{
|
||||||
this.framePositions[frame] = this.AssignedRigidBody3D.Position;
|
this.framePositions[frame] = this.AssignedRigidBody3D.Position;
|
||||||
|
this.frameLinearVelocities[frame] = this.AssignedRigidBody3D.LinearVelocity;
|
||||||
|
this.frameAngularVelocities[frame] = this.AssignedRigidBody3D.AngularVelocity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void LoadState(int frame)
|
public virtual void LoadState(int frame)
|
||||||
{
|
{
|
||||||
this.AssignedRigidBody3D.Position = this.framePositions[frame];
|
this.AssignedRigidBody3D.Position = this.framePositions[frame];
|
||||||
|
this.AssignedRigidBody3D.LinearVelocity = this.frameLinearVelocities[frame];
|
||||||
|
this.AssignedRigidBody3D.AngularVelocity = this.frameAngularVelocities[frame];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -36,6 +42,7 @@ public partial class TASable : Node
|
||||||
TAS.FramesRegressed += this.OnFramesRegressed;
|
TAS.FramesRegressed += this.OnFramesRegressed;
|
||||||
TAS.StartedIncrementing += this.OnStartedIncrementing;
|
TAS.StartedIncrementing += this.OnStartedIncrementing;
|
||||||
TAS.StoppedIncrementing += this.OnStoppedIncrementing;
|
TAS.StoppedIncrementing += this.OnStoppedIncrementing;
|
||||||
|
TAS.FramesReset += this.OnFramesReset;
|
||||||
|
|
||||||
this.SaveState(0);
|
this.SaveState(0);
|
||||||
}
|
}
|
||||||
|
@ -67,4 +74,9 @@ public partial class TASable : Node
|
||||||
{
|
{
|
||||||
this.AssignedRigidBody3D.Freeze = true;
|
this.AssignedRigidBody3D.Freeze = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual void OnFramesReset()
|
||||||
|
{
|
||||||
|
this.SaveState(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue