private bool UnattachedPartRightAgainstNode(Vector3d origToNode, double attachSize, Part attachedPart) { double mag = (origToNode).magnitude; ray.direction = origToNode; ray.origin = part.transform.position; RaycastHit[] hits = Physics.RaycastAll(ray, (float)(mag + attachSize), FARAeroUtil.RaycastMask); foreach (RaycastHit h in hits) { if (h.collider == part.collider) { continue; } if (h.distance < (mag + attachSize) && h.distance > (mag - attachSize * 0.01)) { foreach (Part p in VesselPartList) { if (p == null || p == attachedPart) { continue; } FARPartModule m = p.GetComponent <FARPartModule>(); if (m == null) { if (p.GetPartColliders().Contains(h.collider)) { return(true); } } else { if (m.PartColliders == null) { m.TriggerPartColliderUpdate(); } if (m.PartColliders.Contains(h.collider)) { return(true); } } } } } return(false); }
private FARWingAerodynamicModel ExposureHitDetectionAndWingDetection(RaycastHit[] hits, List <Part> vesselPartList, ref double exposure, double exposureDecreasePerHit) { bool gotSomething = false; bool firstHit = true; double wingInteractionFactor = 0; FARWingAerodynamicModel wingHit = null; RaycastHit[] sortedHits = SortHitsByDistance(hits); for (int j = 0; j < sortedHits.Length; j++) { gotSomething = false; RaycastHit h = sortedHits[j]; if (h.collider != null) { for (int k = 0; k < vesselPartList.Count; k++) { Part p = vesselPartList[k]; if (p == null || p == parentWingPart) { continue; } FARPartModule farModule = p.GetComponent <FARPartModule>(); Collider[] colliders; if (farModule != null) { colliders = farModule.PartColliders; if (colliders == null) { farModule.TriggerPartColliderUpdate(); colliders = farModule.PartColliders; } } else { colliders = new Collider[1] { p.collider } }; for (int l = 0; l < colliders.Length; l++) { if (h.collider == colliders[l] && h.distance > 0) { if (firstHit) { exposure -= exposureDecreasePerHit; firstHit = false; } FARWingAerodynamicModel hitModule = p.GetComponent <FARWingAerodynamicModel>(); if (hitModule != null) { double tmp = Math.Abs(Vector3.Dot(p.transform.forward, parentWingPart.partTransform.forward)); if (tmp > wingInteractionFactor + 0.01) { wingInteractionFactor = tmp; wingHit = hitModule; } } gotSomething = true; break; } } if (gotSomething) { break; } } } } return(wingHit); }