cl_velocityzoom: velocity based zooming of fov -- div0: The bounding on line 200...
authorsamual <samual@f962a42d-fe04-0410-a3ab-8c8b0445ebaa>
Fri, 6 Nov 2009 21:31:57 +0000 (21:31 +0000)
committersamual <samual@f962a42d-fe04-0410-a3ab-8c8b0445ebaa>
Fri, 6 Nov 2009 21:31:57 +0000 (21:31 +0000)
git-svn-id: svn://svn.icculus.org/nexuiz/trunk@8220 f962a42d-fe04-0410-a3ab-8c8b0445ebaa

data/defaultNexuiz.cfg
data/qcsrc/client/View.qc

index ba89e9c..c6c2215 100644 (file)
@@ -216,6 +216,8 @@ seta crosshair_fireball_color_blue 0.2      "crosshair color blue component to displa
 seta crosshair_fireball_color_alpha 1  "crosshair alpha value to display when wielding the fireball"
 seta crosshair_fireball_size 1 "crosshair size when wielding the fireball"
 fov 90
+seta cl_velocityzoom 0 "velocity based zooming of fov, negative values zoom out"
+seta cl_velocityzoomtime 0.3   "time value for averaging speed values"
 seta cl_zoomfactor 5   "how much +zoom will zoom (1-16)"
 seta cl_zoomspeed 3.5  "how fast it will zoom (0.5-16), negative values mean instant zoom"
 seta cl_zoomsensitivity 0      "how zoom changes sensitivity (0 = weakest, 1 = strongest)"
index 4ea84c6..dd404d6 100644 (file)
@@ -134,10 +134,10 @@ float atan2(float y, float x)
        v = vectoangles(v);
        return v_y * 0.01745329251994329576;
 }
-
+float avgspeed;
 vector GetCurrentFov(float fov)
 {
-       float zoomsensitivity, zoomspeed, zoomfactor, zoomdir;
+       float zoomsensitivity, zoomspeed, zoomfactor, zoomdir, velocityzoom;
 
        zoomsensitivity = cvar("cl_zoomsensitivity");
        zoomfactor = cvar("cl_zoomfactor");
@@ -196,9 +196,15 @@ vector GetCurrentFov(float fov)
                setsensitivityscale(pow(current_viewzoom, 1 - zoomsensitivity));
        else
                setsensitivityscale(1);
-
+               
+       velocityzoom = bound(0, drawframetime / max(0.000000001, cvar_or("cl_velocityzoomtime", 0.3)), 1);
+       avgspeed = avgspeed * (1 - velocityzoom) + (vlen(pmove_vel) / 1000) * velocityzoom;
+       velocityzoom = pow(2.718281828459, float2range11(avgspeed * -cvar_or("cl_velocityzoom", 0) / 1) * 1);
+       
+       //print(ftos(avgspeed), " avgspeed, ", ftos(cvar_or("cl_velocityzoom", 0)), " cvar, ", ftos(velocityzoom), " return\n"); // for debugging
+       
        float frustumx, frustumy, fovx, fovy;
-       frustumy = tan(fov * 0.00872664625997164788) * 0.75 * current_viewzoom;
+       frustumy = tan(fov * 0.00872664625997164788) * 0.75 * current_viewzoom * velocityzoom;
        frustumx = frustumy * vid_width / vid_height / vid_pixelheight;
        fovx = atan2(frustumx, 1) / 0.00872664625997164788;
        fovy = atan2(frustumy, 1) / 0.00872664625997164788;