Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GeoCoordinates surface location is sometimes wrong because it raycasts to the vessel #478

Closed
Dunbaratu opened this issue Jan 3, 2015 · 2 comments

Comments

@Dunbaratu
Copy link
Member

This might be part of the problem people have had with getting Geocoordinates' positions and headings.

To learn the surface position, I have two choices:

1 - Take the PQS predicted ideal terrain height, which is never exactly right because it's a smooth surface function that's only approximated by the actual terrain made of flat polygons drawn to verteces of that smooth surface function.

2 - Take a raycast from that position through polygons to find the terrain polygons exact location.

I do option 2 when the terrain is close, or option 1 when it's far away.

The problem is that apparently the raycast used for option 2 is finding hits with the ship itself even though it's allegedly supposed to be masked to only pay attention to terrrain. So the terrain height gets reported as the top of the vessel on the ground above the spot, rather than the height of the ground. Something is wrong with the raycast mask there - I can't figure out why because I'm explicitly using the right raycast mask, or so I thought.

@Dunbaratu
Copy link
Member Author

Possible problem found. The prototypes for Physics.RayCast are set up in such a way that if you leave off the distance cap argument, then the layer mask argument gets placed into the distance cap argument instead, and promoted from an int to a float so it can be read as the distance.

So I'm probably not masking at all. my masking bit pattern of 00000000000000000100000000000000 was taken as just being a really big max distance of 2^15 meters.

Dunbaratu added a commit to Dunbaratu/KOS-1 that referenced this issue Jan 3, 2015
@Dunbaratu
Copy link
Member Author

Verified that it fixed this in the latest develop code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant