コード例 #1
0
 private static void Reset(SimulatedVessel obj)
 {
     SimulatedPart.Release(obj.parts);
     obj.parts.Clear();
     SimulatedLiftingSurface.Release(obj.surfaces);
     obj.surfaces.Clear();
     SimulatedControlSurface.Release(obj.ctrls);
     obj.ctrls.Clear();
     SimulatedEngine.Release(obj.engines);
     obj.engines.Clear();
 }
コード例 #2
0
 protected static void Reset(PartCollection obj)
 {
     SimulatedPart.Release(obj.parts);
     obj.parts.Clear();
     SimulatedLiftingSurface.Release(obj.surfaces);
     obj.surfaces.Clear();
     SimulatedControlSurface.Release(obj.ctrls);
     obj.ctrls.Clear();
     SimulatedEngine.Release(obj.engines);
     obj.engines.Clear();
     PartCollection.Release(obj.partCollections);
     obj.partCollections.Clear();
 }
コード例 #3
0
        private void GenerateHighlightingData(ShipConstruct ship, CelestialBody body, float altitude, float speed, float aoa)
        {
            float mach, atmDensity;

            lock (body)
            {
                atmDensity = (float)Extensions.KSPClassExtensions.GetDensity(body, altitude);
                mach       = speed / (float)body.GetSpeedOfSound(body.GetPressure(altitude), atmDensity);
            }

            int count = ship.parts.Count;

            highlightingData = new PartAeroData[count];

            Vector3 inflow = AeroPredictor.InflowVect(aoa);

            float pseudoReDragMult;

            lock (PhysicsGlobals.DragCurvePseudoReynolds)
                pseudoReDragMult = PhysicsGlobals.DragCurvePseudoReynolds.Evaluate(atmDensity * speed);

            for (int i = 0; i < count; i++)
            {
                if (WindTunnelSettings.HighlightIgnoresLiftingSurfaces && ship.parts[i].HasModuleImplementing <ModuleLiftingSurface>())
                {
                    highlightingData[i] = new PartAeroData(0, 0, ship.parts[i].mass);
                    continue;
                }

                VesselCache.SimulatedPart simPart = VesselCache.SimulatedPart.Borrow(ship.parts[i], null);
                Vector3 partForce = simPart.GetAero(inflow, mach, pseudoReDragMult);

                ModuleLiftingSurface liftingSurface = ship.parts[i].FindModuleImplementing <ModuleLiftingSurface>();
                if (liftingSurface != null)
                {
                    VesselCache.SimulatedLiftingSurface simLiftSurf = VesselCache.SimulatedLiftingSurface.Borrow(liftingSurface, simPart);
                    partForce += simLiftSurf.GetForce(inflow, mach);
                    simLiftSurf.Release();
                }
                simPart.Release();
                //Vector3 partForce = highlightingVessel.parts[i].GetAero(inflow, mach, pseudoReDragMult);
                //Vector3 partForce = StockAeroUtil.SimAeroForce(body, new ShipConstruct("test", "", new List<Part>() { EditorLogic.fetch.ship.parts[i] }), inflow * speed, altitude);
                partForce = AeroPredictor.ToFlightFrame(partForce, aoa);  // (Quaternion.AngleAxis((aoa * 180 / Mathf.PI), Vector3.left) * partForce);

                highlightingData[i] = new PartAeroData(Math.Abs(partForce.z), Math.Abs(partForce.y), ship.parts[i].mass);
            }
        }