Skip to content

Commit 42f7a0c

Browse files
committed
add convex option to meshraw
1 parent 235ad91 commit 42f7a0c

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

include/xbot2_interface/collision.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ struct XBOT2IFC_API Shape
6969
{
7070
std::vector<Eigen::Vector3d> vertices;
7171
std::vector<Eigen::Vector3i> triangles;
72+
bool convex = false;
7273
};
7374

7475
using Variant = std::variant<

src/collision/collision.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,12 @@ bool CollisionModel::Impl::addCollisionShape(string_const_ref name,
622622
bvhModel->addSubModel(vertices, triangles);
623623
bvhModel->endModel();
624624

625+
if(mr.convex)
626+
{
627+
bvhModel->buildConvexHull(true, "Qt");
628+
fcl_geom = bvhModel->convex;
629+
}
630+
625631
std::cout << "mesh raw";
626632

627633

@@ -673,12 +679,6 @@ bool CollisionModel::Impl::addCollisionShape(string_const_ref name,
673679
fcl_geom = bvhModel->convex;
674680
}
675681

676-
if(m.convex)
677-
{
678-
bvhModel->buildConvexHull(true, "Qt");
679-
fcl_geom = bvhModel->convex;
680-
}
681-
682682
std::cout << "mesh";
683683

684684
return true;
@@ -1242,7 +1242,7 @@ void CollisionModel::Impl::CollisionPairData::compute_distance(const ModelInterf
12421242
if(threshold > 0 && aabb_dist > threshold)
12431243
{
12441244
dresult.min_distance = aabb_dist;
1245-
dresult.normal = (dresult.nearest_points[1]-dresult.nearest_points[0]).normalized();
1245+
dresult.normal = (dresult.nearest_points[1] - dresult.nearest_points[0]).normalized();
12461246
return;
12471247
}
12481248

@@ -1267,6 +1267,7 @@ void CollisionModel::Impl::CollisionPairData::compute_distance(const ModelInterf
12671267
drequest,
12681268
dresult);
12691269

1270+
12701271
// hack to fix wrong distance when in deep collision
12711272
if(dresult.min_distance < 0)
12721273
{

0 commit comments

Comments
 (0)