Esempio n. 1
0
 private void RequestShapeBatchBlockingInternal(HkShapeBatch info, bool lod1physics)
 {
     if (!MyPhysics.InsideSimulation && !ReferenceEquals(Thread.CurrentThread, MyUtils.MainThread))
     {
         MyLog.Default.Error("Invalid request shape Thread id: " + Thread.CurrentThread.ManagedThreadId.ToString() + " Stack trace: " + Environment.StackTrace, Array.Empty <object>());
     }
     if (!this.m_voxelMap.MarkedForClose)
     {
         if (!this.m_bodiesInitialized)
         {
             this.CreateRigidBodies();
         }
         this.m_needsShapeUpdate = true;
         int count = info.Count;
         if (((count > 0x4e20) || (Interlocked.Add(ref this.m_voxelQueriesInLastFrames, count) >= 0x2710)) && (Interlocked.Exchange(ref this.m_hasExtendedCache, 1) == 0))
         {
             HkUniformGridShape shape;
             Interlocked.Increment(ref ActiveVoxelPhysicsBodiesWithExtendedCache);
             if (this.GetShape(lod1physics ? 1 : 0, out shape))
             {
                 shape.EnableExtendedCache();
             }
         }
         Parallel.For(0, count, delegate(int i) {
             Vector3I vectori;
             info.GetInfo(i, out vectori);
             int lod = lod1physics ? 1 : 0;
             MyCellCoord geometryCellCoord = new MyCellCoord(lod, vectori);
             if (MyDebugDrawSettings.DEBUG_DRAW_REQUEST_SHAPE_BLOCKING)
             {
                 BoundingBoxD xd;
                 MyVoxelCoordSystems.GeometryCellCoordToWorldAABB(this.m_voxelMap.PositionLeftBottomCorner, ref geometryCellCoord, out xd);
                 MyRenderProxy.DebugDrawAABB(xd, lod1physics ? Color.Yellow : Color.Red, 1f, 1f, false, false, false);
             }
             bool flag = false;
             HkBvCompressedMeshShape empty        = (HkBvCompressedMeshShape)HkShape.Empty;
             MyPrecalcJobPhysicsPrefetch prefetch = this.m_workTracker.Cancel(geometryCellCoord);
             if (((prefetch != null) && prefetch.ResultComplete) && (Interlocked.Exchange(ref prefetch.Taken, 1) == 0))
             {
                 flag  = true;
                 empty = prefetch.Result;
             }
             if (!flag)
             {
                 VrVoxelMesh mesh = this.CreateMesh(geometryCellCoord);
                 empty            = this.CreateShape(mesh, lod);
                 if (mesh != null)
                 {
                     mesh.Dispose();
                 }
             }
             info.SetResult(i, ref empty);
         }, 1, WorkPriority.VeryHigh, new WorkOptions?(Parallel.DefaultOptions.WithDebugInfo(MyProfiler.TaskType.Voxels, "RequestBatch")), true);
     }
 }
Esempio n. 2
0
 private void RequestShapeBlockingLod1(HkShapeBatch batch)
 {
     this.RequestShapeBatchBlockingInternal(batch, true);
 }
Esempio n. 3
0
 private void RequestShapeBlocking(HkShapeBatch batch)
 {
     this.RequestShapeBatchBlockingInternal(batch, false);
 }