]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - clvm_cmds.c
changed all references to entity_render_t->frame to frame2 to eliminate
[xonotic/darkplaces.git] / clvm_cmds.c
index 37deefa867cecafbecb7f176c67472810f743581..c40d668f10354a8cd3bf3439ed45992bd1eb679b 100644 (file)
@@ -404,7 +404,7 @@ static void VM_CL_findradius (void)
                        eorg[2] -= bound(ent->fields.client->mins[2], eorg[2], ent->fields.client->maxs[2]);
                }
                else
-                       VectorMAMAM(1, eorg, 0.5f, ent->fields.client->mins, 0.5f, ent->fields.client->maxs, eorg);
+                       VectorMAMAM(1, eorg, -0.5f, ent->fields.client->mins, -0.5f, ent->fields.client->maxs, eorg);
                if (DotProduct(eorg, eorg) < radius2)
                {
                        ent->fields.client->chain = PRVM_EDICT_TO_PROG(chain);
@@ -625,11 +625,19 @@ static void VM_CL_R_ClearScene (void)
        r_view.width = vid.width;
        r_view.height = vid.height;
        r_view.depth = 1;
+       // FIXME: restore frustum_x/frustum_y
+       r_view.useperspective = true;
+       r_view.frustum_y = tan(scr_fov.value * M_PI / 360.0) * (3.0/4.0) * cl.viewzoom;
+       r_view.frustum_x = r_view.frustum_y * (float)r_view.width / (float)r_view.height / vid_pixelheight.value;
+       r_view.frustum_x *= r_refdef.frustumscale_x;
+       r_view.frustum_y *= r_refdef.frustumscale_y;
+       r_view.ortho_x = scr_fov.value * (3.0 / 4.0) * (float)r_view.width / (float)r_view.height / vid_pixelheight.value;
+       r_view.ortho_y = scr_fov.value * (3.0 / 4.0);
        // FIXME: restore cl.csqc_origin
        // FIXME: restore cl.csqc_angles
        cl.csqc_vidvars.drawworld = true;
-       cl.csqc_vidvars.drawenginesbar = true;
-       cl.csqc_vidvars.drawcrosshair = true;
+       cl.csqc_vidvars.drawenginesbar = false;
+       cl.csqc_vidvars.drawcrosshair = false;
 }
 
 //#301 void(float mask) addentities (EXT_CSQC)
@@ -685,35 +693,32 @@ static void VM_CL_R_SetView (void)
 
        switch(c)
        {
-       case VF_MIN:                    r_view.x = (int)f[0];
-                                                       r_view.y = (int)f[1];
+       case VF_MIN:                    r_view.x = (int)(f[0] * vid.width / vid_conwidth.value);
+                                                       r_view.y = (int)(f[1] * vid.height / vid_conheight.value);
                                                        break;
-       case VF_MIN_X:                  r_view.x = (int)k;
+       case VF_MIN_X:                  r_view.x = (int)(k * vid.width / vid_conwidth.value);
                                                        break;
-       case VF_MIN_Y:                  r_view.y = (int)k;
+       case VF_MIN_Y:                  r_view.y = (int)(k * vid.height / vid_conheight.value);
                                                        break;
-       case VF_SIZE:                   r_view.width = (int)f[0];
-                                                       r_view.height = (int)f[1];
+       case VF_SIZE:                   r_view.width = (int)(f[0] * vid.width / vid_conwidth.value);
+                                                       r_view.height = (int)(f[1] * vid.height / vid_conheight.value);
                                                        break;
-       case VF_SIZE_Y:                 r_view.width = (int)k;
+       case VF_SIZE_Y:                 r_view.width = (int)(k * vid.width / vid_conwidth.value);
                                                        break;
-       case VF_SIZE_X:                 r_view.height = (int)k;
+       case VF_SIZE_X:                 r_view.height = (int)(k * vid.height / vid_conheight.value);
                                                        break;
-       case VF_VIEWPORT:               r_view.x = (int)f[0];
-                                                       r_view.y = (int)f[1];
-                                                       r_view.z = 0;
-                                                       // TODO: make sure that view_z and view_depth are set properly even if csqc does not set them!
+       case VF_VIEWPORT:               r_view.x = (int)(f[0] * vid.width / vid_conwidth.value);
+                                                       r_view.y = (int)(f[1] * vid.height / vid_conheight.value);
                                                        f = PRVM_G_VECTOR(OFS_PARM2);
-                                                       r_view.width = (int)f[0];
-                                                       r_view.height = (int)f[1];
-                                                       r_view.depth = 1;
+                                                       r_view.width = (int)(f[0] * vid.width / vid_conwidth.value);
+                                                       r_view.height = (int)(f[1] * vid.height / vid_conheight.value);
                                                        break;
-       case VF_FOV:                    //r_refdef.fov_x = f[0]; // FIXME!
-                                                       //r_refdef.fov_y = f[1]; // FIXME!
+       case VF_FOV:                    r_view.frustum_x = tan(f[0] * M_PI / 360.0);r_view.ortho_x = f[0];
+                                                       r_view.frustum_y = tan(f[1] * M_PI / 360.0);r_view.ortho_y = f[1];
                                                        break;
-       case VF_FOVX:                   //r_refdef.fov_x = k; // FIXME!
+       case VF_FOVX:                   r_view.frustum_x = tan(k * M_PI / 360.0);r_view.ortho_x = k;
                                                        break;
-       case VF_FOVY:                   //r_refdef.fov_y = k; // FIXME!
+       case VF_FOVY:                   r_view.frustum_y = tan(k * M_PI / 360.0);r_view.ortho_y = k;
                                                        break;
        case VF_ORIGIN:                 VectorCopy(f, cl.csqc_origin);
                                                        CSQC_R_RecalcView();
@@ -755,6 +760,9 @@ static void VM_CL_R_SetView (void)
        case VF_CL_VIEWANGLES_Z:cl.viewangles[2] = k;
                                                        break;
 
+       case VF_PERSPECTIVE:    r_view.useperspective = k != 0;
+                                                       break;
+
        default:                                PRVM_G_FLOAT(OFS_RETURN) = 0;
                                                        VM_Warning("VM_CL_R_SetView : unknown parm %i\n", c);
                                                        return;
@@ -1171,7 +1179,7 @@ static void VM_CL_makestatic (void)
 
                // copy it to the current state
                staticent->render.model = CL_GetModelByIndex((int)ent->fields.client->modelindex);
-               staticent->render.frame = staticent->render.frame1 = staticent->render.frame2 = (int)ent->fields.client->frame;
+               staticent->render.frame1 = staticent->render.frame2 = (int)ent->fields.client->frame;
                staticent->render.framelerp = 0;
                // make torchs play out of sync
                staticent->render.frame1time = staticent->render.frame2time = lhrandom(-10, -1);