I need guidance on how to transform a force vector from world space to a geometry’s local space.
Basically, I am generating a force vector each tick and applying it to a specific point on each triangle of a mesh.
All of this is relative to world space, but using applyForce() from bullet’s rigidbody takes a force vector and a relative position vector, so I need to transform both my force vector and it’s position of application vector into the Geometry’s local space.
Geometry’s worldToLocal() method seems to work as expected for the position at which the force is actually applied, but does not work similarly on the force vector.
I suspect I am missing something in treating the force as a direction vector rather than a position vector, like properly transforming normals when a vertex moves.
(I thought about multiplying the force by the inverse transpose of the Geometry’s world transform matrix, but I use only uniform scaling on the geom, if any scaling at all)
I am currently using the worldspace force vector with the Geometry-transformed local position, which works to move the rigidbody as expected, until the body rotates away from being aligned with it’s local rotation.
For example, if I apply upward force to the front while in initial position, the front will lift… but if I first rotate the rigidbody by 180 degrees around the Y axis (using setPhysicsRotation()), that same upward force at that same local position will lift the rear.
I did try worldToLocal() on the force vector, and I have also tried multiplying the force by the Geometry’s world rotation, but both of those results were even worse.
Does anyone have any insight into how to preserve the relationship of a world force at a world point, when the world point has been transformed into local space?