diff --git a/ThermalDynamics/Data/Scripts/Thermodynamics/Settings.cs b/ThermalDynamics/Data/Scripts/Thermodynamics/Settings.cs index a8ee071..43bd694 100644 --- a/ThermalDynamics/Data/Scripts/Thermodynamics/Settings.cs +++ b/ThermalDynamics/Data/Scripts/Thermodynamics/Settings.cs @@ -22,10 +22,14 @@ public class Settings public static Settings Instance; public static readonly MyStringHash DefaultSubtypeId = MyStringHash.GetOrCompute("DefaultThermodynamics"); + public static readonly MyStringHash DefaultLowMassSubtypeId = MyStringHash.GetOrCompute("DefaultLowMassThermodynamics"); [ProtoMember(1)] public int Version; + [ProtoMember(3)] + public bool EnableEnvironment; + [ProtoMember(5)] public bool EnableSolarHeat; @@ -45,18 +49,18 @@ public class Settings [ProtoMember(16)] public float SimulationSpeed; + /// + /// the temperature in kelven for space + /// + [ProtoMember(30)] + public float VacuumTemperature; + /// /// SolarEnergy = watts/m^2 /// - [ProtoMember(110)] + [ProtoMember(40)] public float SolarEnergy; - [ProtoMember(120)] - public float EnvironmentalRaycastDistance; - - [ProtoMember(130)] - public float VaccumeRadiationStrength; - [ProtoMember(140)] public float PresurizedAtmoConductivity; @@ -74,20 +78,19 @@ public static Settings GetDefaults() { Settings s = new Settings { Version = 1, - EnableSolarHeat = true, //atm includes all external heat source + EnableEnvironment = true, + EnableSolarHeat = false, EnableDamage = true, Frequency = 1, - SimulationSpeed = 10, - SolarEnergy = 0f, - EnvironmentalRaycastDistance = 5000f, - VaccumeRadiationStrength = 0.05f, + SimulationSpeed = 1, + VacuumTemperature = 2.7f, + SolarEnergy = 0f, PresurizedAtmoConductivity = 0.026f, PresurizedAtmoSpecificHeat = 1005, }; s.Init(); - return s; - + return s; } private void Init() { diff --git a/ThermalDynamics/Data/Scripts/Thermodynamics/ThermalCell.cs b/ThermalDynamics/Data/Scripts/Thermodynamics/ThermalCell.cs index 2f36f23..b16c685 100644 --- a/ThermalDynamics/Data/Scripts/Thermodynamics/ThermalCell.cs +++ b/ThermalDynamics/Data/Scripts/Thermodynamics/ThermalCell.cs @@ -458,7 +458,12 @@ private void UpdateFrameAndLastTemperature() private float CalculateTotalRadiation() { float temperatureSquared = Temperature * Temperature; - float totalRadiation = Boltzmann * Definition.Emissivity * (temperatureSquared * temperatureSquared) - Grid.FrameAmbientTempratureP4; + float totalRadiation = 0; + + if (Settings.Instance.EnableEnvironment) + { + totalRadiation = Boltzmann * Definition.Emissivity * (temperatureSquared * temperatureSquared) - Grid.FrameAmbientTempratureP4; + } if (Settings.Instance.EnableSolarHeat && !Grid.FrameSolarOccluded) { diff --git a/ThermalDynamics/Data/Scripts/Thermodynamics/ThermalGrid.cs b/ThermalDynamics/Data/Scripts/Thermodynamics/ThermalGrid.cs index f691a35..f304895 100644 --- a/ThermalDynamics/Data/Scripts/Thermodynamics/ThermalGrid.cs +++ b/ThermalDynamics/Data/Scripts/Thermodynamics/ThermalGrid.cs @@ -87,7 +87,7 @@ public partial class ThermalGrid : MyGameLogicComponent public float FrameAmbientTemprature; public float FrameAmbientTempratureP4; - public float FrameSolarDecay; + //public float FrameSolarDecay; public bool FrameSolarOccluded; public override void Init(MyObjectBuilder_EntityBase objectBuilder) @@ -403,40 +403,49 @@ private void PrepareNextSimulationStep() { Vector3D position = Grid.PositionComp.WorldAABB.Center; - PrepareEnvironmentTemprature(ref position); PrepareSolarEnvironment(ref position); + PrepareEnvironmentTemprature(ref position); } - private void PrepareEnvironmentTemprature(ref Vector3D position) - { - PlanetManager.Planet planet = PlanetManager.GetClosestPlanet(position); - if (planet == null) return; - - - bool isUnderground = false; - PlanetDefinition def = planet.Definition(); - Vector3 local = position - planet.Position; - Vector3D surfacePointLocal = planet.Entity.GetClosestSurfacePointLocal(ref local); - isUnderground = local.LengthSquared() < surfacePointLocal.LengthSquared(); - float airDensity = planet.Entity.GetAirDensity(position); - float windSpeed = planet.Entity.GetWindSpeed(position); + private void PrepareEnvironmentTemprature(ref Vector3D position) { + if (!Settings.Instance.EnableEnvironment) return; - float ambient = def.UndergroundTemperature; - if (!isUnderground) + PlanetManager.Planet planet = PlanetManager.GetClosestPlanet(position); + float frameAmbiSquared; + if (planet == null) { - float dot = (float)Vector3D.Dot(Vector3D.Normalize(local), FrameSolarDirection); - ambient = def.NightTemperature + ((dot + 1f) * 0.5f * (def.DayTemperature - def.NightTemperature)); + FrameAmbientTemprature = Settings.Instance.VacuumTemperature; + frameAmbiSquared = FrameAmbientTemprature * FrameAmbientTemprature; + FrameAmbientTempratureP4 = frameAmbiSquared * frameAmbiSquared; } - else + else { - FrameSolarOccluded = true; - } + bool isUnderground = false; + PlanetDefinition def = planet.Definition(); + Vector3 local = position - planet.Position; + Vector3D surfacePointLocal = planet.Entity.GetClosestSurfacePointLocal(ref local); + isUnderground = local.LengthSquared() < surfacePointLocal.LengthSquared(); + float airDensity = planet.Entity.GetAirDensity(position); + float windSpeed = planet.Entity.GetWindSpeed(position); - FrameAmbientTemprature = Math.Max(2.7f, ambient * airDensity); - float frameAmbiSquared = FrameAmbientTemprature * FrameAmbientTemprature; - FrameAmbientTempratureP4 = frameAmbiSquared * frameAmbiSquared; - FrameSolarDecay = 1 - def.SolarDecay * airDensity; + + float ambient = def.UndergroundTemperature; + if (!isUnderground) + { + float dot = (float)Vector3D.Dot(Vector3D.Normalize(local), FrameSolarDirection); + ambient = def.NightTemperature + ((dot + 1f) * 0.5f * (def.DayTemperature - def.NightTemperature)); + } + else + { + FrameSolarOccluded = true; + } + + FrameAmbientTemprature = Math.Max(Settings.Instance.VacuumTemperature, ambient * airDensity); + frameAmbiSquared = FrameAmbientTemprature * FrameAmbientTemprature; + FrameAmbientTempratureP4 = frameAmbiSquared * frameAmbiSquared; + //FrameSolarDecay = 1 - def.SolarDecay * airDensity; + } //FrameWindDirection = Vector3.Cross(planet.GravityComponent.GetWorldGravityNormalized(position), planet.Entity.WorldMatrix.Forward).Normalized() * windSpeed; //MySimpleObjectDraw.DrawLine(position, position + FrameWindDirection, MyStringId.GetOrCompute("Square"), ref color2, 0.1f); @@ -446,12 +455,14 @@ private void PrepareEnvironmentTemprature(ref Vector3D position) private void PrepareSolarEnvironment(ref Vector3D position) { + + FrameSolarDirection = MyVisualScriptLogicProvider.GetSunDirection(); + if (!Settings.Instance.EnableSolarHeat) return; SolarRadiationNode.Update(); FrameSolarOccluded = false; - FrameSolarDirection = MyVisualScriptLogicProvider.GetSunDirection(); FrameMatrix = Grid.WorldMatrix; LineD line = new LineD(position, position + (FrameSolarDirection * 15000000));