]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Don't draw distant spawn points, improves FPS on larger maps
authorMario <mario@smbclan.net>
Thu, 3 Mar 2016 11:40:03 +0000 (21:40 +1000)
committerMario <mario@smbclan.net>
Thu, 3 Mar 2016 11:40:03 +0000 (21:40 +1000)
qcsrc/client/autocvars.qh
qcsrc/client/main.qc

index 49cafb896a18fcc122d751fdcda6180c657ff802..cbee59e90ef076e1af9430aae53677f51a5c31b1 100644 (file)
@@ -72,6 +72,8 @@ bool autocvar_cl_spawn_event_particles;
 bool autocvar_cl_spawn_event_sound = 1;
 // float autocvar_cl_spawn_point_model;
 bool autocvar_cl_spawn_point_particles;
+float autocvar_cl_spawn_point_dist_min = 1200;
+float autocvar_cl_spawn_point_dist_max = 1600;
 bool autocvar_cl_spawnzoom = 1;
 float autocvar_cl_spawnzoom_speed = 1;
 float autocvar_cl_spawnzoom_factor = 2;
index 14279816efdee0f62642a3cfe2fb0fb370fad76b..5984aba93348f88c0423cff796d4bc0dd5b7f0ef 100644 (file)
@@ -676,6 +676,22 @@ void Spawn_Draw(entity this)
        __pointparticles(this.cnt, this.origin + '0 0 28', '0 0 2', bound(0, frametime, 0.1));
 }
 
+void Spawn_PreDraw(entity this)
+{
+       float alph;
+       vector org = getpropertyvec(VF_ORIGIN);
+       if(this.fade_start)
+               alph = bound(0, (this.fade_end - vlen(org - this.origin - 0.5 * (this.mins + this.maxs))) / (this.fade_end - this.fade_start), 1);
+       else
+               alph = 1;
+       //printf("%v <-> %v\n", view_origin, this.origin + 0.5 * (this.mins + this.maxs));
+       this.alpha = alph;
+       if(alph <= 0)
+               this.drawmask = 0;
+       else
+               this.drawmask = MASK_NORMAL;
+}
+
 NET_HANDLE(ENT_CLIENT_SPAWNPOINT, bool is_new)
 {
        float teamnum = (ReadByte() - 1);
@@ -716,6 +732,9 @@ NET_HANDLE(ENT_CLIENT_SPAWNPOINT, bool is_new)
                        else { this.cnt = particleeffectnum(EFFECT_SPAWNPOINT_NEUTRAL); }
 
                        this.draw = Spawn_Draw;
+                       setpredraw(this, Spawn_PreDraw);
+                       this.fade_start = autocvar_cl_spawn_point_dist_min;
+                       this.fade_end = autocvar_cl_spawn_point_dist_max;
                }
        //}