예제 #1
0
        public override void Draw()
        {
            base.Draw();
            if (OnDraw != null)
            {
                try
                {
                    OnDraw();
                }
                catch (Exception e)
                {
                    OnDraw = null;
                }
            }

            foreach (var entry in AABBsToDraw)
            {
                MyRenderProxy.DebugDrawAABB(entry.Item1, entry.Item2, 1f, 1f, false);
            }

            foreach (var entry in MatricesToDraw)
            {
                MyRenderProxy.DebugDrawAxis(entry.Item1, 1f, false);
                MyRenderProxy.DebugDrawOBB(entry.Item1, entry.Item2, 1f, false, false);
            }
        }
예제 #2
0
        internal void DebugDraw(Vector3I sectorPos, float sectorSize)
        {
            using (m_instancePartsLock.AcquireSharedUsing())
            {
                foreach (var part in m_instanceParts.Values)
                {
                    foreach (var data in part.InstanceData)
                    {
                        var itemWorldPosition = Vector3D.Transform(data.InstanceData.LocalMatrix.Translation, m_sectorMatrix);

                        var dist = (itemWorldPosition - Sandbox.Game.World.MySector.MainCamera.Position).Length();
                        if (dist < 30)
                        {
                            MyRenderProxy.DebugDrawText3D(itemWorldPosition, part.SubtypeId.ToString(), Color.White, 0.7f, true);
                        }
                    }
                }
            }

            //BoundingBoxD bb = new BoundingBoxD(sectorPos * sectorSize, (sectorPos + Vector3I.One) * sectorSize);
            //BoundingBoxD bb2 = new BoundingBoxD(m_AABB.Min, m_AABB.Max);
            //bb2.Min = Vector3D.Max(bb2.Min, bb.Min);
            //bb2.Max = Vector3D.Min(bb2.Max, bb.Max);
            //MyRenderProxy.DebugDrawAABB(bb, Color.Orange, 1.0f, 1.0f, true);
            //MyRenderProxy.DebugDrawAABB(bb2, Color.OrangeRed, 1.0f, 1.0f, true);

            MyRenderProxy.DebugDrawAABB(SectorWorldBox, Color.OrangeRed, 1.0f, 1.0f, true);
        }
예제 #3
0
 public override void Draw()
 {
     base.Draw();
     if (OnDraw != null)
     {
         try
         {
             OnDraw();
         }
         catch (Exception)
         {
             OnDraw = null;
         }
     }
     foreach (Tuple <BoundingBoxD, Color> tuple in AABBsToDraw)
     {
         MyRenderProxy.DebugDrawAABB(tuple.Item1, tuple.Item2, 1f, 1f, false, false, false);
     }
     foreach (Tuple <Matrix, Color> tuple2 in MatricesToDraw)
     {
         MyRenderProxy.DebugDrawAxis(tuple2.Item1, 1f, false, false, false);
         MyRenderProxy.DebugDrawOBB(tuple2.Item1, tuple2.Item2, 1f, false, false, true, false);
     }
     foreach (Tuple <Vector3, Vector3, Color> tuple3 in LinesToDraw)
     {
         MyRenderProxy.DebugDrawLine3D(tuple3.Item1, tuple3.Item2, tuple3.Item3, tuple3.Item3, false, false);
     }
 }
예제 #4
0
 internal void DebugDraw(Vector3I sectorPos, float sectorSize)
 {
     using (this.m_instancePartsLock.AcquireSharedUsing())
     {
         foreach (MyModelInstanceData data in this.m_instanceParts.Values)
         {
             using (data.InstanceBufferLock.AcquireSharedUsing())
             {
                 foreach (KeyValuePair <int, MyInstanceData> pair in data.InstanceData)
                 {
                     MyInstanceData data2       = pair.Value;
                     Matrix         localMatrix = data2.LocalMatrix;
                     Vector3D       vectord     = Vector3D.Transform(localMatrix.Translation, this.m_sectorMatrix);
                     BoundingBox    modelBox    = data.ModelBox;
                     MyRenderProxy.DebugDrawOBB(Matrix.Rescale(data2.LocalMatrix * this.m_sectorMatrix, modelBox.HalfExtents * 2f), Color.OrangeRed, 0.5f, true, true, true, false);
                     if (Vector3D.Distance(MySector.MainCamera.Position, vectord) < 250.0)
                     {
                         MyRenderProxy.DebugDrawText3D(vectord, data.SubtypeId.ToString(), Color.White, 0.7f, true, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, -1, false);
                     }
                 }
             }
         }
     }
     MyRenderProxy.DebugDrawAABB(this.SectorWorldBox, Color.OrangeRed, 1f, 1f, true, false, false);
 }
