From: Rudolf Polzer Date: Wed, 1 Sep 2010 05:14:16 +0000 (+0200) Subject: favor blocky triangles over thin triangles a bit X-Git-Tag: xonotic-v0.5.0~228 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=76e61abc0193149b099d6c512bdccd9e48d7a74a;p=xonotic%2Fnetradiant.git favor blocky triangles over thin triangles a bit --- diff --git a/tools/quake3/q3map2/surface_meta.c b/tools/quake3/q3map2/surface_meta.c index 12f3d467..f61c6b73 100644 --- a/tools/quake3/q3map2/surface_meta.c +++ b/tools/quake3/q3map2/surface_meta.c @@ -417,9 +417,9 @@ void TriangulatePatchSurface( entity_t *e , mapDrawSurface_t *ds ) int MaxAreaIndexes(bspDrawVert_t *vert, int cnt, int *indexes) { int r, s, t, bestR = 0, bestS = 1, bestT = 2; - int i, j, k; - double A, bestA = -1; - vec3_t ab, ac, cross; + int i, j; + double A, bestA = -1, V, bestV = -1; + vec3_t ab, ac, bc, cross; bspDrawVert_t *buf; if(cnt < 3) @@ -432,11 +432,18 @@ int MaxAreaIndexes(bspDrawVert_t *vert, int cnt, int *indexes) { VectorSubtract(vert[s].xyz, vert[r].xyz, ab); VectorSubtract(vert[t].xyz, vert[r].xyz, ac); + VectorSubtract(vert[t].xyz, vert[s].xyz, bc); CrossProduct(ab, ac, cross); A = VectorLength(cross); - if(A > bestA) + + V = A - (VectorLength(ab) - VectorLength(ac) - VectorLength(bc)) * 0.2; + /* value = A - circumference * 0.2, i.e. we back out by 0.2 units from each side, to prevent too acute triangles */ + /* this kind of simulates "number of 0.2x0.2 fragments in the triangle not touched by an edge" */ + + if(bestA < 0 || V > bestV) { bestA = A; + bestV = V; bestR = r; bestS = s; bestT = t;