private unsafe void MarkExploredDirections(ref MyNavmeshComponents.ClosedCellInfo cellInfo) { foreach (Base6Directions.Direction direction in Base6Directions.EnumDirections) { Base6Directions.DirectionFlags directionFlag = Base6Directions.GetDirectionFlag(direction); if (!cellInfo.ExploredDirections.HasFlag(directionFlag)) { Vector3I intVector = Base6Directions.GetIntVector(direction); MyCellCoord coord = new MyCellCoord { Lod = 0, CoordInLod = (Vector3I)(this.m_currentCell + intVector) }; if (((coord.CoordInLod.X != -1) && (coord.CoordInLod.Y != -1)) && (coord.CoordInLod.Z != -1)) { ulong key = coord.PackId64(); if (this.m_triangleLists.ContainsKey(key)) { this.m_navmeshComponents.MarkExplored(key, Base6Directions.GetFlippedDirection(direction)); Base6Directions.DirectionFlags *flagsPtr1 = (Base6Directions.DirectionFlags *) ref cellInfo.ExploredDirections; *((sbyte *)flagsPtr1) = *(((byte *)flagsPtr1)) | Base6Directions.GetDirectionFlag(direction); } } } } this.m_navmeshComponents.SetExplored(this.m_packedCoord, cellInfo.ExploredDirections); }
public IMyHighLevelComponent GetComponent(MyHighLevelPrimitive primitive) { ulong num; Base6Directions.DirectionFlags flags; if (!this.m_navmeshComponents.GetComponentCell(primitive.Index, out num)) { return(null); } if (!this.m_navmeshComponents.GetComponentInfo(primitive.Index, num, out flags)) { return(null); } MyCellCoord coord = new MyCellCoord(); coord.SetUnpack(num); foreach (Base6Directions.Direction direction in Base6Directions.EnumDirections) { Base6Directions.DirectionFlags directionFlag = Base6Directions.GetDirectionFlag(direction); if (!flags.HasFlag(directionFlag)) { Vector3I position = (Vector3I)(coord.CoordInLod + Base6Directions.GetIntVector(direction)); if (this.m_exploredCells.Contains(ref position)) { flags |= directionFlag; } } } return(new Component(primitive.Index, flags)); }
public void SetExplored(ulong packedCoord, Base6Directions.DirectionFlags directionFlags) { CellInfo info = new CellInfo(); if (this.m_cellInfos.TryGetValue(packedCoord, out info)) { info.ExploredDirections = directionFlags; this.m_cellInfos[packedCoord] = info; } }
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++; } } } } } } }
public void SetExplored(ulong packedCoord, Base6Directions.DirectionFlags directionFlags) { CellInfo info = new CellInfo(); if (m_cellInfos.TryGetValue(packedCoord, out info)) { info.ExploredDirections = directionFlags; m_cellInfos[packedCoord] = info; } else { Debug.Assert(false, "Could not find navmesh cell info for setting explored directions!"); } }
public void TryClearCell(ulong packedCoord) { if (m_triangleLists.ContainsKey(packedCoord)) { ClearCachedCell(packedCoord); } RemoveExplored(packedCoord); MyNavmeshComponents.CellInfo cellInfo; if (!m_navmeshComponents.TryGetCell(packedCoord, out cellInfo)) { return; } for (int i = 0; i < cellInfo.ComponentNum; ++i) { int componentIndex = cellInfo.StartingIndex + i; m_mesh.HighLevelGroup.RemovePrimitive(componentIndex); } foreach (var direction in Base6Directions.EnumDirections) { Base6Directions.DirectionFlags dirFlag = Base6Directions.GetDirectionFlag(direction); if (cellInfo.ExploredDirections.HasFlag(dirFlag)) { Vector3I dirVec = Base6Directions.GetIntVector(direction); MyCellCoord otherCoord = new MyCellCoord(); otherCoord.SetUnpack(packedCoord); Debug.Assert(otherCoord.Lod == MyVoxelNavigationMesh.NAVMESH_LOD); otherCoord.CoordInLod = otherCoord.CoordInLod + dirVec; MyNavmeshComponents.CellInfo otherCellInfo; if (m_navmeshComponents.TryGetCell(otherCoord.PackId64(), out otherCellInfo)) { Base6Directions.DirectionFlags flippedFlag = Base6Directions.GetDirectionFlag(Base6Directions.GetFlippedDirection(direction)); m_navmeshComponents.SetExplored(otherCoord.PackId64(), otherCellInfo.ExploredDirections & ~flippedFlag); } else { Debug.Assert(false, "Could not get the oposite explored cell!"); } } } m_navmeshComponents.ClearCell(packedCoord, ref cellInfo); }
public bool GetComponentInfo(int componentIndex, ulong cellIndex, out Base6Directions.DirectionFlags exploredDirections) { CellInfo info; exploredDirections = 0; this.TryGetCell(cellIndex, out info); int num = componentIndex - info.StartingIndex; if ((num < 0) || (num >= info.ComponentNum)) { return(false); } exploredDirections = info.ExploredDirections; return(true); }
public bool GetComponentInfo(int componentIndex, ulong cellIndex, out Base6Directions.DirectionFlags exploredDirections) { exploredDirections = (Base6Directions.DirectionFlags) 0; CellInfo cellInfo; bool success = TryGetCell(cellIndex, out cellInfo); Debug.Assert(success, "Could not retrieve cell info for a cell!"); int relativeComponentIndex = componentIndex - cellInfo.StartingIndex; Debug.Assert(relativeComponentIndex >= 0 && relativeComponentIndex < cellInfo.ComponentNum, "Component index overflow! The component does not belong to this cell!"); if (relativeComponentIndex < 0 || relativeComponentIndex >= cellInfo.ComponentNum) { return(false); } exploredDirections = cellInfo.ExploredDirections; return(true); }
public unsafe void TryClearCell(ulong packedCoord) { MyNavmeshComponents.CellInfo info; if (this.m_triangleLists.ContainsKey(packedCoord)) { this.ClearCachedCell(packedCoord); } this.RemoveExplored(packedCoord); if (this.m_navmeshComponents.TryGetCell(packedCoord, out info)) { for (int i = 0; i < info.ComponentNum; i++) { int index = info.StartingIndex + i; this.m_mesh.HighLevelGroup.RemovePrimitive(index); } foreach (Base6Directions.Direction direction in Base6Directions.EnumDirections) { Base6Directions.DirectionFlags directionFlag = Base6Directions.GetDirectionFlag(direction); if (info.ExploredDirections.HasFlag(directionFlag)) { MyNavmeshComponents.CellInfo info2; Vector3I intVector = Base6Directions.GetIntVector(direction); MyCellCoord coord = new MyCellCoord(); coord.SetUnpack(packedCoord); MyCellCoord *coordPtr1 = (MyCellCoord *)ref coord; coordPtr1->CoordInLod = (Vector3I)(coord.CoordInLod + intVector); if (this.m_navmeshComponents.TryGetCell(coord.PackId64(), out info2)) { Base6Directions.DirectionFlags flags2 = Base6Directions.GetDirectionFlag(Base6Directions.GetFlippedDirection(direction)); this.m_navmeshComponents.SetExplored(coord.PackId64(), info2.ExploredDirections & ((byte)~flags2)); } } } this.m_navmeshComponents.ClearCell(packedCoord, ref info); } }
public Component(int index, Base6Directions.DirectionFlags exploredDirections) { m_componentIndex = index; m_exploredDirections = exploredDirections; }