[iortcw] 78/152: All: Some fixes for portal skies

Simon McVittie smcv at debian.org
Fri Sep 8 10:40:05 UTC 2017


This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to annotated tag 1.5a
in repository iortcw.

commit 9a4aa66c95717333a0ddd2b92fc317d1b37e2d4c
Author: MAN-AT-ARMS <M4N4T4RMS at gmail.com>
Date:   Tue Jul 5 19:15:29 2016 -0400

    All: Some fixes for portal skies
---
 MP/code/cgame/cg_view.c  | 264 +++++++++++++++++++++++------------------------
 MP/code/rend2/tr_local.h |   5 -
 MP/code/rend2/tr_main.c  |  82 ---------------
 MP/code/rend2/tr_shade.c |   6 --
 MP/code/rend2/tr_sky.c   |   2 -
 SP/code/rend2/tr_local.h |   5 -
 SP/code/rend2/tr_main.c  |  88 ----------------
 SP/code/rend2/tr_shade.c |   5 -
 SP/code/rend2/tr_sky.c   |   2 -
 9 files changed, 131 insertions(+), 328 deletions(-)

diff --git a/MP/code/cgame/cg_view.c b/MP/code/cgame/cg_view.c
index 25d89c3..a8495dd 100644
--- a/MP/code/cgame/cg_view.c
+++ b/MP/code/cgame/cg_view.c
@@ -1327,10 +1327,6 @@ void CG_DrawSkyBoxPortal( void ) {
 	float f;
 	static qboolean foginited = qfalse; // only set the portal fog values once
 
-	if ( !cg_skybox.integer ) {
-		return;
-	}
-
 	if ( !( cstr = (char *)CG_ConfigString( CS_SKYBOXORG ) ) || !strlen( cstr ) ) {
 		// no skybox in this map
 		return;
@@ -1345,166 +1341,168 @@ void CG_DrawSkyBoxPortal( void ) {
 
 	backuprefdef = cg.refdef;
 
-	token = COM_ParseExt( &cstr, qfalse );
-	if ( !token || !token[0] ) {
-		CG_Error( "CG_DrawSkyBoxPortal: error parsing skybox configstring\n" );
-	}
-	cg.refdef.vieworg[0] = atof( token );
+	if ( cg_skybox.integer ) {
+		token = COM_ParseExt( &cstr, qfalse );
+		if ( !token || !token[0] ) {
+			CG_Error( "CG_DrawSkyBoxPortal: error parsing skybox configstring\n" );
+		}
+		cg.refdef.vieworg[0] = atof( token );
 
-	token = COM_ParseExt( &cstr, qfalse );
-	if ( !token || !token[0] ) {
-		CG_Error( "CG_DrawSkyBoxPortal: error parsing skybox configstring\n" );
-	}
-	cg.refdef.vieworg[1] = atof( token );
+		token = COM_ParseExt( &cstr, qfalse );
+		if ( !token || !token[0] ) {
+			CG_Error( "CG_DrawSkyBoxPortal: error parsing skybox configstring\n" );
+		}
+		cg.refdef.vieworg[1] = atof( token );
 
-	token = COM_ParseExt( &cstr, qfalse );
-	if ( !token || !token[0] ) {
-		CG_Error( "CG_DrawSkyBoxPortal: error parsing skybox configstring\n" );
-	}
-	cg.refdef.vieworg[2] = atof( token );
+		token = COM_ParseExt( &cstr, qfalse );
+		if ( !token || !token[0] ) {
+			CG_Error( "CG_DrawSkyBoxPortal: error parsing skybox configstring\n" );
+		}
+		cg.refdef.vieworg[2] = atof( token );
 
-	token = COM_ParseExt( &cstr, qfalse );
-	if ( !token || !token[0] ) {
-		CG_Error( "CG_DrawSkyBoxPortal: error parsing skybox configstring\n" );
-	}
+		token = COM_ParseExt( &cstr, qfalse );
+		if ( !token || !token[0] ) {
+			CG_Error( "CG_DrawSkyBoxPortal: error parsing skybox configstring\n" );
+		}
 
-	// setup fog the first time, ignore this part of the configstring after that
-	token = COM_ParseExt( &cstr, qfalse );
-	if ( !token || !token[0] ) {
-		CG_Error( "CG_DrawSkyBoxPortal: error parsing skybox configstring.  No fog state\n" );
-	} else {
-		vec4_t fogColor;
-		int fogStart, fogEnd;
-
-		if ( atoi( token ) ) {   // this camera has fog
-			if ( !foginited ) {
-				token = COM_ParseExt( &cstr, qfalse );
-				if ( !token || !token[0] ) {
-					CG_Error( "CG_DrawSkyBoxPortal: error parsing skybox configstring.  No fog[0]\n" );
-				}
-				fogColor[0] = atof( token );
+		// setup fog the first time, ignore this part of the configstring after that
+		token = COM_ParseExt( &cstr, qfalse );
+		if ( !token || !token[0] ) {
+			CG_Error( "CG_DrawSkyBoxPortal: error parsing skybox configstring.  No fog state\n" );
+		} else {
+			vec4_t fogColor;
+			int fogStart, fogEnd;
+
+			if ( atoi( token ) ) {   // this camera has fog
+				if ( 1 ) {
+					token = COM_ParseExt( &cstr, qfalse );
+					if ( !token || !token[0] ) {
+						CG_Error( "CG_DrawSkyBoxPortal: error parsing skybox configstring.  No fog[0]\n" );
+					}
+					fogColor[0] = atof( token );
 
-				token = COM_ParseExt( &cstr, qfalse );
-				if ( !token || !token[0] ) {
-					CG_Error( "CG_DrawSkyBoxPortal: error parsing skybox configstring.  No fog[1]\n" );
-				}
-				fogColor[1] = atof( token );
+					token = COM_ParseExt( &cstr, qfalse );
+					if ( !token || !token[0] ) {
+						CG_Error( "CG_DrawSkyBoxPortal: error parsing skybox configstring.  No fog[1]\n" );
+					}
+					fogColor[1] = atof( token );
 
-				token = COM_ParseExt( &cstr, qfalse );
-				if ( !token || !token[0] ) {
-					CG_Error( "CG_DrawSkyBoxPortal: error parsing skybox configstring.  No fog[2]\n" );
-				}
-				fogColor[2] = atof( token );
+					token = COM_ParseExt( &cstr, qfalse );
+					if ( !token || !token[0] ) {
+						CG_Error( "CG_DrawSkyBoxPortal: error parsing skybox configstring.  No fog[2]\n" );
+					}
+					fogColor[2] = atof( token );
 
-				token = COM_ParseExt( &cstr, qfalse );
-				if ( !token || !token[0] ) {
-					fogStart = 0;
-				} else {
-					fogStart = atoi( token );
-				}
+					token = COM_ParseExt( &cstr, qfalse );
+					if ( !token || !token[0] ) {
+						fogStart = 0;
+					} else {
+						fogStart = atoi( token );
+					}
 
-				token = COM_ParseExt( &cstr, qfalse );
-				if ( !token || !token[0] ) {
-					fogEnd = 0;
-				} else {
-					fogEnd = atoi( token );
-				}
+					token = COM_ParseExt( &cstr, qfalse );
+					if ( !token || !token[0] ) {
+						fogEnd = 0;
+					} else {
+						fogEnd = atoi( token );
+					}
 
-				trap_R_SetFog( FOG_PORTALVIEW, fogStart, fogEnd, fogColor[0], fogColor[1], fogColor[2], 1.1 );
-				foginited = qtrue;
-			}
-		} else {
-			if ( !foginited ) {
-				trap_R_SetFog( FOG_PORTALVIEW, 0,0,0,0,0,0 ); // init to null
-				foginited = qtrue;
+					trap_R_SetFog( FOG_PORTALVIEW, fogStart, fogEnd, fogColor[0], fogColor[1], fogColor[2], 1.1 );
+					foginited = qtrue;
+				}
+			} else {
+				if ( !foginited ) {
+					trap_R_SetFog( FOG_PORTALVIEW, 0,0,0,0,0,0 ); // init to null
+					foginited = qtrue;
+				}
 			}
 		}
-	}
 
-//----(SA)	end
+		//----(SA)	end
 
 
-	if ( cg.predictedPlayerState.pm_type == PM_INTERMISSION ) {
-		// if in intermission, use a fixed value
-		fov_x = 90;
-	} else {
-		// user selectable
-		if ( ( cgs.dmflags & DF_FIXED_FOV ) || cg_fixedAspect.integer ) {
-			// dmflag to prevent wide fov for all clients
+		if ( cg.predictedPlayerState.pm_type == PM_INTERMISSION ) {
+			// if in intermission, use a fixed value
 			fov_x = 90;
 		} else {
-			fov_x = cg_fov.value;
-			if ( fov_x < 1 ) {
-				fov_x = 1;
-			} else if ( fov_x > 160 ) {
-				fov_x = 160;
+			// user selectable
+			if ( ( cgs.dmflags & DF_FIXED_FOV ) || cg_fixedAspect.integer ) {
+				// dmflag to prevent wide fov for all clients
+				fov_x = 90;
+			} else {
+				fov_x = cg_fov.value;
+				if ( fov_x < 1 ) {
+					fov_x = 1;
+				} else if ( fov_x > 160 ) {
+					fov_x = 160;
+				}
 			}
-		}
 
-		// account for zooms
-		if ( cg.zoomval ) {
-			zoomFov = cg.zoomval;   // (SA) use user scrolled amount
-
-			if ( zoomFov < 1 ) {
-				zoomFov = 1;
-			} else if ( zoomFov > 160 ) {
-				zoomFov = 160;
-			}
-		} else {
-			zoomFov = lastfov;
-		}
+			// account for zooms
+			if ( cg.zoomval ) {
+				zoomFov = cg.zoomval;   // (SA) use user scrolled amount
 
-		// do smooth transitions for the binocs
-		if ( cg.zoomedBinoc ) {        // binoc zooming in
-			f = ( cg.time - cg.zoomTime ) / (float)ZOOM_TIME;
-			if ( f > 1.0 ) {
-				fov_x = zoomFov;
+				if ( zoomFov < 1 ) {
+					zoomFov = 1;
+				} else if ( zoomFov > 160 ) {
+					zoomFov = 160;
+				}
 			} else {
-				fov_x = fov_x + f * ( zoomFov - fov_x );
+				zoomFov = lastfov;
 			}
-			lastfov = fov_x;
-		} else if ( cg.zoomval ) {    // zoomed by sniper/snooper
-			fov_x = cg.zoomval;
-			lastfov = fov_x;
-		} else {                    // binoc zooming out
-			f = ( cg.time - cg.zoomTime ) / (float)ZOOM_TIME;
-			if ( f <= 1.0 ) {
-				fov_x = zoomFov + f * ( fov_x - zoomFov );
+
+			// do smooth transitions for the binocs
+			if ( cg.zoomedBinoc ) {        // binoc zooming in
+				f = ( cg.time - cg.zoomTime ) / (float)ZOOM_TIME;
+				if ( f > 1.0 ) {
+					fov_x = zoomFov;
+				} else {
+					fov_x = fov_x + f * ( zoomFov - fov_x );
+				}
+				lastfov = fov_x;
+			} else if ( cg.zoomval ) {    // zoomed by sniper/snooper
+				fov_x = cg.zoomval;
+				lastfov = fov_x;
+			} else {                    // binoc zooming out
+				f = ( cg.time - cg.zoomTime ) / (float)ZOOM_TIME;
+				if ( f <= 1.0 ) {
+					fov_x = zoomFov + f * ( fov_x - zoomFov );
+				}
 			}
 		}
-	}
 
-	if ( cg.weaponSelect == WP_SNOOPERSCOPE ) {
-		cg.refdef.rdflags |= RDF_SNOOPERVIEW;
-	} else {
-		cg.refdef.rdflags &= ~RDF_SNOOPERVIEW;
-	}
-
-	if ( cg.snap->ps.persistant[PERS_HWEAPON_USE] ) {
-		fov_x = 55;
-	}
-
-	if ( cg_fixedAspect.integer ) {
-		// Based on LordHavoc's code for Darkplaces
-		// http://www.quakeworld.nu/forum/topic/53/what-does-your-qw-look-like/page/30
-		const float baseAspect = 0.75f; // 3/4
-		const float aspect = (float)cg.refdef.width/(float)cg.refdef.height;
-		const float desiredFov = fov_x;
+		if ( cg.weaponSelect == WP_SNOOPERSCOPE ) {
+			cg.refdef.rdflags |= RDF_SNOOPERVIEW;
+		} else {
+			cg.refdef.rdflags &= ~RDF_SNOOPERVIEW;
+		}
 
-		fov_x = atan2( tan( desiredFov*M_PI / 360.0f ) * baseAspect*aspect, 1 )*360.0f / M_PI;
-	}
+		if ( cg.snap->ps.persistant[PERS_HWEAPON_USE] ) {
+			fov_x = 55;
+		}
 
-	cg.refdef.time = cg.time;
+		if ( cg_fixedAspect.integer ) {
+			// Based on LordHavoc's code for Darkplaces
+			// http://www.quakeworld.nu/forum/topic/53/what-does-your-qw-look-like/page/30
+			const float baseAspect = 0.75f; // 3/4
+			const float aspect = (float)cg.refdef.width/(float)cg.refdef.height;
+			const float desiredFov = fov_x;
+	
+			fov_x = atan2( tan( desiredFov*M_PI / 360.0f ) * baseAspect*aspect, 1 )*360.0f / M_PI;
+		}
 
-	x = cg.refdef.width / tan( fov_x / 360 * M_PI );
-	fov_y = atan2( cg.refdef.height, x );
-	fov_y = fov_y * 360 / M_PI;
+		x = cg.refdef.width / tan( fov_x / 360 * M_PI );
+		fov_y = atan2( cg.refdef.height, x );
+		fov_y = fov_y * 360 / M_PI;
 
-	cg.refdef.fov_x = fov_x;
-	cg.refdef.fov_y = fov_y;
+		cg.refdef.fov_x = fov_x;
+		cg.refdef.fov_y = fov_y;
+	}
 
 	cg.refdef.rdflags |= RDF_SKYBOXPORTAL;
 
+	cg.refdef.time = cg.time;
+
 	// draw the skybox
 	trap_R_RenderScene( &cg.refdef );
 
diff --git a/MP/code/rend2/tr_local.h b/MP/code/rend2/tr_local.h
index 4c5b425..7f8264b 100644
--- a/MP/code/rend2/tr_local.h
+++ b/MP/code/rend2/tr_local.h
@@ -2811,11 +2811,6 @@ GL FOG
 extern glfog_t glfogsettings[NUM_FOGS];         // [0] never used (FOG_NONE)
 extern glfogType_t glfogNum;                    // fog type to use (from the fog_t enum list)
 
-extern qboolean fogIsOn;
-
-extern void         R_FogOff( void );
-extern void         R_FogOn( void );
-
 extern void R_SetFog( int fogvar, int var1, int var2, float r, float g, float b, float density );
 
 extern int skyboxportal;
diff --git a/MP/code/rend2/tr_main.c b/MP/code/rend2/tr_main.c
index 941b119..edb2453 100644
--- a/MP/code/rend2/tr_main.c
+++ b/MP/code/rend2/tr_main.c
@@ -58,83 +58,6 @@ surfaceType_t entitySurface = SF_ENTITY;
 // fog stuff
 glfog_t glfogsettings[NUM_FOGS];
 glfogType_t glfogNum = FOG_NONE;
-qboolean fogIsOn = qfalse;
-
-
-/*
-=================
-R_Fog (void)
-=================
-*/
-void R_Fog( glfog_t *curfog ) {
-
-	if ( !r_wolffog->integer ) {
-		R_FogOff();
-		return;
-	}
-
-	if ( !curfog->registered ) {   //----(SA)
-		R_FogOff();
-		return;
-	}
-
-	//----(SA) assme values of '0' for these parameters means 'use default'
-	if ( !curfog->density ) {
-		curfog->density = 1;
-	}
-	if ( !curfog->hint ) {
-		curfog->hint = GL_DONT_CARE;
-	}
-	if ( !curfog->mode ) {
-		curfog->mode = GL_LINEAR;
-	}
-	//----(SA)	end
-
-	R_FogOn();
-}
-
-// Ridah, allow disabling fog temporarily
-void R_FogOff( void ) {
-	if ( !fogIsOn ) {
-		return;
-	}
-	//qglDisable( GL_FOG );
-	fogIsOn = qfalse;
-}
-
-void R_FogOn( void ) {
-	if ( fogIsOn ) {
-		return;
-	}
-
-	if ( r_uiFullScreen->integer ) {   // don't fog in the menu
-		R_FogOff();
-		return;
-	}
-
-	if ( !r_wolffog->integer ) {
-		return;
-	}
-
-//	if(backEnd.viewParms.isGLFogged) {
-//		if(!(backEnd.viewParms.glFog.registered))
-//			return;
-//	}
-
-	if ( backEnd.refdef.rdflags & RDF_SKYBOXPORTAL ) { // don't force world fog on portal sky
-		if ( !( glfogsettings[FOG_PORTALVIEW].registered ) ) {
-			return;
-		}
-	} else if ( !glfogNum )     {
-		return;
-	}
-
-	//qglEnable( GL_FOG );
-	fogIsOn = qtrue;
-}
-// done.
-
-
 
 //----(SA)
 /*
@@ -2295,8 +2218,6 @@ void R_DebugGraphics( void ) {
 		return;
 	}
 
-	R_FogOff(); // moved this in here to keep from /always/ doing the fog state change
-
 	R_IssuePendingRenderCommands();
 
 	GL_BindToTMU(tr.whiteImage, TB_COLORMAP);
@@ -2349,10 +2270,7 @@ void R_RenderView( viewParms_t *parms ) {
 	R_SortDrawSurfs( tr.refdef.drawSurfs + firstDrawSurf, numDrawSurfs - firstDrawSurf );
 
 	// draw main system development information (surface outlines, etc)
-	R_FogOff();
 	R_DebugGraphics();
-	R_FogOn();
-
 }
 
 
diff --git a/MP/code/rend2/tr_shade.c b/MP/code/rend2/tr_shade.c
index c029882..24421c8 100644
--- a/MP/code/rend2/tr_shade.c
+++ b/MP/code/rend2/tr_shade.c
@@ -1060,8 +1060,6 @@ static void ProjectPshadowVBOGLSL( void ) {
 	}
 }
 
-extern qboolean fogIsOn;
-
 /*
 ===================
 RB_FogPass
@@ -1084,12 +1082,8 @@ static void RB_FogPass( int wolfFog ) {
 		return;
 	}
 
-	if (!fogIsOn)
-		return;
- 
 	if (wolfFog)
 	{
-		// from R_Fog(), altered slightly
 		if ( backEnd.projection2D ) {
 			return;
 		}
diff --git a/MP/code/rend2/tr_sky.c b/MP/code/rend2/tr_sky.c
index f97dd7d..550ee11 100644
--- a/MP/code/rend2/tr_sky.c
+++ b/MP/code/rend2/tr_sky.c
@@ -1076,8 +1076,6 @@ void RB_DrawSun( float scale, shader_t *shader ) {
 	qglDepthRange( 0.0, 1.0 );
 }
 
-extern void R_Fog( glfog_t *curfog );
-
 /*
 ================
 RB_StageIteratorSky
diff --git a/SP/code/rend2/tr_local.h b/SP/code/rend2/tr_local.h
index 6148c31..38bb85a 100644
--- a/SP/code/rend2/tr_local.h
+++ b/SP/code/rend2/tr_local.h
@@ -2841,11 +2841,6 @@ GL FOG
 extern glfog_t glfogsettings[NUM_FOGS];         // [0] never used (FOG_NONE)
 extern glfogType_t glfogNum;                    // fog type to use (from the fog_t enum list)
 
-extern qboolean fogIsOn;
-
-extern void         R_FogOff( void );
-extern void         R_FogOn( void );
-
 extern void R_SetFog( int fogvar, int var1, int var2, float r, float g, float b, float density );
 
 extern int skyboxportal;
diff --git a/SP/code/rend2/tr_main.c b/SP/code/rend2/tr_main.c
index 7cc2b2a..b0d9e0f 100644
--- a/SP/code/rend2/tr_main.c
+++ b/SP/code/rend2/tr_main.c
@@ -58,89 +58,6 @@ surfaceType_t entitySurface = SF_ENTITY;
 // fog stuff
 glfog_t glfogsettings[NUM_FOGS];
 glfogType_t glfogNum = FOG_NONE;
-qboolean fogIsOn = qfalse;
-
-
-/*
-=================
-R_Fog (void)
-=================
-*/
-void R_Fog( glfog_t *curfog ) {
-
-	if ( !r_wolffog->integer ) {
-		R_FogOff();
-		return;
-	}
-
-	if ( !curfog->registered ) {   //----(SA)
-		R_FogOff();
-		return;
-	}
-
-	//----(SA) assme values of '0' for these parameters means 'use default'
-	if ( !curfog->density ) {
-		curfog->density = 1;
-	}
-	if ( !curfog->hint ) {
-		curfog->hint = GL_DONT_CARE;
-	}
-	if ( !curfog->mode ) {
-		curfog->mode = GL_LINEAR;
-	}
-	//----(SA)	end
-
-
-	R_FogOn();
-}
-
-// Ridah, allow disabling fog temporarily
-void R_FogOff( void ) {
-	if ( !fogIsOn ) {
-		return;
-	}
-	//qglDisable( GL_FOG );
-	fogIsOn = qfalse;
-}
-
-void R_FogOn( void ) {
-	if ( fogIsOn ) {
-		return;
-	}
-
-//	if(r_uiFullScreen->integer) {	// don't fog in the menu
-//		R_FogOff();
-//		return;
-//	}
-
-	if ( backEnd.projection2D ) {  // no fog in 2d
-		R_FogOff();
-		return;
-	}
-
-	if ( !r_wolffog->integer ) {
-		return;
-	}
-
-//	if(backEnd.viewParms.isGLFogged) {
-//		if(!(backEnd.viewParms.glFog.registered))
-//			return;
-//	}
-
-	if ( backEnd.refdef.rdflags & RDF_SKYBOXPORTAL ) { // don't force world fog on portal sky
-		if ( !( glfogsettings[FOG_PORTALVIEW].registered ) ) {
-			return;
-		}
-	} else if ( !glfogNum )     {
-		return;
-	}
-
-	//qglEnable( GL_FOG );
-	fogIsOn = qtrue;
-}
-// done.
-
-
 
 //----(SA)
 /*
@@ -2344,8 +2261,6 @@ void R_DebugGraphics( void ) {
 		return;
 	}
 
-	R_FogOff(); // moved this in here to keep from /always/ doing the fog state change
-
 	R_IssuePendingRenderCommands();
 
 	GL_BindToTMU(tr.whiteImage, TB_COLORMAP);
@@ -2398,10 +2313,7 @@ void R_RenderView( viewParms_t *parms ) {
 	R_SortDrawSurfs( tr.refdef.drawSurfs + firstDrawSurf, numDrawSurfs - firstDrawSurf );
 
 	// draw main system development information (surface outlines, etc)
-	R_FogOff();
 	R_DebugGraphics();
-	R_FogOn();
-
 }
 
 void R_RenderDlightCubemaps(const refdef_t *fd)
diff --git a/SP/code/rend2/tr_shade.c b/SP/code/rend2/tr_shade.c
index e099f04..f600fb0 100644
--- a/SP/code/rend2/tr_shade.c
+++ b/SP/code/rend2/tr_shade.c
@@ -1054,7 +1054,6 @@ static void ProjectPshadowVBOGLSL( void ) {
 	}
 }
 
-extern qboolean fogIsOn;
 
 /*
 ===================
@@ -1078,12 +1077,8 @@ static void RB_FogPass( int wolfFog ) {
 		return;
 	}
 
-	if (!fogIsOn)
-		return;
- 
 	if (wolfFog)
 	{
-		// from R_Fog(), altered slightly
 		if ( backEnd.projection2D ) {
 			return;
 		}
diff --git a/SP/code/rend2/tr_sky.c b/SP/code/rend2/tr_sky.c
index ff23bdd..71c6d7e 100644
--- a/SP/code/rend2/tr_sky.c
+++ b/SP/code/rend2/tr_sky.c
@@ -1073,8 +1073,6 @@ void RB_DrawSun( float scale, shader_t *shader ) {
 	qglDepthRange( 0.0, 1.0 );
 }
 
-extern void R_Fog( glfog_t *curfog );
-
 /*
 ================
 RB_StageIteratorSky

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/iortcw.git



More information about the Pkg-games-commits mailing list