]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - clvm_cmds.c
comment out another unused var
[xonotic/darkplaces.git] / clvm_cmds.c
index be1f04d851e6392fd908e81cf28e635fda28e9a4..64dcdd734afb11f9bc649939516b99431e750745 100644 (file)
@@ -887,22 +887,28 @@ void VM_CL_R_SetView (void)
        case VF_MIN:
                r_refdef.view.x = (int)(f[0]);
                r_refdef.view.y = (int)(f[1]);
+               DrawQ_RecalcView();
                break;
        case VF_MIN_X:
                r_refdef.view.x = (int)(k);
+               DrawQ_RecalcView();
                break;
        case VF_MIN_Y:
                r_refdef.view.y = (int)(k);
+               DrawQ_RecalcView();
                break;
        case VF_SIZE:
                r_refdef.view.width = (int)(f[0]);
                r_refdef.view.height = (int)(f[1]);
+               DrawQ_RecalcView();
                break;
        case VF_SIZE_X:
                r_refdef.view.width = (int)(k);
+               DrawQ_RecalcView();
                break;
        case VF_SIZE_Y:
                r_refdef.view.height = (int)(k);
+               DrawQ_RecalcView();
                break;
        case VF_VIEWPORT:
                r_refdef.view.x = (int)(f[0]);
@@ -910,6 +916,7 @@ void VM_CL_R_SetView (void)
                f = PRVM_G_VECTOR(OFS_PARM2);
                r_refdef.view.width = (int)(f[0]);
                r_refdef.view.height = (int)(f[1]);
+               DrawQ_RecalcView();
                break;
        case VF_FOV:
                r_refdef.view.frustum_x = tan(f[0] * M_PI / 360.0);r_refdef.view.ortho_x = f[0];
@@ -1051,12 +1058,12 @@ static void VM_CL_unproject (void)
 
        VM_SAFEPARMCOUNT(1, VM_CL_unproject);
        f = PRVM_G_VECTOR(OFS_PARM0);
-       if(v_flipped.integer)
-               f[0] = (2 * r_refdef.view.x + r_refdef.view.width) * (vid_conwidth.integer / (float) vid.width) - f[0];
        VectorSet(temp,
                f[2],
-               (-1.0 + 2.0 * (f[0] / (vid_conwidth.integer / (float) vid.width) - r_refdef.view.x) / r_refdef.view.width) * f[2] * -r_refdef.view.frustum_x,
-               (-1.0 + 2.0 * (f[1] / (vid_conheight.integer / (float) vid.height) - r_refdef.view.y) / r_refdef.view.height) * f[2] * -r_refdef.view.frustum_y);
+               (-1.0 + 2.0 * (f[0] / vid_conwidth.integer)) * f[2] * -r_refdef.view.frustum_x,
+               (-1.0 + 2.0 * (f[1] / vid_conheight.integer)) * f[2] * -r_refdef.view.frustum_y);
+       if(v_flipped.integer)
+               temp[1] = -temp[1];
        Matrix4x4_Transform(&r_refdef.view.matrix, temp, PRVM_G_VECTOR(OFS_RETURN));
 }
 
@@ -1074,9 +1081,12 @@ static void VM_CL_project (void)
        if(v_flipped.integer)
                v[1] = -v[1];
        VectorSet(PRVM_G_VECTOR(OFS_RETURN),
-               (vid_conwidth.integer / (float) vid.width) * (r_refdef.view.x + r_refdef.view.width*0.5*(1.0+v[1]/v[0]/-r_refdef.view.frustum_x)),
-               (vid_conheight.integer / (float) vid.height) * (r_refdef.view.y + r_refdef.view.height*0.5*(1.0+v[2]/v[0]/-r_refdef.view.frustum_y)),
+               vid_conwidth.integer * (0.5*(1.0+v[1]/v[0]/-r_refdef.view.frustum_x)),
+               vid_conheight.integer * (0.5*(1.0+v[2]/v[0]/-r_refdef.view.frustum_y)),
                v[0]);
+       // explanation:
+       // after transforming, relative position to viewport (0..1) = 0.5 * (1 + v[2]/v[0]/-frustum_{x \or y})
+       // as 2D drawing honors the viewport too, to get the same pixel, we simply multiply this by conwidth/height
 }
 
 //#330 float(float stnum) getstatf (EXT_CSQC)
@@ -1248,7 +1258,7 @@ static void VM_CL_pointparticles (void)
 static void VM_CL_boxparticles (void)
 {
        int effectnum;
-       prvm_edict_t *own;
+       // prvm_edict_t *own;
        float *origin_from, *origin_to, *dir_from, *dir_to;
        float count;
        int flags;
@@ -1257,7 +1267,7 @@ static void VM_CL_boxparticles (void)
        VM_SAFEPARMCOUNTRANGE(7, 8, VM_CL_boxparticles);
 
        effectnum = (int)PRVM_G_FLOAT(OFS_PARM0);
-       own = PRVM_G_EDICT(OFS_PARM1); // TODO find use for this
+       // own = PRVM_G_EDICT(OFS_PARM1); // TODO find use for this
        origin_from = PRVM_G_VECTOR(OFS_PARM2);
        origin_to = PRVM_G_VECTOR(OFS_PARM3);
        dir_from = PRVM_G_VECTOR(OFS_PARM4);