bad returned value from NewtonCollisionPointDistance

Report any bugs here and we'll post fixes

Moderators: Sascha Willems, Thomas

bad returned value from NewtonCollisionPointDistance

Postby ravarcade » Thu Jul 23, 2015 5:51 pm

Code: Select all
int NewtonCollisionPointDistance (const NewtonWorld* const newtonWorld, const dFloat* const testPoint, const NewtonCollision* const collision, const dFloat* const matrix, dFloat* const contact, dFloat* const normal, int threadIndex);

Should return 0 if tested testPointis is inside collision shape, but it alway return 1.
As collision in my tests i use cylinder.
Tested in lib version 3.13

Right now it is not a big problem. To get right value i calc normalized vector from contact point returned from NewtonCollisionPointDistance to testPoint. If that normalized vector is different than normal vector returned from NewtonCollisionPointDistance, when returned value should be 0.

Code: Select all
ret = NewtonCollisionPointDistance(newtonWorld, point, collision, matrix, contact, normal, threadIndex);

if (ret == 1)
   dFloat dif[3] = { point[0] - contact[0], point[1] - contact[1], point[2] - contact[2] };
   dFloat l = sqrtf(dif[0] * dif[0] + dif[1] * dif[1] + dif[2] * dif[2]);
   dFloat epsilon = 0.00001f;
   if (l > epsilon)
      l = 1.0f / l;
      dif[0] *= l;
      dif[1] *= l;
      dif[2] *= l;
      dFloat diff = fabsf(dif[0] - normal[0]) + fabsf(dif[1] - normal[1]) + fabsf(dif[2] - normal[2]);
      ret = diff < epsilon;
Posts: 8
Joined: Sat Jul 18, 2015 11:52 am

Return to Bugs and Fixes

Who is online

Users browsing this forum: No registered users and 2 guests