Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Synchronizing softbody, doesn't render
#2
(06-12-2022, 02:41 PM)Milionario Wrote: So I tried using the same script I had for synchronizing ropes, but instead of using a ObiRope component, I replaced it with ObiActor for a more general approach since it's just synchronizing particles. The ropes work fine but the softbody doesn't, the positions are received correctly, I am drawing debug lines to visualize them:

[Image: r91h9FW.png]

You can see the softbody shape, its there.

This script works just fine for ropes, there isn't any rope specific code there.

This is how I am setting the solver positions

Code:
var wantedHostTimeStamp = Host.Now - HostTimespan.FromSeconds(ReceiveDelay);

        var states = GetStatesAroundHostTimeStamp(wantedHostTimeStamp);

        if (states.HasStates)
        {
            var interpolationFactor = GetInterpolationFactorBetweenStates(wantedHostTimeStamp, states.Item1, states.Item2);

            for (int i = 0; i < actor.activeParticleCount; i++)
            {
                var globalPosition = actor.solver.transform.TransformPoint(Vector3.Lerp(states.Item1.Positions[i], states.Item2.Positions[i], interpolationFactor));
                Debug.DrawLine(Vector3.zero, globalPosition);
                actor.solver.positions[actor.solverIndices[i]] = Vector3.Lerp(states.Item1.Positions[i], states.Item2.Positions[i], interpolationFactor);
                actor.solver.invMasses[actor.solverIndices[i]] = 0;
            }
        }

This is where I actually set the particles positions in the solver:
Code:
actor.solver.positions[actor.solverIndices[i]] = Vector3.Lerp(states.Item1.Positions[i], states.Item2.Positions[i], interpolationFactor);
                actor.solver.invMasses[actor.solverIndices[i]] = 0;

Gettings lots of these:

[Image: tF2z4l3.png]}

So it looks like its trying to set invalid values for the softbody transform on Softbody script line 281

It works just fine for the ropes and its the same component that i am using to synchronize them, what can I do to track this problem down?

Hi,

You're setting particle inverse masses to zero, which in the case of softbodies requires recalculating their rest shape since the inertia tensor of the softbody changes as a result. Call UpdateParticleProperties() on the softbody after setting the particle's inverse mass. Quoting the API docs:

Quote:override void Obi.ObiSoftbody.UpdateParticleProperties()

Recalculates the shape used as reference for transform position/orientation when there are no fixed particles, as well as the rest shape matching state. Should be called manually when changing the amount of fixed particles and/ or active particles.

Note all ObiActors declare the UpdateParticleProperties() method, in some cases (like ropes) its implementation is a no-op so you can use the same code for both ropes and softbodies.
Reply


Messages In This Thread
RE: Synchronizing softbody, doesn't render - by josemendez - 06-12-2022, 03:03 PM