@@ -231,23 +231,29 @@ TEST_CASE("[SceneTree][Camera3D] Project/Unproject position") {
231
231
test_camera->set_orthogonal (5 .0f , 0 .5f , 1000 .0f );
232
232
// Center.
233
233
CHECK (test_camera->project_position (Vector2 (200 , 100 ), 0 .5f ).is_equal_approx (Vector3 (0 , 0 , -0 .5f )));
234
+ CHECK (test_camera->project_position (Vector2 (200 , 100 ), test_camera->get_far ()).is_equal_approx (Vector3 (0 , 0 , -test_camera->get_far ())));
234
235
// Top left.
235
236
CHECK (test_camera->project_position (Vector2 (0 , 0 ), 1 .5f ).is_equal_approx (Vector3 (-5 .0f , 2 .5f , -1 .5f )));
237
+ CHECK (test_camera->project_position (Vector2 (0 , 0 ), test_camera->get_near ()).is_equal_approx (Vector3 (-5 .0f , 2 .5f , -test_camera->get_near ())));
236
238
// Bottom right.
237
239
CHECK (test_camera->project_position (Vector2 (400 , 200 ), 5 .0f ).is_equal_approx (Vector3 (5 .0f , -2 .5f , -5 .0f )));
240
+ CHECK (test_camera->project_position (Vector2 (400 , 200 ), test_camera->get_far ()).is_equal_approx (Vector3 (5 .0f , -2 .5f , -test_camera->get_far ())));
238
241
}
239
242
240
243
SUBCASE (" Perspective projection" ) {
241
244
test_camera->set_perspective (120 .0f , 0 .5f , 1000 .0f );
242
245
// Center.
243
246
CHECK (test_camera->project_position (Vector2 (200 , 100 ), 0 .5f ).is_equal_approx (Vector3 (0 , 0 , -0 .5f )));
244
247
CHECK (test_camera->project_position (Vector2 (200 , 100 ), 100 .0f ).is_equal_approx (Vector3 (0 , 0 , -100 .0f )));
248
+ CHECK (test_camera->project_position (Vector2 (200 , 100 ), test_camera->get_far ()).is_equal_approx (Vector3 (0 , 0 , -1 .0f ) * test_camera->get_far ()));
245
249
// 3/4th way to Top left.
246
250
CHECK (test_camera->project_position (Vector2 (100 , 50 ), 0 .5f ).is_equal_approx (Vector3 (-SQRT3 * 0 .5f , SQRT3 * 0 .25f , -0 .5f )));
247
251
CHECK (test_camera->project_position (Vector2 (100 , 50 ), 1 .0f ).is_equal_approx (Vector3 (-SQRT3, SQRT3 * 0 .5f , -1 .0f )));
252
+ CHECK (test_camera->project_position (Vector2 (100 , 50 ), test_camera->get_near ()).is_equal_approx (Vector3 (-SQRT3, SQRT3 * 0 .5f , -1 .0f ) * test_camera->get_near ()));
248
253
// 3/4th way to Bottom right.
249
254
CHECK (test_camera->project_position (Vector2 (300 , 150 ), 0 .5f ).is_equal_approx (Vector3 (SQRT3 * 0 .5f , -SQRT3 * 0 .25f , -0 .5f )));
250
255
CHECK (test_camera->project_position (Vector2 (300 , 150 ), 1 .0f ).is_equal_approx (Vector3 (SQRT3, -SQRT3 * 0 .5f , -1 .0f )));
256
+ CHECK (test_camera->project_position (Vector2 (300 , 150 ), test_camera->get_far ()).is_equal_approx (Vector3 (SQRT3, -SQRT3 * 0 .5f , -1 .0f ) * test_camera->get_far ()));
251
257
}
252
258
}
253
259
0 commit comments