Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1741 Rolling camera and then interacting with the view provide incorrect interactions #1879

Merged
merged 11 commits into from
Jan 12, 2025
2 changes: 1 addition & 1 deletion .github/actions/generic-ci/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ runs:
runner.os == 'macOS' &&
inputs.cpu == 'arm64'
shell: bash
run: echo "F3D_CTEST_EXCEPTIONS=(TestDepthPeelingToneMapping)|(TestDepthPeeling)|(TestTextureColor)|(TestDXF)|(TestScalarsCell)|(TestXCAFColors)|(TestGrid)|(TestConfig)|(TestGLTFDracoImporter)|(TestInteractionActors)|(TestInteractionFocalPointPickingPoints)|(TestInteractionCycleAnimation)|(TestInteractionAnimationSlow)|(TestInteractionConfigFileInteractions)|(TestGLTFRigArmature)" >> $GITHUB_ENV
run: echo "F3D_CTEST_EXCEPTIONS=(TestDepthPeelingToneMapping)|(TestDepthPeeling)|(TestTextureColor)|(TestDXF)|(TestScalarsCell)|(TestXCAFColors)|(TestGrid)|(TestConfig)|(TestGLTFDracoImporter)|(TestInteractionActors)|(TestInteractionFocalPointPickingPoints)|(TestInteractionCycleAnimation)|(TestInteractionAnimationSlow)|(TestInteractionConfigFileInteractions)|(TestGLTFRigArmature)|(TestInteractionRollCameraRotation)" >> $GITHUB_ENV

- name: Test
shell: bash
Expand Down
1 change: 1 addition & 0 deletions application/testing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,7 @@ f3d_test(NAME TestInteractionOrthographicProjection DATA cow.vtp INTERACTION) #5
f3d_test(NAME TestInteractionZoomToggleOrthographicProjection DATA cow.vtp INTERACTION) #MouseWheel;5;Mousewheelx6;5
f3d_test(NAME TestInteractionRotateCameraMinus90 DATA f3d.glb INTERACTION)
f3d_test(NAME TestInteractionRotateCamera90 DATA f3d.glb INTERACTION)
f3d_test(NAME TestInteractionRollCameraRotation DATA f3d.glb ARGS -g INTERACTION) #1;4;LeftMouse;MouseMovements
f3d_test(NAME TestInteractionPanWithShift DATA f3d.glb INTERACTION) #Shift;LeftMouse;MouseMovements
f3d_test(NAME TestInteractionConsoleOpen DATA f3d.glb INTERACTION UI) #Escape
f3d_test(NAME TestInteractionConsoleOpenExit DATA f3d.glb REGEXP "Interactor has been stopped" INTERACTION NO_BASELINE UI) #Escape;exit;Return
Expand Down
14 changes: 13 additions & 1 deletion library/src/interactor_impl.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ class interactor_impl::internals

this->Recorder = vtkSmartPointer<vtkF3DInteractorEventRecorder>::New();
this->Recorder->SetInteractor(this->VTKInteractor);

this->Style->ResetTemporaryUp();
}

//----------------------------------------------------------------------------
Expand Down Expand Up @@ -687,6 +689,8 @@ interactor& interactor_impl::initCommands()
{
check_args(args, 1, "roll_camera");
this->Internals->Window.getCamera().roll(options::parse<int>(args[0]));
this->Internals->Style->SetTemporaryUp(
this->Internals->Window.getCamera().getViewUp().data());
});

