Check obj and ref types before casting them to a geom.

PiperOrigin-RevId: 686616350
Change-Id: I43b14344df6324b371c6bb2447c63197b88178d5
This commit is contained in:
Alessio Quaglino
2024-10-16 13:14:53 -07:00
committed by Copybara-Service
parent c2024ef6d1
commit 8740533644
+2 -2
View File
@@ -6402,8 +6402,8 @@ void mjCSensor::Compile(void) {
}
// height fields are not necessarily convex and are not yet supported
if (static_cast<mjCGeom*>(obj)->Type() == mjGEOM_HFIELD ||
static_cast<mjCGeom*>(ref)->Type() == mjGEOM_HFIELD) {
if ((objtype == mjOBJ_GEOM && static_cast<mjCGeom*>(obj)->Type() == mjGEOM_HFIELD) ||
(reftype == mjOBJ_GEOM && static_cast<mjCGeom*>(ref)->Type() == mjGEOM_HFIELD)) {
throw mjCError(this, "height fields are not supported in geom distance sensors");
}