Only calculate instancemap from active components

One thing to mention is I had a choice of either adding a special case for the rocket itself, or change the result of isStageActive for stage -1 to be true instead of false as previously.  I couldn't see a place where the previous version mattered, so I changed it.
This commit is contained in:
JoePfeiffer 2020-09-09 17:17:10 -06:00
parent 206ba58a7e
commit 20ab8ef8b1

View File

@ -204,7 +204,7 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
*/ */
public boolean isStageActive(int stageNumber) { public boolean isStageActive(int stageNumber) {
if( -1 == stageNumber ) { if( -1 == stageNumber ) {
return false; return true;
} }
return stages.get(stageNumber).active; return stages.get(stageNumber).active;
@ -294,10 +294,12 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
} }
private InstanceMap getContextListAt(final RocketComponent component, final InstanceMap results, final Transformation parentTransform ){ private InstanceMap getContextListAt(final RocketComponent component, final InstanceMap results, final Transformation parentTransform ){
final boolean active = this.isComponentActive(component);
if (!active)
return results;
final int instanceCount = component.getInstanceCount(); final int instanceCount = component.getInstanceCount();
final Coordinate[] allOffsets = component.getInstanceOffsets(); final Coordinate[] allOffsets = component.getInstanceOffsets();
final double[] allAngles = component.getInstanceAngles(); final double[] allAngles = component.getInstanceAngles();
final boolean active = this.isComponentActive(component);
final Transformation compLocTransform = Transformation.getTranslationTransform( component.getPosition() ); final Transformation compLocTransform = Transformation.getTranslationTransform( component.getPosition() );
final Transformation componentTransform = parentTransform.applyTransformation(compLocTransform); final Transformation componentTransform = parentTransform.applyTransformation(compLocTransform);
@ -307,8 +309,8 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
final Transformation offsetTransform = Transformation.getTranslationTransform( allOffsets[currentInstanceNumber] ); final Transformation offsetTransform = Transformation.getTranslationTransform( allOffsets[currentInstanceNumber] );
final Transformation angleTransform = Transformation.getAxialRotation(allAngles[currentInstanceNumber]); final Transformation angleTransform = Transformation.getAxialRotation(allAngles[currentInstanceNumber]);
final Transformation currentTransform = componentTransform.applyTransformation(offsetTransform) final Transformation currentTransform = componentTransform.applyTransformation(offsetTransform)
.applyTransformation(angleTransform); .applyTransformation(angleTransform);
// constructs entry in-place // constructs entry in-place
results.emplace(component, active, currentInstanceNumber, currentTransform); results.emplace(component, active, currentInstanceNumber, currentTransform);