]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
warpzones: optimize tracing if no warpzones exist (less extra work)
authorRudolf Polzer <divverent@alientrap.org>
Tue, 10 Aug 2010 07:11:27 +0000 (09:11 +0200)
committerRudolf Polzer <divverent@alientrap.org>
Tue, 10 Aug 2010 07:11:27 +0000 (09:11 +0200)
qcsrc/warpzonelib/client.qc
qcsrc/warpzonelib/common.qc
qcsrc/warpzonelib/common.qh
qcsrc/warpzonelib/server.qc

index 1dbe824d6629929a90d053e2d9e8b71abea64160..d084e08084ce854d08b723911a97b63185610937 100644 (file)
@@ -1,5 +1,6 @@
 void WarpZone_Read(float isnew)
 {
+       ++warpzone_warpzones_exist;
        if not(self.enemy)
        {
                self.enemy = spawn();
@@ -46,6 +47,7 @@ void WarpZone_Read(float isnew)
 
 void WarpZone_Camera_Read(float isnew)
 {
+       ++warpzone_cameras_exist;
        self.classname = "func_warpzone_camera";
        self.origin_x = ReadCoord();
        self.origin_y = ReadCoord();
index 2fa8d55e4c101aaeca35e116fbad93b6d4a15852..360652d6f24eafa9b4d2b708f8dcf1543e47cf67 100644 (file)
@@ -174,6 +174,27 @@ void WarpZone_TraceBox_ThroughZone(vector org, vector mi, vector ma, vector end,
        vector o0, e0;
        entity wz;
        vector vf, vr, vu;
+
+       WarpZone_Trace_InitTransform();
+       if(!warpzone_warpzones_exist)
+       {
+               if(nomonsters == MOVE_NOTHING)
+               {
+                       trace_endpos = end;
+                       trace_fraction = 1;
+                       if(cb)
+                               cb(org, trace_endpos, end);
+                       return;
+               }
+               else
+               {
+                       tracebox(org, mi, ma, end, nomonsters, forent);
+                       if(cb)
+                               cb(org, trace_endpos, end);
+                       return;
+               }
+       }
+
        vf = v_forward;
        vr = v_right;
        vu = v_up;
@@ -193,7 +214,6 @@ void WarpZone_TraceBox_ThroughZone(vector org, vector mi, vector ma, vector end,
        if((contentshack = (forent.dphitcontentsmask && !(forent.dphitcontentsmask & DPCONTENTS_SOLID))))
                forent.dphitcontentsmask |= DPCONTENTS_SOLID;
 
-       WarpZone_Trace_InitTransform();
        // if starting in warpzone, first transform
        wz = WarpZone_Find(org + mi, org + ma);
        if(wz)
@@ -283,13 +303,24 @@ void WarpZone_TraceToss_ThroughZone(entity e, entity forent, entity zone, WarpZo
        vector vf, vr, vu, v0, o0;
        entity wz;
 
+       WarpZone_Trace_InitTransform();
+       WarpZone_tracetoss_time = 0;
+       if(!warpzone_warpzones_exist)
+       {
+               tracetoss(e, forent);
+               if(cb)
+                       cb(e.origin, trace_endpos, trace_endpos);
+               dt = vlen(e.origin - o0) / vlen(e.velocity);
+               WarpZone_tracetoss_time += dt;
+               return;
+       }
+
        vf = v_forward;
        vr = v_right;
        vu = v_up;
        o0 = e.origin;
        v0 = e.velocity;
 
-       WarpZone_Trace_InitTransform();
        // if starting in warpzone, first transform
        wz = WarpZone_Find(e.origin + e.mins, e.origin + e.maxs);
        if(wz)
@@ -308,7 +339,6 @@ void WarpZone_TraceToss_ThroughZone(entity e, entity forent, entity zone, WarpZo
        }
        WarpZone_MakeAllSolid();
        g = cvar("sv_gravity") * e.gravity;
-       WarpZone_tracetoss_time = 0;
        i = 16;
        for(;;)
        {
@@ -322,9 +352,9 @@ void WarpZone_TraceToss_ThroughZone(entity e, entity forent, entity zone, WarpZo
                if(cb)
                        cb(e.origin, trace_endpos, trace_endpos);
                e.origin = trace_endpos;
-               e.velocity_z -= WarpZone_tracetoss_time * g;
                dt = vlen(e.origin - o0) / vlen(e.velocity);
                WarpZone_tracetoss_time += dt;
+               e.velocity_z -= WarpZone_tracetoss_time * g;
                if(trace_fraction >= 1)
                        break;
                if(trace_ent.classname != "trigger_warpzone")
index ec2e50d162abdef5c909871c6951282e689589db..8405ce6d3c5febbbd4050c127f3c0a3b62df4b78 100644 (file)
@@ -1,6 +1,9 @@
 // uncomment this if your mod uses the roll angle in fixangle
 // #define KEEP_ROLL
 
+float warpzone_warpzones_exist;
+float warpzone_cameras_exist;
+
 const void func_null(void); // never assign to this one please
 
 .float warpzone_isboxy;
index 33b736e562174b71eaee0fab2de381a0eb523ca8..7c53d6e4aaad911d83e4fba029ad3b527486fa62 100644 (file)
@@ -303,6 +303,7 @@ void WarpZoneCamera_InitStep_FindTarget()
                error("Camera with nonexisting target");
                return;
        }
+       ++warpzone_cameras_exist;
        WarpZone_Camera_SetUp(self, self.enemy.origin, self.enemy.angles);
 }
 
@@ -436,6 +437,7 @@ void WarpZone_InitStep_FinalizeTransform()
                return;
        }
 
+       ++warpzone_warpzones_exist;
        WarpZone_SetUp(self, self.warpzone_origin, self.warpzone_angles, self.enemy.warpzone_origin, self.enemy.warpzone_angles);
        self.touch = WarpZone_Touch;
        self.SendFlags = 0xFFFFFF;