Esempio n. 1
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++)
            {
                ObiSkinConstraints dc = solver.actors[i].GetComponent <ObiSkinConstraints>();
                if (dc != null)
                {
                    dc.UpdateIndicesOffset(dc.indicesOffset - skinIndices.Count);
                }
            }

            ObiUtils.RemoveRange(ref solver.skinConstraints.skinIndices, indicesOffset, skinIndices.Count);
            ObiUtils.RemoveRange(ref solver.skinConstraints.skinPoints, indicesOffset, skinIndices.Count);
            ObiUtils.RemoveRange(ref solver.skinConstraints.skinNormals, indicesOffset, skinIndices.Count);
            ObiUtils.RemoveRange(ref solver.skinConstraints.skinRadiiBackstops, indicesOffset * 2, skinIndices.Count * 2);
            ObiUtils.RemoveRange(ref solver.skinConstraints.skinStiffnesses, indicesOffset, skinIndices.Count);
        }
Esempio n. 2
0
        public override void PushDataToSolver(ObiBatchedConstraints constraints)
        {
            if (constraints == null || constraints.Actor == null || !constraints.Actor.InSolver)
            {
                return;
            }

            ObiSkinConstraints sc = (ObiSkinConstraints)constraints;

            float[] stiffnesses = new float[skinStiffnesses.Count];

            for (int i = 0; i < stiffnesses.Length; i++)
            {
                stiffnesses[i] = StiffnessToCompliance(skinStiffnesses[i] * sc.stiffness);
            }

            Oni.SetSkinConstraints(batch, solverIndices,
                                   skinPoints.ToArray(),
                                   skinNormals.ToArray(),
                                   skinRadiiBackstop.ToArray(),
                                   stiffnesses,
                                   ConstraintCount);
            Oni.SetBatchPhaseSizes(batch, phaseSizes.ToArray(), phaseSizes.Count);
        }
Esempio n. 3
0
 public void OnEnable()
 {
     constraints = (ObiSkinConstraints)target;
 }