Skip to content

Optimize detonation range and detonation radius checks#7281

Open
Kestrellius wants to merge 2 commits intoscp-fs2open:masterfrom
Kestrellius:det-range-optimization
Open

Optimize detonation range and detonation radius checks#7281
Kestrellius wants to merge 2 commits intoscp-fs2open:masterfrom
Kestrellius:det-range-optimization

Conversation

@Kestrellius
Copy link
Contributor

When we're checking whether a weapon is past its det range or has a target within det radius, all we need to know is whether the value is smaller or larger, so we can skip the expensive square root.

At some point I should comb through all the instances of vm_vec_dist (and vm_vec_mag) and find all the ones to which this optimization can be applied, because I would guess there are quite a few, but detonation radius is the one I have a short-term use case for, so for now I've just done that one (and detonation range, since it was right there).

@wookieejedi wookieejedi added the optimization Trying to make the engine and tools more efficient label Mar 12, 2026
@Kestrellius Kestrellius requested a review from wookieejedi March 12, 2026 02:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

optimization Trying to make the engine and tools more efficient

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants