Attempt to fix/improve fixed angle Parabola trajectory#2214
Open
Starkku wants to merge 1 commit into
Open
Conversation
|
Nightly build for this pull request:
This comment is automatic and is meant to allow guests to get latest nightly builds for this pull request without registering. It is updated on every successful build. |
CrimRecya
approved these changes
May 17, 2026
Contributor
CrimRecya
left a comment
There was a problem hiding this comment.
The analytical formula seems correct: v = √((g*x²) / (2·cos²θ·(x·tanθ - z))).
And I would be extremely grateful if you rewrite the comments of ParabolaTrajectory::SearchFixedHeightMeetTime and ParabolaTrajectory::SearchFixedAngleMeetTime.
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.
This change specifically concerns
Trajectory=Parabolacombined withTrajectory.Parabola.OpenFireMode=Angle.Examples of faulty/corrected trajectory behaviour courtesy of Gen.Ari:
Before PR changes
After PR changes
The previous implementation for finding velocity for a fixed-angle trajectory involved using Newton's method to iteratively find approximations for roots. It is useful for approximating solutions to complex equations which might be impossible to solve algebraically. However, we're talking about parabolic arc with almost no external constraints or additional factors like air resistance here, just standard inputs for kinematic equations like horizontal and vertical distance, angle and gravity. Pretty much all sane inputs have valid algebraic solutions.
Or at least should have, to my understanding.
So apparently what the old method is essentially doing is using more unstable approximation method to guess solutions that converge in same results as an algebraic formula would give, which is evidenced by the fact that comparing the two methods yields identical results in cases where Newton's method doesn't just flat-out fail. This PR just ditches it in favour of just directly calculating the solutions with a formula. It will still fail under certain nonsense conditions like vertical launch angles but will also output an error message in log in such cases rather than fail completely silently.
[Phobos] Failed to solve fixed angle Parabola trajectory velocity: BulletType: [MarauderGunProj] - Source: 17000,22865,279 - Target: 13440,23680,936 - Angle: 90.00 - Gravity: 6.00Because:

And my knowledge is mostly constrained to algebra and basic calculus and ability to do research on the Internet, someone should probably double check that any of this shit is making sense. In addition to testing that it works as expected in-game.
No Documentation Neededis currently here per still current policy of not writing changes to changelog for changes within same version (Parabola trajectory was introduced after 0.4 and patches)