this->addCommand("increase_light_intensity",
Expand Down Expand Up @@ -727,18 +731,22 @@ interactor& interactor_impl::initCommands()
if (type == "front")
{
this->Internals->SetViewOrbit(internals::ViewType::VT_FRONT);
this->Internals->Style->ResetTemporaryUp();
}
else if (type == "top")
{
this->Internals->SetViewOrbit(internals::ViewType::VT_TOP);
this->Internals->Style->ResetTemporaryUp();
}
else if (type == "right")
{
this->Internals->SetViewOrbit(internals::ViewType::VT_RIGHT);
this->Internals->Style->ResetTemporaryUp();
}
else if (type == "isometric")
{
this->Internals->SetViewOrbit(internals::ViewType::VT_ISOMETRIC);
this->Internals->Style->ResetTemporaryUp();
}
else
{
Expand All @@ -758,7 +766,11 @@ interactor& interactor_impl::initCommands()
this->addCommand("stop_interactor", [&](const std::vector<std::string>&) { this->stop(); });

this->addCommand("reset_camera",
[&](const std::vector<std::string>&) { this->Internals->Window.getCamera().resetToDefault(); });
[&](const std::vector<std::string>&)
{
this->Internals->Window.getCamera().resetToDefault();
this->Internals->Style->ResetTemporaryUp();
});

this->addCommand("toggle_animation",
[&](const std::vector<std::string>&) { this->Internals->AnimationManager->ToggleAnimation(); });
Expand Down
3 changes: 3 additions & 0 deletions testing/baselines/TestInteractionRollCameraRotation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 53 additions & 0 deletions testing/recordings/TestInteractionRollCameraRotation.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# StreamVersion 1.2
EnterEvent 923 334 0 0 0 0 0
RenderEvent 920 336 0 0 0 0 0

KeyPressEvent 840 342 0 52 1 4 0
CharEvent 840 342 0 52 1 4 0
KeyReleaseEvent 840 342 0 52 1 4 0

LeftButtonPressEvent 843 339 0 0 0 4 0
StartInteractionEvent 843 339 0 0 0 4 0
TimerEvent 843 339 0 0 0 4 0
TimerEvent 843 339 0 0 0 4 0
MouseMoveEvent 842 339 0 0 0 4 0
RenderEvent 842 339 0 0 0 4 0
InteractionEvent 842 339 0 0 0 4 0
MouseMoveEvent 841 340 0 0 0 4 0
RenderEvent 841 340 0 0 0 4 0
InteractionEvent 841 340 0 0 0 4 0
MouseMoveEvent 840 340 0 0 0 4 0
RenderEvent 840 340 0 0 0 4 0
InteractionEvent 840 340 0 0 0 4 0
MouseMoveEvent 840 341 0 0 0 4 0
RenderEvent 840 341 0 0 0 4 0
InteractionEvent 840 341 0 0 0 4 0
MouseMoveEvent 839 341 0 0 0 4 0
RenderEvent 839 341 0 0 0 4 0
InteractionEvent 839 341 0 0 0 4 0
TimerEvent 839 341 0 0 0 4 0
MouseMoveEvent 837 342 0 0 0 4 0
RenderEvent 837 342 0 0 0 4 0
InteractionEvent 837 342 0 0 0 4 0
MouseMoveEvent 835 342 0 0 0 4 0
RenderEvent 835 342 0 0 0 4 0
InteractionEvent 835 342 0 0 0 4 0
MouseMoveEvent 834 342 0 0 0 4 0
RenderEvent 834 342 0 0 0 4 0
InteractionEvent 834 342 0 0 0 4 0
MouseMoveEvent 833 342 0 0 0 4 0
RenderEvent 833 342 0 0 0 4 0
InteractionEvent 833 342 0 0 0 4 0
TimerEvent 833 342 0 0 0 4 0
MouseMoveEvent 832 342 0 0 0 4 0
RenderEvent 832 342 0 0 0 4 0
InteractionEvent 832 342 0 0 0 4 0
MouseMoveEvent 831 342 0 0 0 4 0
RenderEvent 831 342 0 0 0 4 0
InteractionEvent 831 342 0 0 0 4 0
MouseMoveEvent 831 343 0 0 0 4 0
RenderEvent 831 343 0 0 0 4 0
InteractionEvent 831 343 0 0 0 4 0
TimerEvent 831 343 0 0 0 4 0
LeftButtonReleaseEvent 831 343 0 0 0 4 0
EndInteractionEvent 831 343 0 0 0 4 0
34 changes: 34 additions & 0 deletions vtkext/private/module/vtkF3DInteractorStyle.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ void vtkF3DInteractorStyle::Rotate()
double dir[3];
camera->GetDirectionOfProjection(dir);
double* up = ren->GetUpVector();
this->InterpolateTemporaryUp(0.1, up);
up = this->TemporaryUp;

double dot = vtkMath::Dot(dir, up);

Expand Down Expand Up @@ -332,3 +334,35 @@ void vtkF3DInteractorStyle::FindPokedRenderer(int vtkNotUsed(x), int vtkNotUsed(
// No need for picking, F3D interaction are only with the first renderer
this->SetCurrentRenderer(this->Interactor->GetRenderWindow()->GetRenderers()->GetFirstRenderer());
}

//------------------------------------------------------------------------------
void vtkF3DInteractorStyle::ResetTemporaryUp()
{
// Make sure this->CurrentRenderer is set
this->FindPokedRenderer(0, 0);

if (this->CurrentRenderer)
{
vtkF3DRenderer* ren = vtkF3DRenderer::SafeDownCast(this->CurrentRenderer);
SetTemporaryUp(ren->GetUpVector());
}
}

//------------------------------------------------------------------------------
void vtkF3DInteractorStyle::SetTemporaryUp(const double *tempUp)
{
for (int i = 0; i < 3; i++)
{
this->TemporaryUp[i] = tempUp[i];
}
}

//------------------------------------------------------------------------------
void vtkF3DInteractorStyle::InterpolateTemporaryUp(double factor, const double* input)
{
for (int i = 0; i < 3; i++)
{
this->TemporaryUp[i] = (1.0 - factor) * this->TemporaryUp[i] + factor * input[i];
}
vtkMath::Normalize(this->TemporaryUp);
}
12 changes: 12 additions & 0 deletions vtkext/private/module/vtkF3DInteractorStyle.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,25 @@ class vtkF3DInteractorStyle : public vtkInteractorStyleTrackballCamera
*/
void FindPokedRenderer(int vtkNotUsed(x), int vtkNotUsed(y));

/**
* Temporary up vector to support rolled camera interaction
*/
void ResetTemporaryUp();
void SetTemporaryUp(const double *tempUp);
void InterpolateTemporaryUp(const double factor, const double* input);

protected:
/**
* Overridden to support being disabled
*/
void Dolly(double factor) override;

bool CameraMovementDisabled = false;

/**
* Temporary up vector to support rolled camera interaction
*/
double TemporaryUp[3] = { 0, 0, 0 };
mwestphal marked this conversation as resolved.
Show resolved Hide resolved
};

#endif
Loading