public static SoftBody CreateFromTriMesh(SoftBodyWorldInfo worldInfo, Vector3[] vertices, int[] triangles, bool randomizeConstraints = true)
        {
            int numTriangleIndices = triangles.Length;
            int numTriangles = numTriangleIndices / 3;

            int maxIndex = 0; // triangles.Max() + 1;
            for (int i = 0; i < numTriangleIndices; i++)
            {
                if (triangles[i] > maxIndex)
                {
                    maxIndex = triangles[i];
                }
            }
            maxIndex++;

            SoftBody psb = new SoftBody(worldInfo, maxIndex, vertices, null);

            BitArray chks = new BitArray(maxIndex * maxIndex);
            for (int i = 0; i < numTriangleIndices; i += 3)
            {
                int[] idx = new int[] { triangles[i], triangles[i + 1], triangles[i + 2] };
                for (int j = 2, k = 0; k < 3; j = k++)
                {
                    int chkIndex = maxIndex * idx[k] + idx[j];
                    if (!chks[chkIndex])
                    {
                        chks[chkIndex] = true;
                        chks[maxIndex * idx[j] + idx[k]] = true;
                        psb.AppendLink(idx[j], idx[k]);
                    }
                }
                psb.AppendFace(idx[0], idx[1], idx[2]);
            }

            if (randomizeConstraints)
            {
                psb.RandomizeConstraints();
            }
            return psb;
        }
        /// <summary>
        /// Apply these SoftBody settings to this SoftBody
        /// </summary>
        /// <param name="softBody"></param>
        public void ConfigureSoftBody(SoftBody softBody)
        {
            softBody.Scale(scale.ToBullet());

            BulletSharp.SoftBody.Material pm = softBody.Materials[0];

            sBMaterial.SetSBMaterial(pm);

            config.SetConfig(softBody.Cfg);

            if (allNodeBendingConstraints)
            {
                for (int i = 0; i < softBody.Nodes.Count - 1; ++i)
                {
                    softBody.GenerateBendingConstraints(1 + i);
                }
            }
            else
            {
                softBody.GenerateBendingConstraints(bendingConstraintDistance, pm);
            }

            if (randomizeConstraints)
                softBody.RandomizeConstraints();

            if (generateClusters)
                softBody.GenerateClusters(0);

            softBody.SetTotalMass(totalMass, fromFaces);

            softBody.SetPose(bvolume, bframe);
        }