Actors initial position with joints

At simulation start, my actors (with joints) move to match the joint constraint and get their correct positions, it result a kind of scene initialisation movement but it is not really realistic in a real time application. Sometimes the joint stress between two actors is strong if they are not precisly positionned at start and it provide a kind of projection of the actors moving them strongly. How I can start the scene with this actors already well positionned according joint constraint ?


I guess the easiest solution is to calculate their most efficient position based on the joint-type your using. The Joint-Constraint solver will always force the bodies to a transformation that applies for that type of joint. So the only way to limit the strange ‘moving’ behaviour is by giving them an initial position as close as possible to the actual needed constraint state.

There is a small topic in the documentation about configuring joints for best behaviour:

The behavior quality of joints in PhysX is largely determined by the ability of the iterative solver to converge. Better convergence can be achieved simply by increasing the attributes of the PxRigidDynamic which controls the solver iteration count. However, joints can also be configured to produce better convergence.

the solver can have difficulty converging well when where a light object is constrained between two heavy objects. Mass ratios of higher than 10 are best avoided in such scenarios.
when one body is significantly heavier than the other, make the lighter body the second actor in the joint. Similarly, when one of the objects is static or kinematic (or the actor pointer is NULL) make the dynamic bodythe the second actor.
A common use for joints is to move objects around in the world. Best results are obtained when the solver has access to the velocity of motion as well as the change in position.

if you want a very stiff controller that moves the object to specific position each frame, consider jointing the object to a kinematic actor and use the setKinematicTarget function to move the actor.
if you want a more springy controller, use a D6 joint with a drive target to set the desired position and orientation, and control the spring parameters to increase stiffness and damping. In general, acceleration drive is much easier to tune than force drive.

The artifact you describe is what I would call ‘settling’. For example, if you add a stack of blocks to a scene and they are interpenetrating when they are added, the stack will jump or pop when the blocks are first woken up. If the interpenetration is slight, they will settle. The same is true for actors connected by joints, if the positions of the actors and the joint setup are such that the system is not at equilibrium at startup. Usually this is taken care of in a level editor, the objects are tweaked until they are in equilibrium, and then the asset or level is saved out, so that when the assets are loaded into the game at runtime, they are in equilibrium. If you are generating assets procedurally at runtime, you could insert them into a special test scene, let them settle, then serialize them to a collection which will be de-serialized into your main scene.