Exemple #1
0
        static int R_DlightGrid(srfGridMesh_t *grid, int dlightBits)
        {
            int       i;
            dlight_t *dl;

            for (i = 0; i < tr.refdef.num_dlights; i++)
            {
                if (!(dlightBits & (1 << i)))
                {
                    continue;
                }
                dl = &tr.refdef.dlights[i];
                if (dl->origin[0] - dl->radius > grid->meshBounds[1][0] ||
                    dl->origin[0] + dl->radius <grid->meshBounds[0][0] ||
                                                dl->origin[1] - dl->radius> grid->meshBounds[1][1] ||
                    dl->origin[1] + dl->radius <grid->meshBounds[0][1] ||
                                                dl->origin[2] - dl->radius> grid->meshBounds[1][2] ||
                    dl->origin[2] + dl->radius < grid->meshBounds[0][2])
                {
                    // dlight doesn't reach the bounds
                    dlightBits &= ~(1 << i);
                }
            }

            if (!dlightBits)
            {
                tr.pc.c_dlightSurfacesCulled++;
            }

            grid->dlightBits[tr.smpFrame] = dlightBits;
            return(dlightBits);
        }
Exemple #2
0
        /*
         * =================
         * R_CullGrid
         *
         * Returns true if the grid is completely culled away.
         * Also sets the clipped hint bit in tess
         * =================
         */
        static bool     R_CullGrid(srfGridMesh_t *cv)
        {
            int boxCull;
            int sphereCull;

            if (r_nocurves->integer)
            {
                return(true);
            }

            if (tr.currentEntityNum != ENTITYNUM_WORLD)
            {
                sphereCull = R_CullLocalPointAndRadius(cv->localOrigin, cv->meshRadius);
            }
            else
            {
                sphereCull = R_CullPointAndRadius(cv->localOrigin, cv->meshRadius);
            }
            boxCull = CULL_OUT;

            // check for trivial reject
            if (sphereCull == CULL_OUT)
            {
                tr.pc.c_sphere_cull_patch_out++;
                return(true);
            }
            // check bounding box if necessary
            else if (sphereCull == CULL_CLIP)
            {
                tr.pc.c_sphere_cull_patch_clip++;

                boxCull = R_CullLocalBox(cv->meshBounds);

                if (boxCull == CULL_OUT)
                {
                    tr.pc.c_box_cull_patch_out++;
                    return(true);
                }
                else if (boxCull == CULL_IN)
                {
                    tr.pc.c_box_cull_patch_in++;
                }
                else
                {
                    tr.pc.c_box_cull_patch_clip++;
                }
            }
            else
            {
                tr.pc.c_sphere_cull_patch_in++;
            }

            return(false);
        }