Skip to content

Commit

Permalink
Fixed train track insert while in submodel editing.
Browse files Browse the repository at this point in the history
  • Loading branch information
leozide committed Nov 30, 2024
1 parent 17078dd commit 642e096
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
7 changes: 7 additions & 0 deletions common/lc_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<lcPiece>& 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)
Expand Down
1 change: 0 additions & 1 deletion common/lc_traintrack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions common/lc_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,9 @@ void lcView::UpdatePiecePreview()
lcTrainTrackType TrainTrackType = static_cast<lcTrainTrackType>((mTrackToolSection >> 8) & 0xff);

std::tie(PreviewInfo, mPiecePreviewTransform) = TrainTrackInfo->GetPieceInsertTransform(Piece, ConnectionIndex, TrainTrackType);

if (GetActiveModel() != mModel)
mPiecePreviewTransform = lcMul(mPiecePreviewTransform, mActiveSubmodelTransform);
}
}

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 642e096

Please sign in to comment.