]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - world.c
slight simplification/optimzation/readability enhancement/whatever to animating textures
[xonotic/darkplaces.git] / world.c
diff --git a/world.c b/world.c
index f4e2436c8fa88b0687496d0e46fff7ce5893000e..5f2e20fddf3f3c615d73695c8717a63de2dc6983 100644 (file)
--- a/world.c
+++ b/world.c
@@ -29,12 +29,12 @@ line of sight checks trace->crosscontent, but bullets don't
 
 */
 
-/*
-typedef struct link_s
+cvar_t sv_useareanodes = {CVAR_NOTIFY, "sv_useareanodes", "1"};
+
+void SV_World_Init(void)
 {
-       struct link_s   *prev, *next;
-} link_t;
-*/
+       Cvar_RegisterVariable(&sv_useareanodes);
+}
 
 
 void ClearLink (link_t *l);
@@ -42,11 +42,6 @@ void RemoveLink (link_t *l);
 void InsertLinkBefore (link_t *l, link_t *before);
 void InsertLinkAfter (link_t *l, link_t *after);
 
-// (type *)STRUCT_FROM_LINK(link_t *link, type, member)
-// ent = STRUCT_FROM_LINK(link,entity_t,order)
-// FIXME: remove this mess!
-//#define      STRUCT_FROM_LINK(l,t,m) ((t *)((qbyte *)l - (int)&(((t *)0)->m)))
-
 #define        EDICT_FROM_AREA(l) ((edict_t *)((qbyte *)l - (int)&(((edict_t *)0)->area)))
 
 //============================================================================
@@ -252,9 +247,6 @@ loc0:
        if (node->axis == -1)
                return;
 