예제 #5
0
        public virtual void DebugDraw()
        {
            Color red = Color.Red;

            if (this.CustomDebugColor != null)
            {
                red = this.CustomDebugColor.Value;
            }
            if (this.m_triggerType == TriggerType.AABB)
            {
                MyRenderProxy.DebugDrawAABB(this.m_AABB, (this.m_queryResult.Count == 0) ? red : Color.Green, 1f, 1f, false, false, false);
            }
            else
            {
                MyRenderProxy.DebugDrawSphere(this.m_boundingSphere.Center, (float)this.m_boundingSphere.Radius, (this.m_queryResult.Count == 0) ? red : Color.Green, 1f, false, false, true, false);
            }
            if (base.Entity.Parent != null)
            {
                MyRenderProxy.DebugDrawLine3D(this.Center, base.Entity.Parent.PositionComp.GetPosition(), Color.Yellow, Color.Green, false, false);
            }
            foreach (MyEntity local1 in this.m_queryResult)
            {
                MyRenderProxy.DebugDrawAABB(local1.PositionComp.WorldAABB, Color.Yellow, 1f, 1f, false, false, false);
                MatrixD worldMatrix = base.Entity.WorldMatrix;
                MyRenderProxy.DebugDrawLine3D(local1.WorldMatrix.Translation, worldMatrix.Translation, Color.Yellow, Color.Green, false, false);
            }
        }
        void DrawTrashAdminView()
        {
            float metric;
            var   state = MyTrashRemoval.GetTrashState(m_grid, MyTrashRemoval.PreviewSettings);
            var   color = Color.Green;
            var   aabb  = m_grid.PositionComp.WorldAABB;

            if (state != MyTrashRemovalFlags.None)
            {
                color = Color.Red;
                string name = MyTrashRemoval.GetName(state);

                if (state == MyTrashRemovalFlags.WithBlockCount)
                {
                    name = string.Format(name, MyTrashRemoval.PreviewSettings.BlockCountThreshold);
                    if (m_grid.BlocksCount < MyTrashRemoval.PreviewSettings.BlockCountThreshold)
                    {
                        color = Color.Green;
                    }
                }
                else if (state == MyTrashRemovalFlags.DistanceFromPlayer)
                {
                    name = string.Format(name, MyTrashRemoval.PreviewSettings.PlayerDistanceThreshold);
                }

                MyRenderProxy.DebugDrawText3D(aabb.Center, name, color, 0.7f, false, VRage.Utils.MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER);
            }
            MyRenderProxy.DebugDrawAABB(aabb, color, 1, 1, false);
        }
        public virtual void DebugDraw()
        {
            var defaultColor = Color.Red;

            if (CustomDebugColor.HasValue)
            {
                defaultColor = CustomDebugColor.Value;
            }

            if (m_triggerType == TriggerType.AABB)
            {
                MyRenderProxy.DebugDrawAABB(m_AABB, m_queryResult.Count == 0 ? defaultColor : Color.Green, 1, 1, false);
            }
            else
            {
                MyRenderProxy.DebugDrawSphere(m_boundingSphere.Center, (float)m_boundingSphere.Radius, m_queryResult.Count == 0 ? defaultColor : Color.Green, 1, false);
            }

            if (Entity.Parent != null)
            {
                MyRenderProxy.DebugDrawLine3D(Center, Entity.Parent.PositionComp.GetPosition(), Color.Yellow, Color.Green, false);
            }

            foreach (var e in m_queryResult)
            {
                MyRenderProxy.DebugDrawAABB(e.PositionComp.WorldAABB, Color.Yellow, 1, 1, false);
                MyRenderProxy.DebugDrawLine3D(e.WorldMatrix.Translation, Entity.WorldMatrix.Translation, Color.Yellow, Color.Green, false);
            }
        }
