Skip to content

Commit

Permalink
Merge pull request coal-library#506 from jcarpent/topic/hppfcl3x
Browse files Browse the repository at this point in the history
Fix segfault issue in Python bindings
  • Loading branch information
jcarpent authored Dec 31, 2023
2 parents ad38e3a + f1c068f commit c2c84e3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 4 additions & 1 deletion python/collision-geometries.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
5 changes: 5 additions & 0 deletions test/python_unit/geometric_shapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ def test_cone(self):
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()
Expand Down

0 comments on commit c2c84e3

Please sign in to comment.