Unable to configure stiffness or damping for spherical joints
I am trying to create some cloth animation in my game, and saw the joints on the rapier's demo page where there is a structure very similar to what I want. The cloth look good when isolated, but when anything interact with it, it behaves extremely unnaturally. I tried different things attempting to make it look better, but the choice is very limited, and the joint configuration itself does not have any effect. Here is the code from the joints demo, namely the one creating the cloth-like joints, I tried applying stiffness and dumping, but it does not change anything. Configuring rigid bodies individually with linear dumping and gravity scale somehow help but it still behaves weird. For me it is strange that I cannot configure anythong about the joints, even stiffness.
rapier3d (0.13.1)
function createBallJoints(
RAPIER: RAPIER_API,
world: RAPIER.World,
num: number,
) {
let rad = 0.5;
let shift = 1.0;
let i, k;
let parents = [];
for (k = 0; k < num; ++k) {
for (i = 0; i < num; ++i) {
let fk = k;
let fi = i;
let bodyType;
if (i == 0) {
bodyType = RAPIER.RigidBodyType.Fixed;
} else {
bodyType = RAPIER.RigidBodyType.Dynamic;
}
let bodyDesc = new RAPIER.RigidBodyDesc(bodyType).setTranslation(
fk * shift,
0.0,
fi * shift,
);
let child = world.createRigidBody(bodyDesc);
let colliderDesc = RAPIER.ColliderDesc.ball(rad);
world.createCollider(colliderDesc, child);
// Vertical joint.
let o = new RAPIER.Vector3(0.0, 0.0, 0.0);
if (i > 0) {
let parent = parents[parents.length - 1];
let params = RAPIER.JointData.spherical(
o,
new RAPIER.Vector3(0.0, 0.0, -shift),
);
params.stiffness = 1.0; // no effect
params.damping = 1.0; // no effect
world.createImpulseJoint(params, parent, child, true);
}
// Horizontal joint.
if (k > 0) {
let parent_index = parents.length - num;
let parent = parents[parent_index];
let params = RAPIER.JointData.spherical(
o,
new RAPIER.Vector3(-shift, 0.0, 0.0),
);
params.stiffness = 100.0; // no effect
params.damping = 100.0; // no effect
console.log(params);
world.createImpulseJoint(params, parent, child, true);
}
parents.push(child);
}
}
}
@khudiiash Hi, did you end up figuring this out? I can't seem to get any type of constraints to function with spherical joints.
Nope I remember using some other type of joint that was more stable. Though even that one was not good enough. A lot of issues with this engine honestly. I dropped using it. No response from devs whatsoever.
There is currently no per-joint stiffness or damping coefficient. It’s controlled globally though simulation parameters, but I realize these are not exposed by the JS API. There are plans to add per-joint parameter.