saharan / OimoPhysics

A cross-platform 3D physics engine
MIT License
863 stars 68 forks source link

Add Linear Factor #73

Closed moisesjpelaez closed 4 months ago

moisesjpelaez commented 5 months ago

The objects already have a rotation factor and inertia. It would be nice to have linear factors as well in _applyTranslation from oimo.dynamics.rigidbody.RigidBody.

saharan commented 4 months ago

Unfortunately mass is a scalar and not a matrix like inertia moment and handling anisotropicity directly in RigidBody is difficult (for isotropic linear factor you can just change mass). If you want to limit linear movements for some axes, you can utilize GenericJoint by setting its TranslationalLimitMotor.

e.g. to lock the X-axis of a generic joint you can genericJoint.getTranslationalLimitMotors()[0].setLimits(0, 0).