Preserve dimensions when switching shapes - #377
Open
chambm wants to merge 1 commit into
Open
Conversation
Switching a part's procedural shape in the editor reset every dimension to the new shape's persisted defaults, which (because the part is anchored by its attach nodes) shifted the part and its attached children. Carry the previous shape's bounding length and outer/inner diameter onto the new shape instead. - Add ProceduralAbstractShape.CopyDimensions(fromShape): no-op by default, overridden per shape to map the generic Length / MaxDiameter / InnerMaxDiameter onto its own fields. Called from ProceduralPart.ChangeShape (editor only) before the attachment reposition so nodes/children map onto the same size. Cones collapse to a straight profile; a truss maps the diameter to its top/bottom envelope; hollow shapes carry the bore. - ChangeShape does a single AdjustDimensionBounds()/UpdateShape() pass per switch (the tail pass is skipped once the editor block has refreshed), avoiding a redundant mesh rebuild and the duplicate model/collider-changed events it would fire. - Enforce dimension validity for programmatic writes, not just the sliders: hollow shapes clamp the inner-diameter value below the outer, and the pill shapes clamp the fillet value to its max, in AdjustDimensionBounds -- so a carried-in thin wall can't build a degenerate torus/capsule.
Author
|
@DRVeyl Could you review this when you get a chance please? Thanks. |
|
After testing, It Just Works™. Good PR 👍 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Switching a part's procedural shape in the editor reset every dimension to the new shape's persisted defaults, which often shifted the part and its attached children and is just generally not what users want for an existing part. Turning a cylinder into a cone or vice versa is probably the most common case where it's very annoying to not have the dimensions carry over, so here we carry the previous shape's bounding length and outer/inner diameter onto the new shape instead.