From: divverent Date: Fri, 15 Jun 2012 08:08:38 +0000 (+0000) Subject: rename a macro with misleading name, as TriangleOverlapsBox doesn't check for actual... X-Git-Tag: xonotic-v0.7.0~125 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=1a05365812a8245cab7ef4778253ededa7dbfbb8;p=xonotic%2Fdarkplaces.git rename a macro with misleading name, as TriangleOverlapsBox doesn't check for actual triangle/box overlap, but just whether an overlap is possible at all using a bbox check. No functional changes, just search/replace. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11829 d7cf8633-e32d-0410-b094-e92efae38249 ::stable-branch::merge=0b2c6dc3a54096a71cc68961e27a486862408b06 --- diff --git a/collision.c b/collision.c index b20e0c34..af0758f5 100644 --- a/collision.c +++ b/collision.c @@ -1036,7 +1036,7 @@ void Collision_TraceBrushTriangleMeshFloat(trace_t *trace, const colbrushf_t *th { for (i = 0;i < numtriangles;i++, element3i += 3) { - if (TriangleOverlapsBox(vertex3f + element3i[0]*3, vertex3f + element3i[1]*3, vertex3f + element3i[2]*3, segmentmins, segmentmaxs)) + if (TriangleBBoxOverlapsBox(vertex3f + element3i[0]*3, vertex3f + element3i[1]*3, vertex3f + element3i[2]*3, segmentmins, segmentmaxs)) { VectorCopy(vertex3f + element3i[0] * 3, points[0].v); VectorCopy(vertex3f + element3i[1] * 3, points[1].v); diff --git a/gl_rsurf.c b/gl_rsurf.c index 611320b5..1075039c 100644 --- a/gl_rsurf.c +++ b/gl_rsurf.c @@ -894,7 +894,7 @@ static void R_Q1BSP_RecursiveGetLightInfo_BSP(r_q1bsp_getlightinfo_t *info, qboo VectorCopy(v[0], v2[0]); VectorCopy(v[1], v2[1]); VectorCopy(v[2], v2[2]); - if (insidebox || TriangleOverlapsBox(v2[0], v2[1], v2[2], info->lightmins, info->lightmaxs)) + if (insidebox || TriangleBBoxOverlapsBox(v2[0], v2[1], v2[2], info->lightmins, info->lightmaxs)) SVBSP_AddPolygon(&r_svbsp, 3, v2[0], true, NULL, NULL, 0); } } @@ -922,7 +922,7 @@ static void R_Q1BSP_RecursiveGetLightInfo_BSP(r_q1bsp_getlightinfo_t *info, qboo VectorCopy(v[0], v2[0]); VectorCopy(v[1], v2[1]); VectorCopy(v[2], v2[2]); - if (!insidebox && !TriangleOverlapsBox(v2[0], v2[1], v2[2], info->lightmins, info->lightmaxs)) + if (!insidebox && !TriangleBBoxOverlapsBox(v2[0], v2[1], v2[2], info->lightmins, info->lightmaxs)) continue; if (svbspactive && !(SVBSP_AddPolygon(&r_svbsp, 3, v2[0], false, NULL, NULL, 0) & 2)) continue; diff --git a/mathlib.h b/mathlib.h index 3e7fa4c8..9a9cd732 100644 --- a/mathlib.h +++ b/mathlib.h @@ -135,7 +135,7 @@ unsigned int CeilPowerOf2(unsigned int value); #define VectorReflect(a,r,b,c) do{double d;d = DotProduct((a), (b)) * -(1.0 + (r));VectorMA((a), (d), (b), (c));}while(0) #define BoxesOverlap(a,b,c,d) ((a)[0] <= (d)[0] && (b)[0] >= (c)[0] && (a)[1] <= (d)[1] && (b)[1] >= (c)[1] && (a)[2] <= (d)[2] && (b)[2] >= (c)[2]) #define BoxInsideBox(a,b,c,d) ((a)[0] >= (c)[0] && (b)[0] <= (d)[0] && (a)[1] >= (c)[1] && (b)[1] <= (d)[1] && (a)[2] >= (c)[2] && (b)[2] <= (d)[2]) -#define TriangleOverlapsBox(a,b,c,d,e) (min((a)[0], min((b)[0], (c)[0])) < (e)[0] && max((a)[0], max((b)[0], (c)[0])) > (d)[0] && min((a)[1], min((b)[1], (c)[1])) < (e)[1] && max((a)[1], max((b)[1], (c)[1])) > (d)[1] && min((a)[2], min((b)[2], (c)[2])) < (e)[2] && max((a)[2], max((b)[2], (c)[2])) > (d)[2]) +#define TriangleBBoxOverlapsBox(a,b,c,d,e) (min((a)[0], min((b)[0], (c)[0])) < (e)[0] && max((a)[0], max((b)[0], (c)[0])) > (d)[0] && min((a)[1], min((b)[1], (c)[1])) < (e)[1] && max((a)[1], max((b)[1], (c)[1])) > (d)[1] && min((a)[2], min((b)[2], (c)[2])) < (e)[2] && max((a)[2], max((b)[2], (c)[2])) > (d)[2]) #define TriangleNormal(a,b,c,n) ( \ (n)[0] = ((a)[1] - (b)[1]) * ((c)[2] - (b)[2]) - ((a)[2] - (b)[2]) * ((c)[1] - (b)[1]), \ diff --git a/portals.c b/portals.c index 0900a34f..2872a8ca 100644 --- a/portals.c +++ b/portals.c @@ -339,7 +339,7 @@ static void Portal_RecursiveFlow (portalrecursioninfo_t *info, mleaf_t *leaf, in VectorCopy(vertex3f + elements[1] * 3, v + 3); VectorCopy(vertex3f + elements[2] * 3, v + 6); if (PointInfrontOfTriangle(info->eye, v + 0, v + 3, v + 6) - && (insidebox || TriangleOverlapsBox(v, v + 3, v + 6, info->boxmins, info->boxmaxs)) + && (insidebox || TriangleBBoxOverlapsBox(v, v + 3, v + 6, info->boxmins, info->boxmaxs)) && (!info->exact || Portal_PortalThroughPortalPlanes(&portalplanes[firstclipplane], numclipplanes, v, 3, &portaltemppoints2[0][0], 256) > 0)) { addedtris = true; diff --git a/r_shadow.c b/r_shadow.c index 49a7435c..9f7b0b74 100644 --- a/r_shadow.c +++ b/r_shadow.c @@ -1300,7 +1300,7 @@ void R_Shadow_MarkVolumeFromBox(int firsttriangle, int numtris, const float *inv v[2] = invertex3f + e[2] * 3; TriangleNormal(v[0], v[1], v[2], normal); if (r_shadow_frontsidecasting.integer == (DotProduct(normal, projectdirection) < 0) - && TriangleOverlapsBox(v[0], v[1], v[2], lightmins, lightmaxs)) + && TriangleBBoxOverlapsBox(v[0], v[1], v[2], lightmins, lightmaxs)) shadowmarklist[numshadowmark++] = t; } } @@ -1312,7 +1312,7 @@ void R_Shadow_MarkVolumeFromBox(int firsttriangle, int numtris, const float *inv v[1] = invertex3f + e[1] * 3; v[2] = invertex3f + e[2] * 3; if (r_shadow_frontsidecasting.integer == PointInfrontOfTriangle(projectorigin, v[0], v[1], v[2]) - && TriangleOverlapsBox(v[0], v[1], v[2], lightmins, lightmaxs)) + && TriangleBBoxOverlapsBox(v[0], v[1], v[2], lightmins, lightmaxs)) shadowmarklist[numshadowmark++] = t; } } @@ -1684,7 +1684,7 @@ int R_Shadow_ChooseSidesFromBox(int firsttriangle, int numtris, const float *inv v[0] = invertex3f + e[0] * 3, v[1] = invertex3f + e[1] * 3, v[2] = invertex3f + e[2] * 3; TriangleNormal(v[0], v[1], v[2], normal); if (r_shadow_frontsidecasting.integer == (DotProduct(normal, projectdirection) < 0) - && TriangleOverlapsBox(v[0], v[1], v[2], lightmins, lightmaxs)) + && TriangleBBoxOverlapsBox(v[0], v[1], v[2], lightmins, lightmaxs)) { Matrix4x4_Transform(worldtolight, v[0], p[0]), Matrix4x4_Transform(worldtolight, v[1], p[1]), Matrix4x4_Transform(worldtolight, v[2], p[2]); mask = R_Shadow_CalcTriangleSideMask(p[0], p[1], p[2], bias); @@ -1704,7 +1704,7 @@ int R_Shadow_ChooseSidesFromBox(int firsttriangle, int numtris, const float *inv { v[0] = invertex3f + e[0] * 3, v[1] = invertex3f + e[1] * 3, v[2] = invertex3f + e[2] * 3; if (r_shadow_frontsidecasting.integer == PointInfrontOfTriangle(projectorigin, v[0], v[1], v[2]) - && TriangleOverlapsBox(v[0], v[1], v[2], lightmins, lightmaxs)) + && TriangleBBoxOverlapsBox(v[0], v[1], v[2], lightmins, lightmaxs)) { Matrix4x4_Transform(worldtolight, v[0], p[0]), Matrix4x4_Transform(worldtolight, v[1], p[1]), Matrix4x4_Transform(worldtolight, v[2], p[2]); mask = R_Shadow_CalcTriangleSideMask(p[0], p[1], p[2], bias);