소스 검색

Merge pull request #99726 from smix8/path_simply_test

Add test for NavigationServer path simplification
Rémi Verschelde 9 달 전
부모
커밋
90087476a3
1개의 변경된 파일15개의 추가작업 그리고 0개의 파일을 삭제
  1. 15 0
      tests/servers/test_navigation_server_3d.h

+ 15 - 0
tests/servers/test_navigation_server_3d.h

@@ -816,6 +816,21 @@ TEST_SUITE("[Navigation]") {
 	}
 	*/
 
+	TEST_CASE("[NavigationServer3D] Server should simplify path properly") {
+		real_t simplify_epsilon = 0.2;
+		Vector<Vector3> source_path;
+		source_path.resize(7);
+		source_path.write[0] = Vector3(0.0, 0.0, 0.0);
+		source_path.write[1] = Vector3(0.0, 0.0, 1.0); // This point needs to go.
+		source_path.write[2] = Vector3(0.0, 0.0, 2.0); // This point needs to go.
+		source_path.write[3] = Vector3(0.0, 0.0, 2.0);
+		source_path.write[4] = Vector3(2.0, 1.0, 3.0);
+		source_path.write[5] = Vector3(2.0, 1.5, 4.0); // This point needs to go.
+		source_path.write[6] = Vector3(2.0, 2.0, 5.0);
+		Vector<Vector3> simplified_path = NavigationServer3D::get_singleton()->simplify_path(source_path, simplify_epsilon);
+		CHECK_EQ(simplified_path.size(), 4);
+	}
+
 	TEST_CASE("[Heap] size") {
 		gd::Heap<int> heap;