Add error messages for collision exception functions

Adds error messages to collision exception functions when used with the wrong object/node instead of failing silently.
This commit is contained in:
smix8 2023-02-24 00:36:30 +01:00
parent ca823e16e4
commit c7a92f68a1
5 changed files with 10 additions and 30 deletions

View file

@ -256,9 +256,7 @@ void RayCast2D::add_exception_rid(const RID &p_rid) {
void RayCast2D::add_exception(const Object *p_object) {
ERR_FAIL_NULL(p_object);
const CollisionObject2D *co = Object::cast_to<CollisionObject2D>(p_object);
if (!co) {
return;
}
ERR_FAIL_COND_MSG(!co, "The passed Node must be an instance of CollisionObject2D.");
add_exception_rid(co->get_rid());
}
@ -269,9 +267,7 @@ void RayCast2D::remove_exception_rid(const RID &p_rid) {
void RayCast2D::remove_exception(const Object *p_object) {
ERR_FAIL_NULL(p_object);
const CollisionObject2D *co = Object::cast_to<CollisionObject2D>(p_object);
if (!co) {
return;
}
ERR_FAIL_COND_MSG(!co, "The passed Node must be an instance of CollisionObject2D.");
remove_exception_rid(co->get_rid());
}

View file

@ -323,9 +323,7 @@ void ShapeCast2D::add_exception_rid(const RID &p_rid) {
void ShapeCast2D::add_exception(const Object *p_object) {
ERR_FAIL_NULL(p_object);
const CollisionObject2D *co = Object::cast_to<CollisionObject2D>(p_object);
if (!co) {
return;
}
ERR_FAIL_COND_MSG(!co, "The passed Node must be an instance of CollisionObject2D.");
add_exception_rid(co->get_rid());
}
@ -336,9 +334,7 @@ void ShapeCast2D::remove_exception_rid(const RID &p_rid) {
void ShapeCast2D::remove_exception(const Object *p_object) {
ERR_FAIL_NULL(p_object);
const CollisionObject2D *co = Object::cast_to<CollisionObject2D>(p_object);
if (!co) {
return;
}
ERR_FAIL_COND_MSG(!co, "The passed Node must be an instance of CollisionObject2D.");
remove_exception_rid(co->get_rid());
}

View file

@ -797,9 +797,7 @@ void ClippedCamera::add_exception_rid(const RID &p_rid) {
void ClippedCamera::add_exception(const Object *p_object) {
ERR_FAIL_NULL(p_object);
const CollisionObject *co = Object::cast_to<CollisionObject>(p_object);
if (!co) {
return;
}
ERR_FAIL_COND_MSG(!co, "The passed Node must be an instance of CollisionObject.");
add_exception_rid(co->get_rid());
}
@ -810,9 +808,7 @@ void ClippedCamera::remove_exception_rid(const RID &p_rid) {
void ClippedCamera::remove_exception(const Object *p_object) {
ERR_FAIL_NULL(p_object);
const CollisionObject *co = Object::cast_to<CollisionObject>(p_object);
if (!co) {
return;
}
ERR_FAIL_COND_MSG(!co, "The passed Node must be an instance of CollisionObject.");
remove_exception_rid(co->get_rid());
}

View file

@ -235,9 +235,7 @@ void RayCast::add_exception_rid(const RID &p_rid) {
void RayCast::add_exception(const Object *p_object) {
ERR_FAIL_NULL(p_object);
const CollisionObject *co = Object::cast_to<CollisionObject>(p_object);
if (!co) {
return;
}
ERR_FAIL_COND_MSG(!co, "The passed Node must be an instance of CollisionObject.");
add_exception_rid(co->get_rid());
}
@ -248,9 +246,7 @@ void RayCast::remove_exception_rid(const RID &p_rid) {
void RayCast::remove_exception(const Object *p_object) {
ERR_FAIL_NULL(p_object);
const CollisionObject *co = Object::cast_to<CollisionObject>(p_object);
if (!co) {
return;
}
ERR_FAIL_COND_MSG(!co, "The passed Node must be an instance of CollisionObject.");
remove_exception_rid(co->get_rid());
}

View file

@ -427,9 +427,7 @@ void ShapeCast::add_exception_rid(const RID &p_rid) {
void ShapeCast::add_exception(const Object *p_object) {
ERR_FAIL_NULL(p_object);
const CollisionObject *co = Object::cast_to<CollisionObject>(p_object);
if (!co) {
return;
}
ERR_FAIL_COND_MSG(!co, "The passed Node must be an instance of CollisionObject.");
add_exception_rid(co->get_rid());
}
@ -440,9 +438,7 @@ void ShapeCast::remove_exception_rid(const RID &p_rid) {
void ShapeCast::remove_exception(const Object *p_object) {
ERR_FAIL_NULL(p_object);
const CollisionObject *co = Object::cast_to<CollisionObject>(p_object);
if (!co) {
return;
}
ERR_FAIL_COND_MSG(!co, "The passed Node must be an instance of CollisionObject.");
remove_exception_rid(co->get_rid());
}