Merge pull request #1647 from SiboVG/issue-1646
[#1646] Increase fin root resolution
This commit is contained in:
commit
bf08a88fc7
@ -29,6 +29,12 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona
|
|||||||
*/
|
*/
|
||||||
public static final double MAX_CANT_RADIANS = (15.0 * Math.PI / 180);
|
public static final double MAX_CANT_RADIANS = (15.0 * Math.PI / 180);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maximum number of root points in the root geometry.
|
||||||
|
*/
|
||||||
|
private static final int MAX_ROOT_DIVISIONS = 100;
|
||||||
|
private static final int MAX_ROOT_DIVISIONS_LOW_RES = 15;
|
||||||
|
|
||||||
public void setOverrideMass() {
|
public void setOverrideMass() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -961,6 +967,22 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona
|
|||||||
*/
|
*/
|
||||||
public abstract Coordinate[] getFinPoints();
|
public abstract Coordinate[] getFinPoints();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* used to get body points for the profile design view
|
||||||
|
*
|
||||||
|
* @return points representing the fin-root points, relative to ( x: fin-front, y: centerline ) i.e. relto: fin Component reference point
|
||||||
|
*/
|
||||||
|
public Coordinate[] getRootPoints(final int maximumBodyDivisionCount) {
|
||||||
|
if( null == parent){
|
||||||
|
return new Coordinate[]{Coordinate.ZERO};
|
||||||
|
}
|
||||||
|
|
||||||
|
final Coordinate finLead = getFinFront();
|
||||||
|
final double xFinEnd = finLead.x + getLength();
|
||||||
|
|
||||||
|
return getMountPoints( finLead.x, xFinEnd, -finLead.x, -finLead.y, maximumBodyDivisionCount);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* used to get body points for the profile design view
|
* used to get body points for the profile design view
|
||||||
*
|
*
|
||||||
@ -984,6 +1006,16 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona
|
|||||||
return combineCurves(getFinPoints(), getRootPoints());
|
return combineCurves(getFinPoints(), getRootPoints());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a list of coordinates defining the geometry of a single fin, including the parent's body points .
|
||||||
|
*
|
||||||
|
* This low res version is for 3D rendering, as a too high resolution would cause clipping and invisible fin faces.
|
||||||
|
* This should at one point be solved by rendering the fin faces using triangulation, instead of how it's currently implemented.
|
||||||
|
*/
|
||||||
|
public Coordinate[] getFinPointsWithLowResRoot() {
|
||||||
|
return combineCurves(getFinPoints(), getRootPoints(MAX_ROOT_DIVISIONS_LOW_RES));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a list of X,Y coordinates defining the geometry of a single fin tab.
|
* Return a list of X,Y coordinates defining the geometry of a single fin tab.
|
||||||
* The origin is the leading root edge, and the tab height (or 'depth') is
|
* The origin is the leading root edge, and the tab height (or 'depth') is
|
||||||
@ -997,7 +1029,6 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona
|
|||||||
* @return List of XY-coordinates.
|
* @return List of XY-coordinates.
|
||||||
*/
|
*/
|
||||||
public Coordinate[] getTabPoints() {
|
public Coordinate[] getTabPoints() {
|
||||||
|
|
||||||
if (MathUtil.equals(getTabHeight(), 0) ||
|
if (MathUtil.equals(getTabHeight(), 0) ||
|
||||||
MathUtil.equals(getTabLength(), 0)){
|
MathUtil.equals(getTabLength(), 0)){
|
||||||
return new Coordinate[]{};
|
return new Coordinate[]{};
|
||||||
@ -1013,6 +1044,47 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return generateTabPointsWithRoot(rootPoints);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a list of X,Y coordinates defining the geometry of a single fin tab.
|
||||||
|
* The origin is the leading root edge, and the tab height (or 'depth') is
|
||||||
|
* the radial distance inwards from the reference point, depending on positioning method:
|
||||||
|
* if via TOP: tab front edge
|
||||||
|
* if via MIDDLE: tab middle
|
||||||
|
* if via BOTTOM: tab trailing edge
|
||||||
|
*
|
||||||
|
* The tab coordinates will generally have negative y values.
|
||||||
|
*
|
||||||
|
* This low res version is for 3D rendering, as a too high resolution would cause clipping and invisible fin faces.
|
||||||
|
* This should at one point be solved by rendering the fin faces using triangulation, instead of how it's currently implemented.
|
||||||
|
*
|
||||||
|
* @return List of XY-coordinates.
|
||||||
|
*/
|
||||||
|
public Coordinate[] getTabPointsLowRes() {
|
||||||
|
if (MathUtil.equals(getTabHeight(), 0) ||
|
||||||
|
MathUtil.equals(getTabLength(), 0)){
|
||||||
|
return new Coordinate[]{};
|
||||||
|
}
|
||||||
|
|
||||||
|
final double xTabFront = getTabFrontEdge();
|
||||||
|
final double xTabTrail = getTabTrailingEdge();
|
||||||
|
|
||||||
|
List<Coordinate> rootPoints = new ArrayList<>();
|
||||||
|
for (Coordinate point : getRootPoints(MAX_ROOT_DIVISIONS_LOW_RES)) {
|
||||||
|
if (point.x > xTabFront && point.x < xTabTrail) {
|
||||||
|
rootPoints.add(point);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return generateTabPointsWithRoot(rootPoints);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Coordinate[] generateTabPointsWithRoot(List<Coordinate> rootPoints) {
|
||||||
|
final double xTabFront = getTabFrontEdge();
|
||||||
|
final double xTabTrail = getTabTrailingEdge();
|
||||||
|
|
||||||
Coordinate[] tabPoints = new Coordinate[4];
|
Coordinate[] tabPoints = new Coordinate[4];
|
||||||
final Coordinate finFront = this.getFinFront();
|
final Coordinate finFront = this.getFinFront();
|
||||||
|
|
||||||
@ -1060,7 +1132,8 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona
|
|||||||
*
|
*
|
||||||
* @return points representing the mount's points
|
* @return points representing the mount's points
|
||||||
*/
|
*/
|
||||||
private Coordinate[] getMountPoints(final double xStart, final double xEnd, final double xOffset, final double yOffset) {
|
private Coordinate[] getMountPoints(final double xStart, final double xEnd, final double xOffset, final double yOffset,
|
||||||
|
final int maximumBodyDivisionCount) {
|
||||||
if (parent == null) {
|
if (parent == null) {
|
||||||
return new Coordinate[]{Coordinate.ZERO};
|
return new Coordinate[]{Coordinate.ZERO};
|
||||||
}
|
}
|
||||||
@ -1077,7 +1150,7 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona
|
|||||||
divisionCount = (int) Math.ceil(intervalLength / xWidth);
|
divisionCount = (int) Math.ceil(intervalLength / xWidth);
|
||||||
|
|
||||||
// When creating body curves, don't create more than this many divisions. -- only relevant on very large components
|
// When creating body curves, don't create more than this many divisions. -- only relevant on very large components
|
||||||
final int maximumBodyDivisionCount = 100;
|
// a too high division count will cause the 3D render to have invisible faces because it can't deal with the geometry.
|
||||||
divisionCount = Math.min(maximumBodyDivisionCount, divisionCount);
|
divisionCount = Math.min(maximumBodyDivisionCount, divisionCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1108,6 +1181,10 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona
|
|||||||
return points;
|
return points;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Coordinate[] getMountPoints(final double xStart, final double xEnd, final double xOffset, final double yOffset) {
|
||||||
|
return getMountPoints(xStart, xEnd, xOffset, yOffset, MAX_ROOT_DIVISIONS);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getAngleOffset() {
|
public double getAngleOffset() {
|
||||||
return firstFinOffsetRadians;
|
return firstFinOffsetRadians;
|
||||||
|
@ -34,8 +34,9 @@ public class FinRenderer {
|
|||||||
gl.glTranslated(-bounds.min.x, -bounds.min.y - finSet.getBodyRadius(), 0);
|
gl.glTranslated(-bounds.min.x, -bounds.min.y - finSet.getBodyRadius(), 0);
|
||||||
gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
|
gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
|
||||||
|
|
||||||
Coordinate finPoints[] = finSet.getFinPointsWithRoot();
|
Coordinate[] finPoints = finSet.getFinPointsWithLowResRoot();
|
||||||
Coordinate tabPoints[] = finSet.getTabPoints();
|
Coordinate[] tabPoints = finSet.getTabPointsLowRes();
|
||||||
|
|
||||||
{
|
{
|
||||||
gl.glPushMatrix();
|
gl.glPushMatrix();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user