Fix issue with mouse input for viewport camera (#3210)
* fix for drift accumulating in the viewport camera Signed-off-by: hultonha <hultonha@amazon.co.uk> * fix typo and update how events are stored Signed-off-by: hultonha <hultonha@amazon.co.uk> * respond to PR feedback and fix linux and windows build issues Signed-off-by: hultonha <hultonha@amazon.co.uk> * fix failing unit tests in camera input Signed-off-by: hultonha <hultonha@amazon.co.uk>
This commit is contained in:
@@ -132,12 +132,11 @@ namespace AZ::ViewportHelpers
|
||||
{
|
||||
static const char TextCantCreateCameraNoLevel[] = "Cannot create camera when no level is loaded.";
|
||||
|
||||
class EditorEntityNotifications
|
||||
: public AzToolsFramework::EditorEntityContextNotificationBus::Handler
|
||||
class EditorEntityNotifications : public AzToolsFramework::EditorEntityContextNotificationBus::Handler
|
||||
{
|
||||
public:
|
||||
EditorEntityNotifications(EditorViewportWidget& renderViewport)
|
||||
: m_renderViewport(renderViewport)
|
||||
EditorEntityNotifications(EditorViewportWidget& editorViewportWidget)
|
||||
: m_editorViewportWidget(editorViewportWidget)
|
||||
{
|
||||
AzToolsFramework::EditorEntityContextNotificationBus::Handler::BusConnect();
|
||||
}
|
||||
@@ -147,22 +146,24 @@ namespace AZ::ViewportHelpers
|
||||
AzToolsFramework::EditorEntityContextNotificationBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
// AzToolsFramework::EditorEntityContextNotificationBus
|
||||
// AzToolsFramework::EditorEntityContextNotificationBus overrides ...
|
||||
void OnStartPlayInEditor() override
|
||||
{
|
||||
m_renderViewport.OnStartPlayInEditor();
|
||||
m_editorViewportWidget.OnStartPlayInEditor();
|
||||
}
|
||||
|
||||
void OnStopPlayInEditor() override
|
||||
{
|
||||
m_renderViewport.OnStopPlayInEditor();
|
||||
m_editorViewportWidget.OnStopPlayInEditor();
|
||||
}
|
||||
|
||||
void OnStartPlayInEditorBegin() override
|
||||
{
|
||||
m_renderViewport.OnStartPlayInEditorBegin();
|
||||
m_editorViewportWidget.OnStartPlayInEditorBegin();
|
||||
}
|
||||
|
||||
private:
|
||||
EditorViewportWidget& m_renderViewport;
|
||||
EditorViewportWidget& m_editorViewportWidget;
|
||||
};
|
||||
} // namespace AZ::ViewportHelpers
|
||||
|
||||
@@ -1027,10 +1028,16 @@ bool EditorViewportWidget::ShowingWorldSpace()
|
||||
}
|
||||
|
||||
AZStd::shared_ptr<AtomToolsFramework::ModularViewportCameraController> CreateModularViewportCameraController(
|
||||
AzFramework::ViewportId viewportId)
|
||||
const AzFramework::ViewportId viewportId)
|
||||
{
|
||||
auto controller = AZStd::make_shared<AtomToolsFramework::ModularViewportCameraController>();
|
||||
|
||||
controller->SetCameraViewportContextBuilderCallback(
|
||||
[viewportId](AZStd::unique_ptr<AtomToolsFramework::ModularCameraViewportContext>& cameraViewportContext)
|
||||
{
|
||||
cameraViewportContext = AZStd::make_unique<AtomToolsFramework::ModularCameraViewportContextImpl>(viewportId);
|
||||
});
|
||||
|
||||
controller->SetCameraPriorityBuilderCallback(
|
||||
[](AtomToolsFramework::CameraControllerPriorityFn& cameraControllerPriorityFn)
|
||||
{
|
||||
@@ -1049,6 +1056,16 @@ AZStd::shared_ptr<AtomToolsFramework::ModularViewportCameraController> CreateMod
|
||||
{
|
||||
return SandboxEditor::CameraTranslateSmoothness();
|
||||
};
|
||||
|
||||
cameraProps.m_rotateSmoothingEnabledFn = []
|
||||
{
|
||||
return SandboxEditor::CameraRotateSmoothingEnabled();
|
||||
};
|
||||
|
||||
cameraProps.m_translateSmoothingEnabledFn = []
|
||||
{
|
||||
return SandboxEditor::CameraTranslateSmoothingEnabled();
|
||||
};
|
||||
});
|
||||
|
||||
controller->SetCameraListBuilderCallback(
|
||||
|
||||
Reference in New Issue
Block a user