Remove 'active' field from InstanceContext

The original plan was that there would be an InstanceContext for every instance of every RocketComponent, with some active and some not (just as RocketComponents may be active or not). The implementation has resulted in InstanceContexts only being created for active RocketComponents, so the active field is superfluous.
This commit is contained in:
JoePfeiffer 2022-03-11 21:49:53 -07:00
parent d290525099
commit 74c2d75e63
5 changed files with 4 additions and 33 deletions

View File

@ -604,35 +604,12 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
}
for (InstanceContext context : contexts) {
/*
* If the instance is not active in the current context, then
* skip the bound calculations. This is mildly confusing since
* getActiveInstances() implies that it will only return the
* instances that are active, but it returns all instances and
* the context indicates if it is active or not.
*/
if (!context.active) {
// break out of per-instance loop.
break;
}
componentBounds.update(instanceBounds.transform(context.transform));
}
} else {
// Legacy Case: These components do not implement the BoxBounded Interface.
Collection<Coordinate> instanceCoordinates = component.getComponentBounds();
for (InstanceContext context : contexts) {
/*
* If the instance is not active in the current context, then
* skip the bound calculations. This is mildly confusing since
* getActiveInstances() implies that it will only return the
* instances that are active, but it returns all instances and
* the context indicates if it is active or not.
*/
if (!context.active) {
continue;
}
Collection<Coordinate> transformedCoords = new ArrayList<>(instanceCoordinates);
// mutating. Transforms coordinates in place.
context.transform.transform(instanceCoordinates);

View File

@ -26,9 +26,8 @@ public class InstanceContext {
return component.hashCode();
}
public InstanceContext(final RocketComponent _component, final boolean _active, final int _instanceNumber, final Transformation _transform) {
public InstanceContext(final RocketComponent _component, final int _instanceNumber, final Transformation _transform) {
component = _component;
active = _active;
instanceNumber = _instanceNumber;
transform = _transform;
@ -48,7 +47,6 @@ public class InstanceContext {
// ==== public ====
final public RocketComponent component;
final public boolean active;
final public int instanceNumber;
final public Transformation transform;

View File

@ -34,7 +34,7 @@ public class InstanceMap extends HashMap<RocketComponent, ArrayList<InstanceCont
put(key, new ArrayList<InstanceContext>());
}
final InstanceContext context = new InstanceContext(component, active, number, xform);
final InstanceContext context = new InstanceContext(component, number, xform);
get(key).add(context);
}

View File

@ -186,7 +186,7 @@ public abstract class RocketRenderer {
for(InstanceContext context: contextList ) {
Geometry instanceGeometry = cr.getComponentGeometry( comp, context.transform );
instanceGeometry.active = context.active;
instanceGeometry.active = true;
treeGeometry.add( instanceGeometry );
}
}

View File

@ -378,11 +378,7 @@ public class RocketFigure extends AbstractScaleFigure {
for(InstanceContext context: contextList ) {
final Transformation currentTransform = this.axialRotation.applyTransformation(context.transform);
// generate shape for this component, if active
if( context.active ) {
allShapes = addThisShape( allShapes, this.currentViewType, comp, currentTransform);
}
allShapes = addThisShape( allShapes, this.currentViewType, comp, currentTransform);
}
}
}