public override void OnStart(StartState state) { base.OnStart(state); //gear = part.GetComponent<ModuleLandingGear>(); OnVesselPartsChange += AttachNodeCdAdjust; UpdateUpVector(false); PartModelTransforms = FARGeoUtil.PartModelTransformArray(part); AttachNodeCdAdjust(); AnimationSetup(); Fields["currentDrag"].guiActive = FARDebugValues.displayForces; }
private void CalculatePartBounds(Part p) { Vector3 minBoundVec, maxBoundVec; minBoundVec = maxBoundVec = Vector3.zero; Transform[] transformList = FARGeoUtil.PartModelTransformArray(p); for (int i = 0; i < transformList.Length; i++) { Transform t = transformList[i]; MeshFilter mf = t.GetComponent <MeshFilter>(); if ((object)mf == null) { continue; } Mesh m = mf.mesh; if ((object)m == null) { continue; } var matrix = part.transform.worldToLocalMatrix * t.localToWorldMatrix; for (int j = 0; j < m.vertices.Length; j++) { Vector3 v = matrix.MultiplyPoint3x4(m.vertices[j]); maxBoundVec.x = Mathf.Max(maxBoundVec.x, v.x); minBoundVec.x = Mathf.Min(minBoundVec.x, v.x); maxBoundVec.y = Mathf.Max(maxBoundVec.y, v.y); minBoundVec.y = Mathf.Min(minBoundVec.y, v.y); maxBoundVec.z = Mathf.Max(maxBoundVec.z, v.z); minBoundVec.z = Mathf.Min(minBoundVec.z, v.z); } minBoundVec.x *= 1.05f; maxBoundVec.x *= 1.05f; minBoundVec.z *= 1.05f; maxBoundVec.z *= 1.05f; } minBounds.Add(minBoundVec); maxBounds.Add(maxBoundVec); }