beaugard wrote:Anyway, I would guess that the data has to be duplicated, but you could certainly get away with updating only the non-sleeping parts. I do this by keeping my own list of active objects that I update after every step (I ensure thread-safety with a mutex that locks the whole list, but only for bulk-copying so it doesn't hurt performance).
IIRC I simply subclassed btRigidBody and implemented a custom setActivationState that adds removes the pointer from my "active bodies" list. Maybe I had to add the rigidbody to the list upon inserting into the world, too.
This is a useful suggestion to avoid a full world recreation and limits the updatable objects, thanks.
beaugard wrote:You could try just implementing your own motionstate that is responsible for synchronizing, I think they are all synchronized in one go at the end of a step (so you can control thread safety without locking for every motionstate update individually).
From generated Doxygen call tracking,
setWorldTransform() seems to be called only from
synchronizeMotionStates(). Unfortunately
synchronizeMotionStates() is called for each simulation sub-step, so updating here the buffers will invalidates my constraints.
getWorldTransform() instead is called only in
saveKinematicState(), executed only once before any sub-step. Someone know why
synchronizeMotionStates() is called so often? Is safe to remove it from the sub-step loop and leaving a single call at the end of the loop? (P.S. There is also a little bug/inefficiency: if
numSimulationSubSteps is not 0, last
synchronizeMotionStates() will be called twice).
Anyway synchronizing over last
synchronizeMotionStates() and using
setWorldTransform() to write the new values would allow a very efficient buffering; but I think that Bullet uses
getInterpolationWorldTransform() to retrieve shapes transform during ray-testing, invalidating my constraint.