danfis / libccd

Library for collision detection between two convex shapes
Other
478 stars 108 forks source link

ccdGJKPenetration does not calculate exact contact location on a large box. #17

Open taesoobear opened 8 years ago

taesoobear commented 8 years ago

I am trying to use libccd for my QP-based physics simulator, because libccd is very clean and compact. Thank you very much for such a nice library. (Previously, I used btGjkEpaSolver in bullet-2.68.) In my tests, everything seemed to work perfectly, unless a box (or any other convex objects) is large. When a box is large, box-box collision test works fine, but ccdGJKPeneration provides incorrect contact location. The contact normal and depth are accurate, and only the location is off. This is so only when a box is much larger than the other box. For example, when one box is 5 meters big while the other box is 0.2 meter big, the results are always inconsistent and inaccurate. I wonder if this is a known problem, or am I doing something wrong? I wrote my code based on testsuites/boxbox.c, and used the ccdSupport function in testsuites/support.c. I am using a Ubuntu machine. libccd was pulled from here a few days ago. (HASH:842646...) But my code has other dependencies so I did not post here.

[UPDATE] This issue has gone when I switched to ccdMPRPenetration. MPRPenetration seems to be less accurate about idepth though.

danfis commented 8 years ago

Could you create unit tests and send them to me (the best way would be a pull request). Then we can try to find out where is the problem and fix it.

taesoobear commented 8 years ago

Shown below is the unit tests that fail only for ccdGJKpenetration. Thanks much.

From 65a053ff38fdb8172d30356a04e8f9611fbdea54 Mon Sep 17 00:00:00 2001 From: taesoo kwon taesoobear@gmail.com Date: Tue, 15 Mar 2016 22:03:37 +0900 Subject: [PATCH 1/1] a


src/testsuites/boxbox.c | 31 +++++++++++++++++++++++++++++++ src/testsuites/boxbox.h | 2 ++ src/testsuites/mpr_boxbox.c | 33 +++++++++++++++++++++++++++++++++ src/testsuites/mpr_boxbox.h | 2 ++ 4 files changed, 68 insertions(+)

diff --git a/src/testsuites/boxbox.c b/src/testsuites/boxbox.c index 314d134..d76b373 100644 --- a/src/testsuites/boxbox.c +++ b/src/testsuites/boxbox.c @@ -464,3 +464,34 @@ TEST(boxboxPenetration) recPen(depth, &dir, &pos, stdout, "Pen 8"); //TOSVT(); } +TEST(boxboxPenetration2) +{