Commit 2d57794b authored by Beuster's avatar Beuster
Browse files

Merge remote-tracking branch 'origin/dev' into dev_cpp_code_conversion

parents 040af2d2 660255ab
Pipeline #11013 passed with stage
in 1 minute and 38 seconds
...@@ -33,7 +33,7 @@ import de.hft.stuttgart.citydoctor2.datastructure.Vertex; ...@@ -33,7 +33,7 @@ import de.hft.stuttgart.citydoctor2.datastructure.Vertex;
import de.hft.stuttgart.citydoctor2.math.Vector3d; import de.hft.stuttgart.citydoctor2.math.Vector3d;
/** /**
* Tesselator to create triangles out of polygons. * Tesselator to create triangles out of polygons. Uses JOGL implementation.
* *
* @author Matthias Betz * @author Matthias Betz
* *
...@@ -102,6 +102,10 @@ public class JoglTesselator { ...@@ -102,6 +102,10 @@ public class JoglTesselator {
} }
public static TesselatedPolygon tesselatePolygon(Polygon p) { public static TesselatedPolygon tesselatePolygon(Polygon p) {
return tesselatePolygon(p, true);
}
public static TesselatedPolygon tesselatePolygon(Polygon p, boolean discardDegeneratedTriangles) {
ArrayList<Vector3d> vertices = new ArrayList<>(); ArrayList<Vector3d> vertices = new ArrayList<>();
Vector3d normal = p.calculateNormalNormalized(); Vector3d normal = p.calculateNormalNormalized();
synchronized (tess) { synchronized (tess) {
...@@ -121,7 +125,7 @@ public class JoglTesselator { ...@@ -121,7 +125,7 @@ public class JoglTesselator {
GLU.gluTessEndPolygon(tess); GLU.gluTessEndPolygon(tess);
ArrayList<Integer> indices = new ArrayList<>(); ArrayList<Integer> indices = new ArrayList<>();
for (Primitive primitive : primitives) { for (Primitive primitive : primitives) {
primitive.fillListWithIndices(indices); primitive.fillListWithIndices(indices, discardDegeneratedTriangles);
} }
primitives.clear(); primitives.clear();
return new TesselatedPolygon(vertices, indices, p); return new TesselatedPolygon(vertices, indices, p);
...@@ -137,7 +141,7 @@ public class JoglTesselator { ...@@ -137,7 +141,7 @@ public class JoglTesselator {
GLU.gluTessEndContour(tess); GLU.gluTessEndContour(tess);
} }
public static TesselatedRing tesselateRing(LinearRing r) { public static TesselatedRing tesselateRing(LinearRing r, boolean discardDegeneratedTriangles) {
ArrayList<Vector3d> vertices = new ArrayList<>(); ArrayList<Vector3d> vertices = new ArrayList<>();
Vector3d normal = r.calculateNormal(); Vector3d normal = r.calculateNormal();
synchronized (tess) { synchronized (tess) {
...@@ -147,12 +151,16 @@ public class JoglTesselator { ...@@ -147,12 +151,16 @@ public class JoglTesselator {
GLU.gluTessEndPolygon(tess); GLU.gluTessEndPolygon(tess);
ArrayList<Integer> indices = new ArrayList<>(); ArrayList<Integer> indices = new ArrayList<>();
for (Primitive primitive : primitives) { for (Primitive primitive : primitives) {
primitive.fillListWithIndices(indices); primitive.fillListWithIndices(indices, discardDegeneratedTriangles);
} }
primitives.clear(); primitives.clear();
return new TesselatedRing(vertices, indices, r); return new TesselatedRing(vertices, indices, r);
} }
} }
public static TesselatedRing tesselateRing(LinearRing r) {
return tesselateRing(r, true);
}
private JoglTesselator() { private JoglTesselator() {
// only static useage // only static useage
......
This diff is collapsed.
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