Ejemplo n.º 1
0
        protected override void OnAddToSolver(object info)
        {
            ObiSolver solver = actor.solver;

            // Set solver constraint data:
            int[] solverIndices = new int[pinParticleIndices.Count * 2];
            for (int i = 0; i < pinOffsets.Count; i++)
            {
                solverIndices[i * 2] = actor.particleIndices[pinParticleIndices[i]];

                if (actor.solver.colliderGroup != null)
                {
                    solverIndices[i * 2 + 1] = actor.solver.colliderGroup.GetIndexOfCollider(pinBodies[i]);
                }
                else
                {
                    solverIndices[i * 2 + 1] = -1;
                }
            }

            indicesOffset = actor.solver.pinConstraints.pinOffsets.Length;
            ObiUtils.AddRange(ref solver.pinConstraints.pinIndices, solverIndices);
            ObiUtils.AddRange(ref solver.pinConstraints.pinOffsets, pinOffsets.ToArray());
            ObiUtils.AddRange(ref solver.pinConstraints.stiffnesses, stiffnesses.ToArray());
        }
        protected override void OnAddToSolver(object info)
        {
            ObiSolver solver = actor.solver;

            // Set solver constraint data:
            int[] solverIndices = new int[aerodynamicIndices.Count];
            for (int i = 0; i < aerodynamicNormals.Count; i++)
            {
                solverIndices[i] = actor.particleIndices[aerodynamicIndices[i]];
            }

            indicesOffset = actor.solver.aerodynamicConstraints.aerodynamicNormals.Length;
            ObiUtils.AddRange(ref solver.aerodynamicConstraints.aerodynamicIndices, solverIndices);
            ObiUtils.AddRange(ref solver.aerodynamicConstraints.aerodynamicNormals, aerodynamicNormals.ToArray());
            ObiUtils.AddRange(ref solver.aerodynamicConstraints.wind, wind.ToArray());
            ObiUtils.AddRange(ref solver.aerodynamicConstraints.aerodynamicCoeffs, aerodynamicCoeffs.ToArray());
        }
        protected override void OnAddToSolver(object info)
        {
            ObiSolver solver = actor.solver;

            // Set solver constraint data:
            int[] solverIndices = new int[tetherIndices.Count];
            for (int i = 0; i < maxLengthsScales.Count; i++)
            {
                solverIndices[i * 2]     = actor.particleIndices[tetherIndices[i * 2]];
                solverIndices[i * 2 + 1] = actor.particleIndices[tetherIndices[i * 2 + 1]];
            }

            indicesOffset = actor.solver.tetherConstraints.maxLengthsScales.Length;
            ObiUtils.AddRange(ref solver.tetherConstraints.tetherIndices, solverIndices);
            ObiUtils.AddRange(ref solver.tetherConstraints.maxLengthsScales, maxLengthsScales.ToArray());
            ObiUtils.AddRange(ref solver.tetherConstraints.stiffnesses, stiffnesses.ToArray());
        }
Ejemplo n.º 4
0
        protected override void OnAddToSolver(object info)
        {
            ObiSolver solver = actor.solver;

            // Set solver constraint data:
            int[] solverIndices = new int[springIndices.Count];
            for (int i = 0; i < restLengths.Count; i++)
            {
                solverIndices[i * 2]     = actor.particleIndices[springIndices[i * 2]];
                solverIndices[i * 2 + 1] = actor.particleIndices[springIndices[i * 2 + 1]];
            }

            indicesOffset = actor.solver.distanceConstraints.restLengths.Length;
            ObiUtils.AddRange(ref solver.distanceConstraints.springIndices, solverIndices);
            ObiUtils.AddRange(ref solver.distanceConstraints.restLengths, restLengths.ToArray());
            ObiUtils.AddRange(ref solver.distanceConstraints.stiffnesses, stiffnesses.ToArray());
            ObiUtils.AddRange(ref solver.distanceConstraints.stretching, stretching.ToArray());
        }
