diff --git a/data/toys/concave_box.cdf b/data/toys/concave_box.cdf
new file mode 100644
index 000000000..1183762d8
Binary files /dev/null and b/data/toys/concave_box.cdf differ
diff --git a/data/toys/concave_box.mtl b/data/toys/concave_box.mtl
new file mode 100644
index 000000000..35c3a209b
--- /dev/null
+++ b/data/toys/concave_box.mtl
@@ -0,0 +1,11 @@
+# Blender MTL File: 'None'
+# Material Count: 1
+
+newmtl None
+Ns 0
+Ka 0.000000 0.000000 0.000000
+Kd 0.8 0.8 0.8
+Ks 0.8 0.8 0.8
+d 1
+illum 2
+map_Kd ../checker_grid.jpg
diff --git a/data/toys/concave_box.obj b/data/toys/concave_box.obj
new file mode 100644
index 000000000..bc58715ec
--- /dev/null
+++ b/data/toys/concave_box.obj
@@ -0,0 +1,949 @@
+# Blender v2.78 (sub 0) OBJ File: ''
+# www.blender.org
+mtllib concave_box.mtl
+o Cube_Cube.003
+v 0.252358 -0.051546 0.073254
+v 0.196823 -0.040500 0.026785
+v 0.133463 -0.027897 -0.007745
+v 0.064714 -0.014222 -0.029009
+v 0.237323 -0.101112 0.073254
+v 0.185009 -0.079443 0.026785
+v 0.125326 -0.054721 -0.007745
+v 0.060565 -0.027897 -0.029009
+v 0.212906 -0.146792 0.073254
+v 0.165826 -0.115334 0.026785
+v 0.112112 -0.079443 -0.007745
+v 0.053829 -0.040500 -0.029009
+v 0.180047 -0.186831 0.073254
+v 0.140008 -0.146792 0.026785
+v 0.094329 -0.101112 -0.007745
+v 0.044763 -0.051546 -0.029009
+v 0.140008 -0.219690 0.073254
+v 0.108550 -0.172609 0.026785
+v 0.072660 -0.118895 -0.007745
+v 0.033716 -0.060612 -0.029009
+v -0.006783 -0.000000 -0.036189
+v 0.094329 -0.244106 0.073254
+v 0.072660 -0.191793 0.026785
+v 0.047938 -0.132109 -0.007745
+v 0.021113 -0.067349 -0.029009
+v 0.044763 -0.259142 0.073254
+v 0.033716 -0.203606 0.026785
+v 0.021113 -0.140246 -0.007745
+v 0.007438 -0.071497 -0.029009
+v -0.006783 -0.264218 0.073254
+v -0.006783 -0.207595 0.026785
+v -0.006783 -0.142994 -0.007745
+v -0.006783 -0.072898 -0.029009
+v -0.058330 -0.259142 0.073254
+v -0.047283 -0.203606 0.026785
+v -0.034680 -0.140246 -0.007745
+v -0.021005 -0.071497 -0.029009
+v -0.107895 -0.244106 0.073254
+v -0.086227 -0.191793 0.026785
+v -0.061505 -0.132109 -0.007745
+v -0.034680 -0.067349 -0.029009
+v -0.153575 -0.219690 0.073254
+v -0.122117 -0.172609 0.026785
+v -0.086227 -0.118895 -0.007745
+v -0.047283 -0.060612 -0.029009
+v -0.193614 -0.186831 0.073254
+v -0.153575 -0.146792 0.026785
+v -0.107895 -0.101112 -0.007745
+v -0.058330 -0.051546 -0.029009
+v -0.226473 -0.146792 0.073254
+v -0.179392 -0.115334 0.026785
+v -0.125679 -0.079443 -0.007745
+v -0.067396 -0.040500 -0.029009
+v -0.250889 -0.101112 0.073254
+v -0.198576 -0.079443 0.026785
+v -0.138893 -0.054721 -0.007745
+v -0.074132 -0.027897 -0.029009
+v -0.265925 -0.051546 0.073254
+v -0.210390 -0.040500 0.026785
+v -0.147030 -0.027897 -0.007745
+v -0.078280 -0.014222 -0.029009
+v -0.271002 0.000000 0.073254
+v -0.214378 0.000000 0.026785
+v -0.149777 -0.000000 -0.007745
+v -0.079681 -0.000000 -0.029009
+v -0.265925 0.051546 0.073254
+v -0.210390 0.040500 0.026785
+v -0.147030 0.027897 -0.007745
+v -0.078280 0.014222 -0.029009
+v -0.250889 0.101112 0.073254
+v -0.198576 0.079443 0.026785
+v -0.138893 0.054721 -0.007745
+v -0.074132 0.027897 -0.029009
+v -0.226473 0.146792 0.073254
+v -0.179392 0.115334 0.026785
+v -0.125679 0.079443 -0.007745
+v -0.067396 0.040500 -0.029009
+v -0.193614 0.186831 0.073254
+v -0.153575 0.146792 0.026785
+v -0.107895 0.101112 -0.007745
+v -0.058330 0.051546 -0.029009
+v -0.153575 0.219690 0.073254
+v -0.122117 0.172609 0.026785
+v -0.086227 0.118895 -0.007745
+v -0.047283 0.060612 -0.029009
+v -0.107895 0.244106 0.073254
+v -0.086227 0.191793 0.026785
+v -0.061505 0.132109 -0.007745
+v -0.034680 0.067349 -0.029009
+v -0.058330 0.259141 0.073254
+v -0.047283 0.203606 0.026785
+v -0.034680 0.140246 -0.007745
+v -0.021005 0.071497 -0.029009
+v -0.006783 0.264218 0.073254
+v -0.006783 0.207595 0.026785
+v -0.006783 0.142994 -0.007745
+v -0.006783 0.072898 -0.029009
+v 0.044763 0.259141 0.073254
+v 0.033716 0.203606 0.026785
+v 0.021113 0.140246 -0.007745
+v 0.007438 0.071497 -0.029009
+v 0.094329 0.244106 0.073254
+v 0.072660 0.191793 0.026785
+v 0.047938 0.132109 -0.007745
+v 0.021113 0.067349 -0.029009
+v 0.140008 0.219689 0.073254
+v 0.108550 0.172609 0.026785
+v 0.072660 0.118895 -0.007745
+v 0.033716 0.060612 -0.029009
+v 0.180047 0.186831 0.073254
+v 0.140008 0.146792 0.026785
+v 0.094328 0.101112 -0.007745
+v 0.044763 0.051546 -0.029009
+v 0.212906 0.146792 0.073254
+v 0.165825 0.115334 0.026785
+v 0.112112 0.079443 -0.007745
+v 0.053829 0.040500 -0.029009
+v 0.237322 0.101112 0.073254
+v 0.185009 0.079443 0.026785
+v 0.125326 0.054721 -0.007745
+v 0.060565 0.027897 -0.029009
+v 0.252358 0.051546 0.073254
+v 0.196823 0.040500 0.026785
+v 0.133463 0.027897 -0.007745
+v 0.064713 0.014222 -0.029009
+v 0.257435 -0.000000 0.073254
+v 0.200811 -0.000000 0.026785
+v 0.136210 -0.000000 -0.007745
+v 0.066114 -0.000000 -0.029009
+v -1.000000 1.000000 -0.100000
+v -1.000000 1.000000 0.100000
+v 1.000000 1.000000 -0.100000
+v 1.000000 1.000000 0.100000
+v -1.000000 -1.000000 -0.100000
+v -1.000000 -1.000000 0.100000
+v 1.000000 -1.000000 -0.100000
+v 1.000000 -1.000000 0.100000
+v -0.006783 -0.286168 0.100000
+v -0.062612 -0.280669 0.100000
+v 0.195568 -0.202351 0.100000
+v 0.231157 -0.158987 0.100000
+v 0.257601 -0.109512 0.100000
+v 0.195568 0.202351 0.100000
+v -0.209135 0.202351 0.100000
+v 0.273886 -0.055829 0.100000
+v 0.273886 0.055829 0.100000
+v 0.257601 0.109512 0.100000
+v 0.152203 0.237940 0.100000
+v -0.209135 -0.202351 0.100000
+v -0.165770 -0.237940 0.100000
+v -0.244724 -0.158986 0.100000
+v -0.116295 -0.264385 0.100000
+v -0.244723 0.158986 0.100000
+v -0.165770 0.237940 0.100000
+v -0.116295 0.264385 0.100000
+v 0.231156 0.158986 0.100000
+v -0.271168 -0.109512 0.100000
+v -0.287453 0.055829 0.100000
+v -0.292951 0.000000 0.100000
+v 0.279384 -0.000000 0.100000
+v 0.102728 -0.264385 0.100000
+v 0.049045 0.280669 0.100000
+v 0.049045 -0.280669 0.100000
+v -0.287453 -0.055829 0.100000
+v -0.062612 0.280669 0.100000
+v -0.006783 0.286168 0.100000
+v 0.152203 -0.237940 0.100000
+v 0.102728 0.264385 0.100000
+v -0.271168 0.109512 0.100000
+vt 0.5258 0.8663
+vt 0.5000 1.0000
+vt 0.5000 0.8663
+vt 0.5202 0.6339
+vt 0.5000 0.6339
+vt 0.5139 0.4613
+vt 0.5000 0.4613
+vt 0.5071 0.3550
+vt 0.5000 0.3550
+vt 0.5000 0.4966
+vt 0.5071 0.5324
+vt 0.5000 0.5331
+vt 0.5139 0.5303
+vt 0.5506 0.8663
+vt 0.5279 1.0000
+vt 0.5274 0.4613
+vt 0.5139 0.3550
+vt 0.5734 0.8663
+vt 0.5548 1.0000
+vt 0.5577 0.6339
+vt 0.5397 0.6339
+vt 0.5397 0.4613
+vt 0.5202 0.3550
+vt 0.5202 0.5269
+vt 0.5258 0.5224
+vt 0.6012 1.0000
+vt 0.5795 1.0000
+vt 0.5734 0.6339
+vt 0.5506 0.4613
+vt 0.5258 0.3550
+vt 0.5700 0.6339
+vt 0.5700 0.8663
+vt 0.5900 0.8663
+vt 0.5363 0.4613
+vt 0.5472 0.4613
+vt 0.5169 0.3550
+vt 0.5224 0.3550
+vt 0.5303 0.5169
+vt 0.5978 1.0000
+vt 0.5514 1.0000
+vt 0.5761 1.0000
+vt 0.5543 0.6339
+vt 0.5472 0.8663
+vt 0.5363 0.6339
+vt 0.5240 0.4613
+vt 0.5337 0.5106
+vt 0.5224 0.8663
+vt 0.5106 0.4613
+vt 0.5106 0.3550
+vt 0.5357 0.5037
+vt 0.4966 1.0000
+vt 0.5245 1.0000
+vt 0.5169 0.6339
+vt 0.4966 0.8663
+vt 0.4966 0.6339
+vt 0.5037 0.3550
+vt 0.4966 0.4613
+vt 0.5364 0.4966
+vt 0.4827 0.4613
+vt 0.4895 0.3550
+vt 0.4966 0.3550
+vt 0.5357 0.4895
+vt 0.4708 0.8663
+vt 0.4461 0.8663
+vt 0.4687 1.0000
+vt 0.4764 0.6339
+vt 0.4569 0.6339
+vt 0.4692 0.4613
+vt 0.5337 0.4827
+vt 0.4827 0.3550
+vt 0.4569 0.4613
+vt 0.5303 0.4764
+vt 0.4232 0.8663
+vt 0.4419 1.0000
+vt 0.4389 0.6339
+vt 0.4032 0.8663
+vt 0.4171 1.0000
+vt 0.4232 0.6339
+vt 0.4708 0.3550
+vt 0.4764 0.3550
+vt 0.5258 0.4708
+vt 0.5202 0.3550
+vt 0.5506 0.4613
+vt 0.5258 0.3550
+vt 0.5202 0.4663
+vt 0.5734 0.8663
+vt 0.6012 1.0000
+vt 0.5934 0.8663
+vt 0.5734 0.6339
+vt 0.5577 0.6339
+vt 0.5506 0.8663
+vt 0.5795 1.0000
+vt 0.5274 0.4613
+vt 0.5397 0.4613
+vt 0.5139 0.4629
+vt 0.5071 0.4609
+vt 0.5279 1.0000
+vt 0.5548 1.0000
+vt 0.5202 0.6339
+vt 0.5397 0.6339
+vt 0.5139 0.4613
+vt 0.5071 0.3550
+vt 0.5139 0.3550
+vt 0.5000 0.8663
+vt 0.5258 0.8663
+vt 0.5000 0.6339
+vt 0.5000 0.4613
+vt 0.5000 0.4602
+vt 0.4929 0.4609
+vt 0.4742 0.8663
+vt 0.5000 1.0000
+vt 0.4798 0.6339
+vt 0.4861 0.4613
+vt 0.4929 0.3550
+vt 0.5000 0.3550
+vt 0.4603 0.6339
+vt 0.4726 0.4613
+vt 0.4861 0.4629
+vt 0.4494 0.8663
+vt 0.4721 1.0000
+vt 0.4266 0.8663
+vt 0.4452 1.0000
+vt 0.4603 0.4613
+vt 0.4861 0.3550
+vt 0.4798 0.4663
+vt 0.4266 0.6339
+vt 0.4423 0.6339
+vt 0.4742 0.3550
+vt 0.4798 0.3550
+vt 0.4742 0.4708
+vt 0.4066 0.8663
+vt 0.4205 1.0000
+vt 0.4232 0.8663
+vt 0.3954 1.0000
+vt 0.4032 0.8663
+vt 0.4389 0.6339
+vt 0.4232 0.6339
+vt 0.4569 0.4613
+vt 0.4461 0.4613
+vt 0.4708 0.3550
+vt 0.4697 0.4764
+vt 0.4569 0.6339
+vt 0.4827 0.3550
+vt 0.4764 0.3550
+vt 0.4663 0.4827
+vt 0.4461 0.8663
+vt 0.4171 1.0000
+vt 0.4708 0.8663
+vt 0.4419 1.0000
+vt 0.4764 0.6339
+vt 0.4827 0.4613
+vt 0.4692 0.4613
+vt 0.4895 0.3550
+vt 0.4643 0.4895
+vt 0.4966 0.3550
+vt 0.4636 0.4966
+vt 0.4966 0.8663
+vt 0.4687 1.0000
+vt 0.4966 0.6339
+vt 0.5224 0.8663
+vt 0.4966 1.0000
+vt 0.5169 0.6339
+vt 0.4966 0.4613
+vt 0.5037 0.3550
+vt 0.4643 0.5037
+vt 0.5106 0.3550
+vt 0.5106 0.4613
+vt 0.4663 0.5106
+vt 0.5472 0.8663
+vt 0.5245 1.0000
+vt 0.5363 0.6339
+vt 0.5240 0.4613
+vt 0.5700 0.8663
+vt 0.5514 1.0000
+vt 0.5363 0.4613
+vt 0.5169 0.3550
+vt 0.4697 0.5169
+vt 0.4742 0.5224
+vt 0.5900 0.8663
+vt 0.5761 1.0000
+vt 0.5700 0.6339
+vt 0.5543 0.6339
+vt 0.5224 0.3550
+vt 0.4423 0.6339
+vt 0.4066 0.8663
+vt 0.4266 0.6339
+vt 0.4603 0.4613
+vt 0.4494 0.4613
+vt 0.4798 0.3550
+vt 0.4742 0.3550
+vt 0.4798 0.5269
+vt 0.4266 0.8663
+vt 0.3988 1.0000
+vt 0.4494 0.8663
+vt 0.4205 1.0000
+vt 0.4603 0.6339
+vt 0.4861 0.3550
+vt 0.4861 0.5303
+vt 0.4798 0.6339
+vt 0.4861 0.4613
+vt 0.4726 0.4613
+vt 0.4929 0.3550
+vt 0.4929 0.5324
+vt 0.4742 0.8663
+vt 0.4452 1.0000
+vt 0.4721 1.0000
+vt 0.0000 1.0000
+vt 1.0000 0.0000
+vt 0.0000 0.0000
+vt 0.0000 1.0000
+vt 1.0000 0.0000
+vt 0.0000 0.0000
+vt 0.0000 1.0000
+vt -1.0000 0.0000
+vt 0.0000 0.0000
+vt 0.0000 1.0000
+vt -1.0000 0.0000
+vt 0.0000 0.0000
+vt 0.0000 -1.0000
+vt -1.0000 0.0000
+vt -0.5279 -0.3631
+vt -0.5000 -0.3603
+vt -0.5000 0.3535
+vt -0.5279 0.3563
+vt -1.0000 0.0000
+vt 0.5934 0.8663
+vt 0.3954 1.0000
+vt 0.4461 0.4613
+vt 0.4494 0.4613
+vt 0.3988 1.0000
+vt 0.5978 1.0000
+vt 0.5472 0.4613
+vt 1.0000 1.0000
+vt 1.0000 1.0000
+vt -1.0000 1.0000
+vt -1.0000 1.0000
+vt 1.0000 -1.0000
+vt -1.0000 -1.0000
+vt -0.6431 -0.5034
+vt -0.6403 -0.4755
+vt -0.3569 -0.5034
+vt 0.0000 -1.0000
+vt 0.0000 0.0000
+vt -0.3597 -0.4755
+vt -0.6322 -0.4486
+vt -0.6190 -0.4239
+vt -0.3678 -0.4486
+vt -0.3810 -0.4239
+vt -0.6012 -0.4022
+vt -0.5795 -0.3844
+vt -0.3988 -0.4022
+vt -0.4205 -0.3844
+vt -0.5548 -0.3712
+vt -0.4452 -0.3712
+vt -0.4721 -0.3631
+vt 0.0000 0.0000
+vt -0.3569 0.4966
+vt -0.3597 0.4687
+vt -0.3678 0.4419
+vt -0.6403 0.4687
+vt -0.6431 0.4966
+vt -0.6322 0.4419
+vt -0.3810 0.4171
+vt -0.3988 0.3954
+vt -0.6190 0.4171
+vt -0.6012 0.3954
+vt -0.4205 0.3776
+vt -0.4452 0.3644
+vt -0.5795 0.3776
+vt -0.5548 0.3644
+vt -0.4721 0.3563
+vn -0.7708 0.0759 0.6326
+vn -0.6332 0.0624 0.7715
+vn -0.4709 0.0464 0.8810
+vn -0.2902 0.0286 0.9565
+vn -0.0980 0.0097 0.9951
+vn -0.0942 0.0286 0.9951
+vn -0.7412 0.2248 0.6326
+vn -0.6088 0.1847 0.7715
+vn -0.4528 0.1374 0.8810
+vn -0.2790 0.0846 0.9565
+vn -0.6831 0.3651 0.6326
+vn -0.5611 0.2999 0.7715
+vn -0.4173 0.2230 0.8810
+vn -0.2571 0.1374 0.9565
+vn -0.0869 0.0464 0.9951
+vn -0.0761 0.0625 0.9951
+vn -0.5987 0.4913 0.6326
+vn -0.4918 0.4036 0.7715
+vn -0.3658 0.3002 0.8810
+vn -0.2254 0.1850 0.9565
+vn -0.4036 0.4918 0.7715
+vn -0.3002 0.3658 0.8810
+vn -0.1850 0.2254 0.9565
+vn -0.0625 0.0761 0.9951
+vn -0.4913 0.5987 0.6326
+vn -0.3651 0.6831 0.6326
+vn -0.2999 0.5611 0.7715
+vn -0.2230 0.4173 0.8810
+vn -0.1374 0.2571 0.9565
+vn -0.0464 0.0869 0.9951
+vn -0.1847 0.6088 0.7715
+vn -0.1374 0.4528 0.8810
+vn -0.0846 0.2790 0.9565
+vn -0.0286 0.0942 0.9951
+vn -0.2248 0.7412 0.6326
+vn -0.0759 0.7708 0.6326
+vn -0.0624 0.6332 0.7715
+vn -0.0464 0.4709 0.8810
+vn -0.0286 0.2902 0.9565
+vn -0.0097 0.0980 0.9951
+vn 0.0464 0.4709 0.8810
+vn 0.0286 0.2902 0.9565
+vn 0.0097 0.0980 0.9951
+vn 0.0759 0.7708 0.6326
+vn 0.0624 0.6332 0.7715
+vn 0.2248 0.7412 0.6326
+vn 0.1847 0.6088 0.7715
+vn 0.1374 0.4528 0.8810
+vn 0.0846 0.2790 0.9565
+vn 0.0286 0.0942 0.9951
+vn 0.1374 0.2571 0.9565
+vn 0.0464 0.0869 0.9951
+vn 0.3651 0.6831 0.6326
+vn 0.2999 0.5611 0.7715
+vn 0.2230 0.4173 0.8810
+vn 0.4913 0.5987 0.6326
+vn 0.4036 0.4918 0.7715
+vn 0.3002 0.3658 0.8810
+vn 0.1850 0.2254 0.9565
+vn 0.0625 0.0761 0.9951
+vn 0.2254 0.1850 0.9565
+vn 0.0761 0.0625 0.9951
+vn 0.5987 0.4913 0.6326
+vn 0.4918 0.4036 0.7715
+vn 0.3658 0.3002 0.8810
+vn 0.6831 0.3651 0.6326
+vn 0.5611 0.2999 0.7715
+vn 0.4173 0.2230 0.8810
+vn 0.2571 0.1374 0.9565
+vn 0.0869 0.0464 0.9951
+vn 0.0942 0.0286 0.9951
+vn 0.7412 0.2248 0.6326
+vn 0.6088 0.1847 0.7715
+vn 0.4528 0.1374 0.8810
+vn 0.2790 0.0846 0.9565
+vn 0.7708 0.0759 0.6326
+vn 0.6332 0.0624 0.7715
+vn 0.4709 0.0464 0.8810
+vn 0.2902 0.0286 0.9565
+vn 0.0980 0.0097 0.9951
+vn 0.0980 -0.0097 0.9951
+vn 0.7708 -0.0759 0.6326
+vn 0.6332 -0.0624 0.7715
+vn 0.4709 -0.0464 0.8810
+vn 0.2902 -0.0286 0.9565
+vn 0.6088 -0.1847 0.7715
+vn 0.4528 -0.1374 0.8810
+vn 0.2790 -0.0846 0.9565
+vn 0.0942 -0.0286 0.9951
+vn 0.7412 -0.2248 0.6326
+vn 0.6831 -0.3651 0.6326
+vn 0.5611 -0.2999 0.7715
+vn 0.4173 -0.2230 0.8810
+vn 0.2571 -0.1374 0.9565
+vn 0.0869 -0.0464 0.9951
+vn 0.3658 -0.3002 0.8810
+vn 0.2254 -0.1850 0.9565
+vn 0.0761 -0.0625 0.9951
+vn 0.5987 -0.4913 0.6326
+vn 0.4918 -0.4036 0.7715
+vn 0.4913 -0.5987 0.6326
+vn 0.4036 -0.4918 0.7715
+vn 0.3002 -0.3658 0.8810
+vn 0.1850 -0.2254 0.9565
+vn 0.0625 -0.0761 0.9951
+vn 0.2230 -0.4173 0.8810
+vn 0.1374 -0.2571 0.9565
+vn 0.0464 -0.0869 0.9951
+vn 0.3651 -0.6831 0.6326
+vn 0.2999 -0.5611 0.7715
+vn 0.2248 -0.7412 0.6326
+vn 0.1847 -0.6088 0.7715
+vn 0.1374 -0.4528 0.8810
+vn 0.0846 -0.2790 0.9565
+vn 0.0286 -0.0942 0.9951
+vn 0.0286 -0.2902 0.9565
+vn 0.0097 -0.0980 0.9951
+vn 0.0759 -0.7708 0.6326
+vn 0.0624 -0.6332 0.7715
+vn 0.0464 -0.4709 0.8810
+vn -0.0759 -0.7708 0.6326
+vn -0.0624 -0.6332 0.7715
+vn -0.0464 -0.4709 0.8810
+vn -0.0286 -0.2902 0.9565
+vn -0.0097 -0.0980 0.9951
+vn -0.0846 -0.2790 0.9565
+vn -0.0286 -0.0942 0.9951
+vn -0.2248 -0.7412 0.6326
+vn -0.1847 -0.6088 0.7715
+vn -0.1374 -0.4528 0.8810
+vn -0.3651 -0.6831 0.6326
+vn -0.2999 -0.5611 0.7715
+vn -0.2231 -0.4173 0.8810
+vn -0.1374 -0.2571 0.9565
+vn -0.0464 -0.0869 0.9951
+vn -0.0625 -0.0761 0.9951
+vn -0.4913 -0.5987 0.6326
+vn -0.4036 -0.4918 0.7715
+vn -0.3002 -0.3658 0.8810
+vn -0.1850 -0.2254 0.9565
+vn -0.4918 -0.4036 0.7715
+vn -0.3658 -0.3002 0.8810
+vn -0.2254 -0.1850 0.9565
+vn -0.0761 -0.0625 0.9951
+vn -0.5987 -0.4913 0.6326
+vn -0.6831 -0.3651 0.6326
+vn -0.5611 -0.2999 0.7715
+vn -0.4173 -0.2231 0.8810
+vn -0.2571 -0.1374 0.9565
+vn -0.0869 -0.0464 0.9951
+vn -0.6088 -0.1847 0.7715
+vn -0.4528 -0.1374 0.8810
+vn -0.2790 -0.0846 0.9565
+vn -0.0942 -0.0286 0.9951
+vn -0.7412 -0.2248 0.6326
+vn -0.7708 -0.0759 0.6326
+vn -0.6332 -0.0624 0.7715
+vn -0.4709 -0.0464 0.8810
+vn -0.2902 -0.0286 0.9565
+vn -0.0980 -0.0097 0.9951
+vn 0.0000 1.0000 0.0000
+vn 1.0000 0.0000 0.0000
+vn 0.0000 -1.0000 0.0000
+vn -1.0000 0.0000 0.0000
+vn 0.0000 0.0000 -1.0000
+vn -0.0000 0.0000 1.0000
+vn 0.2231 0.4173 0.8810
+vn 0.4173 -0.2231 0.8810
+vn -0.4173 -0.2230 0.8810
+usemtl None
+s off
+f 1/1/1 160/2/1 126/3/1
+f 2/4/2 126/3/2 127/5/2
+f 3/6/3 127/5/3 128/7/3
+f 4/8/4 128/7/4 129/9/4
+f 21/10/5 4/11/5 129/12/5
+f 21/10/6 8/13/6 4/11/6
+f 5/14/7 145/15/7 1/1/7
+f 2/4/8 5/14/8 1/1/8
+f 7/16/9 2/4/9 3/6/9
+f 8/17/10 3/6/10 4/8/10
+f 9/18/11 142/19/11 5/14/11
+f 10/20/12 5/14/12 6/21/12
+f 11/22/13 6/21/13 7/16/13
+f 12/23/14 7/16/14 8/17/14
+f 21/10/15 12/24/15 8/13/15
+f 21/10/16 16/25/16 12/24/16
+f 9/18/17 140/26/17 141/27/17
+f 14/28/18 9/18/18 10/20/18
+f 15/29/19 10/20/19 11/22/19
+f 16/30/20 11/22/20 12/23/20
+f 14/31/21 17/32/21 13/33/21
+f 19/34/22 14/31/22 15/35/22
+f 20/36/23 15/35/23 16/37/23
+f 21/10/24 20/38/24 16/25/24
+f 17/32/25 140/39/25 13/33/25
+f 17/32/26 161/40/26 167/41/26
+f 18/42/27 22/43/27 17/32/27
+f 19/34/28 23/44/28 18/42/28
+f 20/36/29 24/45/29 19/34/29
+f 21/10/30 25/46/30 20/38/30
+f 23/44/31 26/47/31 22/43/31
+f 28/48/32 23/44/32 24/45/32
+f 25/49/33 28/48/33 24/45/33
+f 21/10/34 29/50/34 25/46/34
+f 26/47/35 161/40/35 22/43/35
+f 26/47/36 138/51/36 163/52/36
+f 27/53/37 30/54/37 26/47/37
+f 28/48/38 31/55/38 27/53/38
+f 29/56/39 32/57/39 28/48/39
+f 21/10/40 33/58/40 29/50/40
+f 36/59/41 31/55/41 32/57/41
+f 37/60/42 32/57/42 33/61/42
+f 21/10/43 37/62/43 33/58/43
+f 34/63/44 138/51/44 30/54/44
+f 31/55/45 34/63/45 30/54/45
+f 38/64/46 139/65/46 34/63/46
+f 35/66/47 38/64/47 34/63/47
+f 36/59/48 39/67/48 35/66/48
+f 37/60/49 40/68/49 36/59/49
+f 21/10/50 41/69/50 37/62/50
+f 41/70/51 44/71/51 40/68/51
+f 21/10/52 45/72/52 41/69/52
+f 42/73/53 152/74/53 38/64/53
+f 43/75/54 38/64/54 39/67/54
+f 44/71/55 39/67/55 40/68/55
+f 46/76/56 150/77/56 42/73/56
+f 43/75/57 46/76/57 42/73/57
+f 44/71/58 47/78/58 43/75/58
+f 49/79/59 44/71/59 45/80/59
+f 21/10/60 49/81/60 45/72/60
+f 53/82/61 48/83/61 49/84/61
+f 21/10/62 53/85/62 49/81/62
+f 50/86/63 149/87/63 46/88/63
+f 47/89/64 50/86/64 46/88/64
+f 48/83/65 51/90/65 47/89/65
+f 54/91/66 151/92/66 50/86/66
+f 51/90/67 54/91/67 50/86/67
+f 56/93/68 51/90/68 52/94/68
+f 53/82/69 56/93/69 52/94/69
+f 21/10/70 57/95/70 53/85/70
+f 21/10/71 61/96/71 57/95/71
+f 54/91/72 164/97/72 157/98/72
+f 59/99/73 54/91/73 55/100/73
+f 60/101/74 55/100/74 56/93/74
+f 61/102/75 56/93/75 57/103/75
+f 62/104/76 164/97/76 58/105/76
+f 63/106/77 58/105/77 59/99/77
+f 64/107/78 59/99/78 60/101/78
+f 61/102/79 64/107/79 60/101/79
+f 21/10/80 65/108/80 61/96/80
+f 21/10/81 69/109/81 65/108/81
+f 66/110/82 159/111/82 62/104/82
+f 67/112/83 62/104/83 63/106/83
+f 68/113/84 63/106/84 64/107/84
+f 69/114/85 64/107/85 65/115/85
+f 71/116/86 66/110/86 67/112/86
+f 72/117/87 67/112/87 68/113/87
+f 69/114/88 72/117/88 68/113/88
+f 21/10/89 73/118/89 69/109/89
+f 70/119/90 158/120/90 66/110/90
+f 74/121/91 169/122/91 70/119/91
+f 71/116/92 74/121/92 70/119/92
+f 76/123/93 71/116/93 72/117/93
+f 73/124/94 76/123/94 72/117/94
+f 21/10/95 77/125/95 73/118/95
+f 76/123/96 79/126/96 75/127/96
+f 81/128/97 76/123/97 77/129/97
+f 21/10/98 81/130/98 77/125/98
+f 78/131/99 153/132/99 74/121/99
+f 79/126/100 74/121/100 75/127/100
+f 82/133/101 144/134/101 78/135/101
+f 83/136/102 78/135/102 79/137/102
+f 84/138/103 79/137/103 80/139/103
+f 81/140/104 84/138/104 80/139/104
+f 21/10/105 85/141/105 81/130/105
+f 84/138/106 87/142/106 83/136/106
+f 89/143/107 84/138/107 85/144/107
+f 21/10/108 89/145/108 85/141/108
+f 86/146/109 154/147/109 82/133/109
+f 87/142/110 82/133/110 83/136/110
+f 90/148/111 155/149/111 86/146/111
+f 91/150/112 86/146/112 87/142/112
+f 92/151/113 87/142/113 88/152/113
+f 93/153/114 88/152/114 89/143/114
+f 21/10/115 93/154/115 89/145/115
+f 97/155/116 92/151/116 93/153/116
+f 21/10/117 97/156/117 93/154/117
+f 94/157/118 165/158/118 90/148/118
+f 95/159/119 90/148/119 91/150/119
+f 92/151/120 95/159/120 91/150/120
+f 98/160/121 166/161/121 94/157/121
+f 99/162/122 94/157/122 95/159/122
+f 96/163/123 99/162/123 95/159/123
+f 101/164/124 96/163/124 97/155/124
+f 21/10/125 101/165/125 97/156/125
+f 105/166/126 100/167/126 101/164/126
+f 21/10/127 105/168/127 101/165/127
+f 102/169/128 162/170/128 98/160/128
+f 103/171/129 98/160/129 99/162/129
+f 104/172/130 99/162/130 100/167/130
+f 106/173/131 168/174/131 102/169/131
+f 103/171/132 106/173/132 102/169/132
+f 108/175/133 103/171/133 104/172/133
+f 109/176/134 104/172/134 105/166/134
+f 21/10/135 109/177/135 105/168/135
+f 21/10/136 113/178/136 109/177/136
+f 110/179/137 148/180/137 106/173/137
+f 111/181/138 106/173/138 107/182/138
+f 108/175/139 111/181/139 107/182/139
+f 113/183/140 108/175/140 109/176/140
+f 115/184/141 110/185/141 111/186/141
+f 116/187/142 111/186/142 112/188/142
+f 117/189/143 112/188/143 113/190/143
+f 21/10/144 117/191/144 113/178/144
+f 114/192/145 143/193/145 110/185/145
+f 118/194/146 156/195/146 114/192/146
+f 119/196/147 114/192/147 115/184/147
+f 116/187/148 119/196/148 115/184/148
+f 121/197/149 116/187/149 117/189/149
+f 21/10/150 121/198/150 117/191/150
+f 123/199/151 118/194/151 119/196/151
+f 124/200/152 119/196/152 120/201/152
+f 125/202/153 120/201/153 121/197/153
+f 21/10/154 125/203/154 121/198/154
+f 122/204/155 147/205/155 118/194/155
+f 126/3/156 146/206/156 122/204/156
+f 127/5/157 122/204/157 123/199/157
+f 128/7/158 123/199/158 124/200/158
+f 129/9/159 124/200/159 125/202/159
+f 21/10/160 129/12/160 125/203/160
+f 131/207/161 132/208/161 130/209/161
+f 133/210/162 136/211/162 132/212/162
+f 137/213/163 134/214/163 136/215/163
+f 135/216/164 130/217/164 134/218/164
+f 136/211/165 130/219/165 132/212/165
+f 133/220/166 146/221/166 160/222/166
+f 159/223/166 158/224/166 131/225/166
+f 1/1/1 145/15/1 160/2/1
+f 2/4/2 1/1/2 126/3/2
+f 3/6/3 2/4/3 127/5/3
+f 4/8/4 3/6/4 128/7/4
+f 5/14/7 142/19/7 145/15/7
+f 2/4/8 6/21/8 5/14/8
+f 7/16/9 6/21/9 2/4/9
+f 8/17/10 7/16/10 3/6/10
+f 9/18/11 141/27/11 142/19/11
+f 10/20/12 9/18/12 5/14/12
+f 11/22/13 10/20/13 6/21/13
+f 12/23/14 11/22/14 7/16/14
+f 9/18/17 13/226/17 140/26/17
+f 14/28/18 13/226/18 9/18/18
+f 15/29/19 14/28/19 10/20/19
+f 16/30/20 15/29/20 11/22/20
+f 14/31/21 18/42/21 17/32/21
+f 19/34/22 18/42/22 14/31/22
+f 20/36/23 19/34/23 15/35/23
+f 17/32/25 167/41/25 140/39/25
+f 17/32/26 22/43/26 161/40/26
+f 18/42/27 23/44/27 22/43/27
+f 19/34/28 24/45/28 23/44/28
+f 20/36/29 25/49/29 24/45/29
+f 23/44/31 27/53/31 26/47/31
+f 28/48/32 27/53/32 23/44/32
+f 25/49/33 29/56/33 28/48/33
+f 26/47/35 163/52/35 161/40/35
+f 26/47/36 30/54/36 138/51/36
+f 27/53/37 31/55/37 30/54/37
+f 28/48/38 32/57/38 31/55/38
+f 29/56/39 33/61/39 32/57/39
+f 36/59/41 35/66/41 31/55/41
+f 37/60/42 36/59/42 32/57/42
+f 34/63/44 139/65/44 138/51/44
+f 31/55/45 35/66/45 34/63/45
+f 38/64/46 152/74/46 139/65/46
+f 35/66/47 39/67/47 38/64/47
+f 36/59/48 40/68/48 39/67/48
+f 37/60/49 41/70/49 40/68/49
+f 41/70/51 45/80/51 44/71/51
+f 42/73/53 150/77/53 152/74/53
+f 43/75/54 42/73/54 38/64/54
+f 44/71/167 43/75/167 39/67/167
+f 46/76/56 149/227/56 150/77/56
+f 43/75/57 47/78/57 46/76/57
+f 44/71/58 48/228/58 47/78/58
+f 49/79/59 48/228/59 44/71/59
+f 53/82/61 52/94/61 48/83/61
+f 50/86/63 151/92/63 149/87/63
+f 47/89/64 51/90/64 50/86/64
+f 48/83/65 52/94/65 51/90/65
+f 54/91/66 157/98/66 151/92/66
+f 51/90/67 55/100/67 54/91/67
+f 56/93/68 55/100/68 51/90/68
+f 53/82/69 57/103/69 56/93/69
+f 54/91/72 58/105/72 164/97/72
+f 59/99/73 58/105/73 54/91/73
+f 60/101/74 59/99/74 55/100/74
+f 61/102/75 60/101/75 56/93/75
+f 62/104/76 159/111/76 164/97/76
+f 63/106/77 62/104/77 58/105/77
+f 64/107/78 63/106/78 59/99/78
+f 61/102/79 65/115/79 64/107/79
+f 66/110/82 158/120/82 159/111/82
+f 67/112/83 66/110/83 62/104/83
+f 68/113/84 67/112/84 63/106/84
+f 69/114/85 68/113/85 64/107/85
+f 71/116/86 70/119/86 66/110/86
+f 72/117/87 71/116/87 67/112/87
+f 69/114/88 73/124/88 72/117/88
+f 70/119/90 169/122/90 158/120/90
+f 74/121/91 153/132/91 169/122/91
+f 71/116/92 75/127/92 74/121/92
+f 76/123/168 75/127/168 71/116/168
+f 73/124/94 77/129/94 76/123/94
+f 76/123/96 80/229/96 79/126/96
+f 81/128/97 80/229/97 76/123/97
+f 78/131/99 144/230/99 153/132/99
+f 79/126/100 78/131/100 74/121/100
+f 82/133/101 154/147/101 144/134/101
+f 83/136/102 82/133/102 78/135/102
+f 84/138/103 83/136/103 79/137/103
+f 81/140/104 85/144/104 84/138/104
+f 84/138/106 88/152/106 87/142/106
+f 89/143/107 88/152/107 84/138/107
+f 86/146/109 155/149/109 154/147/109
+f 87/142/110 86/146/110 82/133/110
+f 90/148/111 165/158/111 155/149/111
+f 91/150/112 90/148/112 86/146/112
+f 92/151/113 91/150/113 87/142/113
+f 93/153/114 92/151/114 88/152/114
+f 97/155/116 96/163/116 92/151/116
+f 94/157/118 166/161/118 165/158/118
+f 95/159/119 94/157/119 90/148/119
+f 92/151/120 96/163/120 95/159/120
+f 98/160/121 162/170/121 166/161/121
+f 99/162/122 98/160/122 94/157/122
+f 96/163/123 100/167/123 99/162/123
+f 101/164/124 100/167/124 96/163/124
+f 105/166/126 104/172/126 100/167/126
+f 102/169/128 168/174/128 162/170/128
+f 103/171/129 102/169/129 98/160/129
+f 104/172/130 103/171/130 99/162/130
+f 106/173/131 148/180/131 168/174/131
+f 103/171/132 107/182/132 106/173/132
+f 108/175/133 107/182/133 103/171/133
+f 109/176/134 108/175/134 104/172/134
+f 110/179/137 143/231/137 148/180/137
+f 111/181/138 110/179/138 106/173/138
+f 108/175/139 112/232/139 111/181/139
+f 113/183/140 112/232/140 108/175/140
+f 115/184/141 114/192/141 110/185/141
+f 116/187/142 115/184/142 111/186/142
+f 117/189/143 116/187/143 112/188/143
+f 114/192/145 156/195/145 143/193/145
+f 118/194/146 147/205/146 156/195/146
+f 119/196/147 118/194/147 114/192/147
+f 116/187/169 120/201/169 119/196/169
+f 121/197/149 120/201/149 116/187/149
+f 123/199/151 122/204/151 118/194/151
+f 124/200/152 123/199/152 119/196/152
+f 125/202/153 124/200/153 120/201/153
+f 122/204/155 146/206/155 147/205/155
+f 126/3/156 160/2/156 146/206/156
+f 127/5/157 126/3/157 122/204/157
+f 128/7/158 127/5/158 123/199/158
+f 129/9/159 128/7/159 124/200/159
+f 131/207/161 133/233/161 132/208/161
+f 133/210/162 137/234/162 136/211/162
+f 137/213/163 135/235/163 134/214/163
+f 135/216/164 131/236/164 130/217/164
+f 136/211/165 134/237/165 130/219/165
+f 133/220/166 131/238/166 166/239/166
+f 133/220/166 166/239/166 162/240/166
+f 138/241/166 135/242/166 137/243/166
+f 163/244/166 138/241/166 137/243/166
+f 133/220/166 162/240/166 168/245/166
+f 133/220/166 168/245/166 148/246/166
+f 161/247/166 163/244/166 137/243/166
+f 167/248/166 161/247/166 137/243/166
+f 133/220/166 148/246/166 143/249/166
+f 133/220/166 143/249/166 156/250/166
+f 140/251/166 167/248/166 137/243/166
+f 141/252/166 140/251/166 137/243/166
+f 137/243/166 133/220/166 160/222/166
+f 133/220/166 156/250/166 147/253/166
+f 142/254/166 141/252/166 137/243/166
+f 145/255/166 142/254/166 137/243/166
+f 133/220/166 147/253/166 146/221/166
+f 160/222/166 145/255/166 137/243/166
+f 135/256/166 138/257/166 139/258/166
+f 135/256/166 139/258/166 152/259/166
+f 165/260/166 166/261/166 131/225/166
+f 155/262/166 165/260/166 131/225/166
+f 135/256/166 152/259/166 150/263/166
+f 135/256/166 150/263/166 149/264/166
+f 154/265/166 155/262/166 131/225/166
+f 144/266/166 154/265/166 131/225/166
+f 135/256/166 149/264/166 151/267/166
+f 135/256/166 151/267/166 157/268/166
+f 153/269/166 144/266/166 131/225/166
+f 169/270/166 153/269/166 131/225/166
+f 131/225/166 135/256/166 159/223/166
+f 135/256/166 157/268/166 164/271/166
+f 158/224/166 169/270/166 131/225/166
+f 135/256/166 164/271/166 159/223/166
diff --git a/data/toys/concave_box.urdf b/data/toys/concave_box.urdf
new file mode 100644
index 000000000..08ff9c02d
--- /dev/null
+++ b/data/toys/concave_box.urdf
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/examples/ExampleBrowser/OpenGLExampleBrowser.cpp b/examples/ExampleBrowser/OpenGLExampleBrowser.cpp
index 6d70cc946..99c953c09 100644
--- a/examples/ExampleBrowser/OpenGLExampleBrowser.cpp
+++ b/examples/ExampleBrowser/OpenGLExampleBrowser.cpp
@@ -410,6 +410,14 @@ void OpenGLExampleBrowserVisualizerFlagCallback(int flag, bool enable)
if (flag == COV_ENABLE_WIREFRAME)
{
visualWireframe = enable;
+ if (visualWireframe)
+ {
+ gDebugDrawFlags |= btIDebugDraw::DBG_DrawWireframe;
+ }
+ else
+ {
+ gDebugDrawFlags &= ~btIDebugDraw::DBG_DrawWireframe;
+ }
}
}
diff --git a/examples/Importers/ImportURDFDemo/BulletUrdfImporter.cpp b/examples/Importers/ImportURDFDemo/BulletUrdfImporter.cpp
index ce2129435..3f6043d06 100644
--- a/examples/Importers/ImportURDFDemo/BulletUrdfImporter.cpp
+++ b/examples/Importers/ImportURDFDemo/BulletUrdfImporter.cpp
@@ -21,6 +21,7 @@ subject to the following restrictions:
#include "../ImportSTLDemo/LoadMeshFromSTL.h"
#include "../ImportColladaDemo/LoadMeshFromCollada.h"
#include "BulletCollision/CollisionShapes/btShapeHull.h"//to create a tesselation of a generic btConvexShape
+#include "BulletCollision/CollisionShapes/btSdfCollisionShape.h"
#include "../../CommonInterfaces/CommonGUIHelperInterface.h"
#include "Bullet3Common/b3FileUtils.h"
#include
@@ -509,6 +510,10 @@ bool findExistingMeshFile(
{
*out_type = UrdfGeometry::FILE_OBJ;
}
+ else if (ext == ".cdf")
+ {
+ *out_type = UrdfGeometry::FILE_CDF;
+ }
else
{
b3Warning("%s: invalid mesh filename extension '%s'\n", error_message_prefix.c_str(), ext.c_str());
@@ -662,7 +667,53 @@ btCollisionShape* BulletURDFImporter::convertURDFToCollisionShape(const UrdfColl
shape ->setMargin(gUrdfDefaultCollisionMargin);
break;
}
+ case URDF_GEOM_CDF:
+ {
+
+ char relativeFileName[1024];
+ char pathPrefix[1024];
+ pathPrefix[0] = 0;
+ if (b3ResourcePath::findResourcePath(collision->m_geometry.m_meshFileName.c_str(), relativeFileName, 1024))
+ {
+ b3FileUtils::extractPath(relativeFileName, pathPrefix, 1024);
+
+ btAlignedObjectArray sdfData;
+ {
+ std::streampos fsize = 0;
+ std::ifstream file(relativeFileName, std::ios::binary);
+ if (file.good())
+ {
+ fsize = file.tellg();
+ file.seekg(0, std::ios::end);
+ fsize = file.tellg() - fsize;
+ file.seekg(0, std::ios::beg);
+ sdfData.resize(fsize);
+ int bytesRead = file.rdbuf()->sgetn(&sdfData[0], fsize);
+ btAssert(bytesRead == fsize);
+ file.close();
+ }
+ }
+
+ if (sdfData.size())
+ {
+ btSdfCollisionShape* sdfShape = new btSdfCollisionShape();
+ bool valid = sdfShape->initializeSDF(&sdfData[0], sdfData.size());
+ btAssert(valid);
+
+ if (valid)
+ {
+ shape = sdfShape;
+ }
+ else
+ {
+ delete sdfShape;
+ }
+
+ }
+ }
+ break;
+ }
case URDF_GEOM_MESH:
{
GLInstanceGraphicsShape* glmesh = 0;
diff --git a/examples/Importers/ImportURDFDemo/UrdfParser.cpp b/examples/Importers/ImportURDFDemo/UrdfParser.cpp
index c6a30edf7..1be8285c1 100644
--- a/examples/Importers/ImportURDFDemo/UrdfParser.cpp
+++ b/examples/Importers/ImportURDFDemo/UrdfParser.cpp
@@ -436,9 +436,16 @@ bool UrdfParser::parseGeometry(UrdfGeometry& geom, XMLElement* g, ErrorLogger* l
geom.m_capsuleHeight = m_urdfScaling * urdfLexicalCast(shape->Attribute("length"));
}
}
- else if (type_name == "mesh")
+ else if ((type_name == "mesh") || (type_name == "cdf"))
{
- geom.m_type = URDF_GEOM_MESH;
+ if ((type_name == "cdf"))
+ {
+ geom.m_type = URDF_GEOM_CDF;
+ }
+ else
+ {
+ geom.m_type = URDF_GEOM_MESH;
+ }
geom.m_meshScale.setValue(1,1,1);
std::string fn;
diff --git a/examples/Importers/ImportURDFDemo/UrdfParser.h b/examples/Importers/ImportURDFDemo/UrdfParser.h
index 094c1e36a..fed2cc141 100644
--- a/examples/Importers/ImportURDFDemo/UrdfParser.h
+++ b/examples/Importers/ImportURDFDemo/UrdfParser.h
@@ -54,7 +54,8 @@ enum UrdfGeomTypes
URDF_GEOM_CYLINDER,
URDF_GEOM_MESH,
URDF_GEOM_PLANE,
- URDF_GEOM_CAPSULE, //non-standard URDF?
+ URDF_GEOM_CAPSULE, //non-standard URDF
+ URDF_GEOM_CDF,//signed-distance-field, non-standard URDF
URDF_GEOM_UNKNOWN,
};
@@ -79,6 +80,8 @@ struct UrdfGeometry
FILE_STL =1,
FILE_COLLADA =2,
FILE_OBJ =3,
+ FILE_CDF = 4,
+
};
int m_meshFileType;
std::string m_meshFileName;
diff --git a/examples/pybullet/examples/signedDistanceField.py b/examples/pybullet/examples/signedDistanceField.py
new file mode 100644
index 000000000..6e4153ef8
--- /dev/null
+++ b/examples/pybullet/examples/signedDistanceField.py
@@ -0,0 +1,15 @@
+import pybullet as p
+import pybullet
+import time
+p.connect(p.GUI)
+p.loadURDF("toys/concave_box.urdf")
+p.setGravity(0,0,-10)
+for i in range (10):
+ p.loadURDF("sphere_1cm.urdf",[i*0.02,0,0.5])
+p.loadURDF("duck_vhacd.urdf")
+timeStep = 1./240.
+p.setTimeStep(timeStep)
+while (1):
+ p.stepSimulation()
+ time.sleep(timeStep)
+
\ No newline at end of file
diff --git a/src/BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.cpp b/src/BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.cpp
index d2331f5df..d8cbe9614 100644
--- a/src/BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.cpp
+++ b/src/BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.cpp
@@ -153,7 +153,7 @@ partId, int triangleIndex)
{
m_resultOut->setBody1Wrap(tmpWrap);
}
-
+
colAlgo->~btCollisionAlgorithm();
@@ -164,7 +164,7 @@ partId, int triangleIndex)
-void btConvexTriangleCallback::setTimeStepAndCounters(btScalar collisionMarginTriangle,const btDispatcherInfo& dispatchInfo,const btCollisionObjectWrapper* convexBodyWrap, const btCollisionObjectWrapper* triBodyWrap, btManifoldResult* resultOut)
+void btConvexTriangleCallback::setTimeStepAndCounters(btScalar collisionMarginTriangle, const btDispatcherInfo& dispatchInfo, const btCollisionObjectWrapper* convexBodyWrap, const btCollisionObjectWrapper* triBodyWrap, btManifoldResult* resultOut)
{
m_convexBodyWrap = convexBodyWrap;
m_triBodyWrap = triBodyWrap;
@@ -178,14 +178,14 @@ void btConvexTriangleCallback::setTimeStepAndCounters(btScalar collisionMarginTr
convexInTriangleSpace = m_triBodyWrap->getWorldTransform().inverse() * m_convexBodyWrap->getWorldTransform();
const btCollisionShape* convexShape = static_cast(m_convexBodyWrap->getCollisionShape());
//CollisionShape* triangleShape = static_cast(triBody->m_collisionShape);
- convexShape->getAabb(convexInTriangleSpace,m_aabbMin,m_aabbMax);
- btScalar extraMargin = collisionMarginTriangle+ resultOut->m_closestPointDistanceThreshold;
-
- btVector3 extra(extraMargin,extraMargin,extraMargin);
+ convexShape->getAabb(convexInTriangleSpace, m_aabbMin, m_aabbMax);
+ btScalar extraMargin = collisionMarginTriangle + resultOut->m_closestPointDistanceThreshold;
+
+ btVector3 extra(extraMargin, extraMargin, extraMargin);
m_aabbMax += extra;
m_aabbMin -= extra;
-
+
}
void btConvexConcaveCollisionAlgorithm::clearCache()
@@ -194,16 +194,16 @@ void btConvexConcaveCollisionAlgorithm::clearCache()
}
-void btConvexConcaveCollisionAlgorithm::processCollision (const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
+void btConvexConcaveCollisionAlgorithm::processCollision (const btCollisionObjectWrapper* body0Wrap, const btCollisionObjectWrapper* body1Wrap, const btDispatcherInfo& dispatchInfo, btManifoldResult* resultOut)
{
BT_PROFILE("btConvexConcaveCollisionAlgorithm::processCollision");
-
+
const btCollisionObjectWrapper* convexBodyWrap = m_isSwapped ? body1Wrap : body0Wrap;
const btCollisionObjectWrapper* triBodyWrap = m_isSwapped ? body0Wrap : body1Wrap;
if (triBodyWrap->getCollisionShape()->isConcave())
{
- if (triBodyWrap->getCollisionShape()->getShapeType()==SDF_SHAPE_PROXYTYPE)
+ if (triBodyWrap->getCollisionShape()->getShapeType() == SDF_SHAPE_PROXYTYPE)
{
btSdfCollisionShape* sdfShape = (btSdfCollisionShape*)triBodyWrap->getCollisionShape();
if (convexBodyWrap->getCollisionShape()->isConvex())
@@ -214,26 +214,30 @@ void btConvexConcaveCollisionAlgorithm::processCollision (const btCollisionObjec
if (convex->isPolyhedral())
{
- btPolyhedralConvexShape* poly = (btPolyhedralConvexShape*) convex;
- for (int v=0;vgetNumVertices();v++)
+ btPolyhedralConvexShape* poly = (btPolyhedralConvexShape*)convex;
+ for (int v = 0; v < poly->getNumVertices(); v++)
{
btVector3 vtx;
- poly->getVertex(v,vtx);
+ poly->getVertex(v, vtx);
queryVertices.push_back(vtx);
}
}
- if (convex->getShapeType()==SPHERE_SHAPE_PROXYTYPE)
+ btScalar maxDist = SIMD_EPSILON;
+
+ if (convex->getShapeType() == SPHERE_SHAPE_PROXYTYPE)
{
- queryVertices.push_back(btVector3(0,0,0));
-
+ queryVertices.push_back(btVector3(0, 0, 0));
+ btSphereShape* sphere = (btSphereShape*)convex;
+ maxDist = sphere->getRadius() + SIMD_EPSILON;
+
}
if (queryVertices.size())
{
resultOut->setPersistentManifold(m_btConvexTriangleCallback.m_manifoldPtr);
//m_btConvexTriangleCallback.m_manifoldPtr->clearManifold();
- btPolyhedralConvexShape* poly = (btPolyhedralConvexShape*) convex;
- for (int v=0;vgetWorldTransform()*vtx;
@@ -241,12 +245,20 @@ void btConvexConcaveCollisionAlgorithm::processCollision (const btCollisionObjec
btVector3 normalLocal;
btScalar dist;
- if (sdfShape->queryPoint(vtxInSdf,dist, normalLocal))
+ if (sdfShape->queryPoint(vtxInSdf, dist, normalLocal))
{
- if (dist<=SIMD_EPSILON)
+ if (dist <= maxDist)
{
normalLocal.safeNormalize();
btVector3 normal = triBodyWrap->getWorldTransform().getBasis()*normalLocal;
+
+ if (convex->getShapeType() == SPHERE_SHAPE_PROXYTYPE)
+ {
+ btSphereShape* sphere = (btSphereShape*)convex;
+ dist -= sphere->getRadius();
+ vtxWorldSpace -= sphere->getRadius()*normal;
+
+ }
resultOut->addContactPoint(normal,vtxWorldSpace-normal*dist, dist);
}
}
diff --git a/src/BulletCollision/CollisionShapes/btMiniSDF.cpp b/src/BulletCollision/CollisionShapes/btMiniSDF.cpp
index c57673381..afe45e1d2 100644
--- a/src/BulletCollision/CollisionShapes/btMiniSDF.cpp
+++ b/src/BulletCollision/CollisionShapes/btMiniSDF.cpp
@@ -1,5 +1,13 @@
#include "btMiniSDF.h"
+//
+//Based on code from DiscreGrid, https://github.com/InteractiveComputerGraphics/Discregrid
+//example:
+//GenerateSDF.exe -r "32 32 32" -d "-1.6 -1.6 -.6 1.6 1.6 .6" concave_box.obj
+//The MIT License (MIT)
+//
+//Copyright (c) 2017 Dan Koschier
+//
#include
#include //memcpy
@@ -89,7 +97,10 @@ bool btMiniSDF::load(const char* data, int size)
std::size_t n_nodes0;
ds.read(nodes0);
n_nodes0 = nodes0;
-
+ if (n_nodes0 > 1024 * 1024 * 1024)
+ {
+ return m_isValid;
+ }
m_nodes.resize(n_nodes0);
for (unsigned int i=0;i