From: havoc Date: Wed, 6 Aug 2003 10:22:10 +0000 (+0000) Subject: optimized polygon collision code a bit (optimized node side comparison) X-Git-Tag: xonotic-v0.1.0preview~6461 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=23f1bc3fdf9819b0a1e92b26820d791c7789014b;p=xonotic%2Fdarkplaces.git optimized polygon collision code a bit (optimized node side comparison) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@3365 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/collision.c b/collision.c index 21249183..7a7045cf 100644 --- a/collision.c +++ b/collision.c @@ -845,25 +845,29 @@ void Collision_RecursiveTraceBrushNode(colbrushbmodelinfo_t *info, mnode_t *node else { // recurse down node sides - int i, bits; - float dist1, dist2; + int i; + float dist; colpointf_t *ps, *pe; - bits = 0; // FIXME? if TraceBrushPolygonTransform were to be made usable, the // node planes would need to be transformed too - dist1 = node->plane->dist - (1.0f / 8.0f); - dist2 = node->plane->dist + (1.0f / 8.0f); + dist = node->plane->dist - (1.0f / 8.0f); for (i = 0, ps = info->thisbrush_start->points, pe = info->thisbrush_end->points;i < info->thisbrush_start->numpoints;i++, ps++, pe++) { - if (!(bits & 1) && (DotProduct(ps->v, node->plane->normal) > dist1 || DotProduct(pe->v, node->plane->normal) > dist1)) - bits |= 1; - if (!(bits & 2) && (DotProduct(ps->v, node->plane->normal) < dist2 || DotProduct(pe->v, node->plane->normal) < dist2)) - bits |= 2; + if (DotProduct(ps->v, node->plane->normal) > dist || DotProduct(pe->v, node->plane->normal) > dist) + { + Collision_RecursiveTraceBrushNode(info, node->children[0]); + break; + } + } + dist = node->plane->dist + (1.0f / 8.0f); + for (i = 0, ps = info->thisbrush_start->points, pe = info->thisbrush_end->points;i < info->thisbrush_start->numpoints;i++, ps++, pe++) + { + if (DotProduct(ps->v, node->plane->normal) < dist || DotProduct(pe->v, node->plane->normal) < dist) + { + Collision_RecursiveTraceBrushNode(info, node->children[1]); + break; + } } - if (bits & 1) - Collision_RecursiveTraceBrushNode(info, node->children[0]); - if (bits & 2) - Collision_RecursiveTraceBrushNode(info, node->children[1]); } }