Ejemplo n.º 5
0
        protected override void OnAddToSolver(object info)
        {
            ObiSolver solver = actor.solver;

            // Set solver constraint data:
            int[] solverIndices = new int[bendingIndices.Count];
            for (int i = 0; i < restBends.Count; i++)
            {
                solverIndices[i * 3]     = actor.particleIndices[bendingIndices[i * 3]];
                solverIndices[i * 3 + 1] = actor.particleIndices[bendingIndices[i * 3 + 1]];
                solverIndices[i * 3 + 2] = actor.particleIndices[bendingIndices[i * 3 + 2]];
            }

            indicesOffset = actor.solver.bendingConstraints.restBends.Length;
            ObiUtils.AddRange(ref solver.bendingConstraints.bendingIndices, solverIndices);
            ObiUtils.AddRange(ref solver.bendingConstraints.restBends, restBends.ToArray());
            ObiUtils.AddRange(ref solver.bendingConstraints.bendingStiffnesses, bendingStiffnesses.ToArray());
        }
Ejemplo n.º 6
0
        protected override void OnAddToSolver(object info)
        {
            ObiSolver solver = actor.solver;

            // Set solver constraint data:
            int[] solverIndices = new int[skinIndices.Count];
            for (int i = 0; i < skinIndices.Count; i++)
            {
                solverIndices[i] = actor.particleIndices[skinIndices[i]];
                solverIndices[i] = actor.particleIndices[skinIndices[i]];
            }

            indicesOffset = actor.solver.skinConstraints.skinIndices.Length;
            ObiUtils.AddRange(ref solver.skinConstraints.skinIndices, solverIndices);
            ObiUtils.AddRange(ref solver.skinConstraints.skinPoints, skinPoints.ToArray());
            ObiUtils.AddRange(ref solver.skinConstraints.skinNormals, skinNormals.ToArray());
            ObiUtils.AddRange(ref solver.skinConstraints.skinRadiiBackstops, skinRadiiBackstop.ToArray());
            ObiUtils.AddRange(ref solver.skinConstraints.skinStiffnesses, skinStiffnesses.ToArray());
        }
        protected override void OnAddToSolver(object info)
        {
            ObiSolver solver = actor.solver;

            // Set solver constraint data:
            int[] solverIndices = new int[particleIndices.Count];
            for (int i = 0; i < particleIndices.Count; i++)
            {
                solverIndices[i] = actor.particleIndices[particleIndices[i]];
            }

            int[] solverFirstTriangle = new int[firstTriangle.Count];
            for (int i = 0; i < firstTriangle.Count; i++)
            {
                solverFirstTriangle[i] = (int)actor.solver.volumeConstraints.volumeTriangleIndices.Length / 3 + firstTriangle[i];
            }

            int[] solverFirstParticle = new int[firstParticle.Count];
            for (int i = 0; i < firstParticle.Count; i++)
            {
                solverFirstParticle[i] = actor.solver.volumeConstraints.volumeParticleIndices.Length + firstParticle[i];
            }

            indicesOffset         = actor.solver.volumeConstraints.volumeRestVolumes.Length;
            volumeTrianglesOffset = actor.solver.volumeConstraints.volumeTriangleIndices.Length;
            volumeParticlesOffset = actor.solver.volumeConstraints.volumeParticleIndices.Length;

            ObiUtils.AddRange(ref solver.volumeConstraints.volumeTriangleIndices, triangleIndices.ToArray());
            ObiUtils.AddRange(ref solver.volumeConstraints.volumeFirstTriangle, solverFirstTriangle);
            ObiUtils.AddRange(ref solver.volumeConstraints.volumeNumTriangles, numTriangles.ToArray());

            ObiUtils.AddRange(ref solver.volumeConstraints.volumeParticleIndices, solverIndices);
            ObiUtils.AddRange(ref solver.volumeConstraints.volumeFirstParticle, solverFirstParticle);
            ObiUtils.AddRange(ref solver.volumeConstraints.volumeNumParticles, numParticles.ToArray());

            ObiUtils.AddRange(ref solver.volumeConstraints.volumeRestVolumes, restVolumes.ToArray());
            ObiUtils.AddRange(ref solver.volumeConstraints.volumePressureStiffnesses, pressureStiffness.ToArray());
        }