]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/View.qc
Merge branch 'master' into samual/water_and_damage_blur
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / View.qc
index 160ad063f17744ef89c96c6480fa08c36ad82b81..adfdbf0bd50bc6c3d87bc33aadabf6e5005543b3 100644 (file)
@@ -306,6 +306,9 @@ float TrueAimCheck()
        traceline(view_origin, view_origin + view_forward * MAX_SHOT_DISTANCE, mv, ta);
        trueaimpoint = trace_endpos;
 
+       if(vlen(trueaimpoint - view_origin) < g_trueaim_minrange)
+               trueaimpoint = view_origin + view_forward * g_trueaim_minrange;
+
        if(vecs_x > 0)
                vecs_y = -vecs_y;
        else
@@ -357,6 +360,8 @@ float myhealth_flash;
 
 vector myhealth_gentlergb;
 
+float contentavgalpha;
+
 void CSQC_UpdateView(float w, float h)
 {
        entity e;
@@ -572,7 +577,7 @@ void CSQC_UpdateView(float w, float h)
        // next R_RenderScene call
        drawstring('0 0 0', "", '1 1 0', '1 1 1', 0, 0);
 
-       if(autocvar_r_fakelight >= 2 || autocvar_r_fullbright >= 1)
+       if(autocvar_r_fakelight >= 2 || autocvar_r_fullbright)
        if not(serverflags & SERVERFLAG_ALLOW_FULLBRIGHT)
        {
                // apply night vision effect
@@ -666,8 +671,66 @@ void CSQC_UpdateView(float w, float h)
                        drawpic(reticle_pos, "gfx/reticle_nex", reticle_size, '1 1 1', f * autocvar_cl_reticle_item_nex, DRAWFLAG_NORMAL);
        }
 
-       // improved polyblend
+       // improved polyblend with post processing effects
        vector rgb;
+       vector damage_blurpostprocess;
+       vector content_blurpostprocess;
+       if(autocvar_hud_contents)
+       {
+               float contentalpha_temp, incontent, liquidalpha;
+               vector liquidcolor;
+               
+               switch(pointcontents(view_origin))
+               {
+                       case CONTENT_WATER:
+                               liquidalpha = autocvar_hud_contents_water_alpha;
+                               liquidcolor = stov(autocvar_hud_contents_water_color);
+                               incontent = 1;
+                               break;
+                               
+                       case CONTENT_LAVA:
+                               liquidalpha = autocvar_hud_contents_lava_alpha;
+                               liquidcolor = stov(autocvar_hud_contents_lava_color);
+                               incontent = 1;
+                               break;  
+                                                       
+                       case CONTENT_SLIME:
+                               liquidalpha = autocvar_hud_contents_slime_alpha;
+                               liquidcolor = stov(autocvar_hud_contents_slime_color);
+                               incontent = 1;
+                               break;
+                               
+                       default:
+                               liquidalpha = 0;
+                               liquidcolor = '0 0 0';
+                               incontent = 0;
+                               break;
+               }
+               
+               contentalpha_temp = bound(0, drawframetime / max(0.0001, autocvar_hud_contents_fadetime), 1);
+               contentavgalpha = contentavgalpha * (1 - contentalpha_temp) + incontent * contentalpha_temp;
+               //contentalpha_temp = contentavgalpha;
+               
+               if(incontent)
+                       drawfill('0 0 0', eX * vid_conwidth + eY * vid_conheight, liquidcolor, contentavgalpha * liquidalpha, DRAWFLAG_NORMAL);
+               
+               if(autocvar_hud_postprocessing)
+               {
+                       if(autocvar_hud_contents_blur)
+                       {
+                               content_blurpostprocess_x = 1;
+                               content_blurpostprocess_y = contentavgalpha * autocvar_hud_contents_blur;
+                               content_blurpostprocess_z = contentavgalpha * autocvar_hud_contents_blur_alpha;
+                       }
+                       else
+                       {
+                               content_blurpostprocess_x = 0;
+                               content_blurpostprocess_y = 0;
+                               content_blurpostprocess_z = 0;
+                       }
+               }
+       }
+       
        if(autocvar_hud_damage)
        {
                float myhealth_flash_temp;
@@ -725,9 +788,42 @@ void CSQC_UpdateView(float w, float h)
 
                        drawfill('0 0 0', eX * vid_conwidth + eY * vid_conheight, myhealth_gentlergb, autocvar_hud_damage_gentle_alpha_multiplier * bound(0, myhealth_flash_temp, 1) * autocvar_hud_damage, DRAWFLAG_NORMAL);
                }
-               else
+               else if(autocvar_hud_damage_image)
                        drawpic(reticle_pos, "gfx/blood", reticle_size, stov(autocvar_hud_damage_color), bound(0, myhealth_flash_temp, 1) * autocvar_hud_damage, DRAWFLAG_NORMAL);
+                       
+               if(autocvar_hud_postprocessing)
+               {
+                       if(autocvar_hud_damage_blur)
+                       {
+                               damage_blurpostprocess_x = 1;
+                               damage_blurpostprocess_y = bound(0, myhealth_flash_temp, 1) * autocvar_hud_damage_blur;
+                               damage_blurpostprocess_z = bound(0, myhealth_flash_temp, 1) * autocvar_hud_damage_blur_alpha;
+                       }
+                       else
+                       {
+                               damage_blurpostprocess_x = 0;
+                               damage_blurpostprocess_y = 0;
+                               damage_blurpostprocess_z = 0;
+                       }
+               }
+       }
+       
+       if(autocvar_hud_postprocessing)
+       { // lets apply the postprocess effects from the previous two functions if needed
+               if(damage_blurpostprocess_x || content_blurpostprocess_x)
+               {
+                       float blurradius = bound(0, damage_blurpostprocess_y + content_blurpostprocess_y, autocvar_hud_postprocessing_maxblurradius);
+                       float bluralpha = bound(0, damage_blurpostprocess_z + content_blurpostprocess_z, autocvar_hud_postprocessing_maxbluralpha);
+                       cvar_set("r_glsl_postprocess_uservec1", strcat(ftos(blurradius), " ", ftos(bluralpha), " 0 0"));
+                       cvar_set("r_glsl_postprocess_uservec1_enable", "1");
+               }
+               else
+               {
+                       cvar_set("r_glsl_postprocess_uservec1", "0 0 0 0");
+                       cvar_set("r_glsl_postprocess_uservec1_enable", "0");
+               }
        }
+       
 
        // Draw the mouse cursor
        // NOTE: drawpic must happen after R_RenderScene for some reason