mirror of
https://github.com/nzp-team/fteqw.git
synced 2024-11-10 22:51:57 +00:00
write lightstyle changes into mvds.
don't add 'mapname' (for q3 compat) unless we actually need that in the serverinfo for q3 gamecode. fix bloom only blooming sideways. clean up R2D_RT_Configure's arguments to use TF_ constants properly, without gumming up qc apis. make InitFlyby more readable. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4782 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
2dbad9574c
commit
9602ae7247
14 changed files with 104 additions and 112 deletions
|
@ -192,6 +192,21 @@ static qboolean Cam_IsVisible(vec3_t playerorigin, vec3_t vec)
|
|||
|
||||
static qboolean InitFlyby(playerview_t *pv, vec3_t selforigin, vec3_t playerorigin, vec3_t playerviewangles, int checkvis)
|
||||
{
|
||||
vec3_t dirs[] = {
|
||||
{1,1,1},
|
||||
{1,-1,1},
|
||||
{1,1,0},
|
||||
{1,-1,1},
|
||||
{1,0,1},
|
||||
{1,0,-1},
|
||||
{-1,1,1},
|
||||
{-1,-1,1},
|
||||
{-1,0,0},
|
||||
{1,0,0},
|
||||
{0,0,-1},
|
||||
{0,0,1}
|
||||
};
|
||||
int dir;
|
||||
float f, max;
|
||||
vec3_t vec, vec2;
|
||||
vec3_t forward, right, up;
|
||||
|
@ -203,85 +218,17 @@ static qboolean InitFlyby(playerview_t *pv, vec3_t selforigin, vec3_t playerorig
|
|||
// forward[i] *= 3;
|
||||
|
||||
max = 1000;
|
||||
VectorAdd(forward, up, vec2);
|
||||
VectorAdd(vec2, right, vec2);
|
||||
for (dir = 0; dir < sizeof(dirs)/sizeof(dirs[0]); dir++)
|
||||
{
|
||||
VectorScale(forward, dirs[dir][0], vec2);
|
||||
VectorMA(vec2, dirs[dir][1], right, vec2);
|
||||
VectorMA(vec2, dirs[dir][2], up, vec2);
|
||||
if ((f = Cam_TryFlyby(selforigin, playerorigin, vec2, checkvis)) < max)
|
||||
{
|
||||
max = f;
|
||||
VectorCopy(vec2, vec);
|
||||
}
|
||||
VectorAdd(forward, up, vec2);
|
||||
VectorSubtract(vec2, right, vec2);
|
||||
if ((f = Cam_TryFlyby(selforigin, playerorigin, vec2, checkvis)) < max)
|
||||
{
|
||||
max = f;
|
||||
VectorCopy(vec2, vec);
|
||||
}
|
||||
VectorAdd(forward, right, vec2);
|
||||
if ((f = Cam_TryFlyby(selforigin, playerorigin, vec2, checkvis)) < max)
|
||||
{
|
||||
max = f;
|
||||
VectorCopy(vec2, vec);
|
||||
}
|
||||
VectorSubtract(forward, right, vec2);
|
||||
if ((f = Cam_TryFlyby(selforigin, playerorigin, vec2, checkvis)) < max)
|
||||
{
|
||||
max = f;
|
||||
VectorCopy(vec2, vec);
|
||||
}
|
||||
VectorAdd(forward, up, vec2);
|
||||
if ((f = Cam_TryFlyby(selforigin, playerorigin, vec2, checkvis)) < max)
|
||||
{
|
||||
max = f;
|
||||
VectorCopy(vec2, vec);
|
||||
}
|
||||
VectorSubtract(forward, up, vec2);
|
||||
if ((f = Cam_TryFlyby(selforigin, playerorigin, vec2, checkvis)) < max)
|
||||
{
|
||||
max = f;
|
||||
VectorCopy(vec2, vec);
|
||||
}
|
||||
VectorAdd(up, right, vec2);
|
||||
VectorSubtract(vec2, forward, vec2);
|
||||
if ((f = Cam_TryFlyby(selforigin, playerorigin, vec2, checkvis)) < max)
|
||||
{
|
||||
max = f;
|
||||
VectorCopy(vec2, vec);
|
||||
}
|
||||
VectorSubtract(up, right, vec2);
|
||||
VectorSubtract(vec2, forward, vec2);
|
||||
if ((f = Cam_TryFlyby(selforigin, playerorigin, vec2, checkvis)) < max)
|
||||
{
|
||||
max = f;
|
||||
VectorCopy(vec2, vec);
|
||||
}
|
||||
// invert
|
||||
VectorNegate(forward, vec2);
|
||||
if ((f = Cam_TryFlyby(selforigin, playerorigin, vec2, checkvis)) < max)
|
||||
{
|
||||
max = f;
|
||||
VectorCopy(vec2, vec);
|
||||
}
|
||||
VectorCopy(forward, vec2);
|
||||
if ((f = Cam_TryFlyby(selforigin, playerorigin, vec2, checkvis)) < max)
|
||||
{
|
||||
max = f;
|
||||
VectorCopy(vec2, vec);
|
||||
}
|
||||
// invert
|
||||
VectorNegate(right, vec2);
|
||||
if ((f = Cam_TryFlyby(selforigin, playerorigin, vec2, checkvis)) < max)
|
||||
{
|
||||
max = f;
|
||||
VectorCopy(vec2, vec);
|
||||
}
|
||||
VectorCopy(right, vec2);
|
||||
if ((f = Cam_TryFlyby(selforigin, playerorigin, vec2, checkvis)) < max)
|
||||
{
|
||||
max = f;
|
||||
VectorCopy(vec2, vec);
|
||||
}
|
||||
|
||||
// ack, can't find him
|
||||
if (max >= 1000)
|
||||
{
|
||||
|
@ -422,7 +369,7 @@ void Cam_Track(playerview_t *pv, usercmd_t *cmd)
|
|||
player = frame->playerstate + pv->cam_spec_track;
|
||||
self = frame->playerstate + pv->playernum;
|
||||
|
||||
if (!pv->cam_locked || !Cam_IsVisible(player->origin, pv->cam_desired_position))
|
||||
if (!cl_chasecam.value && (!pv->cam_locked || !Cam_IsVisible(player->origin, pv->cam_desired_position)))
|
||||
{
|
||||
if (!pv->cam_locked || realtime - pv->cam_lastviewtime > 0.1)
|
||||
{
|
||||
|
|
|
@ -1359,6 +1359,8 @@ void CL_ClearState (void)
|
|||
cl.playerview[i].maxspeed = 320;
|
||||
cl.playerview[i].entgravity = 1;
|
||||
}
|
||||
for (i = 0; i < MAX_CLIENTS; i++)
|
||||
cl.players[i].stats[STAT_VIEWHEIGHT] = cl.players[i].statsf[STAT_VIEWHEIGHT] = DEFAULT_VIEWHEIGHT;
|
||||
cl.minpitch = -70;
|
||||
cl.maxpitch = 80;
|
||||
|
||||
|
|
|
@ -922,6 +922,7 @@ void CL_PredictMovePNum (int seat)
|
|||
extern cvar_t cl_chasecam;
|
||||
if (!cl_chasecam.ival)
|
||||
{
|
||||
//FIXME: don't early out, so that we can smooth out angles too
|
||||
VectorCopy(pv->cam_desired_position, pv->simorg);
|
||||
VectorClear(pv->simvel);
|
||||
return;
|
||||
|
|
|
@ -3386,6 +3386,7 @@ static qboolean Image_GenMip0(struct pendingtextureinfo *mips, unsigned int flag
|
|||
BZ_Free(rawdata);
|
||||
return false;
|
||||
}
|
||||
mips->encoding = (fmt==TF_RGBA16F)?PTI_RGBA16F:TF_RGBA32F;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -269,6 +269,9 @@ struct pendingtextureinfo
|
|||
PTI_ARGB4444, //16bit format (d3d)
|
||||
PTI_RGBA5551, //16bit alpha format (gl).
|
||||
PTI_ARGB1555, //16bit alpha format (d3d).
|
||||
//floating point formats
|
||||
PTI_RGBA16F,
|
||||
PTI_RGBA32F,
|
||||
//compressed formats
|
||||
PTI_S3RGB1,
|
||||
PTI_S3RGBA1,
|
||||
|
|
|
@ -1434,7 +1434,19 @@ void QCBUILTIN PF_R_GetViewFlag(pubprogfuncs_t *prinst, struct globalvars_s *pr_
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static uploadfmt_t PR_TranslateTextureFormat(int qcformat)
|
||||
{
|
||||
switch(qcformat)
|
||||
{
|
||||
case 1: return TF_RGBA32;
|
||||
case 2: return TF_RGBA16F;
|
||||
case 3: return TF_RGBA32F;
|
||||
case 4: return TF_DEPTH16;
|
||||
case 5: return TF_DEPTH24;
|
||||
case 6: return TF_DEPTH32;
|
||||
default:return TF_INVALID;
|
||||
}
|
||||
}
|
||||
void QCBUILTIN PF_R_SetViewFlag(pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
|
||||
{
|
||||
viewflags parametertype = G_FLOAT(OFS_PARM0);
|
||||
|
@ -1585,7 +1597,7 @@ void QCBUILTIN PF_R_SetViewFlag(pubprogfuncs_t *prinst, struct globalvars_s *pr_
|
|||
{
|
||||
float fmt = G_FLOAT(OFS_PARM2);
|
||||
float *size = G_VECTOR(OFS_PARM3);
|
||||
R2D_RT_Configure(r_refdef.rt_destcolour[i].texname, size[0], size[1], fmt);
|
||||
R2D_RT_Configure(r_refdef.rt_destcolour[i].texname, size[0], size[1], PR_TranslateTextureFormat(fmt));
|
||||
}
|
||||
BE_RenderToTextureUpdate2d(true);
|
||||
}
|
||||
|
@ -1596,7 +1608,7 @@ void QCBUILTIN PF_R_SetViewFlag(pubprogfuncs_t *prinst, struct globalvars_s *pr_
|
|||
{
|
||||
float fmt = G_FLOAT(OFS_PARM2);
|
||||
float *size = G_VECTOR(OFS_PARM3);
|
||||
R2D_RT_Configure(r_refdef.rt_sourcecolour.texname, size[0], size[1], fmt);
|
||||
R2D_RT_Configure(r_refdef.rt_sourcecolour.texname, size[0], size[1], PR_TranslateTextureFormat(fmt));
|
||||
}
|
||||
BE_RenderToTextureUpdate2d(false);
|
||||
break;
|
||||
|
@ -1606,7 +1618,7 @@ void QCBUILTIN PF_R_SetViewFlag(pubprogfuncs_t *prinst, struct globalvars_s *pr_
|
|||
{
|
||||
float fmt = G_FLOAT(OFS_PARM2);
|
||||
float *size = G_VECTOR(OFS_PARM3);
|
||||
R2D_RT_Configure(r_refdef.rt_depth.texname, size[0], size[1], fmt);
|
||||
R2D_RT_Configure(r_refdef.rt_depth.texname, size[0], size[1], PR_TranslateTextureFormat(fmt));
|
||||
}
|
||||
BE_RenderToTextureUpdate2d(false);
|
||||
break;
|
||||
|
@ -1616,7 +1628,7 @@ void QCBUILTIN PF_R_SetViewFlag(pubprogfuncs_t *prinst, struct globalvars_s *pr_
|
|||
{
|
||||
float fmt = G_FLOAT(OFS_PARM2);
|
||||
float *size = G_VECTOR(OFS_PARM3);
|
||||
R2D_RT_Configure(r_refdef.rt_ripplemap.texname, size[0], size[1], fmt);
|
||||
R2D_RT_Configure(r_refdef.rt_ripplemap.texname, size[0], size[1], PR_TranslateTextureFormat(fmt));
|
||||
}
|
||||
BE_RenderToTextureUpdate2d(false);
|
||||
break;
|
||||
|
|
|
@ -1332,16 +1332,6 @@ texid_t R2D_RT_Configure(const char *id, int width, int height, uploadfmt_t rtfm
|
|||
|
||||
if (rtfmt)
|
||||
{
|
||||
switch(rtfmt)
|
||||
{
|
||||
case 1: rtfmt = TF_RGBA32; break;
|
||||
case 2: rtfmt = TF_RGBA16F; break;
|
||||
case 3: rtfmt = TF_RGBA32F; break;
|
||||
case 4: rtfmt = TF_DEPTH16; break;
|
||||
case 5: rtfmt = TF_DEPTH24; break;
|
||||
case 6: rtfmt = TF_DEPTH32; break;
|
||||
default:rtfmt = TF_INVALID; break;
|
||||
}
|
||||
Image_Upload(tid, rtfmt, NULL, NULL, width, height, RT_IMAGEFLAGS);
|
||||
tid->width = width;
|
||||
tid->height = height;
|
||||
|
|
|
@ -176,7 +176,7 @@ void D3D11_ApplyRenderTargets(qboolean usedepth)
|
|||
if (*r_refdef.rt_depth.texname)
|
||||
depth = R2D_RT_GetTexture(r_refdef.rt_depth.texname, &width, &height);
|
||||
else
|
||||
depth = R2D_RT_Configure("depth", width, height, 5);
|
||||
depth = R2D_RT_Configure("depth", width, height, TF_DEPTH24);
|
||||
}
|
||||
else
|
||||
depth = NULL;
|
||||
|
|
|
@ -52,7 +52,7 @@ static shader_t *bloomrescale;
|
|||
static shader_t *bloomblur;
|
||||
static shader_t *bloomfinal;
|
||||
|
||||
#define MAXLEVELS 3
|
||||
#define MAXLEVELS 3 //presumably this could be up to 16, but that will be too expensive.
|
||||
texid_t pingtex[2][MAXLEVELS];
|
||||
fbostate_t fbo_bloom;
|
||||
static int scrwidth, scrheight;
|
||||
|
@ -222,6 +222,7 @@ void R_BloomBlend (texid_t source, int x, int y, int w, int h)
|
|||
GLBE_FBO_Update(&fbo_bloom, 0, &pingtex[1][i], 1, r_nulltex, 0, 0);
|
||||
GLBE_FBO_Sources(pingtex[0][i], r_nulltex);
|
||||
qglViewport (0, 0, texwidth[i], texheight[i]);
|
||||
BE_SelectEntity(&r_worldentity);
|
||||
R2D_ScalePic(0, vid.height, vid.width, -(int)vid.height, bloomblur);
|
||||
|
||||
r_worldentity.glowmod[0] = 0;
|
||||
|
@ -229,6 +230,7 @@ void R_BloomBlend (texid_t source, int x, int y, int w, int h)
|
|||
GLBE_FBO_Update(&fbo_bloom, 0, &pingtex[0][i], 1, r_nulltex, 0, 0);
|
||||
GLBE_FBO_Sources(pingtex[1][i], r_nulltex);
|
||||
qglViewport (0, 0, texwidth[i], texheight[i]);
|
||||
BE_SelectEntity(&r_worldentity);
|
||||
R2D_ScalePic(0, vid.height, vid.width, -(int)vid.height, bloomblur);
|
||||
}
|
||||
r_worldentity.glowmod[0] = 0;
|
||||
|
|
|
@ -392,6 +392,12 @@ qboolean GL_LoadTextureMips(texid_t tex, struct pendingtextureinfo *mips)
|
|||
default:
|
||||
qglTexImage2D(targface, j, GL_RGBA, mips->mip[i].width, mips->mip[i].height, 0, GL_BGRA_EXT, GL_UNSIGNED_INT_8_8_8_8_REV, mips->mip[i].data);
|
||||
break;
|
||||
case PTI_RGBA16F:
|
||||
qglTexImage2D(targface, j, GL_RGBA16F_ARB, mips->mip[i].width, mips->mip[i].height, 0, GL_RGBA, GL_UNSIGNED_BYTE, mips->mip[i].data);
|
||||
break;
|
||||
case PTI_RGBA32F:
|
||||
qglTexImage2D(targface, j, GL_RGBA32F_ARB, mips->mip[i].width, mips->mip[i].height, 0, GL_RGBA, GL_UNSIGNED_BYTE, mips->mip[i].data);
|
||||
break;
|
||||
//16bit formats
|
||||
case PTI_RGBA4444:
|
||||
qglTexImage2D(targface, j, GL_RGBA, mips->mip[i].width, mips->mip[i].height, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, mips->mip[i].data);
|
||||
|
|
|
@ -1683,7 +1683,7 @@ void GLR_RenderView (void)
|
|||
vid.fbvwidth = vid.fbpwidth = (r_refdef.vrect.width * vid.pixelwidth) / vid.width;
|
||||
vid.fbvheight = vid.fbpheight = (r_refdef.vrect.height * vid.pixelheight) / vid.height;
|
||||
|
||||
sourcetex = R2D_RT_Configure("rt/$lastgameview", vid.fbpwidth, vid.fbpheight, TF_RGBA32);
|
||||
sourcetex = R2D_RT_Configure("rt/$lastgameview", vid.fbpwidth, vid.fbpheight, /*(r_refdef.flags&RDF_BLOOM)?TF_RGBA16F:*/TF_RGBA32);
|
||||
|
||||
GLBE_FBO_Update(&fbo_gameview, FBO_RB_DEPTH, &sourcetex, 1, r_nulltex, vid.fbpwidth, vid.fbpheight);
|
||||
dofbo = true;
|
||||
|
|
|
@ -666,7 +666,7 @@ static texid_t Shader_FindImage ( char *name, int flags )
|
|||
return r_whiteimage;
|
||||
}
|
||||
if (flags & IF_RENDERTARGET)
|
||||
return R2D_RT_Configure(name, 0, 0, 0);
|
||||
return R2D_RT_Configure(name, 0, 0, TF_INVALID);
|
||||
return R_LoadHiResTexture(name, NULL, flags);
|
||||
}
|
||||
|
||||
|
|
|
@ -4038,13 +4038,13 @@ void QCBUILTIN PF_applylightstyle(int style, const char *val, vec3_t rgb)
|
|||
continue;
|
||||
if ( client->state == cs_spawned )
|
||||
{
|
||||
if (style >= MAX_STANDARDLIGHTSTYLES)
|
||||
if (style >= MAX_STANDARDLIGHTSTYLES) //only bug out clients if the styles are needed
|
||||
if (!*val)
|
||||
continue;
|
||||
#ifdef PEXT_LIGHTSTYLECOL
|
||||
if ((client->fteprotocolextensions & PEXT_LIGHTSTYLECOL) && (rgb[0] != 1 || rgb[1] != 1 || rgb[2] != 1))
|
||||
{
|
||||
ClientReliableWrite_Begin (client, svcfte_lightstylecol, strlen(val)+4);
|
||||
ClientReliableWrite_Begin (client, svcfte_lightstylecol, 3+6+strlen(val)+1);
|
||||
ClientReliableWrite_Byte (client, style);
|
||||
ClientReliableWrite_Char (client, 0x87);
|
||||
ClientReliableWrite_Short (client, rgb[0]*1024);
|
||||
|
@ -4053,14 +4053,38 @@ void QCBUILTIN PF_applylightstyle(int style, const char *val, vec3_t rgb)
|
|||
ClientReliableWrite_String (client, val);
|
||||
}
|
||||
else
|
||||
{
|
||||
#endif
|
||||
{
|
||||
ClientReliableWrite_Begin (client, svc_lightstyle, strlen(val)+3);
|
||||
ClientReliableWrite_Byte (client, style);
|
||||
ClientReliableWrite_String (client, val);
|
||||
#ifdef PEXT_LIGHTSTYLECOL
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (sv.mvdrecording)
|
||||
{
|
||||
if (style < MAX_STANDARDLIGHTSTYLES || *val)
|
||||
{
|
||||
sizebuf_t *msg = MVDWrite_Begin(dem_all, 0, 3+6+strlen(val)+1);
|
||||
#ifdef PEXT_LIGHTSTYLECOL
|
||||
if ((demo.recorder.fteprotocolextensions & PEXT_LIGHTSTYLECOL) && (rgb[0] != 1 || rgb[1] != 1 || rgb[2] != 1))
|
||||
{
|
||||
MSG_WriteByte (msg, svcfte_lightstylecol);
|
||||
MSG_WriteByte (msg, style);
|
||||
MSG_WriteChar (msg, 0x87);
|
||||
MSG_WriteShort (msg, rgb[0]*1024);
|
||||
MSG_WriteShort (msg, rgb[1]*1024);
|
||||
MSG_WriteShort (msg, rgb[2]*1024);
|
||||
MSG_WriteString (msg, val);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
MSG_WriteByte (msg, svc_lightstyle);
|
||||
MSG_WriteByte (msg, style);
|
||||
MSG_WriteString (msg, val);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4116,6 +4140,9 @@ static void QCBUILTIN PF_lightstylestatic (pubprogfuncs_t *prinst, struct global
|
|||
VectorCopy(G_VECTOR(OFS_PARM2), rgb);
|
||||
#endif
|
||||
|
||||
//with fte+dp, va("=%g", (num*2.0)/26) should work
|
||||
//but will break other clients. so that's a problem.
|
||||
|
||||
val[0] = 'a' + bound(0, num, ('z'-'a')-1);
|
||||
val[1] = 0;
|
||||
PF_applylightstyle(style, val, rgb);
|
||||
|
|
|
@ -1743,11 +1743,6 @@ static void SV_InitBotLib(void)
|
|||
bot_enable->flags |= CVAR_LATCH;
|
||||
Cvar_ForceSet(bot_enable, "0");
|
||||
}
|
||||
else
|
||||
{
|
||||
cvar_t *mapname = Cvar_Get("mapname", "", CVAR_SERVERINFO, "Q3 compatability");
|
||||
Cvar_Set(mapname, sv.name);
|
||||
}
|
||||
#else
|
||||
|
||||
//make sure it's switched off.
|
||||
|
@ -1783,6 +1778,12 @@ qboolean SVQ3_InitGame(void)
|
|||
if (!q3gamevm)
|
||||
return false;
|
||||
|
||||
//q3 needs mapname (while qw has map serverinfo)
|
||||
{
|
||||
cvar_t *mapname = Cvar_Get("mapname", "", CVAR_SERVERINFO, "Q3 compatability");
|
||||
Cvar_Set(mapname, sv.name);
|
||||
}
|
||||
|
||||
SV_InitBotLib();
|
||||
|
||||
World_ClearWorld(&sv.world);
|
||||
|
|
Loading…
Reference in a new issue