diff --git a/engine/client/cl_cam.c b/engine/client/cl_cam.c index d77f44547..e69eaee7c 100644 --- a/engine/client/cl_cam.c +++ b/engine/client/cl_cam.c @@ -192,98 +192,45 @@ 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) { - float f, max; - vec3_t vec, vec2; + 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; VectorCopy(playerviewangles, vec); - vec[0] = 0; + vec[0] = 0; AngleVectors (vec, forward, right, up); // for (i = 0; i < 3; i++) // forward[i] *= 3; - max = 1000; - VectorAdd(forward, up, vec2); - VectorAdd(vec2, right, vec2); - if ((f = Cam_TryFlyby(selforigin, playerorigin, vec2, checkvis)) < max) + max = 1000; + for (dir = 0; dir < sizeof(dirs)/sizeof(dirs[0]); dir++) { - 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); - } - + 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); + } + } // ack, can't find him - if (max >= 1000) + if (max >= 1000) { // Cam_Unlock(); return false; @@ -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) { diff --git a/engine/client/cl_main.c b/engine/client/cl_main.c index 058318201..d79ccdd2b 100644 --- a/engine/client/cl_main.c +++ b/engine/client/cl_main.c @@ -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; diff --git a/engine/client/cl_pred.c b/engine/client/cl_pred.c index 375572996..29b4e13c7 100644 --- a/engine/client/cl_pred.c +++ b/engine/client/cl_pred.c @@ -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; diff --git a/engine/client/image.c b/engine/client/image.c index cc7170615..1adc3ddd8 100644 --- a/engine/client/image.c +++ b/engine/client/image.c @@ -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: diff --git a/engine/client/merged.h b/engine/client/merged.h index 9bab65002..c8308379a 100644 --- a/engine/client/merged.h +++ b/engine/client/merged.h @@ -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, diff --git a/engine/client/pr_csqc.c b/engine/client/pr_csqc.c index d9cb99894..163127315 100644 --- a/engine/client/pr_csqc.c +++ b/engine/client/pr_csqc.c @@ -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; diff --git a/engine/client/r_2d.c b/engine/client/r_2d.c index a718ab134..6d446aff6 100644 --- a/engine/client/r_2d.c +++ b/engine/client/r_2d.c @@ -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; diff --git a/engine/d3d/vid_d3d11.c b/engine/d3d/vid_d3d11.c index 3e0e21064..82a501448 100644 --- a/engine/d3d/vid_d3d11.c +++ b/engine/d3d/vid_d3d11.c @@ -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; diff --git a/engine/gl/gl_bloom.c b/engine/gl/gl_bloom.c index 6c10bcc0b..033a98325 100644 --- a/engine/gl/gl_bloom.c +++ b/engine/gl/gl_bloom.c @@ -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; diff --git a/engine/gl/gl_draw.c b/engine/gl/gl_draw.c index 29e17bbf7..7fdb45ab5 100644 --- a/engine/gl/gl_draw.c +++ b/engine/gl/gl_draw.c @@ -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); diff --git a/engine/gl/gl_rmain.c b/engine/gl/gl_rmain.c index 3729383d1..17b331315 100644 --- a/engine/gl/gl_rmain.c +++ b/engine/gl/gl_rmain.c @@ -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; diff --git a/engine/gl/gl_shader.c b/engine/gl/gl_shader.c index c885272bb..ff77dfabe 100644 --- a/engine/gl/gl_shader.c +++ b/engine/gl/gl_shader.c @@ -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); } diff --git a/engine/server/pr_cmds.c b/engine/server/pr_cmds.c index 22d1121d4..f1d813a31 100644 --- a/engine/server/pr_cmds.c +++ b/engine/server/pr_cmds.c @@ -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); diff --git a/engine/server/svq3_game.c b/engine/server/svq3_game.c index 19d00766e..d53aa793e 100644 --- a/engine/server/svq3_game.c +++ b/engine/server/svq3_game.c @@ -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);