From ec84ddb5a4de42720e59d3d2f62c804b344cb5fd Mon Sep 17 00:00:00 2001 From: Alessio Quaglino Date: Tue, 30 Apr 2024 09:28:17 -0700 Subject: [PATCH] Use plane-convex for plane-sdf collisions, using the marching cube mesh. PiperOrigin-RevId: 629437563 Change-Id: Ic7fb6ec8a5c6680dd2c0a71baa7cc78636d478b1 --- src/engine/engine_collision_convex.c | 1 + src/engine/engine_collision_driver.c | 2 +- src/user/user_model.cc | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/engine/engine_collision_convex.c b/src/engine/engine_collision_convex.c index eed233b5..e6ea9b0d 100644 --- a/src/engine/engine_collision_convex.c +++ b/src/engine/engine_collision_convex.c @@ -163,6 +163,7 @@ void mjccd_support(const void *obj, const ccd_vec3_t *_dir, ccd_vec3_t *vec) { break; case mjGEOM_MESH: + case mjGEOM_SDF: // init search vertdata = m->mesh_vert + 3*m->mesh_vertadr[m->geom_dataid[g]]; tmp = -1E+10; diff --git a/src/engine/engine_collision_driver.c b/src/engine/engine_collision_driver.c index e3a18c2d..194def86 100644 --- a/src/engine/engine_collision_driver.c +++ b/src/engine/engine_collision_driver.c @@ -40,7 +40,7 @@ // table of pair-wise collision functions mjfCollision mjCOLLISIONFUNC[mjNGEOMTYPES][mjNGEOMTYPES] = { /* PLANE HFIELD SPHERE CAPSULE ELLIPSOID CYLINDER BOX MESH SDF */ - /*PLANE */ {0, 0, mjc_PlaneSphere, mjc_PlaneCapsule, mjc_PlaneConvex, mjc_PlaneCylinder, mjc_PlaneBox, mjc_PlaneConvex, mjc_SDF}, + /*PLANE */ {0, 0, mjc_PlaneSphere, mjc_PlaneCapsule, mjc_PlaneConvex, mjc_PlaneCylinder, mjc_PlaneBox, mjc_PlaneConvex, mjc_PlaneConvex}, /*HFIELD */ {0, 0, mjc_ConvexHField, mjc_ConvexHField, mjc_ConvexHField, mjc_ConvexHField, mjc_ConvexHField, mjc_ConvexHField, mjc_HFieldSDF}, /*SPHERE */ {0, 0, mjc_SphereSphere, mjc_SphereCapsule, mjc_Convex, mjc_SphereCylinder, mjc_SphereBox, mjc_Convex, mjc_SDF}, /*CAPSULE */ {0, 0, 0, mjc_CapsuleCapsule, mjc_Convex, mjc_Convex, mjc_CapsuleBox, mjc_Convex, mjc_SDF}, diff --git a/src/user/user_model.cc b/src/user/user_model.cc index 9b55c703..6c1e547c 100644 --- a/src/user/user_model.cc +++ b/src/user/user_model.cc @@ -3213,7 +3213,8 @@ void mjCModel::TryCompile(mjModel*& m, mjData*& d, const mjVFS* vfs) { // mark meshes that need convex hull for (int i=0; imesh && geoms[i]->spec.type==mjGEOM_MESH && + if (geoms[i]->mesh && + (geoms[i]->spec.type==mjGEOM_MESH || geoms[i]->spec.type==mjGEOM_SDF) && (geoms[i]->spec.contype || geoms[i]->spec.conaffinity)) { geoms[i]->mesh->set_needhull(true); }