Created
January 25, 2018 16:43
-
-
Save Starwaster/f0264f3d8798340be189cf8e0b2d97ce to your computer and use it in GitHub Desktop.
Modified version of KoS terrain height calculator
This file contains 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
Vector3d worldRayCastStart = body.GetWorldSurfacePosition(latitude, longitude, body.Radius + 50000); | |
// a point a bit below it, to aim down to the terrain: | |
Vector3d worldRayCastStop = body.GetWorldSurfacePosition(latitude, longitude, body.Radius + 49900); | |
RaycastHit hit; | |
if (Physics.Raycast(worldRayCastStart, (worldRayCastStop - worldRayCastStart), out hit, float.MaxValue, 32768)) | |
{ | |
// Ensure hit is on the topside of planet, near the worldRayCastStart, not on the far side. | |
if (Mathf.Abs(hit.distance) <= 50000) | |
{ | |
// Okay a hit was found, use it instead of PQS alt: | |
alt = ((body.Radius + 50000) - hit.distance); | |
} | |
else | |
alt = 0; | |
} | |
return alt; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment