DanielChappuis / reactphysics3d

Open source C++ physics engine library in 3D
http://www.reactphysics3d.com
zlib License
1.54k stars 223 forks source link

Getting post-update position: User Manual is out of date. #34

Closed TerryHibbert closed 6 years ago

TerryHibbert commented 7 years ago

In section "9.3 Updating a Rigid Body", the code sample provided calls a non-existent "getInterpolatedTransform" method on RigidBody.

// Get the interpolated transform of the rigid body
rp3d::Transform transform = body->getInterpolatedTransform();

Is it now RigidBody::getTransform()? This unexpectedly holds all zeros for me. But that could be some other mistake I'm making.

DanielChappuis commented 7 years ago

Thanks a lot for reporting this.

I have fixed this in the documentation in branch "develop" (commit dfb4b811f9af79d1b53db448dcbfc57411abb52a). This will be integrated in the next release of the library.

Now you need to use the getTransform() method on a body to get the current transform. To avoid unpleasant visual effect, you also need to get the interpolated transform between the previous and the current frame as in the following code :

// Get the current transform of the rigid body
rp3d::Transform currentTransform = body->getTransform();

// Interpolate the transform between the previous one and the new one
rp3d::Transform interpolatedTransform = rp3d::Transform::interpolateTransforms(previousTransform, currentTransform, interpolationFactor);

You can see an example in the testbed application of the library.

DanielChappuis commented 6 years ago

This issue has been fixed in the version v0.7.0 of ReactPhysics3D that has just been released. Thanks a lot for reporting this.