1
0
Fork 0
forked from fte/fteqw

Handle skyautorotate so the q2 remaster's skies do not spin constantly in a really annoying way.

This commit is contained in:
Shpoike 2023-09-02 06:57:07 +01:00
parent 6cffd6f3ab
commit 73d8832318
7 changed files with 27 additions and 8 deletions

View file

@ -2250,6 +2250,7 @@ void CL_ClearState (qboolean gamestart)
cl.autotrack_killer = -1; cl.autotrack_killer = -1;
cl.downloadlist = pendingdownloads; cl.downloadlist = pendingdownloads;
cl.faileddownloads = faileddownloads; cl.faileddownloads = faileddownloads;
cl.skyautorotate = 1;
if (cfg_save_auto.ival && Cvar_UnsavedArchive()) if (cfg_save_auto.ival && Cvar_UnsavedArchive())
Cmd_ExecuteString("cfg_save\n", RESTRICT_LOCAL); Cmd_ExecuteString("cfg_save\n", RESTRICT_LOCAL);

View file

@ -4716,7 +4716,13 @@ static void CLQ2_ParseConfigString (void)
else if (i == Q2CS_SKYAXIS || i == Q2CS_SKYROTATE) else if (i == Q2CS_SKYAXIS || i == Q2CS_SKYROTATE)
{ {
if (i == Q2CS_SKYROTATE) if (i == Q2CS_SKYROTATE)
cl.skyrotate = atof(s); {
s = COM_Parse(s);
cl.skyrotate = atof(com_token);
s = COM_Parse(s);
if (*com_token)
cl.skyautorotate = atoi(com_token);
}
else else
{ {
s = COM_Parse(s); s = COM_Parse(s);
@ -4737,12 +4743,13 @@ static void CLQ2_ParseConfigString (void)
if (cl.skyrotate) if (cl.skyrotate)
{ {
if (cl.skyaxis[0]||cl.skyaxis[1]||cl.skyaxis[2]) if (cl.skyaxis[0]||cl.skyaxis[1]||cl.skyaxis[2])
Cvar_Set(&r_skybox_orientation, va("%g %g %g %g", cl.skyaxis[0], cl.skyaxis[1], cl.skyaxis[2], cl.skyrotate)); Cvar_LockFromServer(&r_skybox_orientation, va("%g %g %g %g", cl.skyaxis[0], cl.skyaxis[1], cl.skyaxis[2], cl.skyrotate));
else else
Cvar_Set(&r_skybox_orientation, va("0 0 1 %g", cl.skyrotate)); Cvar_LockFromServer(&r_skybox_orientation, va("0 0 1 %g", cl.skyrotate));
} }
else else
Cvar_Set(&r_skybox_orientation, ""); Cvar_LockFromServer(&r_skybox_orientation, "");
Cvar_LockFromServer(&r_skybox_autorotate, va("%i", cl.skyautorotate));
} }
else if (i == Q2CS_STATUSBAR) else if (i == Q2CS_STATUSBAR)
{ {

View file

@ -925,6 +925,7 @@ typedef struct
//used for q2 sky/configstrings //used for q2 sky/configstrings
char skyname[MAX_QPATH]; char skyname[MAX_QPATH];
float skyrotate; float skyrotate;
qboolean skyautorotate;
vec3_t skyaxis; vec3_t skyaxis;
qboolean fog_locked; //FIXME: make bitmask qboolean fog_locked; //FIXME: make bitmask

View file

@ -927,6 +927,10 @@ void Mod_ParseInfoFromEntityLump(model_t *wmodel) //actually, this should be in
{ {
cl.skyrotate = atof(token); cl.skyrotate = atof(token);
} }
else if (!strcmp("skyautorotate", key)) //q2ex feature
{
cl.skyautorotate = atof(token);
}
else if (!strcmp("skyaxis", key)) //q2 feature else if (!strcmp("skyaxis", key)) //q2 feature
{ {
char *s; char *s;
@ -955,6 +959,7 @@ void Mod_ParseInfoFromEntityLump(model_t *wmodel) //actually, this should be in
} }
else else
Cvar_Set(&r_skybox_orientation, ""); Cvar_Set(&r_skybox_orientation, "");
Cvar_SetValue(&r_skybox_autorotate, cl.skyautorotate);
if (wmodel) if (wmodel)
{ {

View file

@ -40,6 +40,7 @@ static cvar_t gl_skyboxdist = CVARD ("gl_skyboxdist", "0", "The distance o
static cvar_t r_skycloudalpha = CVARFD ("r_skycloudalpha", "1", CVAR_RENDERERLATCH, "Controls how opaque the front layer of legacy scrolling skies should be."); static cvar_t r_skycloudalpha = CVARFD ("r_skycloudalpha", "1", CVAR_RENDERERLATCH, "Controls how opaque the front layer of legacy scrolling skies should be.");
cvar_t r_skyboxname = CVARFC ("r_skybox", "", CVAR_RENDERERCALLBACK | CVAR_SHADERSYSTEM, R_SkyBox_Changed); cvar_t r_skyboxname = CVARFC ("r_skybox", "", CVAR_RENDERERCALLBACK | CVAR_SHADERSYSTEM, R_SkyBox_Changed);
cvar_t r_skybox_orientation = CVARFD ("r_glsl_skybox_orientation", "0 0 0 0", CVAR_SHADERSYSTEM, "Defines the axis around which skyboxes will rotate (the first three values). The fourth value defines the speed the skybox rotates at, in degrees per second."); cvar_t r_skybox_orientation = CVARFD ("r_glsl_skybox_orientation", "0 0 0 0", CVAR_SHADERSYSTEM, "Defines the axis around which skyboxes will rotate (the first three values). The fourth value defines the speed the skybox rotates at, in degrees per second.");
cvar_t r_skybox_autorotate = CVARFD ("r_glsl_skybox_autorotate", "1", CVAR_SHADERSYSTEM, "Defines the axis around which skyboxes will rotate (the first three values). The fourth value defines the speed the skybox rotates at, in degrees per second.");
cvar_t r_skyfog = CVARD ("r_skyfog", "0.5", "This controls an alpha-blend value for fog on skyboxes, cumulative with regular fog alpha."); cvar_t r_skyfog = CVARD ("r_skyfog", "0.5", "This controls an alpha-blend value for fog on skyboxes, cumulative with regular fog alpha.");
static shader_t *forcedsky; static shader_t *forcedsky;
@ -1344,6 +1345,7 @@ void R_Sky_Register(void)
Cvar_Register (&r_skyfog, groupname); Cvar_Register (&r_skyfog, groupname);
Cvar_Register (&r_skyboxname, groupname); Cvar_Register (&r_skyboxname, groupname);
Cvar_Register (&r_skybox_orientation, groupname); Cvar_Register (&r_skybox_orientation, groupname);
Cvar_Register (&r_skybox_autorotate, groupname);
Cvar_Register (&gl_skyboxdist, groupname); Cvar_Register (&gl_skyboxdist, groupname);
Cmd_AddCommandAD("sky", R_ForceSky_f, R_ForceSky_c, "For compat with Quakespasm, please use r_skybox."); //QS compat Cmd_AddCommandAD("sky", R_ForceSky_f, R_ForceSky_c, "For compat with Quakespasm, please use r_skybox."); //QS compat

View file

@ -1095,5 +1095,5 @@ void CLQ1_AddOrientedCylinder(shader_t *shader, float radius, float height, qboo
void CLQ1_AddOrientedSphere(shader_t *shader, float radius, float *matrix, float r, float g, float b, float a); void CLQ1_AddOrientedSphere(shader_t *shader, float radius, float *matrix, float r, float g, float b, float a);
void CLQ1_AddOrientedHalfSphere(shader_t *shader, float radius, float gap, float *matrix, float r, float g, float b, float a); void CLQ1_AddOrientedHalfSphere(shader_t *shader, float radius, float gap, float *matrix, float r, float g, float b, float a);
extern cvar_t r_fastturb, r_fastsky, r_skyboxname, r_skybox_orientation; extern cvar_t r_fastturb, r_fastsky, r_skyboxname, r_skybox_orientation, r_skybox_autorotate;
#endif #endif

View file

@ -2,6 +2,7 @@
!!samps reflectcube !!samps reflectcube
!!cvardf r_skyfog=0.5 !!cvardf r_skyfog=0.5
!!cvard4 r_glsl_skybox_orientation=0 0 0 0 !!cvard4 r_glsl_skybox_orientation=0 0 0 0
!!cvardf r_glsl_skybox_autorotate=1
#include "sys/defs.h" #include "sys/defs.h"
#include "sys/fog.h" #include "sys/fog.h"
@ -11,10 +12,12 @@ varying vec3 pos;
#ifdef VERTEX_SHADER #ifdef VERTEX_SHADER
mat3 rotateAroundAxis(vec4 axis) //xyz axis, with angle in w mat3 rotateAroundAxis(vec4 axis) //xyz axis, with angle in w
{ {
#define skyang axis.w*(3.14/180.0)*e_time if (bool(r_glsl_skybox_autorotate))
axis.w *= e_time;
axis.w *= (3.14/180.0);
axis.xyz = normalize(axis.xyz); axis.xyz = normalize(axis.xyz);
float s = sin(skyang); float s = sin(axis.w);
float c = cos(skyang); float c = cos(axis.w);
float oc = 1.0 - c; float oc = 1.0 - c;
return mat3(oc * axis.x * axis.x + c, oc * axis.x * axis.y - axis.z * s, oc * axis.z * axis.x + axis.y * s, return mat3(oc * axis.x * axis.x + c, oc * axis.x * axis.y - axis.z * s, oc * axis.z * axis.x + axis.y * s,