diff --git a/common/lc_model.cpp b/common/lc_model.cpp index 1ba7e6a5..9a1a7456 100644 --- a/common/lc_model.cpp +++ b/common/lc_model.cpp @@ -1348,8 +1348,15 @@ void lcModel::GetScene(lcScene* Scene, const lcCamera* ViewCamera, bool AllowHig void lcModel::AddSubModelRenderMeshes(lcScene* Scene, const lcMatrix44& WorldMatrix, int DefaultColorIndex, lcRenderMeshState RenderMeshState, bool ParentActive) const { for (const std::unique_ptr& Piece : mPieces) + { if (Piece->IsVisibleInSubModel()) + { + if (Piece->IsFocused()) + UpdateTrainTrackConnections(Piece.get()); + Piece->AddSubModelRenderMeshes(Scene, WorldMatrix, DefaultColorIndex, RenderMeshState, ParentActive); + } + } } QImage lcModel::GetStepImage(bool Zoom, int Width, int Height, lcStep Step) diff --git a/common/lc_traintrack.cpp b/common/lc_traintrack.cpp index 9665aefd..1f83fb8c 100644 --- a/common/lc_traintrack.cpp +++ b/common/lc_traintrack.cpp @@ -13,7 +13,6 @@ // shortcuts for changing active connection // move config to json // add other track types -// crash when focusing a track during in place submodel editing because GetScene doesn't have the focus piece // macros to encode/decode mTrackToolSection void lcTrainTrackInit(lcPiecesLibrary* Library) diff --git a/common/lc_view.cpp b/common/lc_view.cpp index 3801c5c9..53af95c5 100644 --- a/common/lc_view.cpp +++ b/common/lc_view.cpp @@ -438,6 +438,9 @@ void lcView::UpdatePiecePreview() lcTrainTrackType TrainTrackType = static_cast((mTrackToolSection >> 8) & 0xff); std::tie(PreviewInfo, mPiecePreviewTransform) = TrainTrackInfo->GetPieceInsertTransform(Piece, ConnectionIndex, TrainTrackType); + + if (GetActiveModel() != mModel) + mPiecePreviewTransform = lcMul(mPiecePreviewTransform, mActiveSubmodelTransform); } } @@ -2497,6 +2500,9 @@ void lcView::OnButtonDown(lcTrackButton TrackButton) if (!mPiecePreviewInfo) break; + if (GetActiveModel() != mModel) + mPiecePreviewTransform = lcMul(mPiecePreviewTransform, lcMatrix44AffineInverse(mActiveSubmodelTransform)); + ActiveModel->InsertPieceToolClicked(mPiecePreviewInfo, mPiecePreviewTransform); if ((mMouseModifiers & Qt::ControlModifier) == 0)