ccdGJKPenetration does not calculate exact contact location on a large box.
taesoobear opened this issue · 2 comments
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.
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.
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)
+{
- ccd_t ccd;
- CCD_BOX(box1);
- CCD_BOX(box2);
- int res;
- ccd_real_t depth;
- ccd_vec3_t dir, pos;
- fprintf(stderr, "\n\n\n---- boxboxPenetration ----\n\n\n");
- box1.x = 20;
- box1.y = 0.1;
- box1.z = 20;
- box2.x = 0.2;
- box2.y = 0.15;
- box2.z = 0.2;
- CCD_INIT(&ccd);
- ccd.support1 = ccdSupport;
- ccd.support2 = ccdSupport;
- ccdVec3Set(&box2.pos, 0, 0.1, 0.);
- res = ccdGJKPenetration(&box1, &box2, &ccd, &depth, &dir, &pos);
- assertTrue(res == 0);
- recPen(depth, &dir, &pos, stdout, "Pen largeBox");
- assertTrue(-0.2 < pos.v[0] && pos.v[0] <0.2);
- //TOSVT();
+}
diff --git a/src/testsuites/boxbox.h b/src/testsuites/boxbox.h
index 8127c7c..4d88464 100644
--- a/src/testsuites/boxbox.h
+++ b/src/testsuites/boxbox.h
@@ -14,6 +14,7 @@ TEST(boxboxRot);
TEST(boxboxSeparate);
TEST(boxboxPenetration);
+TEST(boxboxPenetration2);
TEST_SUITE(TSBoxBox) {
TEST_ADD(boxboxSetUp),
@@ -24,6 +25,7 @@ TEST_SUITE(TSBoxBox) {
TEST_ADD(boxboxRot),
TEST_ADD(boxboxSeparate),
TEST_ADD(boxboxPenetration),
- TEST_ADD(boxboxPenetration2),
TEST_ADD(boxboxTearDown),
TEST_SUITE_CLOSURE
diff --git a/src/testsuites/mpr_boxbox.c b/src/testsuites/mpr_boxbox.c
index 22f0a31..4771495 100644
--- a/src/testsuites/mpr_boxbox.c
+++ b/src/testsuites/mpr_boxbox.c
@@ -500,3 +500,36 @@ TEST(mprBoxboxPenetration)
recPen(depth, &dir, &pos, stdout, "Pen 10");
//TOSVT();
}
+TEST(mprBoxboxPenetration2)
+{
- ccd_t ccd;
- CCD_BOX(box1);
- CCD_BOX(box2);
- int res;
- ccd_real_t depth;
- ccd_vec3_t dir, pos;
- fprintf(stderr, "\n\n\n---- boxboxPenetration ----\n\n\n");
- box1.x = 20;
- box1.y = 0.1;
- box1.z = 20;
- box2.x = 0.2;
- box2.y = 0.15;
- box2.z = 0.2;
- CCD_INIT(&ccd);
- ccd.support1 = ccdSupport;
- ccd.support2 = ccdSupport;
- ccd.center1 = ccdObjCenter;
- ccd.center2 = ccdObjCenter;
- ccdVec3Set(&box2.pos, 0, 0.1, 0.);
- res = ccdMPRPenetration(&box1, &box2, &ccd, &depth, &dir, &pos);
- assertTrue(res == 0);
- recPen(depth, &dir, &pos, stdout, "Pen largeBox mpr");
- assertTrue(-0.2 < pos.v[0] && pos.v[0] <0.2);
- //TOSVT();
+}
diff --git a/src/testsuites/mpr_boxbox.h b/src/testsuites/mpr_boxbox.h
index 2f29ad7..283fb6f 100644
--- a/src/testsuites/mpr_boxbox.h
+++ b/src/testsuites/mpr_boxbox.h
@@ -11,6 +11,7 @@ TEST(mprBoxboxRot);
TEST(mprBoxboxSeparate);
TEST(mprBoxboxPenetration);
+TEST(mprBoxboxPenetration2);
TEST_SUITE(TSMPRBoxBox) {
TEST_ADD(mprBoxboxAlignedX),
@@ -19,6 +20,7 @@ TEST_SUITE(TSMPRBoxBox) {
TEST_ADD(mprBoxboxRot),
TEST_ADD(mprBoxboxSeparate),
TEST_ADD(mprBoxboxPenetration),
- TEST_ADD(mprBoxboxPenetration2),
TEST_SUITE_CLOSURE
};
1.9.1