コード例 #1
0
        double CalculateSunArea(ModularFI.ModularFlightIntegrator fi, FlightIntegrator.PartThermalData ptd)
        {
            FARAeroPartModule module = null;

            if (ptd.part.Modules.Contains("FARAeroPartModule"))
            {
                module = (FARAeroPartModule)ptd.part.Modules["FARAeroPartModule"];
            }

            if ((object)module != null)
            {
                double sunArea = module.ProjectedAreaWorld(fi.sunVector) * ptd.sunAreaMultiplier;

                if (sunArea > 0)
                {
                    return(sunArea);
                }
                else
                {
                    return(fi.BaseFIGetSunArea(ptd));
                }
            }
            else
            {
                return(fi.BaseFIGetSunArea(ptd));
            }
        }
コード例 #2
0
        double CalculateBodyArea(ModularFI.ModularFlightIntegrator fi, FlightIntegrator.PartThermalData ptd)
        {
            FARAeroPartModule module = null;

            if (ptd.part.Modules.Contains("FARAeroPartModule"))
            {
                module = (FARAeroPartModule)ptd.part.Modules["FARAeroPartModule"];
            }

            if ((object)module != null)
            {
                double bodyArea = module.ProjectedAreaWorld(-fi.Vessel.upAxis) * ptd.bodyAreaMultiplier;

                if (bodyArea > 0)
                {
                    return(bodyArea);
                }
                else
                {
                    return(fi.BaseFIBodyArea(ptd));
                }
            }
            else
            {
                return(fi.BaseFIBodyArea(ptd));
            }
        }
コード例 #3
0
        double CalculateAreaExposed(ModularFI.ModularFlightIntegrator fi, Part part, FARAeroPartModule aeroModule)
        {
            if ((object)aeroModule != null)
            {
                double exposedArea = aeroModule.ProjectedAreaLocal(-part.dragVectorDirLocal);

                if (exposedArea > 0)
                {
                    return(exposedArea);
                }
                else
                {
                    return(fi.BaseFICalculateAreaExposed(part));
                }
            }
            else
            {
                return(fi.BaseFICalculateAreaExposed(part));
            }

            /*else
             * {
             *  if (stockRadArea > 0)
             *      return aeroModule.ProjectedAreas.totalArea * dragCubeExposed / stockRadArea;
             *  else
             *      return aeroModule.ProjectedAreas.totalArea;
             * }*/
        }
コード例 #4
0
        void CalculateLocalDynPresAndAngularDrag(ModularFI.ModularFlightIntegrator fi, Part p)
        {
            if (fi.CurrentMainBody.ocean && p.submergedPortion > 0)
            {
                p.submergedDynamicPressurekPa = fi.CurrentMainBody.oceanDensity * 1000;
                p.dynamicPressurekPa          = p.atmDensity;
            }
            else
            {
                p.submergedDynamicPressurekPa = 0;
                p.dynamicPressurekPa          = p.atmDensity;
            }
            double tmp = 0.0005 * p.dragVectorSqrMag;

            p.submergedDynamicPressurekPa *= tmp;
            p.dynamicPressurekPa          *= tmp;

            tmp  = p.dynamicPressurekPa * (1.0 - p.submergedPortion);
            tmp += p.submergedDynamicPressurekPa * PhysicsGlobals.BuoyancyWaterAngularDragScalar * p.waterAngularDragMultiplier * p.submergedPortion;

            p.rb.angularDrag = (float)(p.angularDrag * tmp * PhysicsGlobals.AngularDragMultiplier);

            tmp              = Math.Max(fi.pseudoReDragMult, 1);
            p.dragScalar     = (float)((p.dynamicPressurekPa * (1.0 - p.submergedPortion) + p.submergedDynamicPressurekPa * p.submergedPortion) * tmp);   //dyn pres adjusted for submersion
            p.bodyLiftScalar = (float)(p.dynamicPressurekPa * (1.0 - p.submergedPortion) + p.submergedDynamicPressurekPa * p.submergedPortion);
        }
        double CalculateAreaExposed(ModularFI.ModularFlightIntegrator fi, Part part)
        {
            FARAeroPartModule module = null;

            if (part.Modules.Contains <FARAeroPartModule>())
            {
                module = part.Modules.GetModule <FARAeroPartModule>();
            }

            return(CalculateAreaExposed(fi, part, module));
        }
        double CalculateAreaExposed(ModularFI.ModularFlightIntegrator fi, Part part)
        {
            FARAeroPartModule module = null;

            if (part.Modules.Contains("FARAeroPartModule"))
            {
                module = (FARAeroPartModule)part.Modules["FARAeroPartModule"];
            }

            return(CalculateAreaExposed(fi, part, module));
        }
        void SkinThermalMassShenanigansForShieldedParts(ModularFI.ModularFlightIntegrator fi, Part part, double stockRadArea, double calculatedArea)
        {
            part.thermalMass += part.skinThermalMass;                             //reset overall thermalmass

            part.radiativeArea = stockRadArea;                                    //set rad area to stock values
            fi.SetSkinThermalMass(part);                                          //re-run setting skin thermal mass

            part.thermalMass          -= part.skinThermalMass;                    //re-subtract skin thermal mass
            part.thermalMassReciprocal = 1.0 / Math.Max(part.thermalMass, 0.001); //reset thermalMassRecip

            //part.radiativeArea = calculatedArea;      //I doubt that this ever caused a problem, but let's be sure
        }
 double CalculateAreaRadiative(ModularFI.ModularFlightIntegrator fi, Part part, FARAeroPartModule aeroModule)
 {
     //double dragCubeExposed = fi.BaseFICalculateAreaExposed(part);
     if ((object)aeroModule == null)
     {
         return(fi.BaseFICalculateAreaRadiative(part));
     }
     else
     {
         return(aeroModule.ProjectedAreas.totalArea);
     }
 }
 void UpdateAerodynamics(ModularFI.ModularFlightIntegrator fi, Part part)
 {
     if (part.Modules.Contains("ModuleAeroSurface") || part.Modules.Contains("KerbalEVA"))     //FIXME Proper model for airbrakes
     {
         fi.BaseFIUpdateAerodynamics(part);
         return;
     }
     else if (!part.DragCubes.None)
     {
         Rigidbody rb = part.Rigidbody;
         if (rb)
         {
             part.DragCubes.SetDrag(-part.partTransform.worldToLocalMatrix.MultiplyVector(rb.velocity + Krakensbane.GetFrameVelocityV3f()).normalized, (float)part.machNumber);
         }
     }
 }
        void UpdateThermodynamicsPre(ModularFI.ModularFlightIntegrator fi)
        {
            for (int i = 0; i < fi.PartThermalDataCount; i++)
            {
                Part part = fi.partThermalDataList[i].part;
                if (!part.Modules.Contains("FARAeroPartModule"))
                {
                    continue;
                }

                PartModule module = part.Modules["FARAeroPartModule"];

                FARAeroPartModule aeroModule = (FARAeroPartModule)module;

                part.radiativeArea = CalculateAreaRadiative(fi, part, aeroModule);
                part.exposedArea   = part.machNumber > 0 ? CalculateAreaExposed(fi, part, aeroModule) : 0;
            }
            //Debug.Log("MFI: " + fi.CoM + " " + Planetarium.GetUniversalTime());
        }
        double CalculateAreaExposed(ModularFI.ModularFlightIntegrator fi, Part part, FARAeroPartModule aeroModule)
        {
            double dragCubeExposed = fi.BaseFICalculateAreaExposed(part);

            if (aeroModule == null)
            {
                return(dragCubeExposed);
            }
            else
            {
                double cubeRadiative = fi.BaseFICalculateAreaRadiative(part);
                if (cubeRadiative > 0)
                {
                    return(aeroModule.ProjectedAreas.totalArea * dragCubeExposed / cubeRadiative);
                }
                else
                {
                    return(aeroModule.ProjectedAreas.totalArea);
                }
            }
        }