avoid some crashes when recursing BIHs
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 12 Apr 2011 20:05:04 +0000 (20:05 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 12 Apr 2011 20:05:04 +0000 (20:05 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11054 d7cf8633-e32d-0410-b094-e92efae38249

model_brush.c

index 37285c6..1051d28 100644 (file)
@@ -5991,6 +5991,9 @@ void Mod_CollisionBIH_TracePoint(dp_model_t *model, const frameblend_t *frameble
        trace->hitsupercontentsmask = hitsupercontentsmask;
 
        bih = &model->collision_bih;
+       if(!bih->nodes)
+               return;
+
        nodenum = bih->rootnode;
        nodestack[nodestackpos++] = nodenum;
        while (nodestackpos)
@@ -6047,6 +6050,9 @@ void Mod_CollisionBIH_TraceLineShared(dp_model_t *model, const frameblend_t *fra
        vec_t d1, d2, d3, d4, f, nodestackline[1024][6];
        int axis, nodenum, nodestackpos = 0, nodestack[1024];
 
+       if(!bih->nodes)
+               return;
+
        if (VectorCompare(start, end))
        {
                Mod_CollisionBIH_TracePoint(model, frameblend, skeleton, trace, start, hitsupercontentsmask);
@@ -6180,6 +6186,8 @@ void Mod_CollisionBIH_TraceBrush(dp_model_t *model, const frameblend_t *frameble
        }
 
        bih = &model->collision_bih;
+       if(!bih->nodes)
+               return;
        nodenum = bih->rootnode;
 
        // box trace, performed as brush trace