コード例 #1
0
 internal void UpdateAfterSimulation10()
 {
     this.UpdateRigidBodyShape();
     if (this.m_voxelMap.Storage != null)
     {
         foreach (IMyEntity entity in this.m_nearbyEntities)
         {
             if (entity != null)
             {
                 bool          flag    = false;
                 MyPhysicsBody physics = entity.Physics as MyPhysicsBody;
                 if (((physics != null) && (physics.RigidBody != null)) && ((physics.RigidBody.Layer == 0x17) || (physics.RigidBody.Layer == 10)))
                 {
                     flag = true;
                 }
                 if ((((entity is MyCubeGrid) || flag) && !entity.MarkedForClose) && (entity.Physics != null))
                 {
                     BoundingBoxD xd;
                     this.GetPrediction(entity, out xd);
                     if (xd.Intersects(this.m_voxelMap.PositionComp.WorldAABB))
                     {
                         Vector3I           vectori;
                         Vector3I           vectori2;
                         HkUniformGridShape shape;
                         int num1;
                         if (flag || !UseLod1VoxelPhysics)
                         {
                             num1 = 0;
                         }
                         else
                         {
                             num1 = 1;
                         }
                         int          lod  = num1;
                         int          num2 = 1 << (lod & 0x1f);
                         BoundingBoxD xd2  = xd.TransformFast(this.m_voxelMap.PositionComp.WorldMatrixInvScaled);
                         xd2.Translate(this.m_voxelMap.SizeInMetresHalf);
                         Vector3 max = (Vector3)xd2.Max;
                         Vector3 min = (Vector3)xd2.Min;
                         this.ClampVoxelCoords(ref min, ref max, out vectori, out vectori2);
                         vectori  = vectori >> lod;
                         vectori2 = vectori2 >> lod;
                         int size = ((vectori2 - vectori) + 1).Size;
                         if (size >= m_cellsToGenerateBuffer.Length)
                         {
                             m_cellsToGenerateBuffer = new Vector3I[MathHelper.GetNearestBiggerPowerOfTwo(size)];
                         }
                         if (this.GetShape(lod, out shape))
                         {
                             if (shape.Base.IsZero)
                             {
                                 MyAnalyticsHelper.ReportBug("Null voxel shape", "SE-7366", true, @"E:\Repo1\Sources\Sandbox.Game\Engine\Voxels\MyVoxelPhysicsBody.cs", 680);
                             }
                             else
                             {
                                 int requiredCellsCount = shape.GetMissingCellsInRange(ref vectori, ref vectori2, m_cellsToGenerateBuffer);
                                 if (requiredCellsCount != 0)
                                 {
                                     BoundingBoxI box = new BoundingBoxI((vectori * 8) * num2, (Vector3I)(((vectori2 + 1) * 8) * num2));
                                     box.Translate(this.m_voxelMap.StorageMin);
                                     if ((requiredCellsCount > 0) && (this.m_voxelMap.Storage.Intersect(ref box, lod, true) != ContainmentType.Intersects))
                                     {
                                         this.SetEmptyShapes(lod, ref shape, requiredCellsCount);
                                     }
                                     else
                                     {
                                         for (int i = 0; i < requiredCellsCount; i++)
                                         {
                                             this.StartPrecalcJobPhysicsIfNeeded(lod, i);
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         this.ScheduleBatchJobs();
         if (this.m_bodiesInitialized)
         {
             this.CheckAndDiscardShapes();
         }
     }
 }