public bool Equals(PotentiallyVisibleSet other) { if (m_setSize != other.m_setSize) { return(false); } if ((m_visibilityFlags == null && other.m_visibilityFlags != null) || (m_visibilityFlags != null && other.m_visibilityFlags == null)) { return(false); } else if (m_visibilityFlags != null && other.m_visibilityFlags != null) { if (m_visibilityFlags.Length != other.m_visibilityFlags.Length) { return(false); } else { for (int bitIndex = 0; bitIndex < m_visibilityFlags.Length; bitIndex++) { if (m_visibilityFlags[bitIndex] != other.m_visibilityFlags[bitIndex]) { return(false); } } } } return(true); }
public bool Equals(PotentiallyVisibleSet other) { if (m_setSize != other.m_setSize) { return false; } if ((m_visibilityFlags == null && other.m_visibilityFlags != null) || (m_visibilityFlags != null && other.m_visibilityFlags == null)) { return false; } else if (m_visibilityFlags != null && other.m_visibilityFlags != null) { if (m_visibilityFlags.Length != other.m_visibilityFlags.Length) { return false; } else { for (int bitIndex = 0; bitIndex < m_visibilityFlags.Length; bitIndex++) { if (m_visibilityFlags[bitIndex] != other.m_visibilityFlags[bitIndex]) { return false; } } } } return true; }
public NavMesh() { m_roomKey = null; m_boundingBox = new AABB3d(); m_rowCount = 0; m_colomnCount = 0; m_nonEmptyNavCellCount = 0; m_navCells = null; m_pvs = null; }
public static PotentiallyVisibleSet FromCompressedRawByteArray(uint setSize, byte[] compressedBytes) { PotentiallyVisibleSet pvs = new PotentiallyVisibleSet(); byte[] uncompressedBytes = CompressionUtilities.RunLengthDecodeByteArray( compressedBytes, CompressionUtilities.eEncodeType.Ones, null); pvs.m_visibilityFlags = new BitArray(uncompressedBytes); pvs.m_visibilityFlags.Length = BitsNeededForSetSize(setSize); pvs.m_setSize = setSize; return pvs; }
public static PotentiallyVisibleSet FromCompressedRawByteArray(uint setSize, byte[] compressedBytes) { PotentiallyVisibleSet pvs = new PotentiallyVisibleSet(); byte[] uncompressedBytes = CompressionUtilities.RunLengthDecodeByteArray( compressedBytes, CompressionUtilities.eEncodeType.Ones, null); pvs.m_visibilityFlags = new BitArray(uncompressedBytes); pvs.m_visibilityFlags.Length = BitsNeededForSetSize(setSize); pvs.m_setSize = setSize; return(pvs); }
public NavMesh(RoomKey roomKey, NavMesh navMeshTemplate) { m_roomKey = new RoomKey(roomKey); m_boundingBox = new AABB3d(navMeshTemplate.m_boundingBox); m_rowCount = navMeshTemplate.m_rowCount; m_colomnCount = navMeshTemplate.m_colomnCount; m_nonEmptyNavCellCount = navMeshTemplate.m_nonEmptyNavCellCount; m_navCells = new NavCell[navMeshTemplate.m_navCells.Length]; Array.Copy(navMeshTemplate.m_navCells, m_navCells, m_navCells.Length); m_pvs = new PotentiallyVisibleSet(navMeshTemplate.m_pvs); }
public static NavMesh FromCompressedNavMeshData(byte[] compressedNavCells, byte[] compressedPVS) { NavMesh navMesh = new NavMesh(); if (compressedNavCells != null && compressedNavCells.Length > 0) { navMesh.NavCellsFromCompressedRawByteArray(compressedNavCells); } if (compressedPVS != null && compressedPVS.Length > 0) { navMesh.m_pvs = PotentiallyVisibleSet.FromCompressedRawByteArray(navMesh.m_nonEmptyNavCellCount, compressedPVS); } return(navMesh); }
private void BuildNavCellPotentiallyVisibleSet() { if (m_nonEmptyNavCellCount > 0) { // Only need PVS information on non-empty nav cells m_pvs = new PotentiallyVisibleSet(m_nonEmptyNavCellCount); // Raycast from each non-empty nav cell... for (int startNavCellIndex = 0; startNavCellIndex < m_navCells.Length; ++startNavCellIndex) { NavRef startNavRef = new NavRef(startNavCellIndex, m_roomKey); NavCell startNavCell = m_navCells[startNavCellIndex]; if (startNavCell.connectivityId != EMPTY_NAV_CELL) { // ... to every other non-empty nav cell for (int endNavCellIndex = 0; endNavCellIndex < m_navCells.Length; ++endNavCellIndex) { NavCell endNavCell = m_navCells[endNavCellIndex]; if (startNavCellIndex != endNavCellIndex && endNavCell.connectivityId != EMPTY_NAV_CELL) { NavRef endNavRef = new NavRef(endNavCellIndex, m_roomKey); Point3d start = ComputeNavCellCenter((uint)startNavCellIndex); Point3d end = ComputeNavCellCenter((uint)endNavCellIndex); float t; bool hit = Raycast(start, startNavRef, end, endNavRef, out t); // Mark visibility in the PVS where the raycast succeeds if (!hit) { m_pvs.SetCellCanSeeOtherCell((uint)startNavCell.pvsCellIndex, (uint)endNavCell.pvsCellIndex); } } } } } } }
public PotentiallyVisibleSet(PotentiallyVisibleSet pvs) { m_setSize = pvs.m_setSize; m_visibilityFlags = new BitArray(pvs.m_visibilityFlags); }