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

            ObiShapeMatchingConstraints sc = (ObiShapeMatchingConstraints)constraints;

            restComs     = new AlignedVector4Array(ConstraintCount);
            coms         = new AlignedVector4Array(ConstraintCount);
            orientations = new AlignedQuaternionArray(ConstraintCount, constraints.Actor.ActorLocalToSolverMatrix.rotation);

            for (int i = 0; i < shapeMaterialParameters.Count; i++)
            {
                shapeMaterialParameters[i] = new Oni.ElastoplasticMaterial(sc.stiffness, sc.plasticYield, sc.plasticCreep, sc.plasticRecovery, sc.maxDeform);
            }

            Oni.SetShapeMatchingConstraints(batch,
                                            solverIndices,
                                            firstIndex.ToArray(),
                                            numIndices.ToArray(),
                                            explicitGroup.ToArray(),
                                            shapeMaterialParameters.ToArray(),
                                            restComs.GetIntPtr(),
                                            coms.GetIntPtr(),
                                            orientations.GetIntPtr(),
                                            ConstraintCount);

            Oni.CalculateRestShapeMatching(constraints.Actor.Solver.OniSolver, batch);
        }
        public void RecalculateRestShapeMatching()
        {
            if (Application.isPlaying && isLoaded)
            {
                var sc = GetConstraintsByType(Oni.ConstraintType.ShapeMatching) as ObiConstraints <ObiShapeMatchingConstraintsBatch>;

                foreach (var batch in sc.batches)
                {
                    Oni.CalculateRestShapeMatching(solver.OniSolver, batch.oniBatch);
                }
            }
        }
Exemple #3
0
        public override void PushDataToSolver(ParticleData data = ParticleData.NONE)
        {
            if (!InSolver)
            {
                return;
            }

            base.PushDataToSolver(data);

            // Recalculate rest shape matching data when changing particle masses.
            if ((data & ParticleData.INV_MASSES) != 0)
            {
                foreach (ObiShapeMatchingConstraintBatch batch in ShapeMatchingConstraints.GetBatches())
                {
                    Oni.CalculateRestShapeMatching(solver.OniSolver, batch.OniBatch);
                }
            }
        }
        protected override void OnAddToSolver(IObiConstraints constraints)
        {
            for (int i = 0; i < particleIndices.count; i++)
            {
                particleIndices[i] = constraints.GetActor().solverIndices[source.particleIndices[i]];
            }

            for (int i = 0; i < orientations.count; i++)
            {
                orientations[i] = constraints.GetActor().actorLocalToSolverMatrix.rotation;
            }

            // pass constraint data arrays to the solver:
            Oni.SetShapeMatchingConstraints(batch, particleIndices.GetIntPtr(), firstIndex.GetIntPtr(), numIndices.GetIntPtr(), explicitGroup.GetIntPtr(),
                                            materialParameters.GetIntPtr(), restComs.GetIntPtr(), coms.GetIntPtr(), orientations.GetIntPtr(), m_ConstraintCount);
            Oni.SetActiveConstraints(batch, m_ActiveConstraintCount);

            Oni.CalculateRestShapeMatching(constraints.GetActor().solver.OniSolver, batch);
        }
Exemple #5
0
        public override void PushDataToSolver(ObiBatchedConstraints constraints)
        {
            if (constraints == null || constraints.Actor == null || !constraints.Actor.InSolver)
            {
                return;
            }

            //ObiShapeMatchingConstraints sc = (ObiShapeMatchingConstraints) constraints;

            for (int i = 0; i < shapeStiffness.Count; i++)
            {
                shapeStiffness[i] = 1;        //StiffnessToCompliance(sc.stiffness);
            }

            Oni.SetShapeMatchingConstraints(batch,
                                            solverIndices,
                                            firstIndex.ToArray(),
                                            numIndices.ToArray(),
                                            shapeStiffness.ToArray(),
                                            ConstraintCount);

            Oni.CalculateRestShapeMatching(constraints.Actor.Solver.OniSolver, batch);
        }
 public void CalculateRestShapeMatching()
 {
     Oni.RecalculateInertiaTensors(((OniSolverImpl)this.constraints.solver).oniSolver);
     Oni.CalculateRestShapeMatching(((OniSolverImpl)this.constraints.solver).oniSolver, oniBatch);
 }