Merge pull request #1839 from SiboVG/issue-1829
[#1829] Fix tessellation issue on fins with curved root
This commit is contained in:
commit
4c151b2fa0
@ -33,7 +33,7 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona
|
|||||||
* Maximum number of root points in the root geometry.
|
* Maximum number of root points in the root geometry.
|
||||||
*/
|
*/
|
||||||
private static final int MAX_ROOT_DIVISIONS = 100;
|
private static final int MAX_ROOT_DIVISIONS = 100;
|
||||||
private static final int MAX_ROOT_DIVISIONS_LOW_RES = 15;
|
private static final int MAX_ROOT_DIVISIONS_LOW_RES = MAX_ROOT_DIVISIONS / 5;
|
||||||
|
|
||||||
public void setOverrideMass() {
|
public void setOverrideMass() {
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ import net.sf.openrocket.util.Coordinate;
|
|||||||
import net.sf.openrocket.gui.figure3d.geometry.Geometry.Surface;
|
import net.sf.openrocket.gui.figure3d.geometry.Geometry.Surface;
|
||||||
|
|
||||||
public class FinRenderer {
|
public class FinRenderer {
|
||||||
private GLUtessellator tobj = GLU.gluNewTess();
|
private GLUtessellator tess = GLU.gluNewTess();
|
||||||
|
|
||||||
public void renderFinSet(final GL2 gl, FinSet finSet, Surface which) {
|
public void renderFinSet(final GL2 gl, FinSet finSet, Surface which) {
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ public class FinRenderer {
|
|||||||
GLUtessellatorCallback cb = new GLUtessellatorCallbackAdapter() {
|
GLUtessellatorCallback cb = new GLUtessellatorCallbackAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void vertex(Object vertexData) {
|
public void vertex(Object vertexData) {
|
||||||
double d[] = (double[]) vertexData;
|
double[] d = (double[]) vertexData;
|
||||||
gl.glTexCoord2d(d[0], d[1]);
|
gl.glTexCoord2d(d[0], d[1]);
|
||||||
gl.glVertex3dv(d, 0);
|
gl.glVertex3dv(d, 0);
|
||||||
}
|
}
|
||||||
@ -64,70 +64,83 @@ public class FinRenderer {
|
|||||||
public void end() {
|
public void end() {
|
||||||
gl.glEnd();
|
gl.glEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void combine(double[] coords, Object[] data, float[] weight, Object[] outData) {
|
||||||
|
double[] vertex = new double[3];
|
||||||
|
vertex[0] = coords[0];
|
||||||
|
vertex[1] = coords[1];
|
||||||
|
vertex[2] = coords[2];
|
||||||
|
outData[0] = vertex;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
GLU.gluTessCallback(tobj, GLU.GLU_TESS_VERTEX, cb);
|
GLU.gluTessCallback(tess, GLU.GLU_TESS_VERTEX, cb);
|
||||||
GLU.gluTessCallback(tobj, GLU.GLU_TESS_BEGIN, cb);
|
GLU.gluTessCallback(tess, GLU.GLU_TESS_BEGIN, cb);
|
||||||
GLU.gluTessCallback(tobj, GLU.GLU_TESS_END, cb);
|
GLU.gluTessCallback(tess, GLU.GLU_TESS_END, cb);
|
||||||
|
GLU.gluTessCallback(tess, GLU.GLU_TESS_COMBINE, cb);
|
||||||
|
|
||||||
// fin side: +z
|
// fin side: +z
|
||||||
if (finSet.getSpan() > 0 && finSet.getLength() > 0 && which == Surface.INSIDE) { // Right side
|
if (finSet.getSpan() > 0 && finSet.getLength() > 0 && which == Surface.INSIDE) { // Right side
|
||||||
GLU.gluTessBeginPolygon(tobj, null);
|
GLU.gluTessBeginPolygon(tess, null);
|
||||||
GLU.gluTessBeginContour(tobj);
|
GLU.gluTessBeginContour(tess);
|
||||||
gl.glNormal3f(0, 0, 1);
|
gl.glNormal3f(0, 0, 1);
|
||||||
for (int i = finPoints.length - 1; i >= 0; i--) {
|
for (int i = finPoints.length - 1; i >= 0; i--) {
|
||||||
Coordinate c = finPoints[i];
|
Coordinate c = finPoints[i];
|
||||||
double[] p = new double[]{c.x, c.y + finSet.getBodyRadius(),
|
double[] p = new double[]{c.x, c.y + finSet.getBodyRadius(),
|
||||||
c.z + finSet.getThickness() / 2.0};
|
c.z + finSet.getThickness() / 2.0};
|
||||||
GLU.gluTessVertex(tobj, p, 0, p);
|
GLU.gluTessVertex(tess, p, 0, p);
|
||||||
}
|
}
|
||||||
GLU.gluTessEndContour(tobj);
|
GLU.gluTessEndContour(tess);
|
||||||
GLU.gluTessEndPolygon(tobj);
|
GLU.gluTessEndPolygon(tess);
|
||||||
}
|
}
|
||||||
// tab side: +z
|
// tab side: +z
|
||||||
if (finSet.getTabHeight() > 0 && finSet.getTabLength() > 0 && which == Surface.INSIDE) { // Right side
|
if (finSet.getTabHeight() > 0 && finSet.getTabLength() > 0 && which == Surface.INSIDE) { // Right side
|
||||||
GLU.gluTessBeginPolygon(tobj, null);
|
GLU.gluTessBeginPolygon(tess, null);
|
||||||
GLU.gluTessBeginContour(tobj);
|
GLU.gluTessBeginContour(tess);
|
||||||
gl.glNormal3f(0, 0, 1);
|
gl.glNormal3f(0, 0, 1);
|
||||||
for (int i = tabPoints.length - 1; i >= 0; i--) {
|
for (int i = tabPoints.length - 1; i >= 0; i--) {
|
||||||
Coordinate c = tabPoints[i];
|
Coordinate c = tabPoints[i];
|
||||||
double[] p = new double[]{c.x, c.y + finSet.getBodyRadius(),
|
double[] p = new double[]{c.x, c.y + finSet.getBodyRadius(),
|
||||||
c.z + finSet.getThickness() / 2.0};
|
c.z + finSet.getThickness() / 2.0};
|
||||||
GLU.gluTessVertex(tobj, p, 0, p);
|
GLU.gluTessVertex(tess, p, 0, p);
|
||||||
}
|
}
|
||||||
GLU.gluTessEndContour(tobj);
|
GLU.gluTessEndContour(tess);
|
||||||
GLU.gluTessEndPolygon(tobj);
|
GLU.gluTessEndPolygon(tess);
|
||||||
}
|
}
|
||||||
|
|
||||||
// fin side: -z
|
// fin side: -z
|
||||||
if (finSet.getSpan() > 0 && finSet.getLength() > 0 && which == Surface.OUTSIDE) { // Left side
|
if (finSet.getSpan() > 0 && finSet.getLength() > 0 && which == Surface.OUTSIDE) { // Left side
|
||||||
GLU.gluTessBeginPolygon(tobj, null);
|
GLU.gluTessBeginPolygon(tess, null);
|
||||||
GLU.gluTessBeginContour(tobj);
|
GLU.gluTessBeginContour(tess);
|
||||||
gl.glNormal3f(0, 0, -1);
|
gl.glNormal3f(0, 0, -1);
|
||||||
for (Coordinate c : finPoints) {
|
for (Coordinate c : finPoints) {
|
||||||
double[] p = new double[]{c.x, c.y + finSet.getBodyRadius(),
|
double[] p = new double[]{c.x, c.y + finSet.getBodyRadius(),
|
||||||
c.z - finSet.getThickness() / 2.0};
|
c.z - finSet.getThickness() / 2.0};
|
||||||
GLU.gluTessVertex(tobj, p, 0, p);
|
GLU.gluTessVertex(tess, p, 0, p);
|
||||||
|
|
||||||
}
|
}
|
||||||
GLU.gluTessEndContour(tobj);
|
GLU.gluTessEndContour(tess);
|
||||||
GLU.gluTessEndPolygon(tobj);
|
GLU.gluTessEndPolygon(tess);
|
||||||
}
|
}
|
||||||
// tab side: -z
|
// tab side: -z
|
||||||
if (finSet.getTabHeight() > 0 && finSet.getTabLength() > 0 && which == Surface.OUTSIDE) { // Left side
|
if (finSet.getTabHeight() > 0 && finSet.getTabLength() > 0 && which == Surface.OUTSIDE) { // Left side
|
||||||
GLU.gluTessBeginPolygon(tobj, null);
|
GLU.gluTessBeginPolygon(tess, null);
|
||||||
GLU.gluTessBeginContour(tobj);
|
GLU.gluTessBeginContour(tess);
|
||||||
gl.glNormal3f(0, 0, -1);
|
gl.glNormal3f(0, 0, -1);
|
||||||
for (Coordinate c : tabPoints) {
|
for (Coordinate c : tabPoints) {
|
||||||
double[] p = new double[]{c.x, c.y + finSet.getBodyRadius(),
|
double[] p = new double[]{c.x, c.y + finSet.getBodyRadius(),
|
||||||
c.z - finSet.getThickness() / 2.0};
|
c.z - finSet.getThickness() / 2.0};
|
||||||
GLU.gluTessVertex(tobj, p, 0, p);
|
GLU.gluTessVertex(tess, p, 0, p);
|
||||||
|
|
||||||
}
|
}
|
||||||
GLU.gluTessEndContour(tobj);
|
GLU.gluTessEndContour(tess);
|
||||||
GLU.gluTessEndPolygon(tobj);
|
GLU.gluTessEndPolygon(tess);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// delete tessellator after processing
|
||||||
|
GLU.gluDeleteTess(tess);
|
||||||
|
|
||||||
// Fin strip around the edge
|
// Fin strip around the edge
|
||||||
if (finSet.getSpan() > 0 && finSet.getLength() > 0 && which == Surface.EDGES) {
|
if (finSet.getSpan() > 0 && finSet.getLength() > 0 && which == Surface.EDGES) {
|
||||||
if (!(finSet instanceof EllipticalFinSet))
|
if (!(finSet instanceof EllipticalFinSet))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user