Commit 212980db authored by Matthias Betz's avatar Matthias Betz
Browse files

Fix code-review findings in OpenGL view wiring

- resetCamera re-fits the loaded model's bounding box (regression fix)
- remove dead allPolygons local in SceneBuilder.fromModel
- HighlightController: single GPU upload per highlight (no empty intermediate push)
parent 913a2941
...@@ -44,11 +44,15 @@ public class HighlightController { ...@@ -44,11 +44,15 @@ public class HighlightController {
return c == null ? new double[3] : c; return c == null ? new double[3] : c;
} }
public void clearHighlights() { private void resetBuffers() {
points.clear(); points.clear();
pointColors.clear(); pointColors.clear();
lines.clear(); lines.clear();
lineColors.clear(); lineColors.clear();
}
public void clearHighlights() {
resetBuffers();
push(); push();
} }
...@@ -83,10 +87,10 @@ public class HighlightController { ...@@ -83,10 +87,10 @@ public class HighlightController {
lineColors.add(r, g, b); lineColors.add(r, g, b);
} }
// ---- public highlight API (no TriangulatedGeometry) ---- // ---- public highlight API ----
public void highlight(Polygon p) { public void highlight(Polygon p) {
clearHighlights(); resetBuffers();
addHighlight(p, Color.RED, Color.BLUE); addHighlight(p, Color.RED, Color.BLUE);
push(); push();
} }
...@@ -102,7 +106,7 @@ public class HighlightController { ...@@ -102,7 +106,7 @@ public class HighlightController {
} }
public void highlight(LinearRing ring) { public void highlight(LinearRing ring) {
clearHighlights(); resetBuffers();
if (ring.getType() == LinearRingType.EXTERIOR) { if (ring.getType() == LinearRingType.EXTERIOR) {
addHighlight(ring, Color.RED); addHighlight(ring, Color.RED);
} else { } else {
...@@ -112,7 +116,7 @@ public class HighlightController { ...@@ -112,7 +116,7 @@ public class HighlightController {
} }
public void highlight(List<LinearRing> rings) { public void highlight(List<LinearRing> rings) {
clearHighlights(); resetBuffers();
for (LinearRing lr : rings) { for (LinearRing lr : rings) {
if (lr.getType() == LinearRingType.EXTERIOR) { if (lr.getType() == LinearRingType.EXTERIOR) {
addHighlight(lr, Color.RED); addHighlight(lr, Color.RED);
...@@ -138,7 +142,7 @@ public class HighlightController { ...@@ -138,7 +142,7 @@ public class HighlightController {
} }
public void highlight(Edge e) { public void highlight(Edge e) {
clearHighlights(); resetBuffers();
addHighlight(e); addHighlight(e);
push(); push();
} }
...@@ -153,7 +157,7 @@ public class HighlightController { ...@@ -153,7 +157,7 @@ public class HighlightController {
} }
public void highlight(Vertex v) { public void highlight(Vertex v) {
clearHighlights(); resetBuffers();
addPoint(v, Color.RED); addPoint(v, Color.RED);
push(); push();
} }
...@@ -167,7 +171,7 @@ public class HighlightController { ...@@ -167,7 +171,7 @@ public class HighlightController {
} }
public void highlightEdges(List<Edge> errorEdges) { public void highlightEdges(List<Edge> errorEdges) {
clearHighlights(); resetBuffers();
for (Edge e : errorEdges) { for (Edge e : errorEdges) {
addHighlight(e); addHighlight(e);
} }
...@@ -175,7 +179,7 @@ public class HighlightController { ...@@ -175,7 +179,7 @@ public class HighlightController {
} }
public void highlightPolygons(List<List<Polygon>> components) { public void highlightPolygons(List<List<Polygon>> components) {
clearHighlights(); resetBuffers();
for (int i = 0; i < components.size(); i++) { for (int i = 0; i < components.size(); i++) {
Color extColor; Color extColor;
Color intColor = switch (i % 3) { Color intColor = switch (i % 3) {
......
...@@ -892,6 +892,9 @@ public class MainWindow extends Application { ...@@ -892,6 +892,9 @@ public class MainWindow extends Application {
public void resetCamera() { public void resetCamera() {
glViewport.resetCamera(); glViewport.resetCamera();
if (controller.getOriginBB() != null) {
zoomOutForBoundingBox(controller.getOriginBB());
}
alignNorthArrow(); alignNorthArrow();
} }
......
...@@ -64,7 +64,6 @@ public final class SceneBuilder { ...@@ -64,7 +64,6 @@ public final class SceneBuilder {
* {@code TriangulatedGeometry.of(model, filters)}. * {@code TriangulatedGeometry.of(model, filters)}.
*/ */
public static SceneData fromModel(CityDoctorModel model) { public static SceneData fromModel(CityDoctorModel model) {
List<Polygon> allPolygons = new ArrayList<>();
Vector3d center = findCenterOfModel(model); Vector3d center = findCenterOfModel(model);
MeshAccumulator acc = new MeshAccumulator(center); MeshAccumulator acc = new MeshAccumulator(center);
PickRegistry registry = new PickRegistry(); PickRegistry registry = new PickRegistry();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment