]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
significant speed gain on collision_cache 1 by tweaking some numbers
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 12 Mar 2011 10:56:44 +0000 (10:56 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 12 Mar 2011 10:56:44 +0000 (10:56 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10910 d7cf8633-e32d-0410-b094-e92efae38249

collision.c
todo

index fbc8a1cbbe5ba99999de5c5ed7994cb21e8c0805..3438913656ec5581b752f63adcc22151f5c63510 100644 (file)
@@ -1693,6 +1693,7 @@ static int collision_cachedtrace_firstfree;
 static int collision_cachedtrace_lastused;
 static int collision_cachedtrace_max;
 static int collision_cachedtrace_sequence;
+static int collision_cachedtrace_hashsize;
 static int *collision_cachedtrace_hash;
 
 void Collision_Cache_Reset(qboolean resetlimits)
@@ -1705,8 +1706,9 @@ void Collision_Cache_Reset(qboolean resetlimits)
                collision_cachedtrace_max = 1024;
        collision_cachedtrace_firstfree = 1;
        collision_cachedtrace_lastused = 0;
+       collision_cachedtrace_hashsize = collision_cachedtrace_max * 2;
        collision_cachedtrace_array = (collision_cachedtrace_t *)Mem_Alloc(collision_cachedtrace_mempool, collision_cachedtrace_max * sizeof(collision_cachedtrace_t));
-       collision_cachedtrace_hash = (int *)Mem_Alloc(collision_cachedtrace_mempool, collision_cachedtrace_max * sizeof(int));
+       collision_cachedtrace_hash = (int *)Mem_Alloc(collision_cachedtrace_mempool, collision_cachedtrace_hashsize * sizeof(int));
        collision_cachedtrace_sequence = 1;
 }
 
@@ -1722,7 +1724,7 @@ void Collision_Cache_NewFrame(void)
        int index;
        int *p;
        // unlink all stale traces
-       for (hashindex = 0;hashindex < collision_cachedtrace_max;hashindex++)
+       for (hashindex = 0;hashindex < collision_cachedtrace_hashsize;hashindex++)
        {
                if (!collision_cachedtrace_hash[hashindex])
                        continue;
@@ -1766,18 +1768,18 @@ static collision_cachedtrace_t *Collision_Cache_Lookup(dp_model_t *model, const
        else
        {
                // cached trace lookup
-               hashindex = (int)(((size_t)model + (size_t) + (size_t)(VectorLength2(bodymins) + VectorLength2(bodymaxs) + start[0] + start[1] + start[2] + end[0] + end[1] + end[2]) + bodysupercontents + hitsupercontentsmask) % collision_cachedtrace_max);
+               hashindex = (int)(((size_t)model + (size_t) + (size_t)(start[0] * 53 + start[1] * 207 + start[2] * 97 + end[0] * 37 + end[1] * 743 + end[2] * 13) + bodysupercontents + hitsupercontentsmask) % collision_cachedtrace_hashsize);
                for (index = collision_cachedtrace_hash[hashindex];index;index = cached->next)
                {
                        cached = collision_cachedtrace_array + index;
-                       if (cached->model == model
+                       if (VectorCompare(cached->start, start)
+                        && VectorCompare(cached->end, end)
+                        && cached->model == model
                         && VectorCompare(cached->bodymins, bodymins)
                         && VectorCompare(cached->bodymaxs, bodymaxs)
                         && cached->bodysupercontents == bodysupercontents
-                        && VectorCompare(cached->start, start)
                         && VectorCompare(cached->mins, mins)
                         && VectorCompare(cached->maxs, maxs)
-                        && VectorCompare(cached->end, end)
                         && cached->hitsupercontentsmask == hitsupercontentsmask
                         && !memcmp(&cached->matrix, matrix, sizeof(*matrix)))
                        {
diff --git a/todo b/todo
index c979074102f2254aa78cfecf74d4ea5bd0b67b97..0306ca48c92db8fe8a9a7d4b36e997220bbb110a 100644 (file)
--- a/todo
+++ b/todo
@@ -27,6 +27,7 @@
 0 bug darkplaces d3d9: alphatest not working (VorteX)
 0 bug darkplaces d3d9: gamma not working (VorteX)
 0 bug darkplaces d3d9: shadowmaps are clipped - does this mean r_shadows 2 or light shadowmaps? (VorteX)
+0 bug darkplaces d3d9: water/refraction/reflection/warp render scissor is wrong (SavageX)
 0 bug darkplaces effects: add a cvar to disable colored dlights (leileilol)
 0 bug darkplaces effects: dlights don't look anything like quake ones, bring back lightmap dlights as a cvar - with both classic and old dp falloff modes (leileilol)
 0 bug darkplaces effects: quake mode blood trails don't have the appropriate slight gravity - there may be other effects missing this also (leileilol)