public override void PushDataToSolver(ObiBatchedConstraints constraints) { if (constraints == null || constraints.Actor == null || !constraints.Actor.InSolver) { return; } ObiTetherConstraints tc = (ObiTetherConstraints)constraints; for (int i = 0; i < ConstraintCount; i++) { maxLengthsScales[i] = new Vector2(maxLengthsScales[i].x, tc.tetherScale); stiffnesses[i] = StiffnessToCompliance(tc.stiffness); } Oni.SetTetherConstraints(batch, solverIndices, maxLengthsScales.ToArray(), stiffnesses.ToArray(), ConstraintCount); Oni.SetBatchPhaseSizes(batch, phaseSizes.ToArray(), phaseSizes.Count); }
protected override void OnRemoveFromSolver(object info) { ObiSolver solver = actor.solver; // Update following actors' indices: for (int i = actor.actorID + 1; i < solver.actors.Count; i++) { ObiTetherConstraints tc = solver.actors[i].GetComponent <ObiTetherConstraints>(); if (tc != null) { tc.UpdateIndicesOffset(tc.indicesOffset - maxLengthsScales.Count); } } ObiUtils.RemoveRange(ref solver.tetherConstraints.tetherIndices, indicesOffset * 2, maxLengthsScales.Count * 2); ObiUtils.RemoveRange(ref solver.tetherConstraints.maxLengthsScales, indicesOffset, maxLengthsScales.Count); ObiUtils.RemoveRange(ref solver.tetherConstraints.stiffnesses, indicesOffset, maxLengthsScales.Count); }
public void OnEnable() { constraints = (ObiTetherConstraints)target; }