From 87405336445c530bf2e35ba7a572e92f89c6bd0d Mon Sep 17 00:00:00 2001 From: Alessio Quaglino Date: Wed, 16 Oct 2024 13:14:53 -0700 Subject: [PATCH] Check obj and ref types before casting them to a geom. PiperOrigin-RevId: 686616350 Change-Id: I43b14344df6324b371c6bb2447c63197b88178d5 --- src/user/user_objects.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/user/user_objects.cc b/src/user/user_objects.cc index 7d40e0d1..5a50ef87 100644 --- a/src/user/user_objects.cc +++ b/src/user/user_objects.cc @@ -6402,8 +6402,8 @@ void mjCSensor::Compile(void) { } // height fields are not necessarily convex and are not yet supported - if (static_cast(obj)->Type() == mjGEOM_HFIELD || - static_cast(ref)->Type() == mjGEOM_HFIELD) { + if ((objtype == mjOBJ_GEOM && static_cast(obj)->Type() == mjGEOM_HFIELD) || + (reftype == mjOBJ_GEOM && static_cast(ref)->Type() == mjGEOM_HFIELD)) { throw mjCError(this, "height fields are not supported in geom distance sensors"); }