3232
3333#include " dart/dynamics/capsule_shape.hpp"
3434
35+ #include " dart/common/logging.hpp"
3536#include " dart/common/macros.hpp"
3637#include " dart/dynamics/cylinder_shape.hpp"
3738#include " dart/dynamics/sphere_shape.hpp"
@@ -43,11 +44,10 @@ namespace dart {
4344namespace dynamics {
4445
4546// ==============================================================================
46- CapsuleShape::CapsuleShape (double radius, double height)
47- : Shape(CAPSULE ), mRadius (radius), mHeight (height)
47+ CapsuleShape::CapsuleShape (double radius, double height) : Shape(CAPSULE )
4848{
49- DART_ASSERT ( 0.0 < radius);
50- DART_ASSERT ( 0.0 < height);
49+ setRadius ( radius);
50+ setHeight ( height);
5151}
5252
5353// ==============================================================================
@@ -72,7 +72,14 @@ double CapsuleShape::getRadius() const
7272// ==============================================================================
7373void CapsuleShape::setRadius (double radius)
7474{
75- DART_ASSERT (0.0 < radius);
75+ if (!std::isfinite (radius) || radius <= 0.0 ) {
76+ DART_WARN (
77+ " CapsuleShape::setRadius: Invalid radius '{}'. Radius must be a "
78+ " positive finite value. Ignoring request." ,
79+ radius);
80+ return ;
81+ }
82+
7683 mRadius = radius;
7784 mIsBoundingBoxDirty = true ;
7885 mIsVolumeDirty = true ;
@@ -89,7 +96,14 @@ double CapsuleShape::getHeight() const
8996// ==============================================================================
9097void CapsuleShape::setHeight (double height)
9198{
92- DART_ASSERT (0.0 < height);
99+ if (!std::isfinite (height) || height <= 0.0 ) {
100+ DART_WARN (
101+ " CapsuleShape::setHeight: Invalid height '{}'. Height must be a "
102+ " positive finite value. Ignoring request." ,
103+ height);
104+ return ;
105+ }
106+
93107 mHeight = height;
94108 mIsBoundingBoxDirty = true ;
95109 mIsVolumeDirty = true ;
0 commit comments