Merge pull request #73847 from smix8/fix_shapecast3d_exception_functions_4.x

Fix ShapeCast3D add and remove exception functions
This commit is contained in:
Rémi Verschelde 2023-02-24 13:30:36 +01:00
commit e849f07335
No known key found for this signature in database
GPG Key ID: C3336907360768E1
3 changed files with 12 additions and 18 deletions

View File

@ -14,7 +14,7 @@
<methods> <methods>
<method name="add_exception"> <method name="add_exception">
<return type="void" /> <return type="void" />
<param index="0" name="node" type="Object" /> <param index="0" name="node" type="CollisionObject3D" />
<description> <description>
Adds a collision exception so the shape does not report collisions with the specified [CollisionObject3D] node. Adds a collision exception so the shape does not report collisions with the specified [CollisionObject3D] node.
</description> </description>
@ -108,7 +108,7 @@
</method> </method>
<method name="remove_exception"> <method name="remove_exception">
<return type="void" /> <return type="void" />
<param index="0" name="node" type="Object" /> <param index="0" name="node" type="CollisionObject3D" />
<description> <description>
Removes a collision exception so the shape does report collisions with the specified [CollisionObject3D] node. Removes a collision exception so the shape does report collisions with the specified [CollisionObject3D] node.
</description> </description>

View File

@ -437,26 +437,18 @@ void ShapeCast3D::add_exception_rid(const RID &p_rid) {
exclude.insert(p_rid); exclude.insert(p_rid);
} }
void ShapeCast3D::add_exception(const Object *p_object) { void ShapeCast3D::add_exception(const CollisionObject3D *p_node) {
ERR_FAIL_NULL(p_object); ERR_FAIL_NULL_MSG(p_node, "The passed Node must be an instance of CollisionObject3D.");
const CollisionObject3D *co = Object::cast_to<CollisionObject3D>(p_object); add_exception_rid(p_node->get_rid());
if (!co) {
return;
}
add_exception_rid(co->get_rid());
} }
void ShapeCast3D::remove_exception_rid(const RID &p_rid) { void ShapeCast3D::remove_exception_rid(const RID &p_rid) {
exclude.erase(p_rid); exclude.erase(p_rid);
} }
void ShapeCast3D::remove_exception(const Object *p_object) { void ShapeCast3D::remove_exception(const CollisionObject3D *p_node) {
ERR_FAIL_NULL(p_object); ERR_FAIL_NULL_MSG(p_node, "The passed Node must be an instance of CollisionObject3D.");
const CollisionObject3D *co = Object::cast_to<CollisionObject3D>(p_object); remove_exception_rid(p_node->get_rid());
if (!co) {
return;
}
remove_exception_rid(co->get_rid());
} }
void ShapeCast3D::clear_exceptions() { void ShapeCast3D::clear_exceptions() {

View File

@ -34,6 +34,8 @@
#include "scene/3d/node_3d.h" #include "scene/3d/node_3d.h"
#include "scene/resources/shape_3d.h" #include "scene/resources/shape_3d.h"
class CollisionObject3D;
class ShapeCast3D : public Node3D { class ShapeCast3D : public Node3D {
GDCLASS(ShapeCast3D, Node3D); GDCLASS(ShapeCast3D, Node3D);
@ -133,9 +135,9 @@ public:
bool is_colliding() const; bool is_colliding() const;
void add_exception_rid(const RID &p_rid); 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_rid(const RID &p_rid);
void remove_exception(const Object *p_object); void remove_exception(const CollisionObject3D *p_node);
void clear_exceptions(); void clear_exceptions();
virtual PackedStringArray get_configuration_warnings() const override; virtual PackedStringArray get_configuration_warnings() const override;