Fixed train track insert while in submodel editing.
Some checks failed
LeoCAD CI / build-ubuntu (push) Has been cancelled
LeoCAD CI / build-macos (push) Has been cancelled

This commit is contained in:
Leonardo Zide 2024-11-30 12:47:40 -08:00
parent 17078dd447
commit 642e0965ae
3 changed files with 13 additions and 1 deletions

View file

@ -1348,9 +1348,16 @@ 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 void lcModel::AddSubModelRenderMeshes(lcScene* Scene, const lcMatrix44& WorldMatrix, int DefaultColorIndex, lcRenderMeshState RenderMeshState, bool ParentActive) const
{ {
for (const std::unique_ptr<lcPiece>& Piece : mPieces) for (const std::unique_ptr<lcPiece>& Piece : mPieces)
{
if (Piece->IsVisibleInSubModel()) if (Piece->IsVisibleInSubModel())
{
if (Piece->IsFocused())
UpdateTrainTrackConnections(Piece.get());
Piece->AddSubModelRenderMeshes(Scene, WorldMatrix, DefaultColorIndex, RenderMeshState, ParentActive); Piece->AddSubModelRenderMeshes(Scene, WorldMatrix, DefaultColorIndex, RenderMeshState, ParentActive);
} }
}
}
QImage lcModel::GetStepImage(bool Zoom, int Width, int Height, lcStep Step) QImage lcModel::GetStepImage(bool Zoom, int Width, int Height, lcStep Step)
{ {

View file

@ -13,7 +13,6 @@
// shortcuts for changing active connection // shortcuts for changing active connection
// move config to json // move config to json
// add other track types // 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 // macros to encode/decode mTrackToolSection
void lcTrainTrackInit(lcPiecesLibrary* Library) void lcTrainTrackInit(lcPiecesLibrary* Library)

View file

@ -438,6 +438,9 @@ void lcView::UpdatePiecePreview()
lcTrainTrackType TrainTrackType = static_cast<lcTrainTrackType>((mTrackToolSection >> 8) & 0xff); lcTrainTrackType TrainTrackType = static_cast<lcTrainTrackType>((mTrackToolSection >> 8) & 0xff);
std::tie(PreviewInfo, mPiecePreviewTransform) = TrainTrackInfo->GetPieceInsertTransform(Piece, ConnectionIndex, TrainTrackType); 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) if (!mPiecePreviewInfo)
break; break;
if (GetActiveModel() != mModel)
mPiecePreviewTransform = lcMul(mPiecePreviewTransform, lcMatrix44AffineInverse(mActiveSubmodelTransform));
ActiveModel->InsertPieceToolClicked(mPiecePreviewInfo, mPiecePreviewTransform); ActiveModel->InsertPieceToolClicked(mPiecePreviewInfo, mPiecePreviewTransform);
if ((mMouseModifiers & Qt::ControlModifier) == 0) if ((mMouseModifiers & Qt::ControlModifier) == 0)