diff options
author | Juan Linietsky <reduzio@gmail.com> | 2016-06-11 17:22:07 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2016-06-11 17:22:48 -0300 |
commit | 375fbe5c7ce5ebeb45a04e7f6b8aa72b9fb06507 (patch) | |
tree | b666bb863ca27cd9f1456437e5b8ad8bb619c457 | |
parent | b5f2ea542a563fc44870417f1343fd9cb9acc253 (diff) |
Show descriptive errors when look_at is improperly used, closes #5131
-rw-r--r-- | scene/3d/spatial.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/scene/3d/spatial.cpp b/scene/3d/spatial.cpp index 6a9c655141..39225284dc 100644 --- a/scene/3d/spatial.cpp +++ b/scene/3d/spatial.cpp @@ -712,6 +712,15 @@ void Spatial::look_at(const Vector3& p_target, const Vector3& p_up_normal) { Transform lookat; 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 align, look_at() failed"); + ERR_FAIL(); + } lookat=lookat.looking_at(p_target,p_up_normal); set_global_transform(lookat); } |