Fix BoundingBox.merge() inconsistency — deprecate merge() and introduce mergeWith()#2661
Open
Fix BoundingBox.merge() inconsistency — deprecate merge() and introduce mergeWith()#2661
Conversation
Agent-Logs-Url: https://github.com/jMonkeyEngine/jmonkeyengine/sessions/e27f3192-530d-4525-aa2a-ad3e611ae4ed Co-authored-by: riccardobl <4943530+riccardobl@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix BoundingBox.merge() to avoid modifying object in place
Fix BoundingBox.merge() mutating receiver instead of returning new instance
Mar 28, 2026
Member
|
@copilot This is going to break existing apps relying on the current behavior, you should deprecate the old method and annotate why it was deprecated, and create a new method that is not local |
… mergeWith() Agent-Logs-Url: https://github.com/jMonkeyEngine/jmonkeyengine/sessions/223ff945-a733-4b7b-8b8b-2e90418270de Co-authored-by: riccardobl <4943530+riccardobl@users.noreply.github.com>
Contributor
Author
Done in commit
|
Copilot
AI
changed the title
Fix BoundingBox.merge() mutating receiver instead of returning new instance
Fix BoundingBox.merge() inconsistency — deprecate merge() and introduce mergeWith()
Mar 28, 2026
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.
BoundingBox.merge()was delegating directly tomergeLocal(), silently mutatingthis— inconsistent withBoundingSphere.merge(), which correctly returns a new object. Rather than changing the behavior ofmerge()(which would break existing apps relying on the mutating behavior), the old method is deprecated and a new non-mutatingmergeWith()method is introduced.Changes
BoundingVolume.merge()(abstract): marked@Deprecatedwith a Javadoc note explaining the inconsistency across subclasses and directing users tomergeWith()BoundingVolume.mergeWith(): new concrete method that always returns a new non-mutating result viaclone(null).mergeLocal(volume)BoundingBox.merge(): restored to its original mutating behavior (return mergeLocal(volume)), marked@Deprecatedwith a note that it modifies the receiver in placeBoundingSphere.merge(): marked@Deprecatedfor consistency, directing users tomergeWith()TestBoundingBox: addedtestMergeModifiesReceiver()verifying the deprecatedmerge()still mutates in place, andtestMergeWithDoesNotModifyReceiver()verifyingmergeWith()is non-mutating⚡ Quickly spin up Copilot coding agent tasks from anywhere on your macOS or Windows machine with Raycast.