Пример #1
0
        internal void GenerateAllShapes()
        {
            var min = Vector3I.Zero;

            Vector3I storageSize = m_voxelMap.Size;
            Vector3I max         = new Vector3I(0, 0, 0);

            max.X = storageSize.X >> MyVoxelConstants.GEOMETRY_CELL_SIZE_IN_VOXELS_BITS;
            max.Y = storageSize.Y >> MyVoxelConstants.GEOMETRY_CELL_SIZE_IN_VOXELS_BITS;
            max.Z = storageSize.Z >> MyVoxelConstants.GEOMETRY_CELL_SIZE_IN_VOXELS_BITS;

            max += min;

            var args = new MyPrecalcJobPhysicsPrefetch.Args
            {
                GeometryCell  = new MyCellCoord(0, min),
                Storage       = m_voxelMap.Storage,
                TargetPhysics = this,
                Tracker       = m_workTracker,
            };

            for (var it = new Vector3I.RangeIterator(ref min, ref max);
                 it.IsValid();
                 it.GetNext(out args.GeometryCell.CoordInLod))
            {
                MyPrecalcJobPhysicsPrefetch.Start(args);
            }
        }
Пример #2
0
 internal void GenerateAllShapes()
 {
     if (this.m_mesher != null)
     {
         if (!this.m_bodiesInitialized)
         {
             this.CreateRigidBodies();
         }
         Vector3I zero = Vector3I.Zero;
         Vector3I size = this.m_voxelMap.Size;
         Vector3I end  = new Vector3I(0, 0, 0)
         {
             X = size.X >> 3,
             Y = size.Y >> 3,
             Z = size.Z >> 3
         };
         end = (Vector3I)(end + zero);
         MyPrecalcJobPhysicsPrefetch.Args args = new MyPrecalcJobPhysicsPrefetch.Args {
             GeometryCell  = new MyCellCoord(1, zero),
             Storage       = this.m_voxelMap.Storage,
             TargetPhysics = this,
             Tracker       = this.m_workTracker
         };
         Vector3I_RangeIterator iterator = new Vector3I_RangeIterator(ref zero, ref end);
         while (iterator.IsValid())
         {
             MyPrecalcJobPhysicsPrefetch.Start(args);
             iterator.GetNext(out args.GeometryCell.CoordInLod);
         }
     }
 }
Пример #3
0
        private void StartPrecalcJobPhysicsIfNeeded(int lod, int i)
        {
            MyCellCoord id = new MyCellCoord(lod, m_cellsToGenerateBuffer[i]);

            if (!this.m_workTracker.Exists(id))
            {
                MyPrecalcJobPhysicsPrefetch.Args args = new MyPrecalcJobPhysicsPrefetch.Args {
                    TargetPhysics = this,
                    Tracker       = this.m_workTracker,
                    GeometryCell  = id,
                    Storage       = this.m_voxelMap.Storage
                };
                MyPrecalcJobPhysicsPrefetch.Start(args);
            }
        }
Пример #4
0
        private void RequestShapeBlockingInternal(int x, int y, int z, out HkShape shape, out HkReferencePolicy refPolicy, bool lod1physics)
        {
            ProfilerShort.Begin("MyVoxelPhysicsBody.RequestShapeBlocking");

            if (!m_bodiesInitialized)
            {
                CreateRigidBodies();
            }

            int lod       = lod1physics ? 1 : 0;
            var cellCoord = new MyCellCoord(lod, new Vector3I(x, y, z));

            shape = HkShape.Empty;
            // shape must take ownership, otherwise shapes created here will leak, since I can't remove reference
            refPolicy = HkReferencePolicy.TakeOwnership;
            //MyPrecalcComponent.QueueJobCancel(m_workTracker, cellCoord);
            if (m_voxelMap.MarkedForClose)
            {
                ProfilerShort.End();
                return;
            }
            if (MyDebugDrawSettings.DEBUG_DRAW_REQUEST_SHAPE_BLOCKING)
            {
                BoundingBoxD aabb;
                MyVoxelCoordSystems.GeometryCellCoordToWorldAABB(m_voxelMap.PositionLeftBottomCorner, ref cellCoord, out aabb);
                MyRenderProxy.DebugDrawAABB(aabb, lod1physics ? Color.Yellow : Color.Red, 1, 1, true);
            }
            ProfilerShort.Begin("Generating geometry");
            MyIsoMesh geometryData = CreateMesh(m_voxelMap.Storage, cellCoord);

            ProfilerShort.End();

            if (!MyIsoMesh.IsEmpty(geometryData))
            {
                ProfilerShort.Begin("Shape from geometry");
                shape = CreateShape(geometryData, true);
                shape.AddReference();
                var args = new MyPrecalcJobPhysicsPrefetch.Args()
                {
                    GeometryCell = cellCoord, TargetPhysics = this, Tracker = m_workTracker, SimpleShape = shape
                };
                MyPrecalcJobPhysicsPrefetch.Start(args);
                m_needsShapeUpdate = true;
                ProfilerShort.End();
            }

            ProfilerShort.End();
        }
