mirror of
https://github.com/TTimo/GtkRadiant.git
synced 2024-11-10 07:11:54 +00:00
Working on the SnapPlane() issue.
- Adding EXPERIMENTAL_SNAP_PLANE_FIX #define to q3map2.h, it's now set to 1, but will be set to 0 if and when we merge into trunk. - SnapPlaneImproved() no longer takes the center argument but still fixes the snap distance (only snap when normal is axial). - Adding SnapPlaneImprovedWithCenter() that takes the center argument. Basically renamed SnapPlaneImproved() from previous commit to SnapPlaneImprovedWithCenter(). - Adding EXPERIMENTAL_SNAP_PLANE_FIX code block to FindFloatPlane() that uses the experimental SnapPlane(). This is very much a work in progress, many more things to look at. git-svn-id: svn://svn.icculus.org/gtkradiant/GtkRadiant/branches/Rambetter-math-fix-experiments@401 8a3a26a2-13c4-0310-b231-cf6edde360e5
This commit is contained in:
parent
698b1d6285
commit
dee4545065
2 changed files with 44 additions and 2 deletions
|
@ -293,7 +293,29 @@ void SnapPlane( vec3_t normal, vec_t *dist )
|
|||
SnapPlaneImproved()
|
||||
snaps a plane to normal/distance epsilons, improved code
|
||||
*/
|
||||
void SnapPlaneImproved(vec3_t normal, vec_t *dist, vec3_t center)
|
||||
void SnapPlaneImproved(vec3_t normal, vec_t *dist)
|
||||
{
|
||||
vec_t distNearestInt;
|
||||
|
||||
SnapNormal(normal);
|
||||
|
||||
if (VectorIsOnAxis(normal))
|
||||
{
|
||||
// Only snap distance if the normal is an axis. Otherwise there
|
||||
// is nothing "natural" about snapping the distance to an integer.
|
||||
distNearestInt = Q_rint(*dist);
|
||||
if (-distanceEpsilon < *dist - distNearestInt && *dist - distNearestInt < distanceEpsilon)
|
||||
{
|
||||
*dist = distNearestInt;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
SnapPlaneImprovedWithCenter()
|
||||
snaps a plane to normal/distance epsilons, improved code uses center
|
||||
*/
|
||||
void SnapPlaneImprovedWithCenter(vec3_t normal, vec_t *dist, const vec3_t center)
|
||||
{
|
||||
vec_t distNearestInt;
|
||||
|
||||
|
@ -331,8 +353,27 @@ int FindFloatPlane( vec3_t normal, vec_t dist, int numPoints, vec3_t *points )
|
|||
vec_t d;
|
||||
|
||||
|
||||
/* hash the plane */
|
||||
#if EXPERIMENTAL_SNAP_PLANE_FIX
|
||||
vec3_t center;
|
||||
|
||||
if (numPoints > 0)
|
||||
{
|
||||
VectorClear(center);
|
||||
for (i = 0; i < numPoints; i++)
|
||||
{
|
||||
VectorAdd(center, points[i], center);
|
||||
}
|
||||
for (j = 0; j < 3; j++) { center[j] = center[j] / numPoints; }
|
||||
SnapPlaneImprovedWithCenter(normal, &dist, center);
|
||||
}
|
||||
else
|
||||
{
|
||||
SnapPlaneImproved(normal, &dist);
|
||||
}
|
||||
#else
|
||||
SnapPlane( normal, &dist );
|
||||
#endif
|
||||
/* hash the plane */
|
||||
hash = (PLANE_HASHES - 1) & (int) fabs( dist );
|
||||
|
||||
/* search the border bins as well */
|
||||
|
|
|
@ -125,6 +125,7 @@ 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
|
||||
|
||||
/* general */
|
||||
#define MAX_QPATH 64
|
||||
|
|
Loading…
Reference in a new issue