Merge pull request #1376 from hcraigmiller/Streamer-Exit-Preset

Streamer changes exit preset status
This commit is contained in:
SiboVG 2022-05-25 00:47:56 +02:00 committed by GitHub
commit 91d46a5dd8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -40,7 +40,7 @@ public class Streamer extends RecoveryDevice {
if (MathUtil.equals(this.stripLength, stripLength)) if (MathUtil.equals(this.stripLength, stripLength))
return; return;
this.stripLength = stripLength; this.stripLength = stripLength;
clearPreset(); // clearPreset();
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE); fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
} }
@ -95,6 +95,7 @@ public class Streamer extends RecoveryDevice {
double area = getArea(); double area = getArea();
stripWidth = MathUtil.safeSqrt(area / ratio); stripWidth = MathUtil.safeSqrt(area / ratio);
stripLength = ratio * stripWidth; stripLength = ratio * stripWidth;
clearPreset();
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE); fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
} }
@ -117,6 +118,7 @@ public class Streamer extends RecoveryDevice {
double ratio = Math.max(getAspectRatio(), 0.01); double ratio = Math.max(getAspectRatio(), 0.01);
stripWidth = MathUtil.safeSqrt(area / ratio); stripWidth = MathUtil.safeSqrt(area / ratio);
stripLength = ratio * stripWidth; stripLength = ratio * stripWidth;
clearPreset();
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE); fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
} }
@ -136,6 +138,14 @@ public class Streamer extends RecoveryDevice {
if ( preset.has(ComponentPreset.WIDTH)) { if ( preset.has(ComponentPreset.WIDTH)) {
this.stripWidth = preset.get(ComponentPreset.WIDTH); this.stripWidth = preset.get(ComponentPreset.WIDTH);
} }
// Set Cd value when preset is selected after manual Cd change
double density = this.getMaterial().getDensity();
double cd;
cd = 0.034 * ((density + 0.025) / 0.105) * (stripLength + 1) / stripLength;
cd = MathUtil.min(cd, MAX_COMPUTED_CD);
this.cd = cd;
this.cdAutomatic = true;
super.loadFromPreset(preset); super.loadFromPreset(preset);
// Fix the length to the stripWidth since RocketComponent assigns ComponentPreset.LENGTH to length. // Fix the length to the stripWidth since RocketComponent assigns ComponentPreset.LENGTH to length.
this.length = this.stripWidth; this.length = this.stripWidth;
@ -147,7 +157,6 @@ public class Streamer extends RecoveryDevice {
public double getComponentCD(double mach) { public double getComponentCD(double mach) {
double density = this.getMaterial().getDensity(); double density = this.getMaterial().getDensity();
double cd; double cd;
cd = 0.034 * ((density + 0.025) / 0.105) * (stripLength + 1) / stripLength; cd = 0.034 * ((density + 0.025) / 0.105) * (stripLength + 1) / stripLength;
cd = MathUtil.min(cd, MAX_COMPUTED_CD); cd = MathUtil.min(cd, MAX_COMPUTED_CD);
return cd; return cd;