Fixes #2899 terrain raycast now ingores parts.#2900
Merged
Dunbaratu merged 2 commits intoKSP-KOS:developfrom Mar 17, 2021
Merged
Fixes #2899 terrain raycast now ingores parts.#2900Dunbaratu merged 2 commits intoKSP-KOS:developfrom
Dunbaratu merged 2 commits intoKSP-KOS:developfrom
Conversation
The fix I went with was to detect whether or not a raycast hit is inside a Part. If it is, then start a new raycast just past the hit and keep looking. The solution involved writing a wrapper around Raycast that includes this extra logic, such that it could be lifted and put in a utility library later if any other classes need to use it.
Dunbaratu
commented
Mar 16, 2021
I thought I had solved this in the previous commit but noticed it failed in gameplay. My math wasn't quite right. The problem fixed in this commit only shows up when you aren't on the equator, which is why it wasn't seen in testing on the KSC runway. The issue is that I changed algorithms partway through implementing this but didn't fully edit the code to reflect the new algorithm. What I had was a mix of the two. Prev algorithm was "calculate new raycast start by adding (distance plus a bit)*aimvector to the previous start point". New algorithim was "Calculate new raycast start by just using the hit location directly, plus aimvector times a little". The old algorithm required a +=, and the new one just an =. I missed that edit, and that mistake caused it not to work when not on the equator (essentially, when the Z axis of world coords isn't zero, the bug manifested.)
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.
Fixes #2899
The fix I went with was to detect whether or not a raycast hit
is inside a Part. If it is, then start a new raycast just past
the hit and keep looking.
The solution involved writing a wrapper around Raycast that
includes this extra logic, such that it could be lifted and
put in a utility library later if any other classes need to
use it.
Using the same example script and craft as in the issue #2899, with this change it now looks like this:
