示例#1
0
        public static void SV_FatPVS(Single[] org)
        {
            Int32[] leafs = new Int32[64];
            Int32   i, j, count;
            Int32   longs;

            Byte[]   src;
            Single[] mins = new Single[] { 0, 0, 0 }, maxs = new Single[] { 0, 0, 0 };
            for (i = 0; i < 3; i++)
            {
                mins[i] = org[i] - 8;
                maxs[i] = org[i] + 8;
            }

            count = CM.CM_BoxLeafnums(mins, maxs, leafs, 64, null);
            if (count < 1)
            {
                Com.Error(Defines.ERR_FATAL, "SV_FatPVS: count < 1");
            }
            longs = (CM.CM_NumClusters() + 31) >> 5;
            for (i = 0; i < count; i++)
            {
                leafs[i] = CM.CM_LeafCluster(leafs[i]);
            }
            System.Array.Copy(CM.CM_ClusterPVS(leafs[0]), 0, SV_ENTS.fatpvs, 0, longs << 2);
            for (i = 1; i < count; i++)
            {
                for (j = 0; j < i; j++)
                {
                    if (leafs[i] == leafs[j])
                    {
                        break;
                    }
                }
                if (j != i)
                {
                    continue;
                }
                src = CM.CM_ClusterPVS(leafs[i]);
                var k = 0;
                for (j = 0; j < longs; j++)
                {
                    SV_ENTS.fatpvs[k] |= src[k++];
                    SV_ENTS.fatpvs[k] |= src[k++];
                    SV_ENTS.fatpvs[k] |= src[k++];
                    SV_ENTS.fatpvs[k] |= src[k++];
                }
            }
        }
示例#2
0
        /**
         * The client will interpolate the view position, so we can't use a single
         * PVS point.
         */
        public static void SV_FatPVS(float[] org)
        {
            var leafs = new int[64];
            int i, j, count;
            int longs;

            byte[]  src;
            float[] mins = { 0, 0, 0 }, maxs = { 0, 0, 0 };

            for (i = 0; i < 3; i++)
            {
                mins[i] = org[i] - 8;
                maxs[i] = org[i] + 8;
            }

            count = CM.CM_BoxLeafnums(mins, maxs, leafs, 64, null);

            if (count < 1)
            {
                Com.Error(Defines.ERR_FATAL, "SV_FatPVS: count < 1");
            }

            longs = (CM.CM_NumClusters() + 31) >> 5;

            // convert leafs to clusters
            for (i = 0; i < count; i++)
            {
                leafs[i] = CM.CM_LeafCluster(leafs[i]);
            }

            Array.Copy(CM.CM_ClusterPVS(leafs[0]), 0, SV_ENTS.fatpvs, 0, longs << 2);

            // or in all the other leaf bits
            for (i = 1; i < count; i++)
            {
                for (j = 0; j < i; j++)
                {
                    if (leafs[i] == leafs[j])
                    {
                        break;
                    }
                }

                if (j != i)
                {
                    continue;                     // already have the cluster we want
                }
                src = CM.CM_ClusterPVS(leafs[i]);

                //for (j=0 ; j<longs ; j++)
                //	((long *)fatpvs)[j] |= ((long *)src)[j];
                var k = 0;

                for (j = 0; j < longs; j++)
                {
                    SV_ENTS.fatpvs[k] |= src[k++];
                    SV_ENTS.fatpvs[k] |= src[k++];
                    SV_ENTS.fatpvs[k] |= src[k++];
                    SV_ENTS.fatpvs[k] |= src[k++];
                }
            }
        }