예제 #8
0
 public void DebugDraw(ref Matrix drawMatrix, MyWingedEdgeMesh mesh)
 {
     Dictionary <Vector3I, int> .Enumerator enumerator = this.m_outerEdgePoints.EnumerateBins();
     for (int i = 0; enumerator.MoveNext(); i++)
     {
         int binIndex = MyCestmirDebugInputComponent.BinIndex;
         if ((binIndex == this.m_outerEdgePoints.InvalidIndex) || (i == binIndex))
         {
             BoundingBoxD xd;
             BoundingBoxD xd2;
             Vector3I     key   = enumerator.Current.Key;
             int          index = enumerator.Current.Value;
             this.m_outerEdgePoints.GetLocalBinBB(ref key, out xd);
             xd2.Min = Vector3D.Transform(xd.Min, drawMatrix);
             xd2.Max = Vector3D.Transform(xd.Max, drawMatrix);
             while (true)
             {
                 if (index == this.m_outerEdgePoints.InvalidIndex)
                 {
                     MyRenderProxy.DebugDrawAABB(xd2, Color.PowderBlue, 1f, 1f, false, false, false);
                     break;
                 }
                 Vector3 point = this.m_outerEdgePoints.GetPoint(index);
                 MyWingedEdgeMesh.Edge edge = mesh.GetEdge(this.m_outerEdgePoints.GetData(index).EdgeIndex);
                 Vector3  vertexPosition    = mesh.GetVertexPosition(edge.Vertex2);
                 Vector3D pointTo           = Vector3D.Transform(point, drawMatrix);
                 MyRenderProxy.DebugDrawArrow3D(Vector3D.Transform((mesh.GetVertexPosition(edge.Vertex1) + vertexPosition) * 0.5f, drawMatrix), pointTo, Color.Yellow, new Color?(Color.Yellow), false, 0.1, null, 0.5f, false);
                 index = this.m_outerEdgePoints.GetNextBinIndex(index);
             }
         }
     }
 }
        private void KillEveryoneAround()
        {
            if (MySession.Static.LocalCharacter == null || !Sync.IsServer || !MySession.Static.IsAdmin ||
                !MySession.Static.IsAdminMenuEnabled)
            {
                return;
            }

            Vector3D     myPosition = MySession.Static.LocalCharacter.PositionComp.GetPosition();
            Vector3D     offset     = new Vector3D(25, 25, 25);
            BoundingBoxD bb         = new BoundingBoxD(myPosition - offset, myPosition + offset);

            List <MyEntity> entities = new List <MyEntity>();

            MyGamePruningStructure.GetAllEntitiesInBox(ref bb, entities);

            foreach (var entity in entities)
            {
                var character = entity as MyCharacter;
                if (character != null && entity != MySession.Static.LocalCharacter)
                {
                    character.DoDamage(1000000, MyDamageType.Unknown, true);
                }
            }

            MyRenderProxy.DebugDrawAABB(bb, Color.Red, 0.5f, 1f, true, true);
        }
예제 #10
0
 private void DrawDebugTarget()
 {
     if (this.DebugTarget != null)
     {
         MyRenderProxy.DebugDrawSphere(this.DebugTarget.Value, 0.2f, Color.Red, 0f, false, false, true, false);
         MyRenderProxy.DebugDrawAABB(this.m_debugTargetAABB, Color.Green, 1f, 1f, true, false, false);
     }
 }
예제 #11
0
 public void DebugDraw()
 {
     MyRenderProxy.DebugDrawAABB(m_triggerAABB, m_queryResult.Count == 0 ? Color.Red : Color.Green, 1, 1, false);
     foreach (var e in m_queryResult)
     {
         MyRenderProxy.DebugDrawAABB(e.PositionComp.WorldAABB, Color.Yellow, 1, 1, false);
         MyRenderProxy.DebugDrawLine3D(e.WorldMatrix.Translation, Entity.WorldMatrix.Translation, Color.Yellow, Color.Green, false);
     }
 }
예제 #12
0
 private void DebugDrawJob(Color c, BoundingBoxD wAABB)
 {
     ////return;
     //var cam = CameraMatrixGetter();
     //wAABB = wAABB.Translate(-m_parent.m_worldMatrix.Translation);
     //wAABB = wAABB.Transform(MatrixD.CreateScale(0.001f));
     //wAABB = wAABB.Translate(-wAABB.Center / 2 + cam.Translation);
     MyRenderProxy.DebugDrawAABB(wAABB, c, 1, 1, false);
 }
