Пример #1
0
        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++)
            {
                ObiDistanceConstraints dc = solver.actors[i].GetComponent <ObiDistanceConstraints>();
                if (dc != null)
                {
                    dc.UpdateIndicesOffset(dc.indicesOffset - restLengths.Count);
                }
            }

            ObiUtils.RemoveRange(ref solver.distanceConstraints.springIndices, indicesOffset * 2, restLengths.Count * 2);
            ObiUtils.RemoveRange(ref solver.distanceConstraints.restLengths, indicesOffset, restLengths.Count);
            ObiUtils.RemoveRange(ref solver.distanceConstraints.stiffnesses, indicesOffset, restLengths.Count);
            ObiUtils.RemoveRange(ref solver.distanceConstraints.stretching, indicesOffset, restLengths.Count);
        }
Пример #2
0
        public override void PushDataToSolver(ObiBatchedConstraints constraints)
        {
            if (constraints == null || constraints.Actor == null || !constraints.Actor.InSolver)
            {
                return;
            }

            ObiDistanceConstraints dc = (ObiDistanceConstraints)constraints;

            float[] scaledRestLengths = new float[restLengths.Count];

            for (int i = 0; i < restLengths.Count; i++)
            {
                scaledRestLengths[i] = restLengths[i] * dc.stretchingScale;
                stiffnesses[i]       = new Vector2(StiffnessToCompliance(dc.stiffness), dc.slack * scaledRestLengths[i]);
            }

            Oni.SetDistanceConstraints(batch, solverIndices, scaledRestLengths, stiffnesses.ToArray(), ConstraintCount);
            Oni.SetBatchPhaseSizes(batch, phaseSizes.ToArray(), phaseSizes.Count);
        }
 public void OnEnable()
 {
     constraints = (ObiDistanceConstraints)target;
 }
Пример #4
0
        public override void Awake()
        {
            base.Awake();

            distanceConstraints = GetComponent<ObiDistanceConstraints>();
        }
Пример #5
0
        public override void Awake()
        {
            base.Awake();

            distanceConstraints = GetComponent <ObiDistanceConstraints>();
        }