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);
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
}
|
||||
|
||||
@ -961,6 +967,22 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona
|
||||
*/
|
||||
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
|
||||
*
|
||||
@ -984,6 +1006,16 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona
|
||||
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.
|
||||
* 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.
|
||||
*/
|
||||
public Coordinate[] getTabPoints() {
|
||||
|
||||
if (MathUtil.equals(getTabHeight(), 0) ||
|
||||
MathUtil.equals(getTabLength(), 0)){
|
||||
return new Coordinate[]{};
|
||||
@ -1013,9 +1044,50 @@ 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];
|
||||
final Coordinate finFront = this.getFinFront();
|
||||
|
||||
|
||||
final SymmetricComponent body = (SymmetricComponent)this.getParent();
|
||||
|
||||
// // limit the new heights to be no greater than the current body radius.
|
||||
@ -1023,8 +1095,8 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona
|
||||
double yTabTrail = Double.NaN;
|
||||
double yTabBottom = Double.NaN;
|
||||
if( null != body ){
|
||||
yTabFront = body.getRadius( finFront.x + xTabFront ) - finFront.y;
|
||||
yTabTrail = body.getRadius( finFront.x + xTabTrail ) - finFront.y;
|
||||
yTabFront = body.getRadius( finFront.x + xTabFront) - finFront.y;
|
||||
yTabTrail = body.getRadius( finFront.x + xTabTrail) - finFront.y;
|
||||
yTabBottom = MathUtil.min(yTabFront, yTabTrail) - tabHeight;
|
||||
}
|
||||
|
||||
@ -1060,7 +1132,8 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona
|
||||
*
|
||||
* @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) {
|
||||
return new Coordinate[]{Coordinate.ZERO};
|
||||
}
|
||||
@ -1077,7 +1150,7 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona
|
||||
divisionCount = (int) Math.ceil(intervalLength / xWidth);
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
@ -1107,6 +1180,10 @@ public abstract class FinSet extends ExternalComponent implements AxialPositiona
|
||||
|
||||
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
|
||||
public double getAngleOffset() {
|
||||
|
@ -34,8 +34,9 @@ public class FinRenderer {
|
||||
gl.glTranslated(-bounds.min.x, -bounds.min.y - finSet.getBodyRadius(), 0);
|
||||
gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
|
||||
|
||||
Coordinate finPoints[] = finSet.getFinPointsWithRoot();
|
||||
Coordinate tabPoints[] = finSet.getTabPoints();
|
||||
Coordinate[] finPoints = finSet.getFinPointsWithLowResRoot();
|
||||
Coordinate[] tabPoints = finSet.getTabPointsLowRes();
|
||||
|
||||
{
|
||||
gl.glPushMatrix();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user