Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Obi 7:Modify Constraints / Reset skinned cloth in runtime
#1
So I have updated to Obi7,I used to modify skinned cloth constraints to 0 and set back to blueprint's data in runtime to reset cloth,
Just like the example:

var cloth = GetComponent<ObiSkinnedCloth>();

// get constraints stored in the actor:
var actorConstraints = cloth.GetConstraintsByType(Oni.ConstraintType.Skin)
as ObiConstraints<ObiSkinConstraintsBatch>;

// get runtime constraints in the solver:
var solverConstraints = cloth.solver.GetConstraintsByType(Oni.ConstraintType.Skin)
as ObiConstraints<ObiSkinConstraintsBatch>;

// there's only one skin constraint per particle,
// so particleIndex == constraintIndex,
// and there is only need for one skin constraints batch:
var actorSkinBatch = actorConstraints.batches[0];
var solverSkinBatch = solverConstraints.batches[0];

// get the offset of our first -and only- skin batch in the solver:
int offset = cloth.solverBatchOffsets[(int)Oni.ConstraintType.Skin][0];

// iterate over all active skin constraints in the batch,
// setting their properties:
for (int i = 0; i < actorSkinBatch.activeConstraintCount; ++i)
{
int index = i + offset;

// skin radius
solverSkinBatch.skinRadiiBackstop[index * 3] = 0.05f;

// backstop sphere radius
solverSkinBatch.skinRadiiBackstop[index * 3 + 1] = 0.1f;

// backstop sphere distance
solverSkinBatch.skinRadiiBackstop[index * 3 + 2] = 0;

}

So the problem is this method can only use in CPU backend,
Can anyone tell me with out this method, Is there an easy way to reset skinned cloth with GPU backend?
Reply


Messages In This Thread
Obi 7:Modify Constraints / Reset skinned cloth in runtime - by calvantsang - 05-08-2024, 09:00 PM