Frag - Sort fragment bounce target list by distance#11143
Merged
PabstMirror merged 1 commit intoacemod:masterfrom Nov 28, 2025
Merged
Conversation
Fragment bounce was selecting targets in an inconsistent order because the system used an unsorted array. Implemented explicit distance-based sorting to ensure nearest targets are evaluated first, resulting in consistent and predictable fragment bounce behavior.
Contributor
|
Did you really use a global |
Contributor
Author
Thanks for pointing that out — I’ll make sure to use a private loop counter |
Contributor
If you used that slow, ancient format, then yeah. |
LinkIsGrim
approved these changes
Nov 22, 2025
BrettMayson
approved these changes
Nov 25, 2025
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.
Before
https://www.youtube.com/watch?v=plp0JCyKF9I
After
https://www.youtube.com/watch?v=6zzXQA7VR3A
Summary
Fragment bounce target selection was relying on a plain array with no
sorting applied. As a result, the bounce logic processed units in whatever
order they happened to be inserted, which created inconsistent behavior.
This PR adds explicit sorting so that the closest targets are always
evaluated first.
Benchmarking
To verify the best sorting approach, I benchmarked multiple methods.
I’m still fairly new to Arma scripting, so there may be a better or more
idiomatic solution that I’m not aware of:
distancedistanceSqrapplyto build an array of[distanceSquared, target],sorting it with native
sort, then extracting the targets againSummary of results
Test code used:
Test code result:
Notes / Question for Reviewers
Based on my measurements, the
apply + sort + extractpattern seems toperform best over repeated iterations, but I'm not fully certain if this
is the correct or preferred approach within ACE.
Result