[fix] FlightConfiguration now correctly calculates the bounds of partially-active rockets

This commit is contained in:
Daniel_M_Williams 2020-08-29 19:42:04 -04:00
parent 81b2f60e55
commit b0bc372ece

View File

@ -543,9 +543,9 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
* @return the rocket's bounding box (under the selected configuration) * @return the rocket's bounding box (under the selected configuration)
*/ */
public BoundingBox getBoundingBox() { public BoundingBox getBoundingBox() {
if (rocket.getModID() != boundsModID) { // if (rocket.getModID() != boundsModID) {
calculateBounds(); calculateBounds();
} // }
return cachedBounds; return cachedBounds;
} }
@ -558,11 +558,12 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
InstanceMap map = getActiveInstances(); InstanceMap map = getActiveInstances();
for (Map.Entry<RocketComponent, java.util.ArrayList<InstanceContext>> entry : map.entrySet()) { for (Map.Entry<RocketComponent, java.util.ArrayList<InstanceContext>> entry : map.entrySet()) {
RocketComponent component = entry.getKey(); final RocketComponent component = entry.getKey();
BoundingBox componentBounds = new BoundingBox(); final BoundingBox componentBounds = new BoundingBox();
List<InstanceContext> contexts = entry.getValue(); final List<InstanceContext> contexts = entry.getValue();
if( ! component.isAerodynamic()){ if( ! component.isAerodynamic()){
// System.err.println(" << non-aerodynamic");
// all non-aerodynamic components should be surrounded by aerodynamic ones // all non-aerodynamic components should be surrounded by aerodynamic ones
continue; continue;
} }
@ -571,6 +572,7 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
if (component instanceof BoxBounded) { if (component instanceof BoxBounded) {
final BoundingBox instanceBounds = ((BoxBounded) component).getInstanceBoundingBox(); final BoundingBox instanceBounds = ((BoxBounded) component).getInstanceBoundingBox();
if(instanceBounds.isEmpty()) { if(instanceBounds.isEmpty()) {
// probably redundant
// this component is probably non-physical (like an assembly) or has invalid bounds. Skip. // this component is probably non-physical (like an assembly) or has invalid bounds. Skip.
continue; continue;
} }
@ -627,7 +629,7 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
if (rocketBounds.isEmpty()) { if (rocketBounds.isEmpty()) {
cachedLength = 0; cachedLength = 0;
} }
cachedBounds.update( rocketBounds ); cachedBounds = rocketBounds;
} }
/** /**