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

DYN-6489 Dynamo Zoom Extents behavior has changed #14674

Merged
merged 8 commits into from
Dec 13, 2023

Conversation

saintentropy
Copy link
Contributor

@saintentropy saintentropy commented Dec 2, 2023

Purpose

Helix-Toolkit made an adjustment in the ZoomExtents() algorithm in the 2.24.0 Release. Specifically, the change was introduced here -> helix-toolkit/helix-toolkit#1921 and was included in the 2.24.0 release. Previously the ZoomExtents() algorithm was never very accurate or predictable in that results would vary depending on the size and height/width ratio of background preview view window. This change however makes the calculated ZoomExtents appear fully incorrect for some cases. Subsequent to this code change, the Dev branch in helix-toolkit now has a dramatically improved algorithm for ZoomExtents. The PR is found here -> helix-toolkit/helix-toolkit#2003. I assume this new algorithm will be available in the 2.25.0 release and is testable currently with the helix-toolkit daily builds. This PR pulls the relevant implementation into Dynamo for use until the release of 2.25.0 when we can presumably call the updated methods directly. In testing, ZoomExtents is now fully predictable regardless of background preview view window size or height/width ratio.

This PR also takes the opportunity to utilize the native helix-toolkit bounding box calculation for scene objects. This was not available 8 years ago when we added our own implementation. By using the native methods, we also solve the issue where instance geometry was not correctly considered for ZoomExtents calculations.

Also for some reason we have always been clipping the top 20 pixels off of the background preview 🤷. Now you notice it so I removed that margin.

Improved Result
image

Previous Behavior

image

Declarations

Check these if you believe they are true

  • The codebase is in a better state after this PR
  • Is documented according to the standards
  • The level of testing this PR includes is appropriate
  • User facing strings, if any, are extracted into *.resx files
  • All tests pass using the self-service CI.
  • Snapshot of UI changes, if any.
  • Changes to the API follow Semantic Versioning and are documented in the API Changes document.
  • This PR modifies some build requirements and the readme is updated
  • This PR contains no files larger than 50 MB

Release Notes

Zoom Extents for the background preview is now more accurate and predictable regardless of the size of the Dynamo application window.

Reviewers

@aparajit-pratap @mjkkirschner

FYIs

@jnealb @twastvedt

@jnealb
Copy link
Collaborator

jnealb commented Dec 2, 2023

+1

@jnealb jnealb closed this Dec 2, 2023
@saintentropy saintentropy reopened this Dec 2, 2023
@saintentropy
Copy link
Contributor Author

Old clipping
image

vs New
image

Copy link
Member

@mjkkirschner mjkkirschner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple questions, but it looks good otherwise, I think we should add an image comparison test if one doesn't exist already.

We likely also need a followup if one already exists to see if we can make the system more robust.

I think whoever takes the current task can add that test or file that followup task.

@mjkkirschner
Copy link
Member

@saintentropy I've pushed to this branch and will merge / cherry pick after the tests pass.

Copy link

UI Smoke Tests

Test: success. 2 passed, 0 failed.
TestComplete Test Result
Workflow Run: UI Smoke Tests
Check: UI Smoke Tests - net6.0

Copy link

UI Smoke Tests

Test: success. 2 passed, 0 failed.
TestComplete Test Result
Workflow Run: UI Smoke Tests
Check: UI Smoke Tests - net8.0


if (geom.Geometry.Positions.Count > 1)
if(Math.Abs(bounds.Size.LengthSquared()) < defaultBoundsSize * defaultBoundsSize * 3)
Copy link
Contributor

@aparajit-pratap aparajit-pratap Dec 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A square of any number will always be greater than or equal to zero, why do we need Math.Abs?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain this formula, where do you get 3 from?

Copy link
Member

@mjkkirschner mjkkirschner Dec 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I remember @saintentropy 's explanation correctly, he was just trying to set a good minimum zoom size. If we go too small the UI becomes difficult to navigate/pan etc. This value is larger than what we had before but it seems to work well in practice even for just a point.

I don't see a reason for the abs call either. I can remove it.

if(watch_view.Camera.Position.ToVector3().IsUndefined() ||
watch_view.Camera.LookDirection.ToVector3().IsUndefined() ||
watch_view.Camera.LookDirection.Length == 0)
if (watch_view.Camera is HelixToolkit.Wpf.SharpDX.PerspectiveCamera perspectiveCam)
Copy link
Contributor

@aparajit-pratap aparajit-pratap Dec 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to account for the case where the camera is Orthographic if at all possible?

Copy link
Member

@mjkkirschner mjkkirschner Dec 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, let me look into if that was supported before.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, your're right @aparajit-pratap that would have been supported before, I'll move in the code for ortho cameras as well from helix.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2023-12-12 at 2 40 15 PM
Screenshot 2023-12-12 at 2 40 12 PM

done.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, how do we change the camera from perspective to orthographic? Is there a UI option?

Copy link
Member

@mjkkirschner mjkkirschner Dec 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it can be done from a view extension - theres a property on the helix viewport object

Copy link

UI Smoke Tests

Test: success. 2 passed, 0 failed.
TestComplete Test Result
Workflow Run: UI Smoke Tests
Check: UI Smoke Tests - net8.0

Copy link

UI Smoke Tests

Test: success. 2 passed, 0 failed.
TestComplete Test Result
Workflow Run: UI Smoke Tests
Check: UI Smoke Tests - net6.0

Copy link

UI Smoke Tests

Test: success. 2 passed, 0 failed.
TestComplete Test Result
Workflow Run: UI Smoke Tests
Check: UI Smoke Tests - net8.0

Copy link

UI Smoke Tests

Test: success. 2 passed, 0 failed.
TestComplete Test Result
Workflow Run: UI Smoke Tests
Check: UI Smoke Tests - net6.0

@mjkkirschner mjkkirschner merged commit 6d50740 into DynamoDS:master Dec 13, 2023
22 checks passed
saintentropy added a commit that referenced this pull request Dec 14, 2023
* Adopt updated helix ZoomExtents algorithm

* use Helix native bounds implementation

* Why was this ever this way

* changes made

* handle zoom for ortho

* review comments

---------

Co-authored-by: Craig Long <[email protected]>
Co-authored-by: mjk.kirschner <[email protected]>
(cherry picked from commit 6d50740)
QilongTang pushed a commit that referenced this pull request Dec 14, 2023
* Adopt updated helix ZoomExtents algorithm

* use Helix native bounds implementation

* Why was this ever this way

* changes made

* handle zoom for ortho

* review comments

---------

Co-authored-by: Craig Long <[email protected]>
Co-authored-by: mjk.kirschner <[email protected]>
(cherry picked from commit 6d50740)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants