Use multi-comp fin splitting
This commit is contained in:
parent
2822e0ec27
commit
0e93ca7c25
@ -1421,6 +1421,45 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona
|
||||
fireComponentChangeEvent(ComponentChangeEvent.MASS_CHANGE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Split the fin set into individual fins.
|
||||
* @return A list of the new fin sets.
|
||||
*/
|
||||
public List<FinSet> splitFins() {
|
||||
RocketComponent parent = getParent();
|
||||
int index = parent.getChildPosition(this);
|
||||
int count = getFinCount();
|
||||
double base = getBaseRotation();
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
// Split fins for children
|
||||
for (RocketComponent listener : configListeners) {
|
||||
if (listener instanceof FinSet) {
|
||||
((FinSet) listener).splitFins();
|
||||
this.removeConfigListener(listener);
|
||||
}
|
||||
}
|
||||
|
||||
return splitFins;
|
||||
}
|
||||
|
||||
|
||||
// for debugging. You can safely delete this method
|
||||
public static String getPointDescr( final Coordinate[] points, final String name, final String indent){
|
||||
return getPointDescr(Arrays.asList(points), name, indent);
|
||||
|
@ -109,23 +109,8 @@ public abstract class FinSetConfig extends RocketComponentConfig {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
RocketComponent parent = component.getParent();
|
||||
int index = parent.getChildPosition(component);
|
||||
int count = ((FinSet) component).getFinCount();
|
||||
double base = ((FinSet) component).getBaseRotation();
|
||||
if (count <= 1)
|
||||
return;
|
||||
|
||||
document.addUndoPosition("Split fin set");
|
||||
parent.removeChild(index);
|
||||
for (int i = 0; i < count; i++) {
|
||||
FinSet copy = (FinSet) component.copy();
|
||||
copy.setFinCount(1);
|
||||
copy.setBaseRotation(base + i * 2 * Math.PI / count);
|
||||
copy.setName(copy.getName() + " #" + (i + 1));
|
||||
copy.setOverrideMass(((FinSet) component).getOverrideMass()/((FinSet) component).getFinCount());
|
||||
parent.addChild(copy, index + i);
|
||||
}
|
||||
((FinSet) component).splitFins();
|
||||
}
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user