From fee870d33d971fdffc8237a6c38610fa3dd0177c Mon Sep 17 00:00:00 2001 From: Leonardo Zide Date: Sat, 30 Nov 2024 19:06:43 -0800 Subject: [PATCH] Fixed invalid transform when inserting without a track focused. --- common/lc_traintrack.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/common/lc_traintrack.cpp b/common/lc_traintrack.cpp index 1f83fb8c..060f63be 100644 --- a/common/lc_traintrack.cpp +++ b/common/lc_traintrack.cpp @@ -14,6 +14,8 @@ // move config to json // add other track types // macros to encode/decode mTrackToolSection +// better transform and connection selection when adding with the keyboard, keep the same curve direction and use straight for branches +// set focus connection after adding void lcTrainTrackInit(lcPiecesLibrary* Library) { @@ -163,13 +165,13 @@ std::optional lcTrainTrackInfo::GetPieceInsertTransform(lcPiece* Cur const quint32 FocusSection = CurrentPiece->GetFocusSection(); quint32 ConnectionIndex = 0; - if (FocusSection == LC_PIECE_SECTION_POSITION || FocusSection == LC_PIECE_SECTION_INVALID) + if (FocusSection == LC_PIECE_SECTION_POSITION) { for (ConnectionIndex = 0; ConnectionIndex < CurrentTrackInfo->GetConnections().size(); ConnectionIndex++) if (!CurrentPiece->IsTrainTrackConnected(ConnectionIndex)) break; } - else + else if (FocusSection != LC_PIECE_SECTION_INVALID) { if (FocusSection < LC_PIECE_SECTION_TRAIN_TRACK_CONNECTION_FIRST) return std::nullopt;