|
@@ -240,9 +240,14 @@ void RigidBody::SetPosition(const Vector3& position)
|
|
|
worldTrans.setOrigin(ToBtVector3(position + ToQuaternion(worldTrans.getRotation()) * centerOfMass_));
|
|
worldTrans.setOrigin(ToBtVector3(position + ToQuaternion(worldTrans.getRotation()) * centerOfMass_));
|
|
|
|
|
|
|
|
// When forcing the physics position, set also interpolated position so that there is no jitter
|
|
// When forcing the physics position, set also interpolated position so that there is no jitter
|
|
|
- btTransform interpTrans = body_->getInterpolationWorldTransform();
|
|
|
|
|
- interpTrans.setOrigin(worldTrans.getOrigin());
|
|
|
|
|
- body_->setInterpolationWorldTransform(interpTrans);
|
|
|
|
|
|
|
+ // When not inside the simulation loop, this may lead to erratic movement of parented rigidbodies
|
|
|
|
|
+ // so skip in that case
|
|
|
|
|
+ if (physicsWorld_->IsSimulating())
|
|
|
|
|
+ {
|
|
|
|
|
+ btTransform interpTrans = body_->getInterpolationWorldTransform();
|
|
|
|
|
+ interpTrans.setOrigin(worldTrans.getOrigin());
|
|
|
|
|
+ body_->setInterpolationWorldTransform(interpTrans);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
Activate();
|
|
Activate();
|
|
|
MarkNetworkUpdate();
|
|
MarkNetworkUpdate();
|
|
@@ -259,11 +264,15 @@ void RigidBody::SetRotation(const Quaternion& rotation)
|
|
|
if (!centerOfMass_.Equals(Vector3::ZERO))
|
|
if (!centerOfMass_.Equals(Vector3::ZERO))
|
|
|
worldTrans.setOrigin(ToBtVector3(oldPosition + rotation * centerOfMass_));
|
|
worldTrans.setOrigin(ToBtVector3(oldPosition + rotation * centerOfMass_));
|
|
|
|
|
|
|
|
- btTransform interpTrans = body_->getInterpolationWorldTransform();
|
|
|
|
|
- interpTrans.setRotation(worldTrans.getRotation());
|
|
|
|
|
- if (!centerOfMass_.Equals(Vector3::ZERO))
|
|
|
|
|
- interpTrans.setOrigin(worldTrans.getOrigin());
|
|
|
|
|
- body_->setInterpolationWorldTransform(interpTrans);
|
|
|
|
|
|
|
+ if (physicsWorld_->IsSimulating())
|
|
|
|
|
+ {
|
|
|
|
|
+ btTransform interpTrans = body_->getInterpolationWorldTransform();
|
|
|
|
|
+ interpTrans.setRotation(worldTrans.getRotation());
|
|
|
|
|
+ if (!centerOfMass_.Equals(Vector3::ZERO))
|
|
|
|
|
+ interpTrans.setOrigin(worldTrans.getOrigin());
|
|
|
|
|
+ body_->setInterpolationWorldTransform(interpTrans);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
body_->updateInertiaTensor();
|
|
body_->updateInertiaTensor();
|
|
|
|
|
|
|
|
Activate();
|
|
Activate();
|
|
@@ -279,10 +288,14 @@ void RigidBody::SetTransform(const Vector3& position, const Quaternion& rotation
|
|
|
worldTrans.setRotation(ToBtQuaternion(rotation));
|
|
worldTrans.setRotation(ToBtQuaternion(rotation));
|
|
|
worldTrans.setOrigin(ToBtVector3(position + rotation * centerOfMass_));
|
|
worldTrans.setOrigin(ToBtVector3(position + rotation * centerOfMass_));
|
|
|
|
|
|
|
|
- btTransform interpTrans = body_->getInterpolationWorldTransform();
|
|
|
|
|
- interpTrans.setOrigin(worldTrans.getOrigin());
|
|
|
|
|
- interpTrans.setRotation(worldTrans.getRotation());
|
|
|
|
|
- body_->setInterpolationWorldTransform(interpTrans);
|
|
|
|
|
|
|
+ if (physicsWorld_->IsSimulating())
|
|
|
|
|
+ {
|
|
|
|
|
+ btTransform interpTrans = body_->getInterpolationWorldTransform();
|
|
|
|
|
+ interpTrans.setOrigin(worldTrans.getOrigin());
|
|
|
|
|
+ interpTrans.setRotation(worldTrans.getRotation());
|
|
|
|
|
+ body_->setInterpolationWorldTransform(interpTrans);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
body_->updateInertiaTensor();
|
|
body_->updateInertiaTensor();
|
|
|
|
|
|
|
|
Activate();
|
|
Activate();
|