public override void Cook() { batch = Oni.CreateBatch((int)Oni.ConstraintType.Bending, true); // Send initial data to batch: Oni.SetBendingConstraints(batch, bendingIndices.ToArray(), restBends.ToArray(), bendingStiffnesses.ToArray(), ConstraintCount); // cook the batch and retrieve new sorted data: if (Oni.CookBatch(batch)) { constraintCount = Oni.GetBatchConstraintCount(batch); activeConstraints = Enumerable.Range(0, constraintCount).ToList(); int[] cookedIndices = new int[constraintCount * 3]; float[] cookedRestLengths = new float[constraintCount]; Vector2[] cookedStiffnesses = new Vector2[constraintCount]; Oni.GetBendingConstraints(batch, cookedIndices, cookedRestLengths, cookedStiffnesses); bendingIndices = new List <int>(cookedIndices); restBends = new List <float>(cookedRestLengths); bendingStiffnesses = new List <Vector2>(cookedStiffnesses); int phaseCount = Oni.GetBatchPhaseCount(batch); int[] phases = new int[phaseCount]; Oni.GetBatchPhaseSizes(batch, phases); this.phaseSizes = new List <int>(phases); } Oni.DestroyBatch(batch); batch = IntPtr.Zero; }
public override void Cook() { batch = Oni.CreateBatch((int)Oni.ConstraintType.Skin, true); // Send initial data to batch: Oni.SetSkinConstraints(batch, skinIndices.ToArray(), skinPoints.ToArray(), skinNormals.ToArray(), skinRadiiBackstop.ToArray(), skinStiffnesses.ToArray(), ConstraintCount); // cook the batch and retrieve new sorted data: if (Oni.CookBatch(batch)) { constraintCount = Oni.GetBatchConstraintCount(batch); activeConstraints = Enumerable.Range(0, constraintCount).ToList(); int[] cookedIndices = new int[constraintCount]; Vector4[] cookedPoints = new Vector4[constraintCount]; Vector4[] cookedNormals = new Vector4[constraintCount]; float[] cookedRadiiBackstop = new float[constraintCount * 3]; float[] cookedStiffnesses = new float[constraintCount]; Oni.GetSkinConstraints(batch, cookedIndices, cookedPoints, cookedNormals, cookedRadiiBackstop, cookedStiffnesses); skinIndices = new List <int>(cookedIndices); skinPoints = new List <Vector4>(cookedPoints); skinNormals = new List <Vector4>(cookedNormals); skinRadiiBackstop = new List <float>(cookedRadiiBackstop); skinStiffnesses = new List <float>(cookedStiffnesses); int phaseCount = Oni.GetBatchPhaseCount(batch); int[] phases = new int[phaseCount]; Oni.GetBatchPhaseSizes(batch, phases); this.phaseSizes = new List <int>(phases); } Oni.DestroyBatch(batch); batch = IntPtr.Zero; }