예제 #13
0
        public override void DebugDraw()
        {
            base.DebugDraw();

            if (m_aabbPhantom != null && MyDebugDrawSettings.DEBUG_DRAW_VOXEL_MAP_AABB && IsInWorld)
            {
                var offset = ClusterToWorld(Vector3D.Zero);

                BoundingBoxD phantom = (BoundingBoxD)m_aabbPhantom.Aabb;
                phantom.Translate(offset);

                MyRenderProxy.DebugDrawAABB(phantom, Color.Orange, 1.0f, 1.0f, true);
            }

            if (MyDebugDrawSettings.DEBUG_DRAW_VOXEL_PHYSICS_PREDICTION)
            {
                foreach (var entity in m_nearbyEntities)
                {
                    if (entity.MarkedForClose)
                    {
                        continue;
                    }

                    var worldAabb = entity.WorldAABB;
                    MyRenderProxy.DebugDrawAABB(worldAabb, Color.Bisque, 1f, 1f, true);
                    MyRenderProxy.DebugDrawLine3D(GetWorldMatrix().Translation, worldAabb.Center, Color.Bisque, Color.BlanchedAlmond, true);

                    BoundingBoxD predAabb;
                    GetPrediction(entity, out predAabb);
                    MyRenderProxy.DebugDrawAABB(predAabb, Color.Crimson, 1f, 1f, true);
                }

                using (var batch = MyRenderProxy.DebugDrawBatchAABB(GetWorldMatrix(), new Color(Color.Cyan, 0.2f), true, false))
                {
                    int i = 0;
                    foreach (var entry in m_workTracker)
                    {
                        i++;
                        BoundingBoxD localAabb;
                        var          localCell = entry.Key;

                        localAabb.Min  = localCell.CoordInLod << localCell.Lod;
                        localAabb.Min *= MyVoxelConstants.GEOMETRY_CELL_SIZE_IN_METRES;
                        localAabb.Min -= m_voxelMap.SizeInMetresHalf;
                        localAabb.Max  = localAabb.Min + MyVoxelConstants.GEOMETRY_CELL_SIZE_IN_METRES;

                        batch.Add(ref localAabb);
                        if (i > 250)
                        {
                            break;
                        }
                    }
                }
            }
        }
예제 #14
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);
     }
 }
예제 #15
0
        public override bool IsAnyAabbCornerInside(BoundingBoxD worldAabb)
        {
            MyRenderProxy.DebugDrawAABB(worldAabb, Color.White, 1f, 1f, true);

            unsafe
            {
                const int cornerCount = 8;
                Vector3D *corners     = stackalloc Vector3D[cornerCount];
                worldAabb.GetCornersUnsafe(corners);
                return(IsAnyPointInside(corners, cornerCount));
            }
        }
예제 #16
0
 public void DebugDraw()
 {
     if (MyFakes.DEBUG_DRAW_NAVMESH_EXPLORED_HL_CELLS)
     {
         foreach (Vector3I vectori in this.m_exploredCells)
         {
             BoundingBoxD xd;
             MyVoxelCoordSystems.GeometryCellCoordToWorldAABB(this.m_mesh.VoxelMapReferencePosition, ref vectori, out xd);
             MyRenderProxy.DebugDrawAABB(xd, Color.Sienna, 1f, 1f, false, false, false);
         }
     }
     if (MyFakes.DEBUG_DRAW_NAVMESH_FRINGE_HL_CELLS)
     {
         foreach (ulong num in this.m_navmeshComponents.GetPresentCells())
         {
             MyCellCoord coord = new MyCellCoord();
             coord.SetUnpack(num);
             Vector3I coordInLod = coord.CoordInLod;
             if (this.m_exploredCells.Contains(ref coordInLod))
             {
                 MyNavmeshComponents.CellInfo cellInfo = new MyNavmeshComponents.CellInfo();
                 if (this.m_navmeshComponents.TryGetCell(num, out cellInfo))
                 {
                     int num2 = 0;
                     while (num2 < cellInfo.ComponentNum)
                     {
                         int index = cellInfo.StartingIndex + num2;
                         MyHighLevelPrimitive        primitive      = this.m_mesh.HighLevelGroup.GetPrimitive(index);
                         Base6Directions.Direction[] enumDirections = Base6Directions.EnumDirections;
                         int num4 = 0;
                         while (true)
                         {
                             if (num4 >= enumDirections.Length)
                             {
                                 num2++;
                                 break;
                             }
                             Base6Directions.Direction      dir           = enumDirections[num4];
                             Base6Directions.DirectionFlags directionFlag = Base6Directions.GetDirectionFlag(dir);
                             if (!cellInfo.ExploredDirections.HasFlag(directionFlag) && !this.m_exploredCells.Contains((Vector3I)(coordInLod + Base6Directions.GetIntVector(dir))))
                             {
                                 Vector3 vector = Base6Directions.GetVector(dir);
                                 MyRenderProxy.DebugDrawLine3D(primitive.WorldPosition, primitive.WorldPosition + (vector * 3f), Color.Red, Color.Red, false, false);
                             }
                             num4++;
                         }
                     }
                 }
             }
         }
     }
 }
예제 #17
0
 public void DebugDraw()
 {
     this.m_navmeshOBBs.DebugDraw();
     this.m_navInputMesh.DebugDraw();
     MyRenderProxy.DebugDrawOBB(this.m_extendedBaseOBB, Color.White, 0f, true, false, false);
     using (List <BoundingBoxD> .Enumerator enumerator = this.m_groundCaptureAABBs.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             MyRenderProxy.DebugDrawAABB(enumerator.Current, Color.Yellow, 1f, 1f, true, false, false);
         }
     }
 }
