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:
parent
d290525099
commit
74c2d75e63
@ -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);
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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 );
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user