Don't include inactive stages in Cp calculations

This commit is contained in:
SiboVG 2022-06-24 05:37:30 +02:00
parent 4a79581244
commit 77bad60155
2 changed files with 34 additions and 3 deletions

View File

@ -155,7 +155,7 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator {
for( RocketComponent child : comp.getChildren()) {
// Ignore inactive stages
if (child instanceof AxialStage &&
!child.getRocket().getSelectedConfiguration().isStageActive(child.getStageNumber())) {
!((AxialStage) child).isStageActive()) {
continue;
}
// forces particular to each component
@ -278,14 +278,28 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator {
private boolean testIsContinuous( final RocketComponent treeRoot ){
Queue<RocketComponent> queue = new LinkedList<>();
queue.addAll(treeRoot.getChildren());
for (RocketComponent child : treeRoot.getChildren()) {
// Ignore inactive stages
if (child instanceof AxialStage &&
!((AxialStage) child).isStageActive()) {
continue;
}
queue.add(child);
}
boolean isContinuous = true;
SymmetricComponent prevComp = null;
while((isContinuous)&&( null != queue.peek())){
RocketComponent comp = queue.poll();
if( comp instanceof SymmetricComponent ){
queue.addAll( comp.getChildren());
for (RocketComponent child : comp.getChildren()) {
// Ignore inactive stages
if (child instanceof AxialStage &&
!((AxialStage) child).isStageActive()) {
continue;
}
queue.add(child);
}
SymmetricComponent sym = (SymmetricComponent) comp;
if( null == prevComp){

View File

@ -67,6 +67,23 @@ public class AxialStage extends ComponentAssembly implements FlightConfigurableC
public boolean isCompatible(Class<? extends RocketComponent> type) {
return BodyComponent.class.isAssignableFrom(type);
}
/**
* Returns whether the current stage is active in the currently selected configuration.
* @return true if the stage is active, false if not
*/
public boolean isStageActive() {
return getRocket().getSelectedConfiguration().isStageActive(getStageNumber());
}
/**
* Returns whether the current stage is active in the flight configuration.
* @param fc the flight configuration to check
* @return true if the stage is active, false if not
*/
public boolean isStageActive(FlightConfiguration fc) {
return fc.isStageActive(getStageNumber());
}
@Override
public void copyFlightConfiguration(FlightConfigurationId oldConfigId, FlightConfigurationId newConfigId) {