示例#1
0
        AreaParams AreaEntities(Vector3 mins, Vector3 maxs, int count)
        {
            AreaParams ap = new AreaParams();
            ap.mins = mins;
            ap.maxs = maxs;
            ap.list = new int[count];
            ap.count = 0;

            AreaEntities_r(sv_worldSectors[0], ap);

            return ap;
        }
示例#2
0
        void AreaEntities_r(worldSector_t node, AreaParams ap)
        {
            svEntity_t check, next = null;
            sharedEntity gcheck;

            for (check = node.entities; check != null; check = next )
            {
                next = check.nextEntityInWorldSector;

                gcheck = GEntityForSvEntity(check);

                if (gcheck.r.absmin[0] > ap.maxs[0]
                    || gcheck.r.absmin[1] > ap.maxs[1]
                    || gcheck.r.absmin[2] > ap.maxs[2]
                    || gcheck.r.absmax[0] < ap.mins[0]
                    || gcheck.r.absmax[1] < ap.mins[1]
                    || gcheck.r.absmax[2] < ap.mins[2])
                    continue;

                if (ap.list.Length == ap.count)
                {
                    Common.Instance.WriteLine("AreaEntities: MAXCOUNT");
                    return;
                }

                ap.list[ap.count] = check.id;
                ap.count++;
            }

            if (node.axis == -1)
                return; // terminal node

            // recurse down both sides
            if (ap.maxs[node.axis] > node.dist)
                AreaEntities_r(node.children[0], ap);
            if (ap.mins[node.axis] < node.dist)
                AreaEntities_r(node.children[1], ap);
        }