소스 검색

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

Juan Linietsky 9 년 전
부모
커밋
375fbe5c7c
1개의 변경된 파일9개의 추가작업 그리고 0개의 파일을 삭제
  1. 9 0
      scene/3d/spatial.cpp

+ 9 - 0
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);
 }