DanielChappuis / reactphysics3d

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

Feature request: Locking movement along axes #21

Closed ColinGilbert closed 2 years ago

ColinGilbert commented 9 years ago

Hi,

I am working on a dynamic character controller, and it would be great to be able to lock linear/rotational movement along certain axes for a given object. Something along the line of

body->setAngularFactor(rp3d::Vector3(0.0, 0.0, 1.0));
body->setLinearFactor(rp3d::Vector3(1.0, 0.0, 1.0))

Would be really, really handy.

Thanks!

DanielChappuis commented 9 years ago

Good idea ! I will try to add this in the next release.

mokalux commented 3 years ago

I am trying to set a body to a fixed rotation as well, something like body:setFixedRotation(bool) in box2d. Is it possible to do something similar in current reactphysics3d?

In my case when a cube shape collides with a sphere shape the cube rotates backward a little bit. I tried setting the mass to something huge, but the tilting still occurs.

Thank you.

Oops it's been requested many times, sorry for this one!

codenamecpp commented 2 years ago

I hope this feature will be implemented one day :)

DanielChappuis commented 2 years ago

It's already implemented in the 'develop' branch. I will release the next version of the library in the next weeks with this feature.

DanielChappuis commented 2 years ago

I glad to announce that this feature is now implemented in version v0.9.0 that has just been released.

There is now a RigidBody::setLinearLockAxisFactor() method to lock the translational movement of a body along the world-space x, y and z axes and a RigidBody::setAngularLockAxisFactor() method to lock the rotational movement of a body around the world-space x, y and z axes.

Do not hesitate to take a look at the documentation for more information.