Ejemplo n.º 1
0
        internal MyVoxelPhysicsBody(MyVoxelBase voxelMap, float phantomExtend, float predictionSize = 3.0f) : base(voxelMap, RigidBodyFlag.RBF_STATIC)
        {
            m_predictionSize = predictionSize;
            m_phantomExtend  = phantomExtend;
            m_voxelMap       = voxelMap;
            Vector3I storageSize = m_voxelMap.Size;
            Vector3I numCels     = storageSize >> MyVoxelConstants.GEOMETRY_CELL_SIZE_IN_VOXELS_BITS;

            m_cellsOffset = m_voxelMap.StorageMin >> MyVoxelConstants.GEOMETRY_CELL_SIZE_IN_VOXELS_BITS;

            HkUniformGridShape shape;
            HkRigidBody        lod1rb = null;

            if (MyFakes.USE_LOD1_VOXEL_PHYSICS)
            {
                shape = new HkUniformGridShape(
                    new HkUniformGridShapeArgs()
                {
                    CellsCount = numCels,
                    CellSize   = MyVoxelConstants.GEOMETRY_CELL_SIZE_IN_METRES,
                    CellOffset = MyVoxelConstants.VOXEL_SIZE_IN_METRES_HALF,
                    CellExpand = MyVoxelConstants.VOXEL_SIZE_IN_METRES,
                });
                shape.SetShapeRequestHandler(RequestShapeBlockingLod1);

                CreateFromCollisionObject(shape, -m_voxelMap.SizeInMetresHalf, m_voxelMap.WorldMatrix, collisionFilter: MyPhysics.VoxelLod1CollisionLayer);
                shape.Base.RemoveReference();
                lod1rb    = RigidBody;
                RigidBody = null;
            }
            shape = new HkUniformGridShape(
                new HkUniformGridShapeArgs()
            {
                CellsCount = numCels,
                CellSize   = MyVoxelConstants.GEOMETRY_CELL_SIZE_IN_METRES,
                CellOffset = MyVoxelConstants.VOXEL_SIZE_IN_METRES_HALF,
                CellExpand = MyVoxelConstants.VOXEL_SIZE_IN_METRES,
            });
            shape.SetShapeRequestHandler(RequestShapeBlocking);

            CreateFromCollisionObject(shape, -m_voxelMap.SizeInMetresHalf, m_voxelMap.WorldMatrix, collisionFilter: MyPhysics.VoxelCollisionLayer);
            shape.Base.RemoveReference();
            if (MyFakes.USE_LOD1_VOXEL_PHYSICS)
            {
                RigidBody2 = lod1rb;
            }
            if (ENABLE_AABB_PHANTOM)
            {
                m_aabbPhantom = new Havok.HkpAabbPhantom(new BoundingBox(Vector3.Zero, m_voxelMap.SizeInMetres), 0);
                m_aabbPhantom.CollidableAdded   = AabbPhantom_CollidableAdded;
                m_aabbPhantom.CollidableRemoved = AabbPhantom_CollidableRemoved;
            }

            if (MyFakes.ENABLE_PHYSICS_HIGH_FRICTION)
            {
                Friction = 0.65f;
            }

            MaterialType = MyMaterialType.ROCK;
        }
        internal MyVoxelPhysicsBody(MyVoxelMap voxelMap): base(voxelMap, RigidBodyFlag.RBF_STATIC)
        {
            m_voxelMap = voxelMap;
            Vector3I storageSize = m_voxelMap.Size;
            Vector3I numCels = storageSize >> MyVoxelConstants.GEOMETRY_CELL_SIZE_IN_VOXELS_BITS;
            m_cellsOffset = m_voxelMap.StorageMin >> MyVoxelConstants.GEOMETRY_CELL_SIZE_IN_VOXELS_BITS;

            HkUniformGridShape shape = new HkUniformGridShape(
                new HkUniformGridShapeArgs()
                {
                    CellsCount = numCels,
                    CellSize = MyVoxelConstants.GEOMETRY_CELL_SIZE_IN_METRES,
                    CellOffset = MyVoxelConstants.VOXEL_SIZE_IN_METRES_HALF,
                    CellExpand = MyVoxelConstants.VOXEL_SIZE_IN_METRES,
                });
            shape.SetShapeRequestHandler(RequestShapeBlocking);

            CreateFromCollisionObject(shape, -m_voxelMap.SizeInMetresHalf, m_voxelMap.WorldMatrix, collisionFilter: MyPhysics.StaticCollisionLayer);
            shape.Base.RemoveReference();

            if (ENABLE_AABB_PHANTOM)
            {
                m_aabbPhantom = new Havok.HkpAabbPhantom(new BoundingBox(Vector3.Zero, m_voxelMap.SizeInMetres), 0);
                m_aabbPhantom.CollidableAdded = AabbPhantom_CollidableAdded;
                m_aabbPhantom.CollidableRemoved = AabbPhantom_CollidableRemoved;
            }

            if (MyFakes.ENABLE_PHYSICS_HIGH_FRICTION)
                Friction = 0.65f;

            MaterialType = Sandbox.Common.MyMaterialType.ROCK;
        }
Ejemplo n.º 3
0
        public override void Close()
        {
            base.Close();
            m_workTracker.CancelAll();
            if (RunningBatchTask != null)
            {
                RunningBatchTask.Cancel();
                RunningBatchTask = null;
            }

            if (ENABLE_AABB_PHANTOM)
            {
                m_aabbPhantom.Dispose();
                m_aabbPhantom = null;
            }
        }
Ejemplo n.º 4
0
 public override void Close()
 {
     base.Close();
     this.m_workTracker.CancelAll();
     for (int i = 0; i < this.RunningBatchTask.Length; i++)
     {
         if (this.RunningBatchTask[i] != null)
         {
             this.RunningBatchTask[i].Cancel();
             this.RunningBatchTask[i] = null;
         }
     }
     if (this.m_aabbPhantom != null)
     {
         this.m_aabbPhantom.Dispose();
         this.m_aabbPhantom = null;
     }
 }
Ejemplo n.º 5
0
        public override void Close()
        {
            base.Close();
            m_workTracker.CancelAll();

            for (int lod = 0; lod < RunningBatchTask.Length; ++lod)
            {
                if (RunningBatchTask[lod] != null)
                {
                    RunningBatchTask[lod].Cancel();
                    RunningBatchTask[lod] = null;
                }
            }

            if (ENABLE_AABB_PHANTOM && m_aabbPhantom != null)
            {
                m_aabbPhantom.Dispose();
                m_aabbPhantom = null;
            }
        }
 private void CreatePhantom(BoundingBox boundingBox)
 {
     m_aabbPhantom = new HkpAabbPhantom(boundingBox, 0);
     m_aabbPhantom.CollidableAdded = AabbPhantom_CollidableAdded;
     m_aabbPhantom.CollidableRemoved = AabbPhantom_CollidableRemoved;
 }
        public override void Close()
        {
            base.Close();
            m_workTracker.CancelAll();
            if (RunningBatchTask != null)
            {
                RunningBatchTask.Cancel();
                RunningBatchTask = null;
            }

            if (ENABLE_AABB_PHANTOM && m_aabbPhantom != null)
            {
                m_aabbPhantom.Dispose();
                m_aabbPhantom = null;
            }
        }
        public override void Close()
        {
            base.Close();
            m_workTracker.CancelAll();

            for (int lod = 0; lod < RunningBatchTask.Length; ++lod)
            {
                if (RunningBatchTask[lod] != null)
                {
                    RunningBatchTask[lod].Cancel();
                    RunningBatchTask[lod] = null;
                }
            }

            if (ENABLE_AABB_PHANTOM && m_aabbPhantom != null)
            {
                m_aabbPhantom.Dispose();
                m_aabbPhantom = null;
            }
        }
Ejemplo n.º 9
0
 private void CreatePhantom(BoundingBox boundingBox)
 {
     m_aabbPhantom = new HkpAabbPhantom(boundingBox, 0);
     m_aabbPhantom.CollidableAdded   = AabbPhantom_CollidableAdded;
     m_aabbPhantom.CollidableRemoved = AabbPhantom_CollidableRemoved;
 }
Ejemplo n.º 10
0
 private void CreatePhantom(BoundingBox boundingBox)
 {
     this.m_aabbPhantom = new HkpAabbPhantom(boundingBox, 0);
     this.m_aabbPhantom.CollidableAdded   = new CollidableAddedDelegate(this.AabbPhantom_CollidableAdded);
     this.m_aabbPhantom.CollidableRemoved = new CollidableRemovedDelegate(this.AabbPhantom_CollidableRemoved);
 }