mirror of
https://github.com/UberGames/GtkRadiant.git
synced 2025-02-23 20:31:33 +00:00
Fixing SnapWeldVectorAccu(). By the way, the original SnapWeldVector() appears
to be significantly broken, but I don't think it should be fixed at this point. I'm beginning to think that FixWinding() should not be called during the chop winding procedure. git-svn-id: svn://svn.icculus.org/gtkradiant/GtkRadiant/branches/Rambetter-math-fix-experiments@407 8a3a26a2-13c4-0310-b231-cf6edde360e5
This commit is contained in:
parent
3a15b2a305
commit
3da906441c
1 changed files with 22 additions and 15 deletions
|
@ -277,15 +277,18 @@ void SnapWeldVector( vec3_t a, vec3_t b, vec3_t out )
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
SnapWeldVectorAccu()
|
||||
welds two vec3_accu_t's into a third, taking into account nearest-to-integer
|
||||
instead of averaging
|
||||
*/
|
||||
void SnapWeldVectorAccu(vec3_accu_t a, vec3_accu_t b, vec3_accu_t out)
|
||||
{
|
||||
// I have very serious concerns about this function.
|
||||
// This is a first pass where I just copy the original SnapWeldVector()
|
||||
// and make sure it works with the higher resolution data types.
|
||||
// TODO: Examine this function with a fine-toothed comb.
|
||||
|
||||
// I'm just preserving what I think was the intended logic of the original
|
||||
// SnapWeldVector(). I'm not actually sure where this function should even
|
||||
// be used.
|
||||
int i;
|
||||
vec_accu_t ai, bi, outi;
|
||||
vec_accu_t ai, bi, ad, bd;
|
||||
|
||||
if (a == NULL || b == NULL || out == NULL)
|
||||
Error("SnapWeldVectorAccu: NULL argument");
|
||||
|
@ -293,16 +296,20 @@ void SnapWeldVectorAccu(vec3_accu_t a, vec3_accu_t b, vec3_accu_t out)
|
|||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
ai = Q_rintAccu(a[i]);
|
||||
bi = Q_rintAccu(a[i]); // Note, it's using a[i]. This is from legacy code.
|
||||
bi = Q_rintAccu(b[i]);
|
||||
ad = fabs(ai - a[i]);
|
||||
bd = fabs(bi - b[i]);
|
||||
|
||||
if (ai == a[i]) out[i] = a[i];
|
||||
else if (bi == b[i]) out[i] = b[i];
|
||||
|
||||
else if (fabs(ai - a[i]) < fabs(bi < b[i])) out[i] = a[i];
|
||||
if (ad < bd)
|
||||
{
|
||||
if (ad < SNAP_EPSILON) out[i] = ai;
|
||||
else out[i] = a[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bd < SNAP_EPSILON) out[i] = bi;
|
||||
else out[i] = b[i];
|
||||
|
||||
outi = Q_rintAccu(out[i]);
|
||||
if (fabs(outi - out[i]) <= SNAP_EPSILON) out[i] = outi;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue