Merge remote-tracking branch 'birdhouse/gl-render-distance' into Custom
This commit is contained in:
commit
8535ed374b
7 files changed
+123
-11
No files matched your search
@@ -23,6 +23,7 @@
|
||||
|
||||
#define ZCLIP_PLANE 4.0f // Used for the actual game drawing
|
||||
#define NZCLIP_PLANE 0.9f // Seems to be only used for the HUD and screen textures
|
||||
#define FAR_ZCLIP_DEFAULT 32768.0f
|
||||
|
||||
// ==========================================================================
|
||||
// SIMPLE TYPES
|
||||
|
||||
@@ -39,7 +39,7 @@ EXPORT void HWRAPI(SetBlend) (FBITFIELD PolyFlags);
|
||||
EXPORT void HWRAPI(ClearBuffer) (FBOOLEAN ColorMask, FBOOLEAN DepthMask, FRGBAFloat *ClearColor);
|
||||
EXPORT void HWRAPI(SetTexture) (FTextureInfo *TexInfo);
|
||||
EXPORT void HWRAPI(ReadRect) (INT32 x, INT32 y, INT32 width, INT32 height, INT32 dst_stride, UINT16 *dst_data);
|
||||
EXPORT void HWRAPI(GClipRect) (INT32 minx, INT32 miny, INT32 maxx, INT32 maxy, float nearclip);
|
||||
EXPORT void HWRAPI(GClipRect) (INT32 minx, INT32 miny, INT32 maxx, INT32 maxy, float nearclip, float farclip);
|
||||
EXPORT void HWRAPI(ClearMipMapCache) (void);
|
||||
|
||||
//Hurdler: added for backward compatibility
|
||||
|
||||
+111
-6
@@ -80,6 +80,19 @@ consvar_t cv_grsolvetjoin = {"gr_solvetjoin", "On", 0, CV_OnOff, NULL, 0, NULL,
|
||||
|
||||
consvar_t cv_grbatching = {"gr_batching", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
static CV_PossibleValue_t grrenderdistance_cons_t[] = {
|
||||
{0, "Max"}, {1, "1024"}, {2, "2048"}, {3, "4096"}, {4, "6144"}, {5, "8192"},
|
||||
{6, "12288"}, {7, "16384"}, {0, NULL}};
|
||||
consvar_t cv_grrenderdistance = {"gr_renderdistance", "Max", CV_SAVE, grrenderdistance_cons_t,
|
||||
NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
// values for the far clipping plane
|
||||
static float clipping_distances[] = {1024.0f, 2048.0f, 4096.0f, 6144.0f, 8192.0f, 12288.0f, 16384.0f};
|
||||
// values for bsp culling
|
||||
// slightly higher than the far clipping plane to compensate for impreciseness
|
||||
static INT32 bsp_culling_distances[] = {(1024+512)*FRACUNIT, (2048+512)*FRACUNIT, (4096+512)*FRACUNIT,
|
||||
(6144+512)*FRACUNIT, (8192+512)*FRACUNIT, (12288+512)*FRACUNIT, (16384+512)*FRACUNIT};
|
||||
static INT32 current_bsp_culling_distance = 0;
|
||||
|
||||
static void CV_filtermode_ONChange(void)
|
||||
{
|
||||
HWD.pfnSetSpecialState(HWD_SET_TEXTUREFILTERMODE, cv_grfiltermode.value);
|
||||
@@ -2097,6 +2110,70 @@ boolean HWR_CheckBBox(fixed_t *bspcoord)
|
||||
px2 = bspcoord[checkcoord[boxpos][2]];
|
||||
py2 = bspcoord[checkcoord[boxpos][3]];
|
||||
|
||||
if (current_bsp_culling_distance)
|
||||
{
|
||||
//fixed_t midx = (px1 >> 1) + (px2 >> 1);
|
||||
//fixed_t midy = (py1 >> 1) + (py2 >> 1);
|
||||
//fixed_t mindist = min(min(R_PointToDist(px1, py1), R_PointToDist(px2, py2)), R_PointToDist(midx, midy));
|
||||
|
||||
//fixed_t mindist = ClosestPointOnLineDistance(px1, py1, px2, py2);
|
||||
|
||||
//fixed_t mindist1 = ClosestPointOnLineDistance(bspcoord[BOXLEFT], bspcoord[BOXTOP], bspcoord[BOXRIGHT], bspcoord[BOXTOP]); // top line
|
||||
//fixed_t mindist2 = ClosestPointOnLineDistance(bspcoord[BOXLEFT], bspcoord[BOXTOP], bspcoord[BOXLEFT], bspcoord[BOXBOTTOM]); // left line
|
||||
//fixed_t mindist3 = ClosestPointOnLineDistance(bspcoord[BOXLEFT], bspcoord[BOXBOTTOM], bspcoord[BOXRIGHT], bspcoord[BOXBOTTOM]); // bottom line
|
||||
//fixed_t mindist4 = ClosestPointOnLineDistance(bspcoord[BOXRIGHT], bspcoord[BOXTOP], bspcoord[BOXRIGHT], bspcoord[BOXBOTTOM]); // right line
|
||||
// this one seems too lax.. maybe closestpointonlinedistance is glitchy and returns points that are not on the line segment?
|
||||
// could try building an if-else structure that determines what point or line is closest
|
||||
// 1 | 2 | 3
|
||||
//--------------
|
||||
// 4 |node| 5
|
||||
//--------------
|
||||
// 6 | 7 | 8
|
||||
// y
|
||||
// ^
|
||||
// |
|
||||
// -----> x
|
||||
// inside node: always inside draw distance. the above boxpos thing might have returned true already?
|
||||
// 1. check top left corner 2. check top line 3. check top right corner
|
||||
// 4. check left line 5. check right line
|
||||
// 6. check bottom left corner 7. check bottom line 8. check bottom right corner
|
||||
// one if statement will split the space in two for one coordinate
|
||||
// for example:
|
||||
// x < BOXLEFT || BOXLEFT || !(x < BOXLEFT) <-- (same as x >= BOXLEFT)
|
||||
fixed_t mindist;// = min(min(mindist1, mindist2), min(mindist3, mindist4));
|
||||
|
||||
// new thing
|
||||
// calculate distance to axis aligned bounding box.
|
||||
if (viewx < bspcoord[BOXLEFT]) // 1,4,6
|
||||
{
|
||||
if (viewy > bspcoord[BOXTOP]) // 1
|
||||
mindist = R_PointToDist(bspcoord[BOXLEFT], bspcoord[BOXTOP]);
|
||||
else if (viewy < bspcoord[BOXBOTTOM]) // 6
|
||||
mindist = R_PointToDist(bspcoord[BOXLEFT], bspcoord[BOXBOTTOM]);
|
||||
else // 4
|
||||
mindist = bspcoord[BOXLEFT] - viewx;
|
||||
}
|
||||
else if (viewx > bspcoord[BOXRIGHT]) // 3,5,8
|
||||
{
|
||||
if (viewy > bspcoord[BOXTOP]) // 3
|
||||
mindist = R_PointToDist(bspcoord[BOXRIGHT], bspcoord[BOXTOP]);
|
||||
else if (viewy < bspcoord[BOXBOTTOM]) // 8
|
||||
mindist = R_PointToDist(bspcoord[BOXRIGHT], bspcoord[BOXBOTTOM]);
|
||||
else // 5
|
||||
mindist = viewx - bspcoord[BOXRIGHT];
|
||||
}
|
||||
else // 2,node,7
|
||||
{
|
||||
if (viewy > bspcoord[BOXTOP]) // 2
|
||||
mindist = viewy - bspcoord[BOXTOP];
|
||||
else if (viewy < bspcoord[BOXBOTTOM]) // 7
|
||||
mindist = bspcoord[BOXBOTTOM] - viewy;
|
||||
else // node
|
||||
mindist = 0;
|
||||
}
|
||||
if (mindist > current_bsp_culling_distance) return false;
|
||||
}
|
||||
|
||||
angle1 = R_PointToAngleEx(viewx, viewy, px1, py1);
|
||||
angle2 = R_PointToAngleEx(viewx, viewy, px2, py2);
|
||||
return gld_clipper_SafeCheckRange(angle2, angle1);
|
||||
@@ -4012,7 +4089,7 @@ void HWR_AddSprites(sector_t *sec)
|
||||
{
|
||||
mobj_t *thing;
|
||||
precipmobj_t *precipthing;
|
||||
fixed_t approx_dist, limit_dist;
|
||||
fixed_t approx_dist, limit_dist, precip_limit_dist;
|
||||
|
||||
INT32 splitflags;
|
||||
boolean split_drawsprite; // drawing with splitscreen flags
|
||||
@@ -4027,9 +4104,24 @@ void HWR_AddSprites(sector_t *sec)
|
||||
// Well, now it will be done.
|
||||
sec->validcount = validcount;
|
||||
|
||||
if (current_bsp_culling_distance)
|
||||
{
|
||||
// Use the smaller setting
|
||||
if (cv_drawdist.value)
|
||||
limit_dist = min(current_bsp_culling_distance, cv_drawdist.value << FRACBITS);
|
||||
else
|
||||
limit_dist = current_bsp_culling_distance;
|
||||
precip_limit_dist = min(current_bsp_culling_distance, cv_drawdist_precip.value << FRACBITS);
|
||||
}
|
||||
else
|
||||
{
|
||||
limit_dist = cv_drawdist.value << FRACBITS;
|
||||
precip_limit_dist = cv_drawdist_precip.value << FRACBITS;
|
||||
}
|
||||
|
||||
// Handle all things in sector.
|
||||
// If a limit exists, handle things a tiny bit different.
|
||||
if ((limit_dist = (fixed_t)(/*(maptol & TOL_NIGHTS) ? cv_drawdist_nights.value : */cv_drawdist.value) << FRACBITS))
|
||||
if (limit_dist)
|
||||
{
|
||||
for (thing = sec->thinglist; thing; thing = thing->snext)
|
||||
{
|
||||
@@ -4115,7 +4207,7 @@ void HWR_AddSprites(sector_t *sec)
|
||||
}
|
||||
|
||||
// No to infinite precipitation draw distance.
|
||||
if ((limit_dist = (fixed_t)cv_drawdist_precip.value << FRACBITS))
|
||||
if (precip_limit_dist)
|
||||
{
|
||||
for (precipthing = sec->preciplist; precipthing; precipthing = precipthing->snext)
|
||||
{
|
||||
@@ -4124,7 +4216,7 @@ void HWR_AddSprites(sector_t *sec)
|
||||
|
||||
approx_dist = P_AproxDistance(viewx-precipthing->x, viewy-precipthing->y);
|
||||
|
||||
if (approx_dist > limit_dist)
|
||||
if (approx_dist > precip_limit_dist)
|
||||
continue;
|
||||
|
||||
HWR_ProjectPrecipitationSprite(precipthing);
|
||||
@@ -4556,7 +4648,7 @@ static inline void HWR_ClearView(void)
|
||||
(INT32)gr_viewwindowy,
|
||||
(INT32)(gr_viewwindowx + gr_viewwidth),
|
||||
(INT32)(gr_viewwindowy + gr_viewheight),
|
||||
ZCLIP_PLANE);
|
||||
ZCLIP_PLANE, FAR_ZCLIP_DEFAULT);
|
||||
HWD.pfnClearBuffer(false, true, 0);
|
||||
}
|
||||
|
||||
@@ -4686,6 +4778,16 @@ void HWR_RenderFrame(INT32 viewnumber, player_t *player, boolean skybox)
|
||||
if (skybox)
|
||||
drewsky = true;
|
||||
|
||||
if (!skybox && cv_grrenderdistance.value)
|
||||
{
|
||||
HWD.pfnGClipRect((INT32)gr_viewwindowx,
|
||||
(INT32)gr_viewwindowy,
|
||||
(INT32)(gr_viewwindowx + gr_viewwidth),
|
||||
(INT32)(gr_viewwindowy + gr_viewheight),
|
||||
ZCLIP_PLANE, clipping_distances[cv_grrenderdistance.value - 1]);
|
||||
current_bsp_culling_distance = bsp_culling_distances[cv_grrenderdistance.value - 1];
|
||||
}
|
||||
|
||||
a1 = gld_FrustumAngle(gr_aimingangle);
|
||||
gld_clipper_Clear();
|
||||
gld_clipper_SafeAddClipRange(viewangle + a1, viewangle - a1);
|
||||
@@ -4709,6 +4811,8 @@ void HWR_RenderFrame(INT32 viewnumber, player_t *player, boolean skybox)
|
||||
// Recursively "render" the BSP tree.
|
||||
HWR_RenderBSPNode((INT32)numnodes-1);
|
||||
|
||||
current_bsp_culling_distance = 0;
|
||||
|
||||
if (cv_grbatching.value)
|
||||
{
|
||||
int dummy = 0;// the vars in RenderBatches are meant for render stats. But we don't have that stuff in this branch
|
||||
@@ -4740,7 +4844,7 @@ void HWR_RenderFrame(INT32 viewnumber, player_t *player, boolean skybox)
|
||||
|
||||
// added by Hurdler for correct splitscreen
|
||||
// moved here by hurdler so it works with the new near clipping plane
|
||||
HWD.pfnGClipRect(0, 0, vid.width, vid.height, NZCLIP_PLANE);
|
||||
HWD.pfnGClipRect(0, 0, vid.width, vid.height, NZCLIP_PLANE, FAR_ZCLIP_DEFAULT);
|
||||
}
|
||||
|
||||
// ==========================================================================
|
||||
@@ -4800,6 +4904,7 @@ void HWR_AddCommands(void)
|
||||
CV_RegisterVar(&cv_grsolvetjoin);
|
||||
|
||||
CV_RegisterVar(&cv_grbatching);
|
||||
CV_RegisterVar(&cv_grrenderdistance);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
@@ -148,6 +148,7 @@ extern consvar_t cv_grsolvetjoin;
|
||||
extern consvar_t cv_grspritebillboarding;
|
||||
extern consvar_t cv_grfakecontrast;
|
||||
extern consvar_t cv_grfallbackplayermodel;
|
||||
extern consvar_t cv_grrenderdistance;
|
||||
|
||||
extern CV_PossibleValue_t granisotropicmode_cons_t[];
|
||||
|
||||
|
||||
@@ -50,7 +50,9 @@ static const GLubyte white[4] = { 255, 255, 255, 255 };
|
||||
#define N_PI_DEMI (M_PIl/2.0f) //(1.5707963268f)
|
||||
|
||||
#define ASPECT_RATIO (1.0f) //(320.0f/200.0f)
|
||||
#define FAR_CLIPPING_PLANE 32768.0f // Draw further! Tails 01-21-2001
|
||||
//#define FAR_CLIPPING_PLANE 32768.0f // Draw further! Tails 01-21-2001
|
||||
//#define FAR_CLIPPING_PLANE (4096.0f - 512.0f)
|
||||
static float FAR_CLIPPING_PLANE = 32768.0f;
|
||||
static float NEAR_CLIPPING_PLANE = NZCLIP_PLANE;
|
||||
|
||||
// **************************************************************************
|
||||
@@ -1232,12 +1234,13 @@ EXPORT void HWRAPI(ReadRect) (INT32 x, INT32 y, INT32 width, INT32 height,
|
||||
// -----------------+
|
||||
// GClipRect : Defines the 2D hardware clipping window
|
||||
// -----------------+
|
||||
EXPORT void HWRAPI(GClipRect) (INT32 minx, INT32 miny, INT32 maxx, INT32 maxy, float nearclip)
|
||||
EXPORT void HWRAPI(GClipRect) (INT32 minx, INT32 miny, INT32 maxx, INT32 maxy, float nearclip, float farclip)
|
||||
{
|
||||
//GL_DBG_Printf("GClipRect(%d, %d, %d, %d)\n", minx, miny, maxx, maxy);
|
||||
|
||||
pglViewport(minx, screen_height-maxy, maxx-minx, maxy-miny);
|
||||
NEAR_CLIPPING_PLANE = nearclip;
|
||||
FAR_CLIPPING_PLANE = farclip;
|
||||
|
||||
//pglScissor(minx, screen_height-maxy, maxx-minx, maxy-miny);
|
||||
pglMatrixMode(GL_PROJECTION);
|
||||
|
||||
+3
-1
@@ -1320,7 +1320,9 @@ static menuitem_t OP_OpenGLOptionsMenu[] =
|
||||
{IT_STRING|IT_CVAR, NULL, "Sprite Billboarding", &cv_grspritebillboarding, 100},
|
||||
{IT_STRING|IT_CVAR, NULL, "Software Perspective", &cv_grshearing, 110},
|
||||
|
||||
{IT_SUBMENU|IT_STRING, NULL, "Gamma...", &OP_OpenGLColorDef, 130},
|
||||
{IT_STRING|IT_CVAR, NULL, "Rendering Distance", &cv_grrenderdistance, 130},
|
||||
|
||||
{IT_SUBMENU|IT_STRING, NULL, "Gamma...", &OP_OpenGLColorDef, 150},
|
||||
};
|
||||
|
||||
static menuitem_t OP_OpenGLColorMenu[] =
|
||||
|
||||
+1
-1
@@ -229,7 +229,7 @@ void OglSdlFinishUpdate(boolean waitvbl)
|
||||
HWR_DrawScreenFinalTexture(sdlw, sdlh);
|
||||
SDL_GL_SwapWindow(window);
|
||||
|
||||
GClipRect(0, 0, realwidth, realheight, NZCLIP_PLANE);
|
||||
GClipRect(0, 0, realwidth, realheight, NZCLIP_PLANE, FAR_ZCLIP_DEFAULT);
|
||||
|
||||
// Sryder: We need to draw the final screen texture again into the other buffer in the original position so that
|
||||
// effects that want to take the old screen can do so after this
|
||||
|
||||
Reference in new issue
Block a user