[ODE] diffs, box-sphere collider changes
Russ Smith
russ at q12.org
Tue Jul 15 20:02:02 2003
> This one's because I thought it was a bug in box-sphere collider (I've
> reported it to this list, but it didn't gain much interest :)).
> According to comments, the routine should push the sphere to the
> closest box edge. Now, I'm either missing something, or it's pushing
> the sphere to the farthest box edge (finds largest 't', not smallest
> one). Hence this change.
yes, it is a bug! sorry i did not notice your mail before. thankfully
the bug only occurs in the rare deep-penetration case. however, your fix
does not really improve the situation. i've made the correct fix (i
think) and checked it in to CVS - patch below.
russ.
===================================================================
RCS file: /cvsroot/opende/ode/ode/src/collision_std.cpp,v
retrieving revision 1.8
diff -r1.8 collision_std.cpp
1067c1067
< // normal to push the sphere to the closest box edge.
---
> // normal to push the sphere to the closest box face.
1102,1104c1102,1104
< // sphere center inside box. find largest `t' value
< dReal max = dFabs(t[0]);
< int maxi = 0;
---
> // sphere center inside box. find closest face to `t'
> dReal min_distance = l[0] - dFabs(t[0]);
> int mini = 0;
1106,1109c1106,1109
< dReal tt = dFabs(t[i]);
< if (tt > max) {
< max = tt;
< maxi = i;
---
> dReal face_distance = l[i] - dFabs(t[i]);
> if (face_distance < min_distance) {
> min_distance = face_distance;
> mini = i;
1116c1116
< // contact normal aligned with box edge along largest `t' value
---
> // contact normal points to closest face
1121c1121
< tmp[maxi] = (t[maxi] > 0) ? REAL(1.0) : REAL(-1.0);
---
> tmp[mini] = (t[mini] > 0) ? REAL(1.0) : REAL(-1.0);
1124c1124
< contact->depth = l[maxi] - max + sphere->radius;
---
> contact->depth = min_distance + sphere->radius;
--
Russell Smith
http://www.q12.org