- add vertex buffer based drawing for all walls and flats.
This commit is contained in:
parent
7d3beb665b
commit
f7404d20fb
7 changed files with 272 additions and 29 deletions
|
|
@ -45,6 +45,7 @@
|
|||
#include "gl/renderer/gl_renderer.h"
|
||||
#include "gl/renderer/gl_lightdata.h"
|
||||
#include "gl/data/gl_data.h"
|
||||
#include "gl/data/gl_vertexbuffer.h"
|
||||
#include "gl/dynlights/gl_glow.h"
|
||||
#include "gl/scene/gl_drawinfo.h"
|
||||
#include "gl/scene/gl_portal.h"
|
||||
|
|
@ -88,6 +89,37 @@ void GLWall::SplitUpperEdge(texcoord * tcs)
|
|||
vertexcount += sidedef->numsegs-1;
|
||||
}
|
||||
|
||||
void GLWall::SplitUpperEdge(texcoord * tcs, FFlatVertex *&ptr)
|
||||
{
|
||||
if (seg == NULL || seg->sidedef == NULL || (seg->sidedef->Flags & WALLF_POLYOBJ) || seg->sidedef->numsegs == 1) return;
|
||||
|
||||
side_t *sidedef = seg->sidedef;
|
||||
float polyw = glseg.fracright - glseg.fracleft;
|
||||
float facu = (tcs[2].u - tcs[1].u) / polyw;
|
||||
float facv = (tcs[2].v - tcs[1].v) / polyw;
|
||||
float fact = (ztop[1] - ztop[0]) / polyw;
|
||||
float facc = (zceil[1] - zceil[0]) / polyw;
|
||||
float facf = (zfloor[1] - zfloor[0]) / polyw;
|
||||
|
||||
for (int i = 0; i < sidedef->numsegs - 1; i++)
|
||||
{
|
||||
seg_t *cseg = sidedef->segs[i];
|
||||
float sidefrac = cseg->sidefrac;
|
||||
if (sidefrac <= glseg.fracleft) continue;
|
||||
if (sidefrac >= glseg.fracright) return;
|
||||
|
||||
float fracfac = sidefrac - glseg.fracleft;
|
||||
|
||||
ptr->x = cseg->v2->fx;
|
||||
ptr->y = cseg->v2->fy;
|
||||
ptr->z = ztop[0] + fact * fracfac;
|
||||
ptr->u = tcs[1].u + facu * fracfac;
|
||||
ptr->v = tcs[1].v + facv * fracfac;
|
||||
ptr++;
|
||||
}
|
||||
vertexcount += sidedef->numsegs - 1;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Split upper edge of wall
|
||||
|
|
@ -121,6 +153,37 @@ void GLWall::SplitLowerEdge(texcoord * tcs)
|
|||
vertexcount += sidedef->numsegs-1;
|
||||
}
|
||||
|
||||
void GLWall::SplitLowerEdge(texcoord * tcs, FFlatVertex *&ptr)
|
||||
{
|
||||
if (seg == NULL || seg->sidedef == NULL || (seg->sidedef->Flags & WALLF_POLYOBJ) || seg->sidedef->numsegs == 1) return;
|
||||
|
||||
side_t *sidedef = seg->sidedef;
|
||||
float polyw = glseg.fracright - glseg.fracleft;
|
||||
float facu = (tcs[3].u - tcs[0].u) / polyw;
|
||||
float facv = (tcs[3].v - tcs[0].v) / polyw;
|
||||
float facb = (zbottom[1] - zbottom[0]) / polyw;
|
||||
float facc = (zceil[1] - zceil[0]) / polyw;
|
||||
float facf = (zfloor[1] - zfloor[0]) / polyw;
|
||||
|
||||
for (int i = sidedef->numsegs - 2; i >= 0; i--)
|
||||
{
|
||||
seg_t *cseg = sidedef->segs[i];
|
||||
float sidefrac = cseg->sidefrac;
|
||||
if (sidefrac >= glseg.fracright) continue;
|
||||
if (sidefrac <= glseg.fracleft) return;
|
||||
|
||||
float fracfac = sidefrac - glseg.fracleft;
|
||||
|
||||
ptr->x = cseg->v2->fx;
|
||||
ptr->y = cseg->v2->fy;
|
||||
ptr->z = zbottom[0] + facb * fracfac;
|
||||
ptr->u = tcs[0].u + facu * fracfac;
|
||||
ptr->v = tcs[0].v + facv * fracfac;
|
||||
ptr++;
|
||||
}
|
||||
vertexcount += sidedef->numsegs - 1;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Split left edge of wall
|
||||
|
|
@ -153,6 +216,35 @@ void GLWall::SplitLeftEdge(texcoord * tcs)
|
|||
}
|
||||
}
|
||||
|
||||
void GLWall::SplitLeftEdge(texcoord * tcs, FFlatVertex *&ptr)
|
||||
{
|
||||
if (vertexes[0] == NULL) return;
|
||||
|
||||
vertex_t * vi = vertexes[0];
|
||||
|
||||
if (vi->numheights)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
float polyh1 = ztop[0] - zbottom[0];
|
||||
float factv1 = polyh1 ? (tcs[1].v - tcs[0].v) / polyh1 : 0;
|
||||
float factu1 = polyh1 ? (tcs[1].u - tcs[0].u) / polyh1 : 0;
|
||||
|
||||
while (i<vi->numheights && vi->heightlist[i] <= zbottom[0]) i++;
|
||||
while (i<vi->numheights && vi->heightlist[i] < ztop[0])
|
||||
{
|
||||
ptr->x = glseg.x1;
|
||||
ptr->y = glseg.y1;
|
||||
ptr->z = vi->heightlist[i];
|
||||
ptr->u = factu1*(vi->heightlist[i] - ztop[0]) + tcs[1].u;
|
||||
ptr->v = factv1*(vi->heightlist[i] - ztop[0]) + tcs[1].v;
|
||||
ptr++;
|
||||
i++;
|
||||
}
|
||||
vertexcount += i;
|
||||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Split right edge of wall
|
||||
|
|
@ -185,3 +277,32 @@ void GLWall::SplitRightEdge(texcoord * tcs)
|
|||
}
|
||||
}
|
||||
|
||||
void GLWall::SplitRightEdge(texcoord * tcs, FFlatVertex *&ptr)
|
||||
{
|
||||
if (vertexes[1] == NULL) return;
|
||||
|
||||
vertex_t * vi = vertexes[1];
|
||||
|
||||
if (vi->numheights)
|
||||
{
|
||||
int i = vi->numheights - 1;
|
||||
|
||||
float polyh2 = ztop[1] - zbottom[1];
|
||||
float factv2 = polyh2 ? (tcs[2].v - tcs[3].v) / polyh2 : 0;
|
||||
float factu2 = polyh2 ? (tcs[2].u - tcs[3].u) / polyh2 : 0;
|
||||
|
||||
while (i>0 && vi->heightlist[i] >= ztop[1]) i--;
|
||||
while (i>0 && vi->heightlist[i] > zbottom[1])
|
||||
{
|
||||
ptr->x = glseg.x2;
|
||||
ptr->y = glseg.y2;
|
||||
ptr->z = vi->heightlist[i];
|
||||
ptr->u = factu2*(vi->heightlist[i] - ztop[1]) + tcs[2].u;
|
||||
ptr->v = factv2*(vi->heightlist[i] - ztop[1]) + tcs[2].v;
|
||||
ptr++;
|
||||
i--;
|
||||
}
|
||||
vertexcount += i;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue