@@ -455,14 +455,22 @@ void TestQgs3DCameraController::testRotationCenterZoomWheelRotationCenter()
455
455
456
456
// look from the top
457
457
scene->cameraController ()->setLookingAtPoint ( QgsVector3D ( 0 , 0 , 0 ), 2500 , 0 , 0 );
458
+ // XXX: Sometimes the near/far planes aren't calculated correctly, so they're
459
+ // left at the too-deep default. This causes the rest of the test to fail in
460
+ // weird ways every once in a while, so loop until we get good values.
461
+ do {
462
+ // Force recalcualtion of near/far planes.
463
+ scene->cameraController ()->mCameraChanged = true ;
464
+
465
+ // this call is not used but ensures to synchronize the scene
466
+ Qgs3DUtils::captureSceneImage ( engine, scene );
467
+ } while (scene->cameraController ()->camera ()->nearPlane () < 1000 );
468
+
458
469
QVector3D initialCamViewCenter = scene->cameraController ()->camera ()->viewCenter ();
459
470
QVector3D initialCamPosition = scene->cameraController ()->camera ()->position ();
460
471
float initialPitch = scene->cameraController ()->pitch ();
461
472
float initialYaw = scene->cameraController ()->yaw ();
462
473
463
- // this call is not used but ensures to synchronize the scene
464
- Qgs3DUtils::captureSceneImage ( engine, scene );
465
-
466
474
QMouseEvent mousePressEvent ( QEvent::MouseButtonPress, midPos, Qt::LeftButton, Qt::LeftButton, Qt::ShiftModifier );
467
475
scene->cameraController ()->onMousePressed ( new Qt3DInput::QMouseEvent ( mousePressEvent ) );
468
476
@@ -522,8 +530,8 @@ void TestQgs3DCameraController::testRotationCenterZoomWheelRotationCenter()
522
530
depthImage = Qgs3DUtils::captureSceneDepthBuffer ( engine, scene );
523
531
scene->cameraController ()->depthBufferCaptured ( depthImage );
524
532
525
- QGSCOMPARENEARVECTOR3D ( scene->cameraController ()->mZoomPoint , QVector3D ( 283.2 , -923.1 , -27.0 ), 1.5 );
526
- QGSCOMPARENEARVECTOR3D ( scene->cameraController ()->cameraPose ().centerPoint (), QVector3D ( 99.4 , -319.9 , -8.8 ), 2.0 );
533
+ QGSCOMPARENEARVECTOR3D ( scene->cameraController ()->mZoomPoint , QVector3D ( 312.936 , -950.772 , -125.381 ), 1.5 );
534
+ QGSCOMPARENEARVECTOR3D ( scene->cameraController ()->cameraPose ().centerPoint (), QVector3D ( 109.8 , -329.4 , -43.3 ), 2.0 );
527
535
QGSCOMPARENEAR ( scene->cameraController ()->cameraPose ().distanceFromCenterPoint (), 1631.9 , 2.0 );
528
536
QCOMPARE ( scene->cameraController ()->pitch (), initialPitch );
529
537
QCOMPARE ( scene->cameraController ()->yaw (), initialYaw );
@@ -540,6 +548,7 @@ void TestQgs3DCameraController::testRotationCenterZoomWheelRotationCenter()
540
548
initialPitch = scene->cameraController ()->pitch ();
541
549
initialYaw = scene->cameraController ()->yaw ();
542
550
551
+ Qgs3DUtils::waitForFrame (engine, scene);
543
552
// the first mouse event only updates the mouse position
544
553
// the second one will update the camera
545
554
QMouseEvent mouseMoveEvent3 ( QEvent::MouseMove, midPos + movement1 + movement2, Qt::LeftButton, Qt::LeftButton, Qt::ShiftModifier );
@@ -558,9 +567,9 @@ void TestQgs3DCameraController::testRotationCenterZoomWheelRotationCenter()
558
567
QCOMPARE ( scene->cameraController ()->mCurrentOperation , QgsCameraController::MouseOperation::RotationCenter );
559
568
560
569
diffViewCenter = scene->cameraController ()->camera ()->viewCenter () - initialCamViewCenter;
561
- QGSCOMPARENEARVECTOR3D ( diffViewCenter, QVector3D ( 25 .9 , 7.1 , 5.2 ), 1 .0 );
570
+ QGSCOMPARENEARVECTOR3D ( diffViewCenter, QVector3D ( 26 .9 , 7.3 , 5.4 ), 2 .0 );
562
571
diffPosition = scene->cameraController ()->camera ()->position () - initialCamPosition;
563
- QGSCOMPARENEARVECTOR3D ( diffPosition, QVector3D ( -44.3 , -9.1 , -11.7 ), 1.0 );
572
+ QGSCOMPARENEARVECTOR3D ( diffPosition, QVector3D ( -43.2 , -9.1 , -11.1 ), 1.0 );
564
573
diffPitch = scene->cameraController ()->pitch () - initialPitch;
565
574
diffYaw = scene->cameraController ()->yaw () - initialYaw;
566
575
QGSCOMPARENEAR ( diffPitch, 2.5 , 0.1 );
@@ -857,9 +866,9 @@ void TestQgs3DCameraController::testTranslateZoomWheelTranslate()
857
866
QCOMPARE ( scene->cameraController ()->mCurrentOperation , QgsCameraController::MouseOperation::Translation );
858
867
859
868
diffViewCenter = scene->cameraController ()->camera ()->viewCenter () - initialCamViewCenter;
860
- QGSCOMPARENEARVECTOR3D ( diffViewCenter, QVector3D ( -11.3 , 11.3 , 0.0 ), 1.0 );
869
+ QGSCOMPARENEARVECTOR3D ( diffViewCenter, QVector3D ( -17.2 , 17.2 , 0.0 ), 1.0 );
861
870
diffPosition = scene->cameraController ()->camera ()->position () - initialCamPosition;
862
- QGSCOMPARENEARVECTOR3D ( diffPosition, QVector3D ( -11.3 , 11.3 , 0.0 ), 1.0 );
871
+ QGSCOMPARENEARVECTOR3D ( diffPosition, QVector3D ( -17.2 , 17.2 , 0.0 ), 1.0 );
863
872
QCOMPARE ( scene->cameraController ()->pitch (), initialPitch );
864
873
QCOMPARE ( scene->cameraController ()->yaw (), initialYaw );
865
874
0 commit comments