diff --git a/python/collision-geometries.cc b/python/collision-geometries.cc index 14ee334a5ef780786446781feb6c547307f8d225..45c1cf39a9e9cdf3cb58a1ac919a4c9772259a92 100644 --- a/python/collision-geometries.cc +++ b/python/collision-geometries.cc @@ -87,7 +87,10 @@ struct BVHModelBaseWrapper { } static RefRowMatrixX3 vertices(BVHModelBase& bvh) { - return MapRowMatrixX3((*(bvh.vertices))[0].data(), bvh.num_vertices, 3); + if (bvh.num_vertices > 0) + return MapRowMatrixX3(bvh.vertices->data()->data(), bvh.num_vertices, 3); + else + return MapRowMatrixX3(NULL, bvh.num_vertices, 3); } static Triangle tri_indices(const BVHModelBase& bvh, unsigned int i) { diff --git a/test/python_unit/geometric_shapes.py b/test/python_unit/geometric_shapes.py index b64850e5996c1a20eea9cbee33820434cd3cb728..45f551feda29622506d629cb1654a30ccf25708f 100644 --- a/test/python_unit/geometric_shapes.py +++ b/test/python_unit/geometric_shapes.py @@ -156,6 +156,11 @@ class TestGeometricShapes(TestCase): Ic_ref = np.diag([Icx_ref, Icx_ref, Iz_ref]) self.assertApprox(Ic, Ic_ref) + def test_BVH(self): + bvh = hppfcl.BVHModelOBBRSS() + self.assertEqual(bvh.num_vertices, 0) + self.assertEqual(bvh.vertices().shape, (0, 3)) + def test_convex(self): verts = hppfcl.StdVec_Vec3f() faces = hppfcl.StdVec_Triangle()