Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Extracting acting forces on particle
#4
(24-08-2021, 04:34 PM)josemendez Wrote: Being a position-based engine, Obi does not internally deal with forces. It deals with positional corrections, or lambdas. All constraints have a lambda array that stores positional lagrange multipliers for each constraint. To convert a lagrange multiplier to a force magnitude, divide by timestep squared:


Code:
force = batch.lambas[constraintIndex] / (deltaTime * deltaTime);

To learn how to access constraint data at runtime, see:
http://obi.virtualmethodstudio.com/manua...aints.html

You can also take a look at ObiParticleAttachment.cs for reference. The "BreakDynamicAttachment" method at the end of the file iterates trough the pin constraints in use by the attachment, checks the force applied by each one, and deactivates those above their break threshold like so:
Code:
for (int i = 0; i < pinBatch.activeConstraintCount; i++)
{
        // in case the constraint has been broken:
        if (-solverBatch.lambdas[(offset + i) * 4 + 3] / sqrTime > pinBatch.breakThresholds[i])
        {
              pinBatch.DeactivateConstraint(i);
              dirty = true;
        }
}

In the case of pin constraints, there's 4 lagrange multipliers per constraint: 3 for the rotational part, and 1 for the translational part. Since we are only interested in translational force we only access the fourth one of each constraint, hence the seemingly weird indexing:

Code:
lambdas[(offset + i) * 4 + 3]

And since we only want stretching (not compression) forces, we negate the lambda. Hence the minus (-) sign used for the lambda in the comparison.

Hi josemendez, I stumbled upon this thread while searching something similar, and I don't understand. I'd like to know the force vector that's applied to an attachment.
I know the solver index of a particle that's in the particle group of the attachment.
I guess I also can know the direction of the force that's being applied to the attachment, because I can subtract the position of a particle to the position of the next particle (like this other user did in their first solution). All that would be left would be to do would be `direction.normalized * batch.lambas[constraintIndex] / (deltaTime * deltaTime)`?
I don't understand how to get the specific batch and the constraint index of a specific particle.

Sorry for reviving an old post and sorry to not be able to understand the previous explanation Triste
Reply


Messages In This Thread
RE: Extracting acting forces on particle - by KnotANumber - 23-06-2023, 06:26 AM