Exemplo n.º 1
0
        /*
        ==============
        R_ScanEdges

        Input:
        newedges[] array
            this has links to edges, which have links to surfaces

        Output:
        Each surface has a linked list of its visible spans
        ==============
        */
        static void R_ScanEdges()
        {
            int		    iv, bottom;
            surf_t	    s;

            if (basespans == null)
            {
                basespans = new espan_t[MAXSPANS];
                for (int kk = 0; kk < MAXSPANS; kk++) basespans[kk] = new espan_t();
            }
            max_span_p = MAXSPANS - r_refdef.vrect.width;

            span_p = 0;

            // clear active edges to just the background edges around the whole screen
            // FIXME: most of this only needs to be set up once
            edge_head.u = r_refdef.vrect.x << 20;
            edge_head_u_shift20 = edge_head.u >> 20;
            edge_head.u_step = 0;
            edge_head.prev = null;
            edge_head.next = edge_tail;
            edge_head.surfs[0] = 0;
            edge_head.surfs[1] = 1;

            edge_tail.u = (r_refdef.vrectright << 20) + 0xFFFFF;
            edge_tail_u_shift20 = edge_tail.u >> 20;
            edge_tail.u_step = 0;
            edge_tail.prev = edge_head;
            edge_tail.next = edge_aftertail;
            edge_tail.surfs[0] = 1;
            edge_tail.surfs[1] = 0;

            edge_aftertail.u = -1;		// force a move
            edge_aftertail.u_step = 0;
            edge_aftertail.next = edge_sentinel;
            edge_aftertail.prev = edge_tail;

            // FIXME: do we need this now that we clamp x in r_draw.c?
            edge_sentinel.u = 2000 << 24;		// make sure nothing sorts past this
            edge_sentinel.prev = edge_aftertail;

            //
            // process all scan lines
            //
            bottom = render.r_refdef.vrectbottom - 1;

            for (iv=render.r_refdef.vrect.y ; iv<bottom ; iv++)
            {
                current_iv = iv;
                fv = (double)iv;

            // mark that the head (background start) span is pre-included
                surfaces[0].spanstate = 1;

                if (newedges[iv] != null)
                {
                    R_InsertNewEdges (newedges[iv], edge_head.next);
                }

                pdrawfunc ();

            // flush the span list if we can't be sure we have enough spans left for
            // the next scan
                if (span_p >= max_span_p)
                {
                    sound.S_ExtraUpdate();	// don't let sound get messed up if going slow

                    if (r_drawculledpolys)
                    {
                        R_DrawCulledPolys ();
                    }
                    else
                    {
                        draw.D_DrawSurfaces ();
                    }

                // clear the surface span pointers
                    for (int i = 0; i < surface_p; i++)
                    {
                        s = surfaces[i];
                        s.spans = null;
                    }

                    span_p = 0;
                }

                if (removeedges[iv] != null)
                    R_RemoveEdges (removeedges[iv]);

                if (edge_head.next != edge_tail)
                    R_StepActiveU (edge_head.next);
            }

            // do the last scan (no need to step or sort or remove on the last scan)

            current_iv = iv;
            fv = (double)iv;

            // mark that the head (background start) span is pre-included
            surfaces[0].spanstate = 1;

            if (newedges[iv] != null)
                R_InsertNewEdges (newedges[iv], edge_head.next);

            pdrawfunc ();

            // draw whatever's left in the span list
            if (r_drawculledpolys)
                R_DrawCulledPolys ();
            else
                draw.D_DrawSurfaces ();
        }
Exemplo n.º 2
0
        /*
         * ==============
         * R_ScanEdges
         *
         * Input:
         * newedges[] array
         *      this has links to edges, which have links to surfaces
         *
         * Output:
         * Each surface has a linked list of its visible spans
         * ==============
         */
        static void R_ScanEdges()
        {
            int    iv, bottom;
            surf_t s;

            if (basespans == null)
            {
                basespans = new espan_t[MAXSPANS];
                for (int kk = 0; kk < MAXSPANS; kk++)
                {
                    basespans[kk] = new espan_t();
                }
            }
            max_span_p = MAXSPANS - r_refdef.vrect.width;

            span_p = 0;

            // clear active edges to just the background edges around the whole screen
            // FIXME: most of this only needs to be set up once
            edge_head.u         = r_refdef.vrect.x << 20;
            edge_head_u_shift20 = edge_head.u >> 20;
            edge_head.u_step    = 0;
            edge_head.prev      = null;
            edge_head.next      = edge_tail;
            edge_head.surfs[0]  = 0;
            edge_head.surfs[1]  = 1;

            edge_tail.u         = (r_refdef.vrectright << 20) + 0xFFFFF;
            edge_tail_u_shift20 = edge_tail.u >> 20;
            edge_tail.u_step    = 0;
            edge_tail.prev      = edge_head;
            edge_tail.next      = edge_aftertail;
            edge_tail.surfs[0]  = 1;
            edge_tail.surfs[1]  = 0;

            edge_aftertail.u      = -1;         // force a move
            edge_aftertail.u_step = 0;
            edge_aftertail.next   = edge_sentinel;
            edge_aftertail.prev   = edge_tail;

            // FIXME: do we need this now that we clamp x in r_draw.c?
            edge_sentinel.u    = 2000 << 24;            // make sure nothing sorts past this
            edge_sentinel.prev = edge_aftertail;

            //
            // process all scan lines
            //
            bottom = render.r_refdef.vrectbottom - 1;

            for (iv = render.r_refdef.vrect.y; iv < bottom; iv++)
            {
                current_iv = iv;
                fv         = (double)iv;

                // mark that the head (background start) span is pre-included
                surfaces[0].spanstate = 1;

                if (newedges[iv] != null)
                {
                    R_InsertNewEdges(newedges[iv], edge_head.next);
                }

                pdrawfunc();

                // flush the span list if we can't be sure we have enough spans left for
                // the next scan
                if (span_p >= max_span_p)
                {
                    sound.S_ExtraUpdate();      // don't let sound get messed up if going slow

                    if (r_drawculledpolys)
                    {
                        R_DrawCulledPolys();
                    }
                    else
                    {
                        draw.D_DrawSurfaces();
                    }

                    // clear the surface span pointers
                    for (int i = 0; i < surface_p; i++)
                    {
                        s       = surfaces[i];
                        s.spans = null;
                    }

                    span_p = 0;
                }

                if (removeedges[iv] != null)
                {
                    R_RemoveEdges(removeedges[iv]);
                }

                if (edge_head.next != edge_tail)
                {
                    R_StepActiveU(edge_head.next);
                }
            }

            // do the last scan (no need to step or sort or remove on the last scan)

            current_iv = iv;
            fv         = (double)iv;

            // mark that the head (background start) span is pre-included
            surfaces[0].spanstate = 1;

            if (newedges[iv] != null)
            {
                R_InsertNewEdges(newedges[iv], edge_head.next);
            }

            pdrawfunc();

            // draw whatever's left in the span list
            if (r_drawculledpolys)
            {
                R_DrawCulledPolys();
            }
            else
            {
                draw.D_DrawSurfaces();
            }
        }