Use rocket freezing for split fins
This commit is contained in:
parent
0e93ca7c25
commit
62506eced0
@ -1425,7 +1425,8 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona
|
||||
* Split the fin set into individual fins.
|
||||
* @return A list of the new fin sets.
|
||||
*/
|
||||
public List<FinSet> splitFins() {
|
||||
public List<FinSet> splitFins(boolean freezeRocket) {
|
||||
final RocketComponent root = getRoot();
|
||||
RocketComponent parent = getParent();
|
||||
int index = parent.getChildPosition(this);
|
||||
int count = getFinCount();
|
||||
@ -1433,32 +1434,53 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona
|
||||
|
||||
List<FinSet> splitFins = null; // List of all the split fins
|
||||
|
||||
if (count > 1) {
|
||||
parent.removeChild(index);
|
||||
splitFins = new ArrayList<>();
|
||||
for (int i = 0; i < count; i++) {
|
||||
FinSet copy = (FinSet) this.copy();
|
||||
copy.setFinCount(1);
|
||||
copy.setBaseRotation(base + i * 2 * Math.PI / count);
|
||||
copy.setName(copy.getName() + " #" + (i + 1));
|
||||
copy.setOverrideMass(getOverrideMass() / getFinCount());
|
||||
parent.addChild(copy, index + i);
|
||||
|
||||
splitFins.add(copy);
|
||||
try {
|
||||
// Freeze rocket
|
||||
if (freezeRocket && root instanceof Rocket) {
|
||||
((Rocket) root).freeze();
|
||||
}
|
||||
}
|
||||
|
||||
// Split fins for children
|
||||
for (RocketComponent listener : configListeners) {
|
||||
if (listener instanceof FinSet) {
|
||||
((FinSet) listener).splitFins();
|
||||
this.removeConfigListener(listener);
|
||||
// Split the fins
|
||||
if (count > 1) {
|
||||
parent.removeChild(index);
|
||||
splitFins = new ArrayList<>();
|
||||
for (int i = 0; i < count; i++) {
|
||||
FinSet copy = (FinSet) this.copy();
|
||||
copy.setFinCount(1);
|
||||
copy.setBaseRotation(base + i * 2 * Math.PI / count);
|
||||
copy.setName(copy.getName() + " #" + (i + 1));
|
||||
copy.setOverrideMass(getOverrideMass() / getFinCount());
|
||||
parent.addChild(copy, index + i);
|
||||
|
||||
splitFins.add(copy);
|
||||
}
|
||||
}
|
||||
|
||||
// Split fins for children
|
||||
for (RocketComponent listener : configListeners) {
|
||||
if (listener instanceof FinSet) {
|
||||
((FinSet) listener).splitFins(false);
|
||||
this.removeConfigListener(listener);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
// Unfreeze rocket
|
||||
if (freezeRocket && root instanceof Rocket) {
|
||||
((Rocket) root).thaw();
|
||||
}
|
||||
}
|
||||
|
||||
return splitFins;
|
||||
}
|
||||
|
||||
/**
|
||||
* Split the fin set into individual fins.
|
||||
* @return A list of the new fin sets.
|
||||
*/
|
||||
public List<FinSet> splitFins() {
|
||||
return splitFins(true);
|
||||
}
|
||||
|
||||
|
||||
// for debugging. You can safely delete this method
|
||||
public static String getPointDescr( final Coordinate[] points, final String name, final String indent){
|
||||
|
Loading…
x
Reference in New Issue
Block a user