Ok there was a bog in the ray cast, but it was not a raycast failure, it was that ray castion was reportion the wrong collision ID whne ray cation a shape.
This si the ray cat rotine for cation and collision Box in local space
- Code: Select all
dgFloat32 dgCollisionBox::RayCast (
const dgVector& localP0,
const dgVector& localP1,
dgContactPoint& contactOut,
OnRayPrecastAction preFilter,
const dgBody* body,
void* userData) const
{
if (PREFILTER_RAYCAST (preFilter, body, this, userData)) {
return dgFloat32 (1.2f);
}
dgInt32 index = 0;
dgFloat32 signDir = dgFloat32 (0.0f);
dgFloat32 tmin = dgFloat32 (0.0f);
dgFloat32 tmax = dgFloat32 (1.0f);
for (dgInt32 i = 0; i < 3; i++) {
dgFloat32 dp = localP1[i] - localP0[i];
if (dgAbsf (dp) < dgFloat32 (1.0e-8f)) {
if (localP0[i] <= m_size[1][i] || localP0[i] >= m_size[0][i]) {
return dgFloat32 (1.2f);
}
} else {
dp = dgFloat32 (1.0f) / dp;
dgFloat32 t1 = (m_size[1][i] - localP0[i]) * dp;
dgFloat32 t2 = (m_size[0][i] - localP0[i]) * dp;
dgFloat32 sign = dgFloat32 (-1.0f);
if (t1 > t2) {
sign = 1;
Swap(t1, t2);
}
if (t1 > tmin) {
signDir = sign;
index = i;
tmin = t1;
}
if (t2 < tmax) {
tmax = t2;
}
if (tmin > tmax) {
return dgFloat32 (1.2f);
}
}
}
if (tmin >= dgFloat32 (0.0f)) {
_ASSERTE (tmin < 1.0f);
contactOut.m_normal = dgVector (dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f), dgFloat32 (0.0f));
contactOut.m_normal[index] = signDir;
//contactOut.m_userId = SetUserData(); // Julio thsi was the Bug wrong collision ID report to callback
contactOut.m_userId = SetUserDataID();
} else {
tmin = dgFloat32 (1.2f);
}
return tmin;
}
In the end if the function found a Hit, it was setting the contact normal to the hit normal but the sphere user data pointer.
Long time ago, there user data of a collision shape use to store the collision ID of the shape, but when I added the scene collision, there is a new object called body Proxy, which act as a pseudo body.
The object needs to store information in the collision shape, so I separate the ID and the collsionUserData.
I made the changed on all collision routine, by I forgot to change he raycast routines. So the where reportion a userdata pointer as collision id, usually zero instead for the collisionID.
It is fix now.
The callback now reports
normal,3 { 1.0000000 0.00000000 0.00000000}
intersetparam 0.44999999 float
collisionid 1 int
Get SDK 2.25 and try again please