Universe.Physics.BulletSPlugin.BSAPIXNA.CreateMeshShape C# (CSharp) Method

CreateMeshShape() public method

public CreateMeshShape ( BulletWorld pWorld, int pIndicesCount, int indices, int pVerticesCount, float verticesAsFloats ) : BulletShape
pWorld BulletWorld
pIndicesCount int
indices int
pVerticesCount int
verticesAsFloats float
return BulletShape
        public override BulletShape CreateMeshShape(BulletWorld pWorld, int pIndicesCount, int[] indices,
            int pVerticesCount, float[] verticesAsFloats)
        {
            //DumpRaw(indices,verticesAsFloats,pIndicesCount,pVerticesCount);

            for (int iter = 0; iter < pVerticesCount; iter++)
            {
                if (verticesAsFloats[iter] > 0 && verticesAsFloats[iter] < 0.0001) verticesAsFloats[iter] = 0;
                if (verticesAsFloats[iter] < 0 && verticesAsFloats[iter] > -0.0001) verticesAsFloats[iter] = 0;
            }

            ObjectArray<int> indicesarr = new ObjectArray<int>(indices);
            ObjectArray<float> vertices = new ObjectArray<float>(verticesAsFloats);
            DumpRaw(indicesarr, vertices, pIndicesCount, pVerticesCount);
            DiscreteDynamicsWorld world = (pWorld as BulletWorldXNA).world;
            IndexedMesh mesh = new IndexedMesh();
            mesh.m_indexType = PHY_ScalarType.PHY_INTEGER;
            mesh.m_numTriangles = pIndicesCount / 3;
            mesh.m_numVertices = pVerticesCount;
            mesh.m_triangleIndexBase = indicesarr;
            mesh.m_vertexBase = vertices;
            mesh.m_vertexStride = 3;
            mesh.m_vertexType = PHY_ScalarType.PHY_FLOAT;
            mesh.m_triangleIndexStride = 3;

            TriangleIndexVertexArray tribuilder = new TriangleIndexVertexArray();
            tribuilder.AddIndexedMesh(mesh, PHY_ScalarType.PHY_INTEGER);
            BvhTriangleMeshShape meshShape = new BvhTriangleMeshShape(tribuilder, true, true);
            meshShape.SetMargin(world.WorldSettings.Params.collisionMargin);
            // world.UpdateSingleAabb(meshShape);
            return new BulletShapeXNA(meshShape, BSPhysicsShapeType.SHAPE_MESH);
        }
BSAPIXNA