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

CMCL-0000: Improvements to PR-928: Spline position units #929

Merged
merged 18 commits into from Mar 11, 2024

Conversation

glabute
Copy link
Collaborator

@glabute glabute commented Feb 6, 2024

Purpose of this PR

I really like the initiative of PR-928, it significantly improves the UX and is worth implementing. However, I do have problems with the implementation:

  • No implementation for SplineCart
  • Incorrect handling of Undo and multi-select in inspector

I've refactored it here by introducing a SplinePosition struct with its own PropertyDrawer. This allows it to be easily used by multiple clients, including SplineDolly and SplineCart, and potentially other custom classes provided by the user.

The downside of this PR is that it breaks backwards-compatibility for serialization of SplineCart and SplineDolly (because members have moved into a new struct and there is no simple way to handle such changes). I'm willing to bite the bullet on that one, and just document the issue in the changelog.

Samples were updated for this change.

Testing status

  • Added an automated test
  • Passed all automated tests
  • Manually tested

Documentation status

  • Updated CHANGELOG
  • Updated README (if applicable)
  • Commented all public classes, properties, and methods
  • Updated user documentation

Walter-Hulsebos and others added 12 commits February 3, 2024 21:24
* Created `ConvertDistance` method & friends
(Thanks Wybren van den Akker for helping with  math)
* Added `ArgumentOutOfRangeException`s to internal code (could theoretically be accessed if users use ASMREFs)
* Changed the order of upgrading. `m_Path` has to be done first, `CinemachineSplineDolly` needs it before its `PositionUnits` is set.
* Added Unit Tests for my changes
* Added XML Documentation to new Conversion methods.
* `PositionUnits_DoesNotChangeCameraPosition_WhenPositionUnitsSame()` - Added additional asserts, not very important because as the code is now even just one should be enough. But still.
* Fixed small error made in XML comments
* Moved my positionUnitsBackingfield change tracking from OnValidate to the custom editor.
@glabute glabute changed the title CMC-0000: Improvements to PR-928: Spline position units CMCL-0000: Improvements to PR-928: Spline position units Feb 6, 2024
+ "0 represents the first knot on the path, 1 is the second, and so on. "
+ "Values in-between are points on the spline in between the knots. "
+ "If set to Distance, then Spline Position represents distance along the spline.")]
public PathIndexUnit PositionUnits = PathIndexUnit.Distance;
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can't change the API without a major bump 4.X.X

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed it to break less API

Copy link
Collaborator

@AntoineCharton AntoineCharton left a comment

Choose a reason for hiding this comment

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

Change is awesome! We would need a major bump for the changes to the API. Can we make the new fields internal and revert the naming changes?

@glabute
Copy link
Collaborator Author

glabute commented Feb 9, 2024

Maybe we can make an exception. IMO this isn't enough of a reason to bump the major version.

@glabute
Copy link
Collaborator Author

glabute commented Feb 9, 2024

I changed it so that less API is broken (new properties have the same names as the old fields). Maybe that is good enough?

@codecov-commenter
Copy link

codecov-commenter commented Feb 9, 2024

Codecov Report

Attention: Patch coverage is 52.38095% with 80 lines in your changes are missing coverage. Please review.

Project coverage is 26.82%. Comparing base (b82688f) to head (ded4372).
Report is 1 commits behind head on main.

Files Patch % Lines
...or/PropertyDrawers/SplineSettingsPropertyDrawer.cs 0.00% 40 Missing ⚠️
...achine/Runtime/Behaviours/CinemachineSplineCart.cs 0.00% 26 Missing ⚠️
...chine/Runtime/Components/CinemachineSplineDolly.cs 61.53% 10 Missing ⚠️
...hine/Runtime/Deprecated/CinemachineTrackedDolly.cs 50.00% 2 Missing ⚠️
...hine/Editor/Editors/CinemachineSplineCartEditor.cs 0.00% 1 Missing ⚠️
...ine/Editor/Editors/CinemachineSplineDollyEditor.cs 0.00% 1 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #929      +/-   ##
==========================================
+ Coverage   26.64%   26.82%   +0.17%     
==========================================
  Files         248      250       +2     
  Lines       27644    27786     +142     
==========================================
+ Hits         7367     7453      +86     
- Misses      20277    20333      +56     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Walter-Hulsebos
Copy link
Contributor

I changed it so that less API is broken (new properties have the same names as the old fields). Maybe that is good enough?

It would still make it so prior configurations are lost, since this wouldn't preserve serialized values from before this change, no?

@glabute
Copy link
Collaborator Author

glabute commented Feb 11, 2024

It would still make it so prior configurations are lost, since this wouldn't preserve serialized values from before this change, no?

Yes, unfortunately. With a little effort I could possibly fix that (stream into some private place using FormerlySerlializedAs, then find an opportune moment to patch the values into the right place). There are places in CM where this sort of thing happens, but it's always a little iffy imo (search for PerformLegacyUpgrade).

@unity-cla-assistant
Copy link

unity-cla-assistant commented Mar 8, 2024

CLA assistant check
All committers have signed the CLA.

@AntoineCharton AntoineCharton self-requested a review March 8, 2024 21:48
Copy link
Collaborator

@AntoineCharton AntoineCharton left a comment

Choose a reason for hiding this comment

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

Works but for 3.1.X only do not backport plz.

@glabute glabute merged commit 4933236 into main Mar 11, 2024
7 of 9 checks passed
@glabute glabute deleted the dev/pr128variant branch March 11, 2024 15:55
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.

None yet

5 participants