Skip to content

Commit cca5558

Browse files
committed
- added reset for starting velocities
1 parent 0a6851a commit cca5558

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

Simulation/RigidBody.h

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ namespace PBD
2525
Vector3r m_x0;
2626
/** center of mass velocity */
2727
Vector3r m_v;
28+
Vector3r m_v0;
2829
/** acceleration (by external forces) */
2930
Vector3r m_a;
3031

@@ -57,6 +58,7 @@ namespace PBD
5758
Matrix3r m_rot;
5859
/** Angular velocity, defines rotation axis and velocity (magnitude of the vector) */
5960
Vector3r m_omega;
61+
Vector3r m_omega0;
6062
/** external torque */
6163
Vector3r m_torque;
6264

@@ -152,8 +154,8 @@ namespace PBD
152154
getOldRotation() = getRotation0();
153155
getLastRotation() = getRotation0();
154156

155-
getVelocity().setZero();
156-
getAngularVelocity().setZero();
157+
getVelocity() = getVelocity0();
158+
getAngularVelocity() = getAngularVelocity0();
157159

158160
getAcceleration().setZero();
159161
getTorque().setZero();
@@ -369,6 +371,21 @@ namespace PBD
369371
m_v = value;
370372
}
371373

374+
FORCE_INLINE Vector3r &getVelocity0()
375+
{
376+
return m_v0;
377+
}
378+
379+
FORCE_INLINE const Vector3r &getVelocity0() const
380+
{
381+
return m_v0;
382+
}
383+
384+
FORCE_INLINE void setVelocity0(const Vector3r &value)
385+
{
386+
m_v0 = value;
387+
}
388+
372389
FORCE_INLINE Vector3r &getAcceleration()
373390
{
374391
return m_a;
@@ -535,6 +552,21 @@ namespace PBD
535552
m_omega = value;
536553
}
537554

555+
FORCE_INLINE Vector3r &getAngularVelocity0()
556+
{
557+
return m_omega0;
558+
}
559+
560+
FORCE_INLINE const Vector3r &getAngularVelocity0() const
561+
{
562+
return m_omega0;
563+
}
564+
565+
FORCE_INLINE void setAngularVelocity0(const Vector3r &value)
566+
{
567+
m_omega0 = value;
568+
}
569+
538570
FORCE_INLINE Vector3r &getTorque()
539571
{
540572
return m_torque;

0 commit comments

Comments
 (0)