public static CompoundShape Create(GImpactMeshShape gImpactMesh, float depth)
 {
     CompoundShape colShape = new CompoundShape();
     using (var cb = new MyInternalTriangleIndexCallback(colShape, gImpactMesh, depth))
     {
         Vector3 aabbMin, aabbMax;
         gImpactMesh.GetAabb(Matrix.Identity, out aabbMin, out aabbMax);
         gImpactMesh.MeshInterface.InternalProcessAllTriangles(cb, aabbMin, aabbMax);
     }
     return colShape;
 }
Exemplo n.º 2
0
        public static CompoundShape Create(GImpactMeshShape gImpactMesh, float depth)
        {
            CompoundShape colShape = new CompoundShape();

            using (var cb = new MyInternalTriangleIndexCallback(colShape, gImpactMesh, depth))
            {
                Vector3 aabbMin, aabbMax;
                gImpactMesh.GetAabb(Matrix.Identity, out aabbMin, out aabbMax);
                gImpactMesh.MeshInterface.InternalProcessAllTriangles(cb, aabbMin, aabbMax);
            }
            return(colShape);
        }
        public static CompoundShape Create(GImpactMeshShape impactMesh, Scalar depth)
        {
            var shape = new CompoundShape();

            using (var callback = new MyInternalTriangleIndexCallback(shape, impactMesh, depth))
            {
                Vector3 aabbMin, aabbMax;
                impactMesh.GetAabb(Matrix.Identity, out aabbMin, out aabbMax);
                impactMesh.MeshInterface.InternalProcessAllTriangles(callback, aabbMin, aabbMax);
            }
            return(shape);
        }
Exemplo n.º 4
0
        public override void Run()
        {
            var conf = new DefaultCollisionConfiguration();
            var dispatcher = new CollisionDispatcher(conf);
            var broadphase = new AxisSweep3(new Vector3(-1000, -1000, -1000), new Vector3(1000, 1000, 1000));
            world = new DiscreteDynamicsWorld(dispatcher, broadphase, null, conf);

            var indexVertexArray = new TriangleIndexVertexArray(TorusMesh.Indices, TorusMesh.Vertices);
            foreach (var indexedMesh in indexVertexArray.IndexedMeshArray)
            {
                indexedMesh.ToString();
            }
            AddToDisposeQueue(indexVertexArray);

            var gImpactMesh = new GImpactMeshShape(indexVertexArray);
            Vector3 aabbMin, aabbMax;
            gImpactMesh.GetAabb(Matrix.Identity, out aabbMin, out aabbMax);
            CreateBody(1.0f, gImpactMesh, Vector3.Zero);
            AddToDisposeQueue(gImpactMesh);
            gImpactMesh = null;

            var triangleMesh = new BvhTriangleMeshShape(indexVertexArray, true);
            triangleMesh.CalculateLocalInertia(1.0f);
            triangleMesh.GetAabb(Matrix.Identity, out aabbMin, out aabbMax);
            CreateBody(1.0f, triangleMesh, Vector3.Zero);
            AddToDisposeQueue(triangleMesh);
            triangleMesh = null;

            indexVertexArray = null;

            AddToDisposeQueue(conf);
            AddToDisposeQueue(dispatcher);
            AddToDisposeQueue(broadphase);
            AddToDisposeQueue(world);

            //conf.Dispose();
            conf = null;
            //dispatcher.Dispose();
            dispatcher = null;
            //broadphase.Dispose();
            broadphase = null;
            for (int i = 0; i < 600; i++)
            {
                world.StepSimulation(1.0f / 60.0f);
            }
            world.Dispose();
            world = null;

            ForceGC();
            TestWeakRefs();
            ClearRefs();
        }