// checks for occlusion by each celestial body public void IsOccluded(Vector3d source, Vector3d dest, string wavelength, out CelestialBody celestialBody, out bool occluded) { bool planetocclusion = HighLogic.CurrentGame.Parameters.CustomParams <BPSettings>().planetOcclusion; Transform transform2; double radius2; celestialBody = new CelestialBody(); occluded = new bool(); if (planetocclusion) { for (int x = 0; x < FlightGlobals.Bodies.Count; x++) { transform2 = FlightGlobals.Bodies[x].transform; radius2 = FlightGlobals.Bodies[x].Radius; celestialBody = FlightGlobals.Bodies[x]; radius2 *= (wavelength == "Long") ? 0.7 : 0.95; OccluderHorizonCulling occlusion = new OccluderHorizonCulling(transform2, radius2, radius2, radius2); occlusion.Update(); occluded = occlusion.Raycast(source, dest); if (occluded == true) { break; } } } else { occluded = false; } }
// checks for occlusion by each celestial body public void IsOccluded(Vector3d source, Vector3d dest, string wavelength, out CelestialBody celestialBody, out bool occluded) { bool planetocclusion = HighLogic.CurrentGame.Parameters.CustomParams <BPSettings>().planetOcclusion; Transform transform2; double radius2; celestialBody = new CelestialBody(); occluded = new bool(); if (planetocclusion) { for (int x = 0; x < FlightGlobals.Bodies.Count; x++) { transform2 = FlightGlobals.Bodies[x].transform; radius2 = FlightGlobals.Bodies[x].Radius; celestialBody = FlightGlobals.Bodies[x]; float occlusionMult; if (wavelength == "Radiowaves") { occlusionMult = 0.3f; } else if (wavelength == "Microwaves") { occlusionMult = 0.6f; } else if (wavelength == "Infrared") { occlusionMult = 0.7f; } else if (wavelength == "Ultraviolet") { occlusionMult = 0.9f; } else if (wavelength == "XRays") { occlusionMult = 0.95f; } else if (wavelength == "GammaRays") { occlusionMult = 1f; } else { occlusionMult = 0.9f; } radius2 *= occlusionMult; OccluderHorizonCulling occlusion = new OccluderHorizonCulling(transform2, radius2, radius2, radius2); occlusion.Update(); occluded = occlusion.Raycast(source, dest); if (occluded == true) { break; } } } else { occluded = false; } }