public override void PushDataToSolver(ObiBatchedConstraints constraints)
        {
            if (constraints == null || constraints.Actor == null || !constraints.Actor.InSolver)
            {
                return;
            }

            ObiBendingConstraints bc = (ObiBendingConstraints)constraints;

            for (int i = 0; i < bendingStiffnesses.Count; i++)
            {
                bendingStiffnesses[i] = new Vector2(bc.maxBending, StiffnessToCompliance(bc.stiffness));
            }

            Oni.SetBendingConstraints(batch, solverIndices, restBends.ToArray(), bendingStiffnesses.ToArray(), ConstraintCount);
            Oni.SetBatchPhaseSizes(batch, phaseSizes.ToArray(), phaseSizes.Count);
        }
Beispiel #2
0
        protected override void OnRemoveFromSolver(object info)
        {
            ObiSolver solver = actor.solver;

            // subtract our amount of constraints from other actor's offsets:
            for (int i = actor.actorID + 1; i < solver.actors.Count; i++)
            {
                ObiBendingConstraints bc = solver.actors[i].GetComponent <ObiBendingConstraints>();
                if (bc != null)
                {
                    bc.UpdateIndicesOffset(bc.indicesOffset - restBends.Count);
                }
            }

            ObiUtils.RemoveRange(ref solver.bendingConstraints.bendingIndices, indicesOffset * 3, restBends.Count * 3);
            ObiUtils.RemoveRange(ref solver.bendingConstraints.restBends, indicesOffset, restBends.Count);
            ObiUtils.RemoveRange(ref solver.bendingConstraints.bendingStiffnesses, indicesOffset, restBends.Count);
        }
 public void OnEnable()
 {
     constraints = (ObiBendingConstraints)target;
 }