Skip to content

Fixed lookdev movement #2757

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

Merged
merged 2 commits into from
Nov 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 40 additions & 14 deletions com.unity.render-pipelines.core/Editor/LookDev/CameraController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,24 @@ enum Direction
bool m_InFlyMotion;

bool m_IsDragging;
ViewTool m_BehaviorState;
static TimeHelper s_Timer = new TimeHelper();

ViewTool m_BehaviorState;
ViewTool behaviorState
{
get { return m_BehaviorState; }
set
{
if (value != m_BehaviorState && m_BehaviorState == ViewTool.FPS)
{
isDragging = false;
inFlyMotion = false;
m_DirectionKeyPressed = Direction.None;
}
m_BehaviorState = value;
}
}

protected CameraState m_CameraState;
DisplayWindow m_Window;
protected Action m_Focused;
Expand Down Expand Up @@ -125,13 +140,13 @@ private void ResetCameraControl()
{
isDragging = false;
inFlyMotion = false;
m_BehaviorState = ViewTool.None;
behaviorState = ViewTool.None;
}

protected virtual void OnScrollWheel(WheelEvent evt)
{
// See UnityEditor.SceneViewMotion.HandleScrollWheel
switch (m_BehaviorState)
switch (behaviorState)
{
case ViewTool.FPS: OnChangeFPSCameraSpeed(evt); break;
default: OnZoom(evt); break;
Expand All @@ -140,7 +155,7 @@ protected virtual void OnScrollWheel(WheelEvent evt)

void OnMouseDrag(MouseMoveEvent evt)
{
switch (m_BehaviorState)
switch (behaviorState)
{
case ViewTool.Orbit: OnMouseDragOrbit(evt); break;
case ViewTool.FPS: OnMouseDragFPS(evt); break;
Expand Down Expand Up @@ -241,7 +256,7 @@ void OnKeyDownReset(KeyDownEvent evt)
void OnKeyUpOrDownFPS<T>(KeyboardEventBase<T> evt)
where T : KeyboardEventBase<T>, new()
{
if (m_BehaviorState != ViewTool.FPS)
if (behaviorState != ViewTool.FPS)
return;

//Note: Keydown is called in loop but between first occurence of the
Expand Down Expand Up @@ -319,29 +334,40 @@ bool GetKeyCombinationByID(string ID, out KeyCombination combination)
}
}

ViewTool GetBehaviorTool<T>(MouseEventBase<T> evt, bool onMac) where T : MouseEventBase<T>, new()
{
if (evt.button == 2)
return ViewTool.Pan;
else if (evt.button == 0 && evt.ctrlKey && onMac || evt.button == 1 && evt.altKey)
return ViewTool.Zoom;
else if (evt.button == 0)
return ViewTool.Orbit;
else if (evt.button == 1 && !evt.altKey)
return ViewTool.FPS;
return ViewTool.None;
}

void OnMouseUp(MouseUpEvent evt)
{
ResetCameraControl();
bool onMac = Application.platform == RuntimePlatform.OSXEditor;
var state = GetBehaviorTool(evt, onMac);

if (state == behaviorState)
ResetCameraControl();
evt.StopPropagation();
}

void OnMouseDown(MouseDownEvent evt)
{
bool onMac = Application.platform == RuntimePlatform.OSXEditor;
behaviorState = GetBehaviorTool(evt, onMac);

if (evt.button == 2)
m_BehaviorState = ViewTool.Pan;
else if (evt.button == 0 && evt.ctrlKey && onMac || evt.button == 1 && evt.altKey)
if (behaviorState == ViewTool.Zoom)
{
m_BehaviorState = ViewTool.Zoom;
m_StartZoom = m_CameraState.viewSize;
m_ZoomSpeed = Mathf.Max(Mathf.Abs(m_StartZoom), .3f);
m_TotalMotion = 0;
}
else if (evt.button == 0)
m_BehaviorState = ViewTool.Orbit;
else if (evt.button == 1 && !evt.altKey)
m_BehaviorState = ViewTool.FPS;

// see also SceneView.HandleClickAndDragToFocus()
if (evt.button == 1 && onMac)
Expand Down
1 change: 1 addition & 0 deletions com.unity.render-pipelines.high-definition/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

### Fixed
- Fixed probe volumes debug views.
- Fixed lookdev movement.
- Fixed volume component tooltips using the same parameter name.

### Changed
Expand Down