From f8a85809e805975f6a4554370a886354299c3bff Mon Sep 17 00:00:00 2001 From: leo Date: Mon, 16 Mar 2015 01:15:30 +0000 Subject: [PATCH] Fixed multiple checkpoints when using the mouse to edit. --- common/lc_mainwindow.cpp | 24 ++++++++++++------------ common/lc_model.cpp | 22 ++++++++++++---------- common/lc_model.h | 8 ++++---- 3 files changed, 28 insertions(+), 26 deletions(-) diff --git a/common/lc_mainwindow.cpp b/common/lc_mainwindow.cpp index 09292804..91fd4252 100644 --- a/common/lc_mainwindow.cpp +++ b/common/lc_mainwindow.cpp @@ -1939,51 +1939,51 @@ void lcMainWindow::HandleCommand(lcCommandId CommandId) break; case LC_PIECE_MOVE_PLUSX: - lcGetActiveModel()->MoveSelectedObjects(mActiveView->GetMoveDirection(lcVector3(lcMax(GetMoveXYSnap(), 0.01f), 0.0f, 0.0f)), true, true); + lcGetActiveModel()->MoveSelectedObjects(mActiveView->GetMoveDirection(lcVector3(lcMax(GetMoveXYSnap(), 0.01f), 0.0f, 0.0f)), true, true, true); break; case LC_PIECE_MOVE_MINUSX: - lcGetActiveModel()->MoveSelectedObjects(mActiveView->GetMoveDirection(lcVector3(-lcMax(GetMoveXYSnap(), 0.01f), 0.0f, 0.0f)), true, true); + lcGetActiveModel()->MoveSelectedObjects(mActiveView->GetMoveDirection(lcVector3(-lcMax(GetMoveXYSnap(), 0.01f), 0.0f, 0.0f)), true, true, true); break; case LC_PIECE_MOVE_PLUSY: - lcGetActiveModel()->MoveSelectedObjects(mActiveView->GetMoveDirection(lcVector3(0.0f, lcMax(GetMoveXYSnap(), 0.01f), 0.0f)), true, true); + lcGetActiveModel()->MoveSelectedObjects(mActiveView->GetMoveDirection(lcVector3(0.0f, lcMax(GetMoveXYSnap(), 0.01f), 0.0f)), true, true, true); break; case LC_PIECE_MOVE_MINUSY: - lcGetActiveModel()->MoveSelectedObjects(mActiveView->GetMoveDirection(lcVector3(0.0f, -lcMax(GetMoveXYSnap(), 0.01f), 0.0f)), true, true); + lcGetActiveModel()->MoveSelectedObjects(mActiveView->GetMoveDirection(lcVector3(0.0f, -lcMax(GetMoveXYSnap(), 0.01f), 0.0f)), true, true, true); break; case LC_PIECE_MOVE_PLUSZ: - lcGetActiveModel()->MoveSelectedObjects(mActiveView->GetMoveDirection(lcVector3(0.0f, 0.0f, lcMax(GetMoveZSnap(), 0.01f))), true, true); + lcGetActiveModel()->MoveSelectedObjects(mActiveView->GetMoveDirection(lcVector3(0.0f, 0.0f, lcMax(GetMoveZSnap(), 0.01f))), true, true, true); break; case LC_PIECE_MOVE_MINUSZ: - lcGetActiveModel()->MoveSelectedObjects(mActiveView->GetMoveDirection(lcVector3(0.0f, 0.0f, -lcMax(GetMoveZSnap(), 0.01f))), true, true); + lcGetActiveModel()->MoveSelectedObjects(mActiveView->GetMoveDirection(lcVector3(0.0f, 0.0f, -lcMax(GetMoveZSnap(), 0.01f))), true, true, true); break; case LC_PIECE_ROTATE_PLUSX: - lcGetActiveModel()->RotateSelectedPieces(mActiveView->GetMoveDirection(lcVector3(lcMax(GetAngleSnap(), 1.0f), 0.0f, 0.0f)), true, true); + lcGetActiveModel()->RotateSelectedPieces(mActiveView->GetMoveDirection(lcVector3(lcMax(GetAngleSnap(), 1.0f), 0.0f, 0.0f)), true, true, true); break; case LC_PIECE_ROTATE_MINUSX: - lcGetActiveModel()->RotateSelectedPieces(mActiveView->GetMoveDirection(-lcVector3(lcMax(GetAngleSnap(), 1.0f), 0.0f, 0.0f)), true, true); + lcGetActiveModel()->RotateSelectedPieces(mActiveView->GetMoveDirection(-lcVector3(lcMax(GetAngleSnap(), 1.0f), 0.0f, 0.0f)), true, true, true); break; case LC_PIECE_ROTATE_PLUSY: - lcGetActiveModel()->RotateSelectedPieces(mActiveView->GetMoveDirection(lcVector3(0.0f, lcMax(GetAngleSnap(), 1.0f), 0.0f)), true, true); + lcGetActiveModel()->RotateSelectedPieces(mActiveView->GetMoveDirection(lcVector3(0.0f, lcMax(GetAngleSnap(), 1.0f), 0.0f)), true, true, true); break; case LC_PIECE_ROTATE_MINUSY: - lcGetActiveModel()->RotateSelectedPieces(mActiveView->GetMoveDirection(lcVector3(0.0f, -lcMax(GetAngleSnap(), 1.0f), 0.0f)), true, true); + lcGetActiveModel()->RotateSelectedPieces(mActiveView->GetMoveDirection(lcVector3(0.0f, -lcMax(GetAngleSnap(), 1.0f), 0.0f)), true, true, true); break; case LC_PIECE_ROTATE_PLUSZ: - lcGetActiveModel()->RotateSelectedPieces(mActiveView->GetMoveDirection(lcVector3(0.0f, 0.0f, lcMax(GetAngleSnap(), 1.0f))), true, true); + lcGetActiveModel()->RotateSelectedPieces(mActiveView->GetMoveDirection(lcVector3(0.0f, 0.0f, lcMax(GetAngleSnap(), 1.0f))), true, true, true); break; case LC_PIECE_ROTATE_MINUSZ: - lcGetActiveModel()->RotateSelectedPieces(mActiveView->GetMoveDirection(lcVector3(0.0f, 0.0f, -lcMax(GetAngleSnap(), 1.0f))), true, true); + lcGetActiveModel()->RotateSelectedPieces(mActiveView->GetMoveDirection(lcVector3(0.0f, 0.0f, -lcMax(GetAngleSnap(), 1.0f))), true, true, true); break; case LC_PIECE_MINIFIG_WIZARD: diff --git a/common/lc_model.cpp b/common/lc_model.cpp index f939e3c1..245e5dc4 100644 --- a/common/lc_model.cpp +++ b/common/lc_model.cpp @@ -2048,7 +2048,7 @@ bool lcModel::RemoveSelectedObjects() return RemovedPiece || RemovedCamera || RemovedLight; } -void lcModel::MoveSelectedObjects(const lcVector3& PieceDistance, const lcVector3& ObjectDistance, bool Relative, bool Update) +void lcModel::MoveSelectedObjects(const lcVector3& PieceDistance, const lcVector3& ObjectDistance, bool Relative, bool Update, bool Checkpoint) { bool Moved = false; lcMatrix44 RelativeRotation; @@ -2107,12 +2107,13 @@ void lcModel::MoveSelectedObjects(const lcVector3& PieceDistance, const lcVector if (Moved && Update) { gMainWindow->UpdateAllViews(); - SaveCheckpoint("Moving"); + if (Checkpoint) + SaveCheckpoint("Moving"); gMainWindow->UpdateFocusObject(GetFocusObject()); } } -void lcModel::RotateSelectedPieces(const lcVector3& Angles, bool Relative, bool Update) +void lcModel::RotateSelectedPieces(const lcVector3& Angles, bool Relative, bool Update, bool Checkpoint) { if (Angles.LengthSquared() < 0.001f) return; @@ -2203,7 +2204,8 @@ void lcModel::RotateSelectedPieces(const lcVector3& Angles, bool Relative, bool if (Rotated && Update) { gMainWindow->UpdateAllViews(); - SaveCheckpoint("Rotating"); + if (Checkpoint) + SaveCheckpoint("Rotating"); gMainWindow->UpdateFocusObject(GetFocusObject()); } } @@ -2213,19 +2215,19 @@ void lcModel::TransformSelectedObjects(lcTransformType TransformType, const lcVe switch (TransformType) { case LC_TRANSFORM_ABSOLUTE_TRANSLATION: - MoveSelectedObjects(Transform, false, true); + MoveSelectedObjects(Transform, false, true, true); break; case LC_TRANSFORM_RELATIVE_TRANSLATION: - MoveSelectedObjects(Transform, true, true); + MoveSelectedObjects(Transform, true, true, true); break; case LC_TRANSFORM_ABSOLUTE_ROTATION: - RotateSelectedPieces(Transform, false, true); + RotateSelectedPieces(Transform, false, true, true); break; case LC_TRANSFORM_RELATIVE_ROTATION: - RotateSelectedPieces(Transform, true, true); + RotateSelectedPieces(Transform, true, true, true); break; } } @@ -3273,7 +3275,7 @@ void lcModel::UpdateMoveTool(const lcVector3& Distance) lcVector3 PieceDistance = LockVector(SnapPosition(Distance) - SnapPosition(mMouseToolDistance)); lcVector3 ObjectDistance = Distance - mMouseToolDistance; - MoveSelectedObjects(PieceDistance, ObjectDistance, true, true); + MoveSelectedObjects(PieceDistance, ObjectDistance, true, true, false); mMouseToolDistance = Distance; gMainWindow->UpdateFocusObject(GetFocusObject()); @@ -3283,7 +3285,7 @@ void lcModel::UpdateMoveTool(const lcVector3& Distance) void lcModel::UpdateRotateTool(const lcVector3& Angles) { lcVector3 Delta = LockVector(SnapRotation(Angles) - SnapRotation(mMouseToolDistance)); - RotateSelectedPieces(Delta, true, false); + RotateSelectedPieces(Delta, true, false, false); mMouseToolDistance = Angles; gMainWindow->UpdateFocusObject(GetFocusObject()); diff --git a/common/lc_model.h b/common/lc_model.h index cb197915..edf5d47d 100644 --- a/common/lc_model.h +++ b/common/lc_model.h @@ -300,13 +300,13 @@ public: void ZoomExtents(lcCamera* Camera, float Aspect); void Zoom(lcCamera* Camera, float Amount); - void MoveSelectedObjects(const lcVector3& Distance, bool Relative, bool Update) + void MoveSelectedObjects(const lcVector3& Distance, bool Relative, bool Update, bool Checkpoint) { - MoveSelectedObjects(Distance, Distance, Relative, Update); + MoveSelectedObjects(Distance, Distance, Relative, Update, Checkpoint); } - void MoveSelectedObjects(const lcVector3& PieceDistance, const lcVector3& ObjectDistance, bool Relative, bool Update); - void RotateSelectedPieces(const lcVector3& Angles, bool Relative, bool Update); + void MoveSelectedObjects(const lcVector3& PieceDistance, const lcVector3& ObjectDistance, bool Relative, bool Update, bool Checkpoint); + void RotateSelectedPieces(const lcVector3& Angles, bool Relative, bool Update, bool Checkpoint); void TransformSelectedObjects(lcTransformType TransformType, const lcVector3& Transform); void SetObjectProperty(lcObject* Object, lcObjectPropertyType ObjectPropertyType, const void* Value);