예제 #18
0
        public override void Draw()
        {
            base.Draw();
            foreach (var line in m_lines)
            {
                MyRenderProxy.DebugDrawLine3D(line.From, line.To, line.ColorFrom, line.ColorTo, line.DepthRead);
            }

            if (ShowDebugDrawTests)
            {
                Vector3D position = new Vector3D(1000000000.0, 1000000000.0, 1000000000.0);
                MyRenderProxy.DebugDrawLine3D(position, position + Vector3D.Up, Color.Red, Color.Blue, true);
                position += Vector3D.Left;
                MyRenderProxy.DebugDrawLine3D(position, position + Vector3D.Up, Color.Red, Color.Blue, false);

                MyRenderProxy.DebugDrawLine2D(new Vector2(10, 10), new Vector2(50, 50), Color.Red, Color.Blue);

                position += Vector3D.Left;
                MyRenderProxy.DebugDrawPoint(position, Color.White, true);
                position += Vector3D.Left;
                MyRenderProxy.DebugDrawPoint(position, Color.White, false);

                position += Vector3D.Left;
                MyRenderProxy.DebugDrawSphere(position, 0.5f, Color.White, 1.0f, true);

                position += Vector3D.Left;
                MyRenderProxy.DebugDrawAABB(new BoundingBoxD(position - Vector3D.One * 0.5, position + Vector3D.One * 0.5), Color.White, 1.0f, 1.0f, true);

                position += Vector3D.Left;
                //MyRenderProxy.DebugDrawCone(position, Vector3D.Up, Vector3D.One, Color.Yellow, true);
                position += Vector3D.Left;
                MyRenderProxy.DebugDrawAxis(MatrixD.CreateFromTransformScale(Quaternion.Identity, position, Vector3D.One * 0.5), 1.0f, true);
                position += Vector3D.Left;
                MyRenderProxy.DebugDrawOBB(new MyOrientedBoundingBoxD(position, Vector3D.One * 0.5, Quaternion.Identity), Color.White, 1.0f, true, false);
                position += Vector3D.Left;
                MyRenderProxy.DebugDrawCylinder(MatrixD.CreateFromTransformScale(Quaternion.Identity, position, Vector3D.One * 0.5), Color.White, 1.0f, true, true);
                position += Vector3D.Left;
                MyRenderProxy.DebugDrawTriangle(position, position + Vector3D.Up, position + Vector3D.Left, Color.White, true, true);
                position += Vector3D.Left;
                var msg = MyRenderProxy.PrepareDebugDrawTriangles();
                msg.AddTriangle(position, position + Vector3D.Up, position + Vector3D.Left);
                msg.AddTriangle(position, position + Vector3D.Left, position - Vector3D.Up);
                MyRenderProxy.DebugDrawTriangles(msg, MatrixD.Identity, Color.White, true, true);
                position += Vector3D.Left;
                MyRenderProxy.DebugDrawCapsule(position, position + Vector3D.Up, 0.5f, Color.White, true);
                MyRenderProxy.DebugDrawText2D(new Vector2(100, 100), "text", Color.Green, 1.0f);
                position += Vector3D.Left;
                MyRenderProxy.DebugDrawText3D(position, "3D Text", Color.Blue, 1.0f, true);
            }
        }
예제 #19
0
        public override void DebugDraw()
        {
            Vector3D positionLeftBottomCorner = this.m_voxelMap.PositionLeftBottomCorner;

            if (MyDebugDrawSettings.DEBUG_DRAW_VOXEL_MAP_AABB)
            {
                MyRenderProxy.DebugDrawAABB(this.m_voxelMap.PositionComp.WorldAABB, Color.White, 0.2f, 1f, true, false, false);
                MyRenderProxy.DebugDrawLine3D(positionLeftBottomCorner, positionLeftBottomCorner + new Vector3(1f, 0f, 0f), Color.Red, Color.Red, true, false);
                MyRenderProxy.DebugDrawLine3D(positionLeftBottomCorner, positionLeftBottomCorner + new Vector3(0f, 1f, 0f), Color.Green, Color.Green, true, false);
                MyRenderProxy.DebugDrawLine3D(positionLeftBottomCorner, positionLeftBottomCorner + new Vector3(0f, 0f, 1f), Color.Blue, Color.Blue, true, false);
                MyRenderProxy.DebugDrawAxis(this.m_voxelMap.PositionComp.WorldMatrix, 2f, false, false, false);
                MyRenderProxy.DebugDrawSphere(this.m_voxelMap.PositionComp.GetPosition(), 1f, Color.OrangeRed, 1f, false, false, true, false);
            }
        }