-       // LordHavoc: optimized recursion
-//     if (ent->v.absmax[node->axis] > node->dist) SV_TouchLinks (ent, node->children[0]);
-//     if (ent->v.absmin[node->axis] < node->dist) SV_TouchLinks (ent, node->children[1]);
        if (ent->v.absmax[node->axis] > node->dist)
        {
                if (ent->v.absmin[node->axis] < node->dist)
@@ -295,46 +287,6 @@ void SV_LinkEdict (edict_t *ent, qboolean touch_triggers)
 
 // set the abs box
 
-       /*
-// LordHavoc: enabling rotating bmodels
-       if (ent->v.solid == SOLID_BSP && (ent->v.angles[0] || ent->v.angles[1] || ent->v.angles[2]))
-       {
-               // expand for rotation
-               float           max, v;
-               int                     i;
-
-               max = DotProduct(ent->v.mins, ent->v.mins);
-               v = DotProduct(ent->v.maxs, ent->v.maxs);
-               if (max < v)
-                       max = v;
-               max = sqrt(max);
-       */
-               /*
-               max = 0;
-               for (i=0 ; i<3 ; i++)
-               {
-                       v = fabs(ent->v.mins[i]);
-                       if (max < v)
-                               max = v;
-                       v = fabs(ent->v.maxs[i]);
-                       if (max < v)
-                               max = v;
-               }
-               */
-       /*
-               for (i=0 ; i<3 ; i++)
-               {
-                       ent->v.absmin[i] = ent->v.origin[i] - max;
-                       ent->v.absmax[i] = ent->v.origin[i] + max;
-               }
-       }
-       else
-       {
-               VectorAdd (ent->v.origin, ent->v.mins, ent->v.absmin);
-               VectorAdd (ent->v.origin, ent->v.maxs, ent->v.absmax);
-       }
-       */
-
        if (ent->v.solid == SOLID_BSP)
        {
                if (ent->v.modelindex < 0 || ent->v.modelindex > MAX_MODELS)
@@ -438,20 +390,6 @@ POINT TESTING IN HULLS
 ===============================================================================
 */
 
-/*
-==================
-SV_HullPointContents
-
-==================
-*/
-int SV_HullPointContents (hull_t *hull, int num, vec3_t p)
-{
-       while (num >= 0)
-               num = hull->clipnodes[num].children[(hull->planes[hull->clipnodes[num].planenum].type < 3 ? p[hull->planes[hull->clipnodes[num].planenum].type] : DotProduct (hull->planes[hull->clipnodes[num].planenum].normal, p)) < hull->planes[hull->clipnodes[num].planenum].dist];
-
-       return num;
-}
-
 /*
 ============
 SV_TestEntityPosition
@@ -459,16 +397,9 @@ SV_TestEntityPosition
 This could be a lot more efficient...
 ============
 */
-edict_t        *SV_TestEntityPosition (edict_t *ent)
+int SV_TestEntityPosition (edict_t *ent)
 {
-       trace_t trace;
-
-       trace = SV_Move (ent->v.origin, ent->v.mins, ent->v.maxs, ent->v.origin, MOVE_NORMAL, ent);
-
-       if (trace.startsolid)
-               return sv.edicts;
-
-       return NULL;
+       return SV_Move (ent->v.origin, ent->v.mins, ent->v.maxs, ent->v.origin, MOVE_NORMAL, ent).startsolid;
 }
 
 
@@ -576,10 +507,10 @@ loc0:
                }
 
                // might interact, so do an exact clip
-               if ((int)touch->v.flags & FL_MONSTER)
-                       trace = SV_ClipMoveToEntity (touch, clip->start, clip->mins2, clip->maxs2, clip->end);
-               else if (touch->v.solid == SOLID_BSP)
+               if (touch->v.solid == SOLID_BSP)
                        trace = SV_ClipMoveToEntity (touch, clip->start, clip->hullmins, clip->hullmaxs, clip->end);
+               else if ((int)touch->v.flags & FL_MONSTER)
+                       trace = SV_ClipMoveToEntity (touch, clip->start, clip->mins2, clip->maxs2, clip->end);
                else
                        trace = SV_ClipMoveToEntity (touch, clip->start, clip->mins, clip->maxs, clip->end);
                // LordHavoc: take the 'best' answers from the new trace and combine with existing data
@@ -609,9 +540,6 @@ loc0:
        if (node->axis == -1)
                return;
 
-       // LordHavoc: optimized recursion
-//     if (clip->boxmaxs[node->axis] > node->dist) SV_ClipToLinks(node->children[0], clip);
-//     if (clip->boxmins[node->axis] < node->dist) SV_ClipToLinks(node->children[1], clip);
        if (clip->boxmaxs[node->axis] > node->dist)
        {
                if (clip->boxmins[node->axis] < node->dist)
@@ -634,27 +562,30 @@ SV_MoveBounds
 */
 void SV_MoveBounds (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, vec3_t boxmins, vec3_t boxmaxs)
 {
-#if 0
-// debug to test against everything
-boxmins[0] = boxmins[1] = boxmins[2] = -999999999;
-boxmaxs[0] = boxmaxs[1] = boxmaxs[2] =  999999999;
-#else
-       int             i;
-
-       for (i=0 ; i<3 ; i++)
+       if (sv_useareanodes.integer)
        {
-               if (end[i] > start[i])
-               {
-                       boxmins[i] = start[i] + mins[i] - 1;
-                       boxmaxs[i] = end[i] + maxs[i] + 1;
-               }
-               else
+               int i;
+
+               for (i=0 ; i<3 ; i++)
                {
-                       boxmins[i] = end[i] + mins[i] - 1;
-                       boxmaxs[i] = start[i] + maxs[i] + 1;
+                       if (end[i] > start[i])
+                       {
+                               boxmins[i] = start[i] + mins[i] - 1;
+                               boxmaxs[i] = end[i] + maxs[i] + 1;
+                       }
+                       else
+                       {
+                               boxmins[i] = end[i] + mins[i] - 1;
+                               boxmaxs[i] = start[i] + maxs[i] + 1;
+                       }
                }
        }
-#endif
+       else
+       {
+               // debug to test against everything
+               boxmins[0] = boxmins[1] = boxmins[2] = -999999999;
+               boxmaxs[0] = boxmaxs[1] = boxmaxs[2] =  999999999;
+       }
 }
 
 /*
@@ -712,3 +643,4 @@ trace_t SV_Move (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int type, e
 
        return clip.trace;
 }
+