From fa1e7feb5cbe2e525104aaa05a9ca06dd42861fc Mon Sep 17 00:00:00 2001 From: divverent Date: Tue, 8 Nov 2011 20:49:52 +0000 Subject: [PATCH] 1. make the first CSQC rendered view the "main" view, for use e.g. by origin display in r_speeds, prydon cursor, etc. 2. add an extension DP_CSQC_MAINVIEW to override DP's notion of the "main" view when necessesary git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11540 d7cf8633-e32d-0410-b094-e92efae38249 ::stable-branch::merge=7938a89abdf37e9452182f64bc9aec0293f493a3 --- client.h | 2 ++ clvm_cmds.c | 18 ++++++++++++++++++ csprogs.c | 7 ++++++- csprogs.h | 2 ++ dpdefs/csprogsdefs.qc | 13 ++++++++++++- gl_rmain.c | 2 +- render.h | 1 + svvm_cmds.c | 1 + 8 files changed, 43 insertions(+), 3 deletions(-) diff --git a/client.h b/client.h index 41656fe4..5c1d8f27 100644 --- a/client.h +++ b/client.h @@ -1669,6 +1669,8 @@ typedef struct r_refdef_view_s qboolean clear; // if true, don't clear or do any post process effects (bloom, etc) qboolean isoverlay; + // if true, this is the MAIN view (which is, after CSQC, copied into the scene for use e.g. by r_speeds 1, showtex, prydon cursor) + qboolean ismain; // whether to draw r_showtris and such, this is only true for the main // view render, all secondary renders (mirrors, portals, cameras, diff --git a/clvm_cmds.c b/clvm_cmds.c index 227e9f2b..cbcc5486 100644 --- a/clvm_cmds.c +++ b/clvm_cmds.c @@ -24,6 +24,7 @@ extern cvar_t v_flipped; extern cvar_t r_equalize_entities_fullbright; r_refdef_view_t csqc_original_r_refdef_view; +r_refdef_view_t csqc_main_r_refdef_view; sfx_t *S_FindName(const char *name); int Sbar_GetSortedPlayerIndex (int index); @@ -884,6 +885,9 @@ void VM_CL_R_SetView (void) case VF_CLEARSCREEN: PRVM_G_FLOAT(OFS_RETURN) = r_refdef.view.isoverlay; break; + case VF_MAINVIEW: + PRVM_G_FLOAT(OFS_RETURN) = r_refdef.view.ismain; + break; case VF_FOG_DENSITY: PRVM_G_FLOAT(OFS_RETURN) = r_refdef.fog_density; break; @@ -1031,6 +1035,9 @@ void VM_CL_R_SetView (void) case VF_CLEARSCREEN: r_refdef.view.isoverlay = !k; break; + case VF_MAINVIEW: + PRVM_G_FLOAT(OFS_RETURN) = r_refdef.view.ismain; + break; case VF_FOG_DENSITY: r_refdef.fog_density = k; break; @@ -3090,6 +3097,17 @@ void VM_CL_R_RenderScene (void) vmpolygons_t* polys = vmpolygons + PRVM_GetProgNr(); VM_SAFEPARMCOUNT(0, VM_CL_R_RenderScene); + // update the views + if(r_refdef.view.ismain) + { + // set the main view + csqc_main_r_refdef_view = r_refdef.view; + + // clear the flags so no other view becomes "main" unless CSQC sets VF_MAINVIEW + r_refdef.view.ismain = false; + csqc_original_r_refdef_view.ismain = false; + } + // we need to update any RENDER_VIEWMODEL entities at this point because // csqc supplies its own view matrix CL_UpdateViewEntities(); diff --git a/csprogs.c b/csprogs.c index 8181505b..089587db 100644 --- a/csprogs.c +++ b/csprogs.c @@ -465,6 +465,7 @@ qboolean CL_VM_InputEvent (int eventtype, int x, int y) } extern r_refdef_view_t csqc_original_r_refdef_view; +extern r_refdef_view_t csqc_main_r_refdef_view; qboolean CL_VM_UpdateView (void) { vec3_t emptyvector; @@ -476,7 +477,9 @@ qboolean CL_VM_UpdateView (void) return false; R_TimeReport("pre-UpdateView"); CSQC_BEGIN + r_refdef.view.ismain = true; csqc_original_r_refdef_view = r_refdef.view; + csqc_main_r_refdef_view = r_refdef.view; //VectorCopy(cl.viewangles, oldangles); PRVM_clientglobalfloat(time) = cl.time; PRVM_clientglobaledict(self) = cl.csqc_server2csqcentitynumber[cl.playerentity]; @@ -492,8 +495,10 @@ qboolean CL_VM_UpdateView (void) //VectorCopy(oldangles, cl.viewangles); // Dresk : Reset Dmg Globals Here CL_VM_UpdateDmgGlobals(0, 0, emptyvector); - r_refdef.view = csqc_original_r_refdef_view; + r_refdef.view = csqc_main_r_refdef_view; + R_RenderView_UpdateViewVectors(); // we have to do this, as we undid the scene render doing this for us CSQC_END + R_TimeReport("UpdateView"); return true; } diff --git a/csprogs.h b/csprogs.h index a5f478c1..f6fb753e 100644 --- a/csprogs.h +++ b/csprogs.h @@ -52,6 +52,8 @@ #define VF_FOG_HEIGHT 210 //(float) #define VF_FOG_FADEDEPTH 211 //(float) +#define VF_MAINVIEW 212 //(float) + #define RF_VIEWMODEL 1 // The entity is never drawn in mirrors. In engines with realtime lighting, it casts no shadows. #define RF_EXTERNALMODEL 2 // The entity is appears in mirrors but not in the normal view. It does still cast shadows in engines with realtime lighting. #define RF_DEPTHHACK 4 // The entity appears closer to the view than normal, either by scaling it wierdly or by just using a depthrange. This will usually be found in conjunction with RF_VIEWMODEL diff --git a/dpdefs/csprogsdefs.qc b/dpdefs/csprogsdefs.qc index cca16019..8fa52e44 100644 --- a/dpdefs/csprogsdefs.qc +++ b/dpdefs/csprogsdefs.qc @@ -881,4 +881,15 @@ string(string command, float bindmap) findkeysforcommand = #610; //builtin definitions: (CSQC) float(string url, float id, string content_type, string delim, float buf, float keyid) crypto_uri_postbuf = #513; //description: -//use -1 as buffer handle to justs end delim as postdata \ No newline at end of file +//use -1 as buffer handle to justs end delim as postdata + +//DP_CSQC_MAINVIEW +//idea: divVerent +//darkplaces implementation: divVerent +//constant definitions: +const float VF_MAINVIEW = 212; +//use setproperty(VF_MAINVIEW, 1); before calling R_RenderView for the render +//that shall become the "main" view, which is e.g. used by PRYDON_CLIENTCURSOR +//this flag is set for the first scene, and not cleared by R_ClearScene +//this flag is automatically cleared by R_RenderView +//so when not using this extension, the first view rendered is the main view diff --git a/gl_rmain.c b/gl_rmain.c index a4011abd..a0c1b0e9 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -5521,7 +5521,7 @@ void R_ResetViewRendering3D(int fbo, rtexture_t *depthtexture, rtexture_t *color R_RenderView_UpdateViewVectors ================ */ -static void R_RenderView_UpdateViewVectors(void) +void R_RenderView_UpdateViewVectors(void) { // break apart the view matrix into vectors for various purposes // it is important that this occurs outside the RenderScene function because that can be called from reflection renders, where the vectors come out wrong diff --git a/render.h b/render.h index 0ddb2f57..ccde73d7 100644 --- a/render.h +++ b/render.h @@ -126,6 +126,7 @@ extern cvar_t r_dynamic; void R_Init(void); void R_UpdateVariables(void); // must call after setting up most of r_refdef, but before calling R_RenderView void R_RenderView(void); // must set r_refdef and call R_UpdateVariables first +void R_RenderView_UpdateViewVectors(void); // just updates r_refdef.view.{forward,left,up,origin,right,inverse_matrix} typedef enum r_refdef_scene_type_s { RST_CLIENT, diff --git a/svvm_cmds.c b/svvm_cmds.c index ad027b44..741cae36 100644 --- a/svvm_cmds.c +++ b/svvm_cmds.c @@ -24,6 +24,7 @@ const char *vm_sv_extensions = "DP_CSQC_ENTITYWORLDOBJECT " "DP_CSQC_ENTITYMODELLIGHT " "DP_CSQC_ENTITYTRANSPARENTSORTING_OFFSET " +"DP_CSQC_MAINVIEW " "DP_CSQC_MULTIFRAME_INTERPOLATION " "DP_CSQC_BOXPARTICLES " "DP_CSQC_SPAWNPARTICLE " -- 2.39.2