예제 #20
0
 public void DebugDraw()
 {
     foreach (GridInfo info in this.m_lastGridsInfo)
     {
         foreach (CubeInfo info2 in info.Cubes)
         {
             if (this.m_lastIntersectedGridsInfoCubes.Contains(info2))
             {
                 MyRenderProxy.DebugDrawAABB(info2.BoundingBox, Color.White, 1f, 1f, true, false, false);
                 continue;
             }
             MyRenderProxy.DebugDrawAABB(info2.BoundingBox, Color.Yellow, 1f, 1f, true, false, false);
         }
     }
 }
예제 #21
0
 public override unsafe void DebugDraw()
 {
     base.DebugDraw();
     if (((this.m_aabbPhantom != null) && MyDebugDrawSettings.DEBUG_DRAW_VOXEL_MAP_AABB) && this.IsInWorld)
     {
         BoundingBoxD aabb = this.m_aabbPhantom.Aabb;
         aabb.Translate(this.ClusterToWorld(Vector3.Zero));
         MyRenderProxy.DebugDrawAABB(aabb, Color.Orange, 1f, 1f, true, false, false);
     }
     if (MyDebugDrawSettings.DEBUG_DRAW_VOXEL_PHYSICS_PREDICTION)
     {
         foreach (IMyEntity entity in this.m_nearbyEntities)
         {
             if (!entity.MarkedForClose)
             {
                 BoundingBoxD xd3;
                 BoundingBoxD worldAABB = entity.WorldAABB;
                 MyRenderProxy.DebugDrawAABB(worldAABB, Color.Bisque, 1f, 1f, true, false, false);
                 MyRenderProxy.DebugDrawLine3D(this.GetWorldMatrix().Translation, worldAABB.Center, Color.Bisque, Color.BlanchedAlmond, true, false);
                 this.GetPrediction(entity, out xd3);
                 MyRenderProxy.DebugDrawAABB(xd3, Color.Crimson, 1f, 1f, true, false, false);
             }
         }
         using (IMyDebugDrawBatchAabb aabb = MyRenderProxy.DebugDrawBatchAABB(this.GetWorldMatrix(), new Color(Color.Cyan, 0.2f), true, false))
         {
             int num = 0;
             foreach (KeyValuePair <MyCellCoord, MyPrecalcJobPhysicsPrefetch> pair in this.m_workTracker)
             {
                 BoundingBoxD xd5;
                 num++;
                 MyCellCoord key = pair.Key;
                 xd5.Min = (Vector3D)(key.CoordInLod << key.Lod);
                 Vector3D *vectordPtr1 = (Vector3D *)ref xd5.Min;
                 vectordPtr1[0] *= 8.0;
                 Vector3D *vectordPtr2 = (Vector3D *)ref xd5.Min;
                 vectordPtr2[0] -= this.m_voxelMap.SizeInMetresHalf;
                 BoundingBoxD *xdPtr1 = (BoundingBoxD *)ref xd5;
                 xdPtr1->Max = xd5.Min + 8f;
                 Color?color = null;
                 aabb.Add(ref xd5, color);
                 if (num > 250)
                 {
                     break;
                 }
             }
         }
     }
 }
예제 #22
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();
        }
예제 #23
0
        private bool QueryEmptyOrFull(int minX, int minY, int minZ, int maxX, int maxY, int maxZ)
        {
            BoundingBoxI box = new BoundingBoxI(new Vector3I(minX, minY, minZ), new Vector3I(maxX, maxY, maxZ));

            if (box.Volume() < 100f)
            {
                return(false);
            }
            bool         flag = this.m_voxelMap.Storage.Intersect(ref box, 0, true) != ContainmentType.Intersects;
            BoundingBoxD xd   = new BoundingBoxD(new Vector3((float)minX, (float)minY, (float)minZ) * 8f, new Vector3((float)maxX, (float)maxY, (float)maxZ) * 8f);

            xd.TransformFast(base.Entity.WorldMatrix);
            MyOrientedBoundingBoxD xd1 = new MyOrientedBoundingBoxD(xd, base.Entity.WorldMatrix);

            MyRenderProxy.DebugDrawAABB(xd, flag ? Color.Green : Color.Red, 1f, 1f, false, false, false);
            return(flag);
        }
예제 #24
0
 public void DebugDraw()
 {
     foreach (KeyValuePair <MyPlanet, List <MyNavmeshManager> > pair in this.m_planetManagers)
     {
         using (List <MyNavmeshManager> .Enumerator enumerator2 = pair.Value.GetEnumerator())
         {
             while (enumerator2.MoveNext())
             {
                 enumerator2.Current.DebugDraw();
             }
         }
     }
     if (this.m_debugInvalidateTileAABB != null)
     {
         MyRenderProxy.DebugDrawAABB(this.m_debugInvalidateTileAABB.Value, Color.Yellow, 0f, 1f, true, false, false);
     }
     this.DebugDrawPaths();
 }
