Obi Official Forum
Bug / Crash Rod loses initial shape when forced - Printable Version

+- Obi Official Forum (https://obi.virtualmethodstudio.com/forum)
+-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html)
+--- Forum: Obi Rope (https://obi.virtualmethodstudio.com/forum/forum-4.html)
+--- Thread: Bug / Crash Rod loses initial shape when forced (/thread-4537.html)



Rod loses initial shape when forced - Qriva0 - 12-08-2025

There is rod with some bended initial shape and I push it into place where it's not possible to keep this shape fully. In my case it's some kind of tunnel collider.
The problem is that rod loses it's shape during that operation, like it had plastic deformation enabled. Meanwhile plastic creep and yield is set to 0.
Is that expected outcome?

Example of such a deformation below.
All constraint values are set to default (0).


RE: Rod loses initial shape when forced - chenji - 13-08-2025

(12-08-2025, 03:58 PM)Qriva0 Wrote: There is rod with some bended initial shape and I push it into place where it's not possible to keep this shape fully. In my case it's some kind of tunnel collider.
The problem is that rod loses it's shape during that operation, like it had plastic deformation enabled. Meanwhile plastic creep and yield is set to 0.
Is that expected outcome?

Example of such a deformation below.
All constraint values are set to default (0).
The doc says: https://obi.virtualmethodstudio.com/manual/7.1/bendtwistconstraints.html

Plastic yield

Strain threshold that marks the transition from elastic to plastic deformation. Low values will make it easier to permanently deform the constraint. At high values it will take more violent deformation to permanently deform the constraint.

So set it to 0 is wrong in your case. But it also says this so I assume there is a bug as percentage 0 should mean no deformation.

Plastic creep
Once the plastic yield threshold is surpassed, plastic creep determines what percentage of the deformation is permanently absorbed by the constraint.


RE: Rod loses initial shape when forced - Qriva0 - 13-08-2025

(Yesterday, 03:35 AM)chenji Wrote: So set it to 0 is wrong in your case. But it also says this so I assume there is a bug as percentage 0 should mean no deformation.

Plastic creep
Once the plastic yield threshold is surpassed, plastic creep determines what percentage of the deformation is permanently absorbed by the constraint.

Yes that is what I mean, if it's 0 then there should be no problem, but the same happens if it's greater than 0.

However I think there might be something else wrong, because I tried to display restDarbouxVectors for each particle and (assuming I did it correctly) I doubt there should be NaN's there.
Is that bug and perhaps related to my problem?


RE: Rod loses initial shape when forced - josemendez - 14-08-2025

(Yesterday, 04:22 PM)Qriva0 Wrote: There is rod with some bended initial shape and I push it into place where it's not possible to keep this shape fully. In my case it's some kind of tunnel collider.
The problem is that rod loses it's shape during that operation, like it had plastic deformation enabled. Meanwhile plastic creep and yield is set to 0.
Is that expected outcome?

Hi!

Plastic creep is the amount of deformation that is allowed to creep into the object's rest shape, once deformed past the plastic yield threshold. Setting it to zero disables plasticity, so no amount of deformation should be absorbed by the rest state of the rod.

Tested this by jamming a straight rod into a curved collider and then disabling the collider, but the rod immediately recovered its initial shape. Here's a video of the behavior you should expect using plastic creep = 1 (the rod retains the shape of the collider it was jammed into, even after the collider is gone) and plastic creep = 0 (the rod goes back to straight after the collider disappears).



(Yesterday, 04:22 PM)Qriva0 Wrote: However I think there might be something else wrong, because I tried to display restDarbouxVectors for each particle and (assuming I did it correctly) I doubt there should be NaN's there.
Is that bug and perhaps related to my problem?

Particles don't have darboux vectors (either rest or current), constraints do. They're accessed very differently. How are you looking at these values? Data lists in Obi usually are uninitialized, so unused areas of them may have any value.


RE: Rod loses initial shape when forced - Qriva0 - 14-08-2025

(11 hours ago)josemendez Wrote: Plastic creep is the amount of deformation that is allowed to creep into the object's rest shape, once deformed past the plastic yield threshold. Setting it to zero disables plasticity, so no amount of deformation should be absorbed by the rest state of the rod.

Exactly, however I thought that maybe some precision error builds up or something, so I commented code in BendTwistBatch, to be precise those lines:
Code:
// plasticity
if (math.lengthsq(omega.value.xyz) > plasticity[i].x * plasticity[i].x)
{
    rest.value += omega.value * plasticity[i].y * deltaTime;
    restDarboux[i] = rest;
}

but it still breaks and problem persists.

(11 hours ago)josemendez Wrote: They're accessed very differently. How are you looking at these values? Data lists in Obi usually are uninitialized, so unused areas of them may have any value.

I did something like this:
Code:
private void OnDrawGizmos()
{
    ObiRod rod = GetComponent<ObiRod>();
    if (rod == null || !rod.isLoaded)
    {
        return;
    }

    var solverConstraints = rod.solver.GetConstraintsByType(Oni.ConstraintType.BendTwist) as ObiConstraints<ObiBendTwistConstraintsBatch>;
    if (solverConstraints != null)
    {
        for (int j = 0; j < solverConstraints.batchCount; ++j)
        {
            var batch = solverConstraints.GetBatch(j) as ObiBendTwistConstraintsBatch;

            for (int i = 0; i < batch.activeConstraintCount; i++)
            {
                int indexA = batch.particleIndices[i * 2];
                int indexB = batch.particleIndices[i * 2 + 1];

                //Gizmos.DrawWireSphere(rod.solver.positions[indexA], 0.5f);
                UnityEditor.Handles.Label(rod.solver.positions[indexA], batch.restDarbouxVectors[i * 2].ToString());
                //Gizmos.color = Color.yellow;
                //Gizmos.DrawRay(rod.solver.positions[indexA], (rod.solver.orientations[indexA] * batch.restDarbouxVectors[i * 2]) * Vector3.forward);
            }
        }
    }
}

In my case currently there is mesh collider with distance field as tunnel (but the same happens for simple boxes) and yes, your video shows what should happen, but take into account that your rod is not bended from the start and this might affect results. I try to push into stright tunnel already bended rod and while inside of it it makes sense that it bends, but after pulling out it should go back to initial shape.
Here I have video of pushing the rod into hole made of boxes, I failed to push it inside, but notice the same thing happened and after leaving it, the rod tip is not perfectly roundly bended.
I attached constraint values of my rod and it looks like I can't attach video clips, so I fast uploaded it here (but will expire in 2 days): https://streamable.com/cyt3k5