mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-12-27 04:41:23 +00:00
Merge branch 'opengl-improvements-backport' into 'master'
Opengl improvements backport See merge request STJr/SRB2!304
This commit is contained in:
commit
925a56ad98
10 changed files with 221 additions and 276 deletions
11
src/d_main.c
11
src/d_main.c
|
@ -417,10 +417,13 @@ static void D_Display(void)
|
|||
}
|
||||
|
||||
// Image postprocessing effect
|
||||
if (postimgtype)
|
||||
V_DoPostProcessor(0, postimgtype, postimgparam);
|
||||
if (postimgtype2)
|
||||
V_DoPostProcessor(1, postimgtype2, postimgparam2);
|
||||
if (rendermode == render_soft)
|
||||
{
|
||||
if (postimgtype)
|
||||
V_DoPostProcessor(0, postimgtype, postimgparam);
|
||||
if (postimgtype2)
|
||||
V_DoPostProcessor(1, postimgtype2, postimgparam2);
|
||||
}
|
||||
}
|
||||
|
||||
if (lastdraw)
|
||||
|
|
|
@ -878,8 +878,8 @@ static void AdjustSegs(void)
|
|||
count = subsectors[i].numlines;
|
||||
lseg = &segs[subsectors[i].firstline];
|
||||
p = extrasubsectors[i].planepoly;
|
||||
if (!p)
|
||||
continue;
|
||||
//if (!p)
|
||||
//continue;
|
||||
for (; count--; lseg++)
|
||||
{
|
||||
float distv1,distv2,tmp;
|
||||
|
@ -892,29 +892,31 @@ static void AdjustSegs(void)
|
|||
continue;
|
||||
#endif
|
||||
|
||||
for (j = 0; j < p->numpts; j++)
|
||||
{
|
||||
distv1 = p->pts[j].x - FIXED_TO_FLOAT(lseg->v1->x);
|
||||
tmp = p->pts[j].y - FIXED_TO_FLOAT(lseg->v1->y);
|
||||
distv1 = distv1*distv1+tmp*tmp;
|
||||
if (distv1 <= nearv1)
|
||||
if (p) {
|
||||
for (j = 0; j < p->numpts; j++)
|
||||
{
|
||||
v1found = j;
|
||||
nearv1 = distv1;
|
||||
}
|
||||
// the same with v2
|
||||
distv2 = p->pts[j].x - FIXED_TO_FLOAT(lseg->v2->x);
|
||||
tmp = p->pts[j].y - FIXED_TO_FLOAT(lseg->v2->y);
|
||||
distv2 = distv2*distv2+tmp*tmp;
|
||||
if (distv2 <= nearv2)
|
||||
{
|
||||
v2found = j;
|
||||
nearv2 = distv2;
|
||||
distv1 = p->pts[j].x - FIXED_TO_FLOAT(lseg->v1->x);
|
||||
tmp = p->pts[j].y - FIXED_TO_FLOAT(lseg->v1->y);
|
||||
distv1 = distv1*distv1+tmp*tmp;
|
||||
if (distv1 <= nearv1)
|
||||
{
|
||||
v1found = j;
|
||||
nearv1 = distv1;
|
||||
}
|
||||
// the same with v2
|
||||
distv2 = p->pts[j].x - FIXED_TO_FLOAT(lseg->v2->x);
|
||||
tmp = p->pts[j].y - FIXED_TO_FLOAT(lseg->v2->y);
|
||||
distv2 = distv2*distv2+tmp*tmp;
|
||||
if (distv2 <= nearv2)
|
||||
{
|
||||
v2found = j;
|
||||
nearv2 = distv2;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (nearv1 <= NEARDIST*NEARDIST)
|
||||
if (p && nearv1 <= NEARDIST*NEARDIST)
|
||||
// share vertice with segs
|
||||
lseg->v1 = (vertex_t *)&(p->pts[v1found]);
|
||||
lseg->pv1 = &(p->pts[v1found]);
|
||||
else
|
||||
{
|
||||
// BP: here we can do better, using PointInSeg and compute
|
||||
|
@ -925,24 +927,24 @@ static void AdjustSegs(void)
|
|||
polyvertex_t *pv = HWR_AllocVertex();
|
||||
pv->x = FIXED_TO_FLOAT(lseg->v1->x);
|
||||
pv->y = FIXED_TO_FLOAT(lseg->v1->y);
|
||||
lseg->v1 = (vertex_t *)pv;
|
||||
lseg->pv1 = pv;
|
||||
}
|
||||
if (nearv2 <= NEARDIST*NEARDIST)
|
||||
lseg->v2 = (vertex_t *)&(p->pts[v2found]);
|
||||
if (p && nearv2 <= NEARDIST*NEARDIST)
|
||||
lseg->pv2 = &(p->pts[v2found]);
|
||||
else
|
||||
{
|
||||
polyvertex_t *pv = HWR_AllocVertex();
|
||||
pv->x = FIXED_TO_FLOAT(lseg->v2->x);
|
||||
pv->y = FIXED_TO_FLOAT(lseg->v2->y);
|
||||
lseg->v2 = (vertex_t *)pv;
|
||||
lseg->pv2 = pv;
|
||||
}
|
||||
|
||||
// recompute length
|
||||
{
|
||||
float x,y;
|
||||
x = ((polyvertex_t *)lseg->v2)->x - ((polyvertex_t *)lseg->v1)->x
|
||||
x = ((polyvertex_t *)lseg->pv2)->x - ((polyvertex_t *)lseg->pv1)->x
|
||||
+ FIXED_TO_FLOAT(FRACUNIT/2);
|
||||
y = ((polyvertex_t *)lseg->v2)->y - ((polyvertex_t *)lseg->v1)->y
|
||||
y = ((polyvertex_t *)lseg->pv2)->y - ((polyvertex_t *)lseg->pv1)->y
|
||||
+ FIXED_TO_FLOAT(FRACUNIT/2);
|
||||
lseg->flength = (float)hypot(x, y);
|
||||
// BP: debug see this kind of segs
|
||||
|
|
|
@ -26,10 +26,6 @@
|
|||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#if defined (VID_X11) && !defined (HAVE_SDL)
|
||||
#include <GL/glx.h>
|
||||
#endif
|
||||
|
||||
#include "../doomdef.h"
|
||||
//THIS MUST DISAPPEAR!!!
|
||||
#include "hw_glide.h"
|
||||
|
|
|
@ -32,10 +32,6 @@
|
|||
// STANDARD DLL EXPORTS
|
||||
// ==========================================================================
|
||||
|
||||
#ifdef HAVE_SDL
|
||||
#undef VID_X11
|
||||
#endif
|
||||
|
||||
EXPORT boolean HWRAPI(Init) (I_Error_t ErrorFunction);
|
||||
#ifndef HAVE_SDL
|
||||
EXPORT void HWRAPI(Shutdown) (void);
|
||||
|
@ -43,9 +39,6 @@ EXPORT void HWRAPI(Shutdown) (void);
|
|||
#ifdef _WINDOWS
|
||||
EXPORT void HWRAPI(GetModeList) (vmode_t **pvidmodes, INT32 *numvidmodes);
|
||||
#endif
|
||||
#ifdef VID_X11
|
||||
EXPORT Window HWRAPI(HookXwin) (Display *, INT32, INT32, boolean);
|
||||
#endif
|
||||
#if defined (PURESDL) || defined (macintosh)
|
||||
EXPORT void HWRAPI(SetPalette) (INT32 *, RGBA_t *gamma);
|
||||
#else
|
||||
|
@ -71,10 +64,6 @@ EXPORT void HWRAPI(SetTransform) (FTransform *ptransform);
|
|||
EXPORT INT32 HWRAPI(GetTextureUsed) (void);
|
||||
EXPORT INT32 HWRAPI(GetRenderVersion) (void);
|
||||
|
||||
#ifdef VID_X11 // ifdef to be removed as soon as windoze supports that as well
|
||||
// metzgermeister: added for Voodoo detection
|
||||
EXPORT char *HWRAPI(GetRenderer) (void);
|
||||
#endif
|
||||
#ifdef SHUFFLE
|
||||
#define SCREENVERTS 10
|
||||
EXPORT void HWRAPI(PostImgRedraw) (float points[SCREENVERTS][SCREENVERTS][2]);
|
||||
|
@ -115,10 +104,6 @@ struct hwdriver_s
|
|||
#ifdef _WINDOWS
|
||||
GetModeList pfnGetModeList;
|
||||
#endif
|
||||
#ifdef VID_X11
|
||||
HookXwin pfnHookXwin;
|
||||
GetRenderer pfnGetRenderer;
|
||||
#endif
|
||||
#ifndef HAVE_SDL
|
||||
Shutdown pfnShutdown;
|
||||
#endif
|
||||
|
|
|
@ -323,9 +323,6 @@ static angle_t gr_xtoviewangle[MAXVIDWIDTH+1];
|
|||
// test change fov when looking up/down but bsp projection messup :(
|
||||
//#define NOCRAPPYMLOOK
|
||||
|
||||
/// \note crappy
|
||||
#define drawtextured true
|
||||
|
||||
// base values set at SetViewSize
|
||||
static float gr_basecentery;
|
||||
|
||||
|
@ -856,11 +853,11 @@ static void HWR_DrawSegsSplats(FSurfaceInfo * pSurf)
|
|||
|
||||
M_ClearBox(segbbox);
|
||||
M_AddToBox(segbbox,
|
||||
FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->v1)->x),
|
||||
FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->v1)->y));
|
||||
FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->pv1)->x),
|
||||
FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->pv1)->y));
|
||||
M_AddToBox(segbbox,
|
||||
FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->v2)->x),
|
||||
FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->v2)->y));
|
||||
FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->pv2)->x),
|
||||
FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->pv2)->y));
|
||||
|
||||
splat = (wallsplat_t *)gr_curline->linedef->splats;
|
||||
for (; splat; splat = splat->next)
|
||||
|
@ -1367,10 +1364,10 @@ static void HWR_StoreWallRange(double startfrac, double endfrac)
|
|||
gr_sidedef = gr_curline->sidedef;
|
||||
gr_linedef = gr_curline->linedef;
|
||||
|
||||
vs.x = ((polyvertex_t *)gr_curline->v1)->x;
|
||||
vs.y = ((polyvertex_t *)gr_curline->v1)->y;
|
||||
ve.x = ((polyvertex_t *)gr_curline->v2)->x;
|
||||
ve.y = ((polyvertex_t *)gr_curline->v2)->y;
|
||||
vs.x = ((polyvertex_t *)gr_curline->pv1)->x;
|
||||
vs.y = ((polyvertex_t *)gr_curline->pv1)->y;
|
||||
ve.x = ((polyvertex_t *)gr_curline->pv2)->x;
|
||||
ve.y = ((polyvertex_t *)gr_curline->pv2)->y;
|
||||
|
||||
#ifdef ESLOPE
|
||||
v1x = FLOAT_TO_FIXED(vs.x);
|
||||
|
@ -1378,44 +1375,21 @@ static void HWR_StoreWallRange(double startfrac, double endfrac)
|
|||
v2x = FLOAT_TO_FIXED(ve.x);
|
||||
v2y = FLOAT_TO_FIXED(ve.y);
|
||||
#endif
|
||||
|
||||
if (gr_frontsector->heightsec != -1)
|
||||
{
|
||||
#ifdef ESLOPE
|
||||
worldtop = worldtopslope = sectors[gr_frontsector->heightsec].ceilingheight;
|
||||
worldbottom = worldbottomslope = sectors[gr_frontsector->heightsec].floorheight;
|
||||
#else
|
||||
worldtop = sectors[gr_frontsector->heightsec].ceilingheight;
|
||||
worldbottom = sectors[gr_frontsector->heightsec].floorheight;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef ESLOPE
|
||||
if (gr_frontsector->c_slope)
|
||||
{
|
||||
worldtop = P_GetZAt(gr_frontsector->c_slope, v1x, v1y);
|
||||
worldtopslope = P_GetZAt(gr_frontsector->c_slope, v2x, v2y);
|
||||
}
|
||||
else
|
||||
{
|
||||
worldtop = worldtopslope = gr_frontsector->ceilingheight;
|
||||
}
|
||||
|
||||
if (gr_frontsector->f_slope)
|
||||
{
|
||||
worldbottom = P_GetZAt(gr_frontsector->f_slope, v1x, v1y);
|
||||
worldbottomslope = P_GetZAt(gr_frontsector->f_slope, v2x, v2y);
|
||||
}
|
||||
else
|
||||
{
|
||||
worldbottom = worldbottomslope = gr_frontsector->floorheight;
|
||||
}
|
||||
#define SLOPEPARAMS(slope, end1, end2, normalheight) \
|
||||
if (slope) { \
|
||||
end1 = P_GetZAt(slope, v1x, v1y); \
|
||||
end2 = P_GetZAt(slope, v2x, v2y); \
|
||||
} else \
|
||||
end1 = end2 = normalheight;
|
||||
|
||||
SLOPEPARAMS(gr_frontsector->c_slope, worldtop, worldtopslope, gr_frontsector->ceilingheight)
|
||||
SLOPEPARAMS(gr_frontsector->f_slope, worldbottom, worldbottomslope, gr_frontsector->floorheight)
|
||||
#else
|
||||
worldtop = gr_frontsector->ceilingheight;
|
||||
worldbottom = gr_frontsector->floorheight;
|
||||
worldtop = gr_frontsector->ceilingheight;
|
||||
worldbottom = gr_frontsector->floorheight;
|
||||
#endif
|
||||
}
|
||||
|
||||
// remember vertices ordering
|
||||
// 3--2
|
||||
|
@ -1430,7 +1404,6 @@ static void HWR_StoreWallRange(double startfrac, double endfrac)
|
|||
wallVerts[2].z = wallVerts[1].z = ve.y;
|
||||
wallVerts[0].w = wallVerts[1].w = wallVerts[2].w = wallVerts[3].w = 1.0f;
|
||||
|
||||
if (drawtextured)
|
||||
{
|
||||
// x offset the texture
|
||||
fixed_t texturehpeg = gr_sidedef->textureoffset + gr_curline->offset;
|
||||
|
@ -1459,43 +1432,15 @@ static void HWR_StoreWallRange(double startfrac, double endfrac)
|
|||
{
|
||||
INT32 gr_toptexture, gr_bottomtexture;
|
||||
// two sided line
|
||||
if (gr_backsector->heightsec != -1)
|
||||
{
|
||||
#ifdef ESLOPE
|
||||
worldhigh = worldhighslope = sectors[gr_backsector->heightsec].ceilingheight;
|
||||
worldlow = worldlowslope = sectors[gr_backsector->heightsec].floorheight;
|
||||
#else
|
||||
worldhigh = sectors[gr_backsector->heightsec].ceilingheight;
|
||||
worldlow = sectors[gr_backsector->heightsec].floorheight;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef ESLOPE
|
||||
if (gr_backsector->c_slope)
|
||||
{
|
||||
worldhigh = P_GetZAt(gr_backsector->c_slope, v1x, v1y);
|
||||
worldhighslope = P_GetZAt(gr_backsector->c_slope, v2x, v2y);
|
||||
}
|
||||
else
|
||||
{
|
||||
worldhigh = worldhighslope = gr_backsector->ceilingheight;
|
||||
}
|
||||
|
||||
if (gr_backsector->f_slope)
|
||||
{
|
||||
worldlow = P_GetZAt(gr_backsector->f_slope, v1x, v1y);
|
||||
worldlowslope = P_GetZAt(gr_backsector->f_slope, v2x, v2y);
|
||||
}
|
||||
else
|
||||
{
|
||||
worldlow = worldlowslope = gr_backsector->floorheight;
|
||||
}
|
||||
#ifdef ESLOPE
|
||||
SLOPEPARAMS(gr_backsector->c_slope, worldhigh, worldhighslope, gr_backsector->ceilingheight)
|
||||
SLOPEPARAMS(gr_backsector->f_slope, worldlow, worldlowslope, gr_backsector->floorheight)
|
||||
#undef SLOPEPARAMS
|
||||
#else
|
||||
worldhigh = gr_backsector->ceilingheight;
|
||||
worldlow = gr_backsector->floorheight;
|
||||
worldhigh = gr_backsector->ceilingheight;
|
||||
worldlow = gr_backsector->floorheight;
|
||||
#endif
|
||||
}
|
||||
|
||||
// hack to allow height changes in outdoor areas
|
||||
// This is what gets rid of the upper textures if there should be sky
|
||||
|
@ -1519,7 +1464,6 @@ static void HWR_StoreWallRange(double startfrac, double endfrac)
|
|||
worldhigh < worldtop
|
||||
) && gr_toptexture)
|
||||
{
|
||||
if (drawtextured)
|
||||
{
|
||||
fixed_t texturevpegtop; // top
|
||||
|
||||
|
@ -1600,7 +1544,6 @@ static void HWR_StoreWallRange(double startfrac, double endfrac)
|
|||
#endif
|
||||
worldlow > worldbottom) && gr_bottomtexture) //only if VISIBLE!!!
|
||||
{
|
||||
if (drawtextured)
|
||||
{
|
||||
fixed_t texturevpegbottom = 0; // bottom
|
||||
|
||||
|
@ -1792,7 +1735,6 @@ static void HWR_StoreWallRange(double startfrac, double endfrac)
|
|||
h = min(highcut, polytop);
|
||||
l = max(polybottom, lowcut);
|
||||
|
||||
if (drawtextured)
|
||||
{
|
||||
// PEGGING
|
||||
#ifdef ESLOPE
|
||||
|
@ -1848,7 +1790,6 @@ static void HWR_StoreWallRange(double startfrac, double endfrac)
|
|||
h = min(highcut, polytop);
|
||||
l = max(polybottom, lowcut);
|
||||
|
||||
if (drawtextured)
|
||||
{
|
||||
// PEGGING
|
||||
if (!!(gr_linedef->flags & ML_DONTPEGBOTTOM) ^ !!(gr_linedef->flags & ML_EFFECT3))
|
||||
|
@ -2039,7 +1980,6 @@ static void HWR_StoreWallRange(double startfrac, double endfrac)
|
|||
gr_midtexture = R_GetTextureNum(gr_sidedef->midtexture);
|
||||
if (gr_midtexture)
|
||||
{
|
||||
if (drawtextured)
|
||||
{
|
||||
fixed_t texturevpeg;
|
||||
// PEGGING
|
||||
|
@ -2180,7 +2120,7 @@ static void HWR_StoreWallRange(double startfrac, double endfrac)
|
|||
wallVerts[0].s = wallVerts[3].s = 0;
|
||||
wallVerts[2].s = wallVerts[1].s = 0;
|
||||
}
|
||||
else if (drawtextured)
|
||||
else
|
||||
{
|
||||
fixed_t texturevpeg;
|
||||
|
||||
|
@ -2316,7 +2256,7 @@ static void HWR_StoreWallRange(double startfrac, double endfrac)
|
|||
wallVerts[0].s = wallVerts[3].s = 0;
|
||||
wallVerts[2].s = wallVerts[1].s = 0;
|
||||
}
|
||||
else if (drawtextured)
|
||||
else
|
||||
{
|
||||
grTex = HWR_GetTexture(texnum);
|
||||
|
||||
|
@ -2456,7 +2396,7 @@ static void HWR_ClipSolidWallSegment(INT32 first, INT32 last)
|
|||
}
|
||||
else
|
||||
{
|
||||
highfrac = HWR_ClipViewSegment(start->first+1, (polyvertex_t *)gr_curline->v1, (polyvertex_t *)gr_curline->v2);
|
||||
highfrac = HWR_ClipViewSegment(start->first+1, (polyvertex_t *)gr_curline->pv1, (polyvertex_t *)gr_curline->pv2);
|
||||
HWR_StoreWallRange(0, highfrac);
|
||||
}
|
||||
// Now adjust the clip size.
|
||||
|
@ -2480,8 +2420,8 @@ static void HWR_ClipSolidWallSegment(INT32 first, INT32 last)
|
|||
}
|
||||
else
|
||||
{
|
||||
lowfrac = HWR_ClipViewSegment(next->last-1, (polyvertex_t *)gr_curline->v1, (polyvertex_t *)gr_curline->v2);
|
||||
highfrac = HWR_ClipViewSegment((next+1)->first+1, (polyvertex_t *)gr_curline->v1, (polyvertex_t *)gr_curline->v2);
|
||||
lowfrac = HWR_ClipViewSegment(next->last-1, (polyvertex_t *)gr_curline->pv1, (polyvertex_t *)gr_curline->pv2);
|
||||
highfrac = HWR_ClipViewSegment((next+1)->first+1, (polyvertex_t *)gr_curline->pv1, (polyvertex_t *)gr_curline->pv2);
|
||||
HWR_StoreWallRange(lowfrac, highfrac);
|
||||
}
|
||||
next++;
|
||||
|
@ -2515,7 +2455,7 @@ static void HWR_ClipSolidWallSegment(INT32 first, INT32 last)
|
|||
}
|
||||
else
|
||||
{
|
||||
lowfrac = HWR_ClipViewSegment(next->last-1, (polyvertex_t *)gr_curline->v1, (polyvertex_t *)gr_curline->v2);
|
||||
lowfrac = HWR_ClipViewSegment(next->last-1, (polyvertex_t *)gr_curline->pv1, (polyvertex_t *)gr_curline->pv2);
|
||||
HWR_StoreWallRange(lowfrac, 1);
|
||||
}
|
||||
}
|
||||
|
@ -2578,8 +2518,8 @@ static void HWR_ClipPassWallSegment(INT32 first, INT32 last)
|
|||
else
|
||||
{
|
||||
highfrac = HWR_ClipViewSegment(min(start->first + 1,
|
||||
start->last), (polyvertex_t *)gr_curline->v1,
|
||||
(polyvertex_t *)gr_curline->v2);
|
||||
start->last), (polyvertex_t *)gr_curline->pv1,
|
||||
(polyvertex_t *)gr_curline->pv2);
|
||||
HWR_StoreWallRange(0, highfrac);
|
||||
}
|
||||
}
|
||||
|
@ -2598,8 +2538,8 @@ static void HWR_ClipPassWallSegment(INT32 first, INT32 last)
|
|||
}
|
||||
else
|
||||
{
|
||||
lowfrac = HWR_ClipViewSegment(max(start->last-1,start->first), (polyvertex_t *)gr_curline->v1, (polyvertex_t *)gr_curline->v2);
|
||||
highfrac = HWR_ClipViewSegment(min((start+1)->first+1,(start+1)->last), (polyvertex_t *)gr_curline->v1, (polyvertex_t *)gr_curline->v2);
|
||||
lowfrac = HWR_ClipViewSegment(max(start->last-1,start->first), (polyvertex_t *)gr_curline->pv1, (polyvertex_t *)gr_curline->pv2);
|
||||
highfrac = HWR_ClipViewSegment(min((start+1)->first+1,(start+1)->last), (polyvertex_t *)gr_curline->pv1, (polyvertex_t *)gr_curline->pv2);
|
||||
HWR_StoreWallRange(lowfrac, highfrac);
|
||||
}
|
||||
start++;
|
||||
|
@ -2629,8 +2569,8 @@ static void HWR_ClipPassWallSegment(INT32 first, INT32 last)
|
|||
else
|
||||
{
|
||||
lowfrac = HWR_ClipViewSegment(max(start->last - 1,
|
||||
start->first), (polyvertex_t *)gr_curline->v1,
|
||||
(polyvertex_t *)gr_curline->v2);
|
||||
start->first), (polyvertex_t *)gr_curline->pv1,
|
||||
(polyvertex_t *)gr_curline->pv2);
|
||||
HWR_StoreWallRange(lowfrac, 1);
|
||||
}
|
||||
}
|
||||
|
@ -2685,16 +2625,21 @@ static void HWR_AddLine(seg_t * line)
|
|||
// SoM: Backsector needs to be run through R_FakeFlat
|
||||
static sector_t tempsec;
|
||||
|
||||
fixed_t v1x, v1y, v2x, v2y; // the seg's vertexes as fixed_t
|
||||
|
||||
if (line->polyseg && !(line->polyseg->flags & POF_RENDERSIDES))
|
||||
return;
|
||||
|
||||
gr_curline = line;
|
||||
|
||||
v1x = FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->pv1)->x);
|
||||
v1y = FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->pv1)->y);
|
||||
v2x = FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->pv2)->x);
|
||||
v2y = FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->pv2)->y);
|
||||
|
||||
// OPTIMIZE: quickly reject orthogonal back sides.
|
||||
angle1 = R_PointToAngle(FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->v1)->x),
|
||||
FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->v1)->y));
|
||||
angle2 = R_PointToAngle(FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->v2)->x),
|
||||
FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->v2)->y));
|
||||
angle1 = R_PointToAngle(v1x, v1y);
|
||||
angle2 = R_PointToAngle(v2x, v2y);
|
||||
|
||||
// Clip to view edges.
|
||||
span = angle1 - angle2;
|
||||
|
@ -2736,8 +2681,8 @@ static void HWR_AddLine(seg_t * line)
|
|||
float fx1,fx2,fy1,fy2;
|
||||
//BP: test with a better projection than viewangletox[R_PointToAngle(angle)]
|
||||
// do not enable this at release 4 mul and 2 div
|
||||
fx1 = ((polyvertex_t *)(line->v1))->x-gr_viewx;
|
||||
fy1 = ((polyvertex_t *)(line->v1))->y-gr_viewy;
|
||||
fx1 = ((polyvertex_t *)(line->pv1))->x-gr_viewx;
|
||||
fy1 = ((polyvertex_t *)(line->pv1))->y-gr_viewy;
|
||||
fy2 = (fx1 * gr_viewcos + fy1 * gr_viewsin);
|
||||
if (fy2 < 0)
|
||||
// the point is back
|
||||
|
@ -2745,8 +2690,8 @@ static void HWR_AddLine(seg_t * line)
|
|||
else
|
||||
fx1 = gr_windowcenterx + (fx1 * gr_viewsin - fy1 * gr_viewcos) * gr_centerx / fy2;
|
||||
|
||||
fx2 = ((polyvertex_t *)(line->v2))->x-gr_viewx;
|
||||
fy2 = ((polyvertex_t *)(line->v2))->y-gr_viewy;
|
||||
fx2 = ((polyvertex_t *)(line->pv2))->x-gr_viewx;
|
||||
fy2 = ((polyvertex_t *)(line->pv2))->y-gr_viewy;
|
||||
fy1 = (fx2 * gr_viewcos + fy2 * gr_viewsin);
|
||||
if (fy1 < 0)
|
||||
// the point is back
|
||||
|
@ -2785,14 +2730,9 @@ static void HWR_AddLine(seg_t * line)
|
|||
#ifdef ESLOPE
|
||||
if (gr_frontsector->f_slope || gr_frontsector->c_slope || gr_backsector->f_slope || gr_backsector->c_slope)
|
||||
{
|
||||
fixed_t v1x, v1y, v2x, v2y; // the seg's vertexes as fixed_t
|
||||
fixed_t frontf1,frontf2, frontc1, frontc2; // front floor/ceiling ends
|
||||
fixed_t backf1, backf2, backc1, backc2; // back floor ceiling ends
|
||||
|
||||
v1x = FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->v1)->x);
|
||||
v1y = FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->v1)->y);
|
||||
v2x = FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->v2)->x);
|
||||
v2y = FLOAT_TO_FIXED(((polyvertex_t *)gr_curline->v2)->y);
|
||||
#define SLOPEPARAMS(slope, end1, end2, normalheight) \
|
||||
if (slope) { \
|
||||
end1 = P_GetZAt(slope, v1x, v1y); \
|
||||
|
@ -2813,6 +2753,13 @@ static void HWR_AddLine(seg_t * line)
|
|||
goto clipsolid;
|
||||
}
|
||||
|
||||
// Check for automap fix.
|
||||
if (backc1 <= backf1 && backc2 <= backf2
|
||||
&& ((backc1 >= frontc1 && backc2 >= frontc2) || gr_curline->sidedef->toptexture)
|
||||
&& ((backf1 <= frontf1 && backf2 >= frontf2) || gr_curline->sidedef->bottomtexture)
|
||||
&& (gr_backsector->ceilingpic != skyflatnum || gr_frontsector->ceilingpic != skyflatnum))
|
||||
goto clipsolid;
|
||||
|
||||
// Window.
|
||||
if (backc1 != frontc1 || backc2 != frontc2
|
||||
|| backf1 != frontf1 || backf2 != frontf2)
|
||||
|
@ -2828,6 +2775,13 @@ static void HWR_AddLine(seg_t * line)
|
|||
gr_backsector->floorheight >= gr_frontsector->ceilingheight)
|
||||
goto clipsolid;
|
||||
|
||||
// Check for automap fix.
|
||||
if (gr_backsector->ceilingheight <= gr_backsector->floorheight
|
||||
&& ((gr_backsector->ceilingheight >= gr_frontsector->ceilingheight) || gr_curline->sidedef->toptexture)
|
||||
&& ((gr_backsector->floorheight <= gr_backsector->floorheight) || gr_curline->sidedef->bottomtexture)
|
||||
&& (gr_backsector->ceilingpic != skyflatnum || gr_frontsector->ceilingpic != skyflatnum))
|
||||
goto clipsolid;
|
||||
|
||||
// Window.
|
||||
if (gr_backsector->ceilingheight != gr_frontsector->ceilingheight ||
|
||||
gr_backsector->floorheight != gr_frontsector->floorheight)
|
||||
|
@ -2849,8 +2803,21 @@ static void HWR_AddLine(seg_t * line)
|
|||
&& gr_backsector->c_slope == gr_frontsector->c_slope
|
||||
#endif
|
||||
&& gr_backsector->lightlevel == gr_frontsector->lightlevel
|
||||
&& gr_curline->sidedef->midtexture == 0
|
||||
&& !gr_backsector->ffloors && !gr_frontsector->ffloors)
|
||||
&& !gr_curline->sidedef->midtexture
|
||||
// Check offsets too!
|
||||
&& gr_backsector->floor_xoffs == gr_frontsector->floor_xoffs
|
||||
&& gr_backsector->floor_yoffs == gr_frontsector->floor_yoffs
|
||||
&& gr_backsector->floorpic_angle == gr_frontsector->floorpic_angle
|
||||
&& gr_backsector->ceiling_xoffs == gr_frontsector->ceiling_xoffs
|
||||
&& gr_backsector->ceiling_yoffs == gr_frontsector->ceiling_yoffs
|
||||
&& gr_backsector->ceilingpic_angle == gr_frontsector->ceilingpic_angle
|
||||
// Consider altered lighting.
|
||||
&& gr_backsector->floorlightsec == gr_frontsector->floorlightsec
|
||||
&& gr_backsector->ceilinglightsec == gr_frontsector->ceilinglightsec
|
||||
// Consider colormaps
|
||||
&& gr_backsector->extra_colormap == gr_frontsector->extra_colormap
|
||||
&& ((!gr_frontsector->ffloors && !gr_backsector->ffloors)
|
||||
|| gr_frontsector->tag == gr_backsector->tag))
|
||||
// SoM: For 3D sides... Boris, would you like to take a
|
||||
// crack at rendering 3D sides? You would need to add the
|
||||
// above check and add code to HWR_StoreWallRange...
|
||||
|
@ -2987,8 +2954,8 @@ static inline void HWR_AddPolyObjectSegs(void)
|
|||
pv2->x = FIXED_TO_FLOAT(gr_fakeline->v2->x);
|
||||
pv2->y = FIXED_TO_FLOAT(gr_fakeline->v2->y);
|
||||
|
||||
gr_fakeline->v1 = (vertex_t *)pv1;
|
||||
gr_fakeline->v2 = (vertex_t *)pv2;
|
||||
gr_fakeline->pv1 = pv1;
|
||||
gr_fakeline->pv2 = pv2;
|
||||
|
||||
HWR_AddLine(gr_fakeline);
|
||||
}
|
||||
|
|
|
@ -304,8 +304,8 @@ static md2_model_t *md2_readModel(const char *filename)
|
|||
// initialize model and read header
|
||||
|
||||
if (fread(&model->header, sizeof (model->header), 1, file) != 1
|
||||
|| model->header.magic !=
|
||||
(INT32)(('2' << 24) + ('P' << 16) + ('D' << 8) + 'I'))
|
||||
|| model->header.magic != MD2_IDENT
|
||||
|| model->header.version != MD2_VERSION)
|
||||
{
|
||||
fclose(file);
|
||||
free(model);
|
||||
|
@ -319,6 +319,7 @@ static md2_model_t *md2_readModel(const char *filename)
|
|||
{ \
|
||||
CONS_Alert(CONS_ERROR, "md2_readModel: %s has too many " msgname " (# found: %d, maximum: %d)\n", filename, field, max); \
|
||||
md2_freeModel (model); \
|
||||
fclose(file); \
|
||||
return 0; \
|
||||
}
|
||||
|
||||
|
@ -340,6 +341,7 @@ static md2_model_t *md2_readModel(const char *filename)
|
|||
fread(model->skins, sizeof (md2_skin_t), model->header.numSkins, file))
|
||||
{
|
||||
md2_freeModel (model);
|
||||
fclose(file);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -353,6 +355,7 @@ static md2_model_t *md2_readModel(const char *filename)
|
|||
fread(model->texCoords, sizeof (md2_textureCoordinate_t), model->header.numTexCoords, file))
|
||||
{
|
||||
md2_freeModel (model);
|
||||
fclose(file);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -366,6 +369,7 @@ static md2_model_t *md2_readModel(const char *filename)
|
|||
fread(model->triangles, sizeof (md2_triangle_t), model->header.numTriangles, file))
|
||||
{
|
||||
md2_freeModel (model);
|
||||
fclose(file);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -378,6 +382,7 @@ static md2_model_t *md2_readModel(const char *filename)
|
|||
if (!model->frames)
|
||||
{
|
||||
md2_freeModel (model);
|
||||
fclose(file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -391,6 +396,7 @@ static md2_model_t *md2_readModel(const char *filename)
|
|||
fread(frame, 1, model->header.frameSize, file))
|
||||
{
|
||||
md2_freeModel (model);
|
||||
fclose(file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -416,6 +422,7 @@ static md2_model_t *md2_readModel(const char *filename)
|
|||
fread(model->glCommandBuffer, sizeof (INT32), model->header.numGlCommands, file))
|
||||
{
|
||||
md2_freeModel (model);
|
||||
fclose(file);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,11 @@
|
|||
|
||||
#include "hw_glob.h"
|
||||
|
||||
// magic number "IDP2" or 844121161
|
||||
#define MD2_IDENT (INT32)(('2' << 24) + ('P' << 16) + ('D' << 8) + 'I')
|
||||
// model version
|
||||
#define MD2_VERSION 8
|
||||
|
||||
#define MD2_MAX_TRIANGLES 8192
|
||||
#define MD2_MAX_VERTICES 4096
|
||||
#define MD2_MAX_TEXCOORDS 4096
|
||||
|
|
|
@ -107,17 +107,17 @@ static void releaseLineChains(void)
|
|||
|
||||
for (i = 0; i < numsectors; i++)
|
||||
{
|
||||
sector = §ors[i];
|
||||
nextElem = sector->sectorLines;
|
||||
sector = §ors[i];
|
||||
nextElem = sector->sectorLines;
|
||||
|
||||
while (nextElem)
|
||||
{
|
||||
thisElem = nextElem;
|
||||
nextElem = thisElem->next;
|
||||
free(thisElem);
|
||||
}
|
||||
while (nextElem)
|
||||
{
|
||||
thisElem = nextElem;
|
||||
nextElem = thisElem->next;
|
||||
free(thisElem);
|
||||
}
|
||||
|
||||
sector->sectorLines = NULL;
|
||||
sector->sectorLines = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -397,7 +397,7 @@ static void sortStacklist(sector_t *sector)
|
|||
i = 0;
|
||||
finished = true;
|
||||
|
||||
while (NULL != *(list+i+1))
|
||||
while (*(list+i+1))
|
||||
{
|
||||
sec1 = *(list+i);
|
||||
sec2 = *(list+i+1);
|
||||
|
@ -438,7 +438,7 @@ static double calcLineoutLength(sector_t *sector)
|
|||
double length = 0.0L;
|
||||
chain = sector->sectorLines;
|
||||
|
||||
while (NULL != chain) // sum up lengths of all lines
|
||||
while (chain) // sum up lengths of all lines
|
||||
{
|
||||
length += lineLength(chain->line);
|
||||
chain = chain->next;
|
||||
|
@ -454,7 +454,7 @@ static void calcLineouts(sector_t *sector)
|
|||
size_t secCount = 0;
|
||||
sector_t *encSector = *(sector->stackList);
|
||||
|
||||
while (NULL != encSector)
|
||||
while (encSector)
|
||||
{
|
||||
if (encSector->lineoutLength < 0.0L) // if length has not yet been calculated
|
||||
{
|
||||
|
@ -552,7 +552,7 @@ static boolean areBottomtexturesMissing(sector_t *thisSector)
|
|||
if (frontSector == backSector) // skip damn renderer tricks here
|
||||
continue;
|
||||
|
||||
if (frontSector == NULL || backSector == NULL)
|
||||
if (!frontSector || !backSector)
|
||||
continue;
|
||||
|
||||
sider = &sides[thisElem->line->sidenum[0]];
|
||||
|
@ -587,73 +587,12 @@ static boolean areBottomtexturesMissing(sector_t *thisSector)
|
|||
static boolean isCeilingFloating(sector_t *thisSector)
|
||||
{
|
||||
sector_t *adjSector, *refSector = NULL, *frontSector, *backSector;
|
||||
boolean floating = true;
|
||||
linechain_t *thisElem, *nextElem;
|
||||
|
||||
if (!thisSector)
|
||||
return false;
|
||||
|
||||
nextElem = thisSector->sectorLines;
|
||||
|
||||
while (NULL != nextElem) // walk through chain
|
||||
{
|
||||
thisElem = nextElem;
|
||||
nextElem = thisElem->next;
|
||||
|
||||
frontSector = thisElem->line->frontsector;
|
||||
backSector = thisElem->line->backsector;
|
||||
|
||||
if (frontSector == thisSector)
|
||||
adjSector = backSector;
|
||||
else
|
||||
adjSector = frontSector;
|
||||
|
||||
if (!adjSector) // assume floating sectors have surrounding sectors
|
||||
{
|
||||
floating = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!refSector)
|
||||
{
|
||||
refSector = adjSector;
|
||||
continue;
|
||||
}
|
||||
|
||||
// if adjacent sector has same height or more than one adjacent sector exists -> stop
|
||||
if (thisSector->ceilingheight == adjSector->ceilingheight ||
|
||||
refSector != adjSector)
|
||||
{
|
||||
floating = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// now check for walltextures
|
||||
if (floating)
|
||||
{
|
||||
if (!areToptexturesMissing(thisSector))
|
||||
{
|
||||
floating = false;
|
||||
}
|
||||
}
|
||||
return floating;
|
||||
}
|
||||
|
||||
//
|
||||
// check if no adjacent sector has same ceiling height
|
||||
// FIXME: throw that together with isCeilingFloating??
|
||||
//
|
||||
static boolean isFloorFloating(sector_t *thisSector)
|
||||
{
|
||||
sector_t *adjSector, *refSector = NULL, *frontSector, *backSector;
|
||||
boolean floating = true;
|
||||
linechain_t *thisElem, *nextElem;
|
||||
|
||||
if (!thisSector)
|
||||
return false;
|
||||
|
||||
nextElem = thisSector->sectorLines;
|
||||
nextElem = thisSector->sectorLines;
|
||||
|
||||
while (nextElem) // walk through chain
|
||||
{
|
||||
|
@ -668,36 +607,83 @@ static boolean isFloorFloating(sector_t *thisSector)
|
|||
else
|
||||
adjSector = frontSector;
|
||||
|
||||
if (NULL == adjSector) // assume floating sectors have surrounding sectors
|
||||
{
|
||||
floating = false;
|
||||
break;
|
||||
}
|
||||
if (!adjSector) // assume floating sectors have surrounding sectors
|
||||
return false;
|
||||
|
||||
if (NULL == refSector)
|
||||
#ifdef ESLOPE
|
||||
if (adjSector->c_slope) // Don't bother with slopes
|
||||
return false;
|
||||
#endif
|
||||
|
||||
if (!refSector)
|
||||
{
|
||||
refSector = adjSector;
|
||||
continue;
|
||||
}
|
||||
|
||||
// if adjacent sector has same height or more than one adjacent sector exists -> stop
|
||||
if (thisSector->floorheight == adjSector->floorheight ||
|
||||
refSector != adjSector)
|
||||
{
|
||||
floating = false;
|
||||
break;
|
||||
}
|
||||
if (thisSector->ceilingheight == adjSector->ceilingheight || refSector != adjSector)
|
||||
return false;
|
||||
}
|
||||
|
||||
// now check for walltextures
|
||||
if (floating)
|
||||
if (!areToptexturesMissing(thisSector))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//
|
||||
// check if no adjacent sector has same ceiling height
|
||||
// FIXME: throw that together with isCeilingFloating??
|
||||
//
|
||||
static boolean isFloorFloating(sector_t *thisSector)
|
||||
{
|
||||
sector_t *adjSector, *refSector = NULL, *frontSector, *backSector;
|
||||
linechain_t *thisElem, *nextElem;
|
||||
|
||||
if (!thisSector)
|
||||
return false;
|
||||
|
||||
nextElem = thisSector->sectorLines;
|
||||
|
||||
while (nextElem) // walk through chain
|
||||
{
|
||||
if (!areBottomtexturesMissing(thisSector))
|
||||
thisElem = nextElem;
|
||||
nextElem = thisElem->next;
|
||||
|
||||
frontSector = thisElem->line->frontsector;
|
||||
backSector = thisElem->line->backsector;
|
||||
|
||||
if (frontSector == thisSector)
|
||||
adjSector = backSector;
|
||||
else
|
||||
adjSector = frontSector;
|
||||
|
||||
if (!adjSector) // assume floating sectors have surrounding sectors
|
||||
return false;
|
||||
|
||||
#ifdef ESLOPE
|
||||
if (adjSector->f_slope) // Don't bother with slopes
|
||||
return false;
|
||||
#endif
|
||||
|
||||
if (!refSector)
|
||||
{
|
||||
floating = false;
|
||||
refSector = adjSector;
|
||||
continue;
|
||||
}
|
||||
|
||||
// if adjacent sector has same height or more than one adjacent sector exists -> stop
|
||||
if (thisSector->floorheight == adjSector->floorheight || refSector != adjSector)
|
||||
return false;
|
||||
}
|
||||
return floating;
|
||||
|
||||
// now check for walltextures
|
||||
if (!areBottomtexturesMissing(thisSector))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -707,14 +693,12 @@ static fixed_t estimateCeilHeight(sector_t *thisSector)
|
|||
{
|
||||
sector_t *adjSector;
|
||||
|
||||
if (!thisSector ||
|
||||
!thisSector->sectorLines ||
|
||||
!thisSector->sectorLines->line)
|
||||
if (!thisSector || !thisSector->sectorLines || !thisSector->sectorLines->line)
|
||||
return 0;
|
||||
|
||||
adjSector = thisSector->sectorLines->line->frontsector;
|
||||
if (adjSector == thisSector)
|
||||
adjSector = thisSector->sectorLines->line->backsector;
|
||||
adjSector = thisSector->sectorLines->line->backsector;
|
||||
|
||||
if (!adjSector)
|
||||
return 0;
|
||||
|
@ -729,17 +713,15 @@ static fixed_t estimateFloorHeight(sector_t *thisSector)
|
|||
{
|
||||
sector_t *adjSector;
|
||||
|
||||
if (!thisSector ||
|
||||
!thisSector->sectorLines ||
|
||||
!thisSector->sectorLines->line)
|
||||
return 0;
|
||||
if (!thisSector || !thisSector->sectorLines || !thisSector->sectorLines->line)
|
||||
return 0;
|
||||
|
||||
adjSector = thisSector->sectorLines->line->frontsector;
|
||||
if (adjSector == thisSector)
|
||||
adjSector = thisSector->sectorLines->line->backsector;
|
||||
adjSector = thisSector->sectorLines->line->backsector;
|
||||
|
||||
if (NULL == adjSector)
|
||||
return 0;
|
||||
if (!adjSector)
|
||||
return 0;
|
||||
|
||||
return adjSector->floorheight;
|
||||
}
|
||||
|
@ -845,18 +827,12 @@ void HWR_CorrectSWTricks(void)
|
|||
// correct height of floating sectors
|
||||
if (isCeilingFloating(floatSector))
|
||||
{
|
||||
fixed_t corrheight;
|
||||
|
||||
corrheight = estimateCeilHeight(floatSector);
|
||||
floatSector->virtualCeilingheight = corrheight;
|
||||
floatSector->virtualCeilingheight = estimateCeilHeight(floatSector);
|
||||
floatSector->virtualCeiling = true;
|
||||
}
|
||||
if (isFloorFloating(floatSector))
|
||||
{
|
||||
fixed_t corrheight;
|
||||
|
||||
corrheight = estimateFloorHeight(floatSector);
|
||||
floatSector->virtualFloorheight = corrheight;
|
||||
floatSector->virtualFloorheight = estimateFloorHeight(floatSector);
|
||||
floatSector->virtualFloor = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -451,6 +451,7 @@ static void P_LoadSegs(lumpnum_t lumpnum)
|
|||
//Hurdler: 04/12/2000: for now, only used in hardware mode
|
||||
li->lightmaps = NULL; // list of static lightmap for this seg
|
||||
}
|
||||
li->pv1 = li->pv2 = NULL;
|
||||
#endif
|
||||
|
||||
li->angle = (SHORT(ml->angle))<<FRACBITS;
|
||||
|
|
|
@ -574,6 +574,9 @@ typedef struct seg_s
|
|||
sector_t *backsector;
|
||||
|
||||
#ifdef HWRENDER
|
||||
// new pointers so that AdjustSegs doesn't mess with v1/v2
|
||||
void *pv1; // polyvertex_t
|
||||
void *pv2; // polyvertex_t
|
||||
float flength; // length of the seg, used by hardware renderer
|
||||
|
||||
lightmap_t *lightmaps; // for static lightmap
|
||||
|
|
Loading…
Reference in a new issue