Skip to content

Commit

Permalink
Fixed issue where physically insignificant part mass was not being co…
Browse files Browse the repository at this point in the history
…rrectly cascaded down through parent parts.
  • Loading branch information
CYBUTEK committed Jul 15, 2015
1 parent 618330c commit 0e25404
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
3 changes: 2 additions & 1 deletion Documents/CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
1.0.17.1
1.0.18.0
Added: Orbital readouts - "Speed at Periapsis" and "Speed at Apoapsis". (Padishar)
Added: Manoeuvre readouts - "Post-burn Apoapsis" and "Post-burn Periapsis". (Padishar)
Fixed: Synched the minimum simulation time sliders and stopped them from snapping back after 999ms. (saybur)
Fixed: Added workaround for the bug in Vessel.horizontalSrfSpeed (Padishar)
Fixed: Physically insignificant part masses were not correctly being cascaded down through its parents.

1.0.17.0
Added: 'Mach Number' readout under the 'Surface' category and included it on the default surface HUD.
Expand Down
2 changes: 1 addition & 1 deletion KerbalEngineer/EngineerGlobals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static class EngineerGlobals
/// <summary>
/// Current version of the Kerbal Engineer assembly.
/// </summary>
public const string ASSEMBLY_VERSION = "1.0.17.0";
public const string ASSEMBLY_VERSION = "1.0.18.0";

private static string assemblyFile;
private static string assemblyName;
Expand Down
30 changes: 19 additions & 11 deletions KerbalEngineer/VesselSimulator/Simulation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

namespace KerbalEngineer.VesselSimulator
{
using System.ComponentModel;
using CompoundParts;
using Extensions;
using Helpers;
Expand Down Expand Up @@ -675,21 +676,28 @@ public double UpdatePartMasses()
for (int i = 0; i < this.allParts.Count; i++)
{
PartSim part = this.allParts[i];
// If the part has a parent
if (part.parent != null)

// Check if part should pass it's mass onto its parent.
if (part.isNoPhysics && part.parent != null)
{
if (part.isNoPhysics)
PartSim partParent = part.parent;

// Loop through all parents until a physically significant parent is found.
while (partParent != null)
{
if (part.parent.isNoPhysics && part.parent.parent != null)
// Check if parent is physically significant.
if (partParent.isNoPhysics == false)
{
part.baseMass = 0d;
part.baseMassForCoM = 0d;
}
else
{
part.parent.baseMassForCoM += part.baseMassForCoM;
part.baseMassForCoM = 0d;
// Apply the mass to the parent and remove it from the originating part.
partParent.baseMassForCoM += part.baseMassForCoM;
part.baseMassForCoM = 0.0;

// Break out of the recursive loop.
break;
}

// Recursively loop through the parent parts.
partParent = partParent.parent;
}
}
}
Expand Down
Binary file modified Output/KerbalEngineer/KerbalEngineer.dll
Binary file not shown.

0 comments on commit 0e25404

Please sign in to comment.