Пример #1
0
        private static void recurseParts(Part part, Vector3 refVel, ref Vector3 CoL, ref Vector3 DoL, ref float t, double refAlt, double refStp, double refDens)
        {
            int num = part.Modules.Count;

            while (num-- > 0)
            {
                ILiftProvider liftProvider = part.Modules[num] as ILiftProvider;
                if (liftProvider != null)
                {
                    lQry.Reset();
                    lQry.refVector         = refVel;
                    lQry.refAltitude       = refAlt;
                    lQry.refStaticPressure = refStp;
                    lQry.refAirDensity     = refDens;
                    liftProvider.OnCenterOfLiftQuery(lQry);
                    CoL += lQry.pos * lQry.lift;
                    DoL += lQry.dir * lQry.lift;
                    t   += lQry.lift;
                }
            }

            for (int i = 0; i < part.children.Count; i++)
            {
                Part part2 = part.children[i];
                recurseParts(part2, refVel, ref CoL, ref DoL, ref t, refAlt, refStp, refDens);
            }
        }
        private void RecurseCenterOfLift(Part part, Vector3 refVel, double refAlt, double refStp, double refDens)
        {
            var count = part.Modules.Count;

            while (count-- > 0)
            {
                var module = part.Modules[count] as ILiftProvider;
                if (module == null)
                {
                    continue;
                }

                _centerOfLiftQuery.Reset();
                _centerOfLiftQuery.refVector         = refVel;
                _centerOfLiftQuery.refAltitude       = refAlt;
                _centerOfLiftQuery.refStaticPressure = refStp;
                _centerOfLiftQuery.refAirDensity     = refDens;

                module.OnCenterOfLiftQuery(_centerOfLiftQuery);

                _weightedPositionAvg.Add(_centerOfLiftQuery.pos, _centerOfLiftQuery.lift);
                _weightedDirectionAvg.Add(_centerOfLiftQuery.dir, _centerOfLiftQuery.lift);
            }

            count = part.children.Count;
            for (var i = 0; i < count; i++)
            {
                RecurseCenterOfLift(part.children[i], refVel, refAlt, refStp, refDens);
            }
        }