예제 #1
0
        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;
        }
예제 #3
0
 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;
        }
예제 #5
0
        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);
        }
예제 #6
0
        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);
        }
예제 #7
0
        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);
        }
예제 #8
0
        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);
 }
예제 #10
0
 public PotentiallyVisibleSet(PotentiallyVisibleSet pvs)
 {
     m_setSize         = pvs.m_setSize;
     m_visibilityFlags = new BitArray(pvs.m_visibilityFlags);
 }
예제 #11
0
 public NavMesh()
 {
     m_roomKey = null;
     m_boundingBox = new AABB3d();
     m_rowCount = 0;
     m_colomnCount = 0;
     m_nonEmptyNavCellCount = 0;
     m_navCells = null;
     m_pvs = null;
 }
예제 #12
0
        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);
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #13
0
        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);
        }