The first time a TubeFinSet is added to a rocket, inherit the thickness from
the parent BodyTube. The two rockets I was using to test my code both turned out to have the thickness of their tube fins set to the default, so the need for a user to do this is clearly easy to miss (I created one of those rockets myself!).
This commit is contained in:
parent
d5291d7b52
commit
a3dfb8ecd4
@ -550,4 +550,19 @@ public class BodyTube extends SymmetricComponent implements BoxBounded, MotorMou
|
||||
// The motor config also has listeners, so clear them as well
|
||||
getDefaultMotorConfig().clearConfigListeners();
|
||||
}
|
||||
|
||||
/**
|
||||
* The first time we add a TubeFinSet to the component tree, inherit the tube thickness from
|
||||
* the parent body tube
|
||||
*/
|
||||
@Override
|
||||
public final void addChild(RocketComponent component, int index, boolean trackStage) {
|
||||
super.addChild(component, index, trackStage);
|
||||
if (component instanceof TubeFinSet) {
|
||||
TubeFinSet finset = (TubeFinSet) component;
|
||||
if (Double.isNaN(finset.getThickness())) {
|
||||
finset.setThickness(getThickness());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ public class TubeFinSet extends Tube implements AxialPositionable, BoxBounded, R
|
||||
|
||||
private boolean autoRadius = true; // Radius chosen automatically based on parent component
|
||||
private double outerRadius = DEFAULT_RADIUS;
|
||||
protected double thickness = 0.002;
|
||||
protected double thickness = Double.NaN;
|
||||
private AngleMethod angleMethod = AngleMethod.FIXED;
|
||||
protected RadiusMethod radiusMethod = RadiusMethod.RELATIVE;
|
||||
|
||||
@ -49,7 +49,7 @@ public class TubeFinSet extends Tube implements AxialPositionable, BoxBounded, R
|
||||
|
||||
|
||||
/**
|
||||
* New FinSet with given number of fins and given base rotation angle.
|
||||
* New TubeFinSet with default values
|
||||
* Sets the component relative position to POSITION_RELATIVE_BOTTOM,
|
||||
* i.e. fins are positioned at the bottom of the parent component.
|
||||
*/
|
||||
@ -146,6 +146,7 @@ public class TubeFinSet extends Tube implements AxialPositionable, BoxBounded, R
|
||||
* Sets whether the radius is selected automatically or not.
|
||||
*/
|
||||
public void setOuterRadiusAutomatic(boolean auto) {
|
||||
|
||||
for (RocketComponent listener : configListeners) {
|
||||
if (listener instanceof TubeFinSet) {
|
||||
((TubeFinSet) listener).setOuterRadiusAutomatic(auto);
|
||||
@ -195,8 +196,9 @@ public class TubeFinSet extends Tube implements AxialPositionable, BoxBounded, R
|
||||
|
||||
if ((this.thickness == thickness))
|
||||
return;
|
||||
|
||||
this.thickness = MathUtil.clamp(thickness, 0, getOuterRadius());
|
||||
fireComponentChangeEvent(ComponentChangeEvent.MASS_CHANGE);
|
||||
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
|
||||
clearPreset();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user