예제 #25
0
            internal void DebugDrawCells()
            {
                if (!IsUsed())
                {
                    return;
                }

                foreach (var cellProxy in m_mergedLodMeshProxies)
                {
                    var mergedMeshId = MyMeshes.GetMergedLodMesh(cellProxy.MeshId, 0);
                    if (mergedMeshId.Info.MergedLodMeshes.Count <= 0)
                    {
                        continue;
                    }

                    BoundingBoxD worldAabb = cellProxy.LocalAabb.Transform(cellProxy.WorldMatrix);
                    MyRenderProxy.DebugDrawAABB(worldAabb, MyClipmap.LOD_COLORS[m_lod], 1.0f, 1.0f, false);
                }
            }
예제 #26
0
        public override void DebugDrawPhysics()
        {
            if (m_physicsShapes != null)
            {
                foreach (var shape in m_physicsShapes)
                {
                    Vector3 min = (Vector3)shape.Key * PHYSICS_SECTOR_SIZE_METERS + PositionLeftBottomCorner;
                    var     box = new BoundingBoxD(min, min + PHYSICS_SECTOR_SIZE_METERS);

                    if (shape.Value != null && !shape.Value.Closed)
                    {
                        shape.Value.Physics.DebugDraw();
                        MyRenderProxy.DebugDrawAABB(box, Color.Cyan, 1.0f, 1.0f, true);
                    }
                    else
                    {
                        MyRenderProxy.DebugDrawAABB(box, Color.DarkGreen, 1.0f, 1.0f, true);
                    }
                }
            }
        }
예제 #27
0
        private bool QueryEmptyOrFull(int minX, int minY, int minZ, int maxX, int maxY, int maxZ)
        {
            ////return false;
            var bb = new BoundingBox(new Vector3(minX, minY, minZ), new Vector3(maxX, maxY, maxZ));

            if (bb.Volume() < 100)
            {
                return(false);
            }

            //bb.Translate(m_voxelMap.StorageMin);
            var result = m_voxelMap.Storage.Intersect(ref bb, false) != ContainmentType.Intersects;

            {
                var bbd = new BoundingBoxD(new Vector3(minX, minY, minZ) * 8, new Vector3(maxX, maxY, maxZ) * 8);
                bbd.Transform(Entity.WorldMatrix);
                var obb = new MyOrientedBoundingBoxD(bbd, Entity.WorldMatrix);
                MyRenderProxy.DebugDrawAABB(bbd, result ? Color.Green : Color.Red, 1, 1, false);
            }
            return(result);
        }
        internal void DebugDraw(Vector3I sectorPos, float sectorSize)
        {
            using (m_instancePartsLock.AcquireSharedUsing())
            {
                foreach (var idata in m_instanceParts.Values)
                {
                    using (idata.InstanceBufferLock.AcquireSharedUsing())
                    {
                        foreach (var entry in idata.InstanceData)
                        {
                            var ii = entry.Value;
                            var itemWorldPosition = Vector3D.Transform(ii.LocalMatrix.Translation, m_sectorMatrix);



                            //var dist = (itemWorldPosition - Sandbox.Game.World.MySector.MainCamera.Position).Length();
                            //if (dist < 30)

                            //BoundingBoxD bb = idata.ModelBox.Transform(ii.LocalMatrix);
                            MyRenderProxy.DebugDrawOBB(Matrix.Rescale(ii.LocalMatrix * m_sectorMatrix, idata.ModelBox.HalfExtents * 2), Color.OrangeRed, .5f, true, true);

                            var dist = Vector3D.Distance(MySector.MainCamera.Position, itemWorldPosition);
                            if (dist < 250)
                            {
                                MyRenderProxy.DebugDrawText3D(itemWorldPosition, idata.SubtypeId.ToString(), Color.White, 0.7f, true);
                            }
                        }
                    }
                }
            }

            //BoundingBoxD bb = new BoundingBoxD(sectorPos * sectorSize, (sectorPos + Vector3I.One) * sectorSize);
            //BoundingBoxD bb2 = new BoundingBoxD(m_AABB.Min, m_AABB.Max);
            //bb2.Min = Vector3D.Max(bb2.Min, bb.Min);
            //bb2.Max = Vector3D.Min(bb2.Max, bb.Max);
            //MyRenderProxy.DebugDrawAABB(bb, Color.Orange, 1.0f, 1.0f, true);
            //MyRenderProxy.DebugDrawAABB(bb2, Color.OrangeRed, 1.0f, 1.0f, true);

            MyRenderProxy.DebugDrawAABB(SectorWorldBox, Color.OrangeRed, 1.0f, 1.0f, true);
        }
