fix bugs with CSQC clearscene function - it now restores the view to
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 14 Oct 2011 14:34:03 +0000 (14:34 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 14 Oct 2011 14:34:03 +0000 (14:34 +0000)
what was given to CSQC_UpdateView in the first place
fix bugs with getpropertyvec(VF_FOV) - it reads view.ortho_x and y
values assuming they are the original angles, so these needed to be set
correctly by the engine before invoking CSQC_UpdateView

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11410 d7cf8633-e32d-0410-b094-e92efae38249

cl_screen.c
clvm_cmds.c
csprogs.c
gl_rmain.c

index c327fec..7485a11 100644 (file)
@@ -1453,6 +1453,8 @@ static void R_Envmap_f (void)
 
        r_refdef.view.frustum_x = 1; // tan(45 * M_PI / 180.0);
        r_refdef.view.frustum_y = 1; // tan(45 * M_PI / 180.0);
+       r_refdef.view.ortho_x = 90; // abused as angle by VM_CL_R_SetView
+       r_refdef.view.ortho_y = 90; // abused as angle by VM_CL_R_SetView
 
        buffer1 = (unsigned char *)Mem_Alloc(tempmempool, size * size * 4);
        buffer2 = (unsigned char *)Mem_Alloc(tempmempool, size * size * 3);
@@ -1743,6 +1745,8 @@ void SCR_DrawScreen (void)
 
                r_refdef.view.frustum_x *= r_refdef.frustumscale_x;
                r_refdef.view.frustum_y *= r_refdef.frustumscale_y;
+               r_refdef.view.ortho_x = atan(r_refdef.view.frustum_x) * (360.0 / M_PI); // abused as angle by VM_CL_R_SetView
+               r_refdef.view.ortho_y = atan(r_refdef.view.frustum_y) * (360.0 / M_PI); // abused as angle by VM_CL_R_SetView
 
                if(!CL_VM_UpdateView())
                        R_RenderView();
@@ -1765,6 +1769,9 @@ void SCR_DrawScreen (void)
                        r_refdef.view.frustum_x *= r_refdef.frustumscale_x;
                        r_refdef.view.frustum_y *= r_refdef.frustumscale_y;
 
+                       r_refdef.view.ortho_x = atan(r_refdef.view.frustum_x) * (360.0 / M_PI); // abused as angle by VM_CL_R_SetView
+                       r_refdef.view.ortho_y = atan(r_refdef.view.frustum_y) * (360.0 / M_PI); // abused as angle by VM_CL_R_SetView
+
                        if(!CL_VM_UpdateView())
                                R_RenderView();
                }
index 16b37e0..67c8b70 100644 (file)
@@ -23,6 +23,8 @@
 extern cvar_t v_flipped;
 extern cvar_t r_equalize_entities_fullbright;
 
+r_refdef_view_t csqc_original_r_refdef_view;
+
 sfx_t *S_FindName(const char *name);
 int Sbar_GetSortedPlayerIndex (int index);
 void Sbar_SortFrags (void);
@@ -722,23 +724,8 @@ void VM_CL_R_ClearScene (void)
        // clear renderable entity and light lists
        r_refdef.scene.numentities = 0;
        r_refdef.scene.numlights = 0;
-       // FIXME: restore these to the values from VM_CL_UpdateView
-       r_refdef.view.x = 0;
-       r_refdef.view.y = 0;
-       r_refdef.view.z = 0;
-       r_refdef.view.width = vid.width;
-       r_refdef.view.height = vid.height;
-       r_refdef.view.depth = 1;
-       // FIXME: restore frustum_x/frustum_y
-       r_refdef.view.useperspective = true;
-       r_refdef.view.frustum_y = tan(scr_fov.value * M_PI / 360.0) * (3.0/4.0) * cl.viewzoom;
-       r_refdef.view.frustum_x = r_refdef.view.frustum_y * (float)r_refdef.view.width / (float)r_refdef.view.height / vid_pixelheight.value;
-       r_refdef.view.frustum_x *= r_refdef.frustumscale_x;
-       r_refdef.view.frustum_y *= r_refdef.frustumscale_y;
-       r_refdef.view.ortho_x = scr_fov.value * (3.0 / 4.0) * (float)r_refdef.view.width / (float)r_refdef.view.height / vid_pixelheight.value;
-       r_refdef.view.ortho_y = scr_fov.value * (3.0 / 4.0);
-       r_refdef.view.clear = true;
-       r_refdef.view.isoverlay = false;
+       // restore the view settings to the values that VM_CL_UpdateView received from the client code
+       r_refdef.view = csqc_original_r_refdef_view;
        VectorCopy(cl.csqc_vieworiginfromengine, cl.csqc_vieworigin);
        VectorCopy(cl.csqc_viewanglesfromengine, cl.csqc_viewangles);
        cl.csqc_vidvars.drawworld = r_drawworld.integer != 0;
index 1d3065d..8181505 100644 (file)
--- a/csprogs.c
+++ b/csprogs.c
@@ -464,6 +464,7 @@ qboolean CL_VM_InputEvent (int eventtype, int x, int y)
        return r;
 }
 
+extern r_refdef_view_t csqc_original_r_refdef_view;
 qboolean CL_VM_UpdateView (void)
 {
        vec3_t emptyvector;
@@ -475,6 +476,7 @@ qboolean CL_VM_UpdateView (void)
                return false;
        R_TimeReport("pre-UpdateView");
        CSQC_BEGIN
+               csqc_original_r_refdef_view = r_refdef.view;
                //VectorCopy(cl.viewangles, oldangles);
                PRVM_clientglobalfloat(time) = cl.time;
                PRVM_clientglobaledict(self) = cl.csqc_server2csqcentitynumber[cl.playerentity];
@@ -490,6 +492,7 @@ 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;
        CSQC_END
        R_TimeReport("UpdateView");
        return true;
index e9b213b..73b8f58 100644 (file)
@@ -5924,6 +5924,8 @@ static void R_Water_ProcessPlanes(void)
                        r_refdef.view.height = r_waterstate.cameraheight;
                        r_refdef.view.frustum_x = 1; // tan(45 * M_PI / 180.0);
                        r_refdef.view.frustum_y = 1; // tan(45 * M_PI / 180.0);
+                       r_refdef.view.ortho_x = 90; // abused as angle by VM_CL_R_SetView
+                       r_refdef.view.ortho_y = 90; // abused as angle by VM_CL_R_SetView
 
                        if(p->camera_entity)
                        {