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.
|
* Split the fin set into individual fins.
|
||||||
* @return A list of the new fin sets.
|
* @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();
|
RocketComponent parent = getParent();
|
||||||
int index = parent.getChildPosition(this);
|
int index = parent.getChildPosition(this);
|
||||||
int count = getFinCount();
|
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
|
List<FinSet> splitFins = null; // List of all the split fins
|
||||||
|
|
||||||
if (count > 1) {
|
try {
|
||||||
parent.removeChild(index);
|
// Freeze rocket
|
||||||
splitFins = new ArrayList<>();
|
if (freezeRocket && root instanceof Rocket) {
|
||||||
for (int i = 0; i < count; i++) {
|
((Rocket) root).freeze();
|
||||||
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
|
// Split the fins
|
||||||
for (RocketComponent listener : configListeners) {
|
if (count > 1) {
|
||||||
if (listener instanceof FinSet) {
|
parent.removeChild(index);
|
||||||
((FinSet) listener).splitFins();
|
splitFins = new ArrayList<>();
|
||||||
this.removeConfigListener(listener);
|
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;
|
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
|
// for debugging. You can safely delete this method
|
||||||
public static String getPointDescr( final Coordinate[] points, final String name, final String indent){
|
public static String getPointDescr( final Coordinate[] points, final String name, final String indent){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user