[fix] Rail Buttons now properly display in 2d side views (when the rocket is rotated

This commit is contained in:
Daniel_M_Williams 2020-05-08 17:35:32 -04:00
parent deed818fd3
commit 4ba395ac77

View File

@ -18,7 +18,11 @@ public class RailButtonShapes extends RocketComponentShape {
RailButton btn = (RailButton)component;
final double rotation_rad = btn.getAngleOffset();
final Coordinate instanceAbsoluteLocation = transformation.transform(Coordinate.ZERO);
final Coordinate unitOrientation = transformation.transform(new Coordinate(0,1,0));
final double view_rotation_rad = -Math.atan2(unitOrientation.y, unitOrientation.z) + Math.PI/2;
final double angle_offset_rad = btn.getAngleOffset();
final double baseHeight = btn.getStandoff();
final double innerHeight = btn.getInnerHeight();
final double flangeHeight = btn.getFlangeHeight();
@ -27,18 +31,16 @@ public class RailButtonShapes extends RocketComponentShape {
final double innerDiameter = btn.getInnerDiameter();
final double innerRadius = innerDiameter/2;
final double sinr = Math.abs(Math.sin(rotation_rad));
final double cosr = Math.cos(rotation_rad);
final double sinr = Math.abs(Math.sin(angle_offset_rad + view_rotation_rad));
final double cosr = Math.cos(angle_offset_rad + view_rotation_rad);
final double baseHeightcos = baseHeight*cosr;
final double innerHeightcos = innerHeight*cosr;
final double flangeHeightcos = flangeHeight*cosr;
final Coordinate instanceAbsoluteLocation = transformation.transform(Coordinate.ZERO);
// System.err.println(String.format("Generating Shapes for RailButtons..."));
// System.err.println(String.format(" @ %s", instanceAbsoluteLocation));
// System.err.println(String.format(" angle: %f", view_rotation_rad));
System.err.println(String.format("Generating Shapes for RailButtons..."));
System.err.println(String.format(" @ %s", instanceAbsoluteLocation));
Path2D.Double path = new Path2D.Double();
{// central pillar
final double drawWidth = outerDiameter;