From d2acd0ed0184ff4244fae0bd1535b5c87794c13c Mon Sep 17 00:00:00 2001 From: SiboVG Date: Mon, 28 Feb 2022 00:24:14 +0100 Subject: [PATCH] [fixes #1164] Account for different RockSim FinSet location directions --- .../file/rocksim/importt/FinSetHandler.java | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/core/src/net/sf/openrocket/file/rocksim/importt/FinSetHandler.java b/core/src/net/sf/openrocket/file/rocksim/importt/FinSetHandler.java index fed01a4f7..84f9d473e 100644 --- a/core/src/net/sf/openrocket/file/rocksim/importt/FinSetHandler.java +++ b/core/src/net/sf/openrocket/file/rocksim/importt/FinSetHandler.java @@ -146,6 +146,11 @@ class FinSetHandler extends AbstractElementHandler { private final RockSimAppearanceBuilder appearanceBuilder; + /** + * Checks whether the location is already loaded in or not + */ + private boolean locationLoaded = false; + /** * Constructor. * @@ -180,12 +185,27 @@ class FinSetHandler extends AbstractElementHandler { finish = RocksimFinishCode.fromCode(Integer.parseInt(content)).asOpenRocket(); } if (RocksimCommonConstants.XB.equals(element)) { - // Opposite value accounts for the different relative distance directions used + location = Double.parseDouble(content) / RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_LENGTH; + + // Account for the different relative distance directions used // Issue Ref: https://github.com/openrocket/openrocket/issues/881 - location = -Double.parseDouble(content) / RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_LENGTH; + if (axialMethod != null) { + if (axialMethod == AxialMethod.BOTTOM) { + location = -location; + } + } + + this.locationLoaded = true; } if (RocksimCommonConstants.LOCATION_MODE.equals(element)) { axialMethod = RocksimLocationMode.fromCode(Integer.parseInt(content)).asOpenRocket(); + + // If the location is loaded before the axialMethod, we still need to correct for the different relative distance directions + if (locationLoaded) { + if (axialMethod == AxialMethod.BOTTOM) { + location = -location; + } + } } if (RocksimCommonConstants.FIN_COUNT.equals(element)) { finCount = Integer.parseInt(content);