예제 #29
0
        internal void DebugDraw(Vector3I sectorPos, float sectorSize)
        {
            foreach (var part in m_instanceParts.Values)
            {
                foreach (var data in part.InstanceData)
                {
                    var dist = (data.LocalMatrix.Translation - Sandbox.Game.World.MySector.MainCamera.Position).Length();
                    if (dist < 30)
                    {
                        MyRenderProxy.DebugDrawText3D(data.LocalMatrix.Translation, part.SubtypeId.ToString(), Color.Red, (float)(7.0 / dist), true);
                    }
                }
            }

            BoundingBoxD bb  = new BoundingBoxD(sectorPos * sectorSize, (sectorPos + Vector3I.One) * sectorSize);
            BoundingBoxD bb2 = new BoundingBoxD(m_AABB.Min, m_AABB.Max);

            bb2.Min = Vector3D.Max(bb2.Min, bb.Min);
            bb2.Max = Vector3D.Min(bb2.Max, bb.Max);
            MyRenderProxy.DebugDrawAABB(bb, Color.Orange, 1.0f, 1.0f, true);
            MyRenderProxy.DebugDrawAABB(bb2, Color.OrangeRed, 1.0f, 1.0f, true);
        }
예제 #30
0
        public override void DebugDraw()
        {
            Vector3D positionLeftBottomCorner = this.m_planet.PositionLeftBottomCorner;

            if (MyDebugDrawSettings.DEBUG_DRAW_VOXEL_MAP_AABB)
            {
                this.m_planet.Components.Get <MyPlanetEnvironmentComponent>().DebugDraw();
                this.m_planet.DebugDrawPhysics();
                MyRenderProxy.DebugDrawAABB(this.m_planet.PositionComp.WorldAABB, Color.White, 1f, 1f, true, false, false);
                MyRenderProxy.DebugDrawLine3D(positionLeftBottomCorner, positionLeftBottomCorner + new Vector3(1f, 0f, 0f), Color.Red, Color.Red, true, false);
                MyRenderProxy.DebugDrawLine3D(positionLeftBottomCorner, positionLeftBottomCorner + new Vector3(0f, 1f, 0f), Color.Green, Color.Green, true, false);
                MyRenderProxy.DebugDrawLine3D(positionLeftBottomCorner, positionLeftBottomCorner + new Vector3(0f, 0f, 1f), Color.Blue, Color.Blue, true, false);
                MyRenderProxy.DebugDrawAxis(this.m_planet.PositionComp.WorldMatrix, 2f, false, false, false);
                MyRenderProxy.DebugDrawSphere(this.m_planet.PositionComp.GetPosition(), 1f, Color.OrangeRed, 1f, false, false, true, false);
            }
            if (MyDebugDrawSettings.DEBUG_DRAW_VOXEL_GEOMETRY_CELL)
            {
                MyIntersectionResultLineTriangleEx?nullable;
                MyCamera mainCamera = MySector.MainCamera;
                LineD    line       = new LineD(mainCamera.Position, mainCamera.Position + (25f * mainCamera.ForwardVector));
                if (this.m_planet.GetIntersectionWithLine(ref line, out nullable, IntersectionFlags.ALL_TRIANGLES))
                {
                    Vector3I            vectori;
                    Vector3I            vectori2;
                    BoundingBoxD        xd2;
                    MyTriangle_Vertices inputTriangle = nullable.Value.Triangle.InputTriangle;
                    MyRenderProxy.DebugDrawTriangle(inputTriangle.Vertex0 + positionLeftBottomCorner, inputTriangle.Vertex1 + positionLeftBottomCorner, inputTriangle.Vertex2 + positionLeftBottomCorner, Color.Red, true, false, false);
                    Vector3D intersectionPointInWorldSpace = nullable.Value.IntersectionPointInWorldSpace;
                    MyVoxelCoordSystems.WorldPositionToVoxelCoord(positionLeftBottomCorner, ref intersectionPointInWorldSpace, out vectori2);
                    MyVoxelCoordSystems.VoxelCoordToWorldAABB(positionLeftBottomCorner, ref vectori2, out xd2);
                    MyRenderProxy.DebugDrawAABB(xd2, Vector3.UnitY, 1f, 1f, true, false, false);
                    MyVoxelCoordSystems.WorldPositionToGeometryCellCoord(positionLeftBottomCorner, ref intersectionPointInWorldSpace, out vectori);
                    MyVoxelCoordSystems.GeometryCellCoordToWorldAABB(positionLeftBottomCorner, ref vectori, out xd2);
                    MyRenderProxy.DebugDrawAABB(xd2, Vector3.UnitZ, 1f, 1f, true, false, false);
                }
            }
        }