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 committed by Relintai
parent 0b5e773f02
commit 90f81c0013
5 changed files with 10 additions and 30 deletions

View File

@ -257,9 +257,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());
}
@ -270,9 +268,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

@ -808,9 +808,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());
}
@ -821,9 +819,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

@ -238,9 +238,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());
}
@ -251,9 +249,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

@ -430,9 +430,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());
}
@ -443,9 +441,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());
}