Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Extracting acting forces on particle
#3
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.
Reply


Messages In This Thread
RE: Extracting acting forces on particle - by josemendez - 24-08-2021, 04:34 PM