diff options
author | smix8 <52464204+smix8@users.noreply.github.com> | 2023-02-23 23:45:16 +0100 |
---|---|---|
committer | smix8 <52464204+smix8@users.noreply.github.com> | 2023-02-23 23:45:16 +0100 |
commit | 5d1a6e9b12df0b53af86c7a0cd31adaf1b900b06 (patch) | |
tree | 7ffd6e0a4e11ddfa63f4404884efa766cb8dca5a /scene | |
parent | e930c8d3838280e40baabc4426bd8236f7ac50a3 (diff) |
Fix ShapeCast3D add and remove exception functions
Fixes that ShapeCast3D would accept any parameter object and silently return when it was not a CollisionObject3D.
Diffstat (limited to 'scene')
-rw-r--r-- | scene/3d/shape_cast_3d.cpp | 20 | ||||
-rw-r--r-- | scene/3d/shape_cast_3d.h | 6 |
2 files changed, 10 insertions, 16 deletions
diff --git a/scene/3d/shape_cast_3d.cpp b/scene/3d/shape_cast_3d.cpp index 87361d6b38..d880e422f0 100644 --- a/scene/3d/shape_cast_3d.cpp +++ b/scene/3d/shape_cast_3d.cpp @@ -437,26 +437,18 @@ void ShapeCast3D::add_exception_rid(const RID &p_rid) { exclude.insert(p_rid); } -void ShapeCast3D::add_exception(const Object *p_object) { - ERR_FAIL_NULL(p_object); - const CollisionObject3D *co = Object::cast_to<CollisionObject3D>(p_object); - if (!co) { - return; - } - add_exception_rid(co->get_rid()); +void ShapeCast3D::add_exception(const CollisionObject3D *p_node) { + ERR_FAIL_NULL_MSG(p_node, "The passed Node must be an instance of CollisionObject3D."); + add_exception_rid(p_node->get_rid()); } void ShapeCast3D::remove_exception_rid(const RID &p_rid) { exclude.erase(p_rid); } -void ShapeCast3D::remove_exception(const Object *p_object) { - ERR_FAIL_NULL(p_object); - const CollisionObject3D *co = Object::cast_to<CollisionObject3D>(p_object); - if (!co) { - return; - } - remove_exception_rid(co->get_rid()); +void ShapeCast3D::remove_exception(const CollisionObject3D *p_node) { + ERR_FAIL_NULL_MSG(p_node, "The passed Node must be an instance of CollisionObject3D."); + remove_exception_rid(p_node->get_rid()); } void ShapeCast3D::clear_exceptions() { diff --git a/scene/3d/shape_cast_3d.h b/scene/3d/shape_cast_3d.h index 344f1d3b8a..98158d3c7c 100644 --- a/scene/3d/shape_cast_3d.h +++ b/scene/3d/shape_cast_3d.h @@ -34,6 +34,8 @@ #include "scene/3d/node_3d.h" #include "scene/resources/shape_3d.h" +class CollisionObject3D; + class ShapeCast3D : public Node3D { GDCLASS(ShapeCast3D, Node3D); @@ -133,9 +135,9 @@ public: bool is_colliding() const; void add_exception_rid(const RID &p_rid); - void add_exception(const Object *p_object); + void add_exception(const CollisionObject3D *p_node); void remove_exception_rid(const RID &p_rid); - void remove_exception(const Object *p_object); + void remove_exception(const CollisionObject3D *p_node); void clear_exceptions(); virtual PackedStringArray get_configuration_warnings() const override; |