r5518 - trunk/data/qcsrc/server
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Wed Jan 14 07:18:13 EST 2009
Author: div0
Date: 2009-01-14 07:18:12 -0500 (Wed, 14 Jan 2009)
New Revision: 5518
Modified:
trunk/data/qcsrc/server/g_subs.qc
trunk/data/qcsrc/server/gamecommand.qc
Log:
fixed the bug causing sv_cmd radarmap --trace take so long.
Please also test if shooting through walls with the camping rifle still works fine, as it uses the same code.
Modified: trunk/data/qcsrc/server/g_subs.qc
===================================================================
--- trunk/data/qcsrc/server/g_subs.qc 2009-01-14 11:42:05 UTC (rev 5517)
+++ trunk/data/qcsrc/server/g_subs.qc 2009-01-14 12:18:12 UTC (rev 5518)
@@ -291,7 +291,7 @@
traceline_antilag_force(source, v1, v2, nomonst, forent, lag);
}
-void tracebox_inverted (vector v1, vector mi, vector ma, vector v2, float nomonsters, entity forent)
+float tracebox_inverted (vector v1, vector mi, vector ma, vector v2, float nomonsters, entity forent) // returns the number of traces done, for benchmarking
{
vector pos, dir, t;
float nudge;
@@ -303,34 +303,48 @@
pos = v1 + dir * nudge;
+ float c;
+ c = 0;
+
for(;;)
{
if((pos - v1) * dir >= (v2 - v1) * dir)
{
// went too far
trace_fraction = 1;
- return;
+ return c;
}
tracebox(pos, mi, ma, v2, nomonsters, forent);
+ ++c;
+ if(c >= 50)
+ {
+ // wtf
+ print("When tracing from ", vtos(v1), " to ", vtos(v2), "\n");
+ print("Nudging gets us nowhere at ", vtos(pos), "\n");
+ print("trace_endpos is ", vtos(trace_endpos), "\n");
+ print("trace distance is ", ftos(vlen(pos - trace_endpos)), "\n");
+ }
+
if(trace_startsolid)
{
// we started inside solid.
// then trace from endpos to pos
t = trace_endpos;
tracebox(t, mi, ma, pos, nomonsters, forent);
+ ++c;
if(trace_startsolid)
{
- // t is inside solid? bad
- // force advance, then
- pos = pos + dir * nudge;
+ // t is still inside solid? bad
+ // force advance, then, and retry
+ pos = t + dir * nudge;
}
else
{
// we actually LEFT solid!
trace_fraction = ((trace_endpos - v1) * dir) / ((v2 - v1) * dir);
- return;
+ return c;
}
}
else
@@ -338,7 +352,7 @@
// pos is outside solid?!? but why?!? never mind, just return it.
trace_endpos = pos;
trace_fraction = ((trace_endpos - v1) * dir) / ((v2 - v1) * dir);
- return;
+ return c;
}
}
}
Modified: trunk/data/qcsrc/server/gamecommand.qc
===================================================================
--- trunk/data/qcsrc/server/gamecommand.qc 2009-01-14 11:42:05 UTC (rev 5517)
+++ trunk/data/qcsrc/server/gamecommand.qc 2009-01-14 12:18:12 UTC (rev 5518)
@@ -10,19 +10,30 @@
c = a;
+ //float n, m;
+ //n = m = 0;
+
while(vlen(c - b) > 1)
{
+ //++m;
+
tracebox(c, mi, ma, b, MOVE_WORLDONLY, world);
+ //++n;
+
if(!trace_startsolid)
{
black += vlen(trace_endpos - c);
c = trace_endpos;
}
- tracebox_inverted(c, mi, ma, b, MOVE_WORLDONLY, world);
+
+ //n += tracebox_inverted(c, mi, ma, b, MOVE_WORLDONLY, world);
+
white += vlen(trace_endpos - c);
c = trace_endpos;
}
+ //dprint("FullTraceFraction: ", ftos(n), " total traces, ", ftos(m), " iterations\n");
+
return white / (black + white);
}
More information about the nexuiz-commits
mailing list