Show descriptive errors when look_at is improperly used, closes #5131

(cherry picked from commit 375fbe5c7c
and db1e9bac79)
This commit is contained in:
Juan Linietsky 2016-06-11 17:22:07 -03:00 committed by Rémi Verschelde
parent dd7e7c94c1
commit 8289760227
1 changed files with 9 additions and 0 deletions

View File

@ -712,6 +712,15 @@ void Spatial::look_at(const Vector3& p_target, const Vector3& p_up_normal) {
Transform lookat; Transform lookat;
lookat.origin=get_global_transform().origin; lookat.origin=get_global_transform().origin;
if (lookat.origin==p_target) {
ERR_EXPLAIN("Node origin and target are in the same position, look_at() failed");
ERR_FAIL();
}
if (p_up_normal.cross(p_target-lookat.origin)==Vector3()) {
ERR_EXPLAIN("Up vector and direction between node origin and target are aligned, look_at() failed");
ERR_FAIL();
}
lookat=lookat.looking_at(p_target,p_up_normal); lookat=lookat.looking_at(p_target,p_up_normal);
set_global_transform(lookat); set_global_transform(lookat);
} }