From 0306f2c5b9f372ed309aba3bfa73b752e6178424 Mon Sep 17 00:00:00 2001 From: rambetter Date: Mon, 10 Jan 2011 05:38:30 +0000 Subject: [PATCH] Getting ready to commit Rambetter-math-fix-experiments branch changes to trunk, as pertaining to q3map2. Some last-minute changes: - EXPERIMENTAL_HIGH_PRECISION_MATH_Q3MAP2_FIXES, EXPERIMENTAL_SNAP_NORMAL_FIX, and EXPERIMENTAL_SNAP_PLANE_FIX all set to 0 to make sure stuff in trunk uses old "broken but stable" code, at least initially until there is further testing done and/or some decision is made about which code to use. - Fixing small typo in comment in PlaneEqual() in map.c. - In comment to BaseWindingForPlane() function, describing why the old function is broken as far as accuracy goes. This used to be a TODO. - VectorIsOnAxialPlane() function comment fixed in mathlib.c. git-svn-id: svn://svn.icculus.org/gtkradiant/GtkRadiant/branches/Rambetter-math-fix-experiments@415 8a3a26a2-13c4-0310-b231-cf6edde360e5 --- libs/mathlib/mathlib.c | 2 +- tools/quake3/common/polylib.c | 9 ++++++++- tools/quake3/q3map2/map.c | 2 +- tools/quake3/q3map2/q3map2.h | 6 +++--- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/libs/mathlib/mathlib.c b/libs/mathlib/mathlib.c index 8c9196e..0738c9c 100644 --- a/libs/mathlib/mathlib.c +++ b/libs/mathlib/mathlib.c @@ -55,7 +55,7 @@ qboolean VectorIsOnAxis(vec3_t v) /* ================ -VectorIsOnAxis +VectorIsOnAxialPlane ================ */ qboolean VectorIsOnAxialPlane(vec3_t v) diff --git a/tools/quake3/common/polylib.c b/tools/quake3/common/polylib.c index 4413466..3788f27 100644 --- a/tools/quake3/common/polylib.c +++ b/tools/quake3/common/polylib.c @@ -371,7 +371,14 @@ winding_accu_t *BaseWindingForPlaneAccu(vec3_t normal, vec_t dist) BaseWindingForPlane Original BaseWindingForPlane() function that has serious accuracy problems. Here is why. -TODO: Explain why. +The base winding is computed as a rectangle with very large coordinates. These coordinates +are in the range 2^17 or 2^18. "Epsilon" (meaning the distance between two adjacent numbers) +at these magnitudes in 32 bit floating point world is about 0.02. So for example, if things +go badly (by bad luck), then the whole plane could be shifted by 0.02 units (its distance could +be off by that much). Then if we were to compute the winding of this plane and another of +the brush's planes met this winding at a very acute angle, that error could multiply to around +0.1 or more when computing the final vertex coordinates of the winding. 0.1 is a very large +error, and can lead to all sorts of disappearing triangle problems. ================= */ winding_t *BaseWindingForPlane(vec3_t normal, vec_t dist) diff --git a/tools/quake3/q3map2/map.c b/tools/quake3/q3map2/map.c index 5978b0b..330e2de 100644 --- a/tools/quake3/q3map2/map.c +++ b/tools/quake3/q3map2/map.c @@ -69,7 +69,7 @@ qboolean PlaneEqual( plane_t *p, vec3_t normal, vec_t dist ) de = distanceEpsilon; /* compare */ - // We check equality of each component since the we're using '<', not '<=' + // We check equality of each component since we're using '<', not '<=' // (the epsilons may be zero). We want to use '<' intead of '<=' to be // consistent with the true meaning of "epsilon", and also because other // parts of the code uses this inequality. diff --git a/tools/quake3/q3map2/q3map2.h b/tools/quake3/q3map2/q3map2.h index 654716b..e3de7b7 100644 --- a/tools/quake3/q3map2/q3map2.h +++ b/tools/quake3/q3map2/q3map2.h @@ -123,9 +123,9 @@ constants ------------------------------------------------------------------------------- */ /* temporary hacks and tests (please keep off in SVN to prevent anyone's legacy map from screwing up) */ -#define EXPERIMENTAL_HIGH_PRECISION_MATH_Q3MAP2_FIXES 1 -#define EXPERIMENTAL_SNAP_NORMAL_FIX 1 -#define EXPERIMENTAL_SNAP_PLANE_FIX 1 +#define EXPERIMENTAL_HIGH_PRECISION_MATH_Q3MAP2_FIXES 0 +#define EXPERIMENTAL_SNAP_NORMAL_FIX 0 +#define EXPERIMENTAL_SNAP_PLANE_FIX 0 /* general */ #define MAX_QPATH 64