Пример #5
0
 public void PrefetchShapeOnRay(ref LineD ray)
 {
     if (this.m_mesher != null)
     {
         Vector3            vector;
         Vector3            vector2;
         HkUniformGridShape shape;
         int lod = UseLod1VoxelPhysics ? 1 : 0;
         MyVoxelCoordSystems.WorldPositionToLocalPosition(this.m_voxelMap.PositionLeftBottomCorner, ref ray.From, out vector);
         MyVoxelCoordSystems.WorldPositionToLocalPosition(this.m_voxelMap.PositionLeftBottomCorner, ref ray.To, out vector2);
         if (this.GetShape(lod, out shape))
         {
             if (m_cellsToGenerateBuffer.Length < 0x40)
             {
                 m_cellsToGenerateBuffer = new Vector3I[0x40];
             }
             int num2 = shape.GetHitCellsInRange(vector, vector2, m_cellsToGenerateBuffer);
             if (num2 != 0)
             {
                 for (int i = 0; i < num2; i++)
                 {
                     MyCellCoord id = new MyCellCoord(lod, m_cellsToGenerateBuffer[i]);
                     if (!this.m_workTracker.Exists(id))
                     {
                         MyPrecalcJobPhysicsPrefetch.Args args = new MyPrecalcJobPhysicsPrefetch.Args {
                             TargetPhysics = this,
                             Tracker       = this.m_workTracker,
                             GeometryCell  = id,
                             Storage       = this.m_voxelMap.Storage
                         };
                         MyPrecalcJobPhysicsPrefetch.Start(args);
                     }
                 }
             }
         }
     }
 }
        internal void GenerateAllShapes()
        {
            if (!m_bodiesInitialized) CreateRigidBodies();

            var min = Vector3I.Zero;

            Vector3I storageSize = m_voxelMap.Size;
            Vector3I max = new Vector3I(0, 0, 0);
            max.X = storageSize.X >> MyVoxelConstants.GEOMETRY_CELL_SIZE_IN_VOXELS_BITS;
            max.Y = storageSize.Y >> MyVoxelConstants.GEOMETRY_CELL_SIZE_IN_VOXELS_BITS;
            max.Z = storageSize.Z >> MyVoxelConstants.GEOMETRY_CELL_SIZE_IN_VOXELS_BITS;

            max += min;

            var args = new MyPrecalcJobPhysicsPrefetch.Args
            {
                GeometryCell = new MyCellCoord(1, min),
                Storage = m_voxelMap.Storage,
                TargetPhysics = this,
                Tracker = m_workTracker
            };
            for (var it = new Vector3I.RangeIterator(ref min, ref max);
                it.IsValid();
                it.GetNext(out args.GeometryCell.CoordInLod))
            {
                MyPrecalcJobPhysicsPrefetch.Start(args);
            }
        }
Пример #7
0
        private void RequestShapeBlockingInternal(int x, int y, int z, out HkShape shape, out HkReferencePolicy refPolicy, bool lod1physics)
        {
            ProfilerShort.Begin("MyVoxelPhysicsBody.RequestShapeBlocking");

            if (!m_bodiesInitialized) CreateRigidBodies();

            int lod = lod1physics ? 1 : 0;
            var cellCoord = new MyCellCoord(lod, new Vector3I(x, y, z));
            shape = HkShape.Empty;
            // shape must take ownership, otherwise shapes created here will leak, since I can't remove reference
            refPolicy = HkReferencePolicy.TakeOwnership;
            //MyPrecalcComponent.QueueJobCancel(m_workTracker, cellCoord);
            if (m_voxelMap.MarkedForClose)
            {
                ProfilerShort.End();
                return;
            }
            if (MyDebugDrawSettings.DEBUG_DRAW_REQUEST_SHAPE_BLOCKING)
            {
                BoundingBoxD aabb;
                MyVoxelCoordSystems.GeometryCellCoordToWorldAABB(m_voxelMap.PositionLeftBottomCorner, ref cellCoord, out aabb);
                MyRenderProxy.DebugDrawAABB(aabb, lod1physics ? Color.Yellow : Color.Red, 1, 1, true);
            }
            ProfilerShort.Begin("Generating geometry");
            MyIsoMesh geometryData = CreateMesh(m_voxelMap.Storage, cellCoord);
            ProfilerShort.End();

            if (!MyIsoMesh.IsEmpty(geometryData))
            {
                ProfilerShort.Begin("Shape from geometry");
                shape = CreateShape(geometryData, true);
                shape.AddReference();
                var args = new MyPrecalcJobPhysicsPrefetch.Args() {GeometryCell = cellCoord, TargetPhysics = this, Tracker = m_workTracker, SimpleShape = shape};
                MyPrecalcJobPhysicsPrefetch.Start(args);
                m_needsShapeUpdate = true;
                ProfilerShort.End();
            }

            ProfilerShort.End();
        }