diff --git a/common/camera.cpp b/common/camera.cpp index a25af025..b261a84e 100644 --- a/common/camera.cpp +++ b/common/camera.cpp @@ -634,6 +634,18 @@ void lcCamera::DrawInterface(lcContext* Context) const } } +void lcCamera::RemoveKeyFrames() +{ + mPositionKeys.RemoveAll(); + ChangeKey(mPositionKeys, mPosition, 1, true); + + mTargetPositionKeys.RemoveAll(); + ChangeKey(mTargetPositionKeys, mTargetPosition, 1, true); + + mUpVectorKeys.RemoveAll(); + ChangeKey(mUpVectorKeys, mUpVector, 1, true); +} + void lcCamera::RayTest(lcObjectRayTest& ObjectRayTest) const { lcVector3 Min = lcVector3(-LC_CAMERA_POSITION_EDGE, -LC_CAMERA_POSITION_EDGE, -LC_CAMERA_POSITION_EDGE); diff --git a/common/camera.h b/common/camera.h index ebf67850..9ffe03c0 100644 --- a/common/camera.h +++ b/common/camera.h @@ -262,6 +262,7 @@ public: virtual void RayTest(lcObjectRayTest& ObjectRayTest) const override; virtual void BoxTest(lcObjectBoxTest& ObjectBoxTest) const override; virtual void DrawInterface(lcContext* Context) const override; + virtual void RemoveKeyFrames() override; void InsertTime(lcStep Start, lcStep Time); void RemoveTime(lcStep Start, lcStep Time); diff --git a/common/lc_commands.cpp b/common/lc_commands.cpp index 5dbe74e5..253c8fec 100644 --- a/common/lc_commands.cpp +++ b/common/lc_commands.cpp @@ -1060,6 +1060,13 @@ lcCommand gCommands[LC_NUM_COMMANDS] = QT_TRANSLATE_NOOP("Status", "Reset the pivot point of the selected pieces to their origin"), QT_TRANSLATE_NOOP("Shortcut", "") }, + // LC_PIECE_REMOVE_KEY_FRAMES + { + QT_TRANSLATE_NOOP("Action", "Piece.RemoveKeyFrames"), + QT_TRANSLATE_NOOP("Menu", "Remove &Key Frames"), + QT_TRANSLATE_NOOP("Status", "Remove all key frames from the selected pieces"), + QT_TRANSLATE_NOOP("Shortcut", "") + }, // LC_PIECE_CONTROL_POINT_INSERT { QT_TRANSLATE_NOOP("Action", "Piece.ControlPoint.Insert"), diff --git a/common/lc_commands.h b/common/lc_commands.h index f99786ec..993772ad 100644 --- a/common/lc_commands.h +++ b/common/lc_commands.h @@ -165,6 +165,7 @@ enum lcCommandId LC_PIECE_DELETE, LC_PIECE_DUPLICATE, LC_PIECE_RESET_PIVOT_POINT, + LC_PIECE_REMOVE_KEY_FRAMES, LC_PIECE_CONTROL_POINT_INSERT, LC_PIECE_CONTROL_POINT_REMOVE, LC_PIECE_MOVE_PLUSX, diff --git a/common/lc_mainwindow.cpp b/common/lc_mainwindow.cpp index d89d2186..084938e2 100644 --- a/common/lc_mainwindow.cpp +++ b/common/lc_mainwindow.cpp @@ -510,9 +510,10 @@ void lcMainWindow::CreateMenus() PieceMenu->addAction(mActions[LC_PIECE_INSERT]); PieceMenu->addAction(mActions[LC_PIECE_DELETE]); PieceMenu->addAction(mActions[LC_PIECE_DUPLICATE]); - PieceMenu->addAction(mActions[LC_PIECE_RESET_PIVOT_POINT]); PieceMenu->addAction(mActions[LC_PIECE_ARRAY]); PieceMenu->addAction(mActions[LC_PIECE_MINIFIG_WIZARD]); + PieceMenu->addAction(mActions[LC_PIECE_RESET_PIVOT_POINT]); + PieceMenu->addAction(mActions[LC_PIECE_REMOVE_KEY_FRAMES]); PieceMenu->addSeparator(); PieceMenu->addAction(mActions[LC_PIECE_VIEW_SELECTED_MODEL]); PieceMenu->addAction(mActions[LC_PIECE_INLINE_SELECTED_MODELS]); @@ -1782,6 +1783,7 @@ void lcMainWindow::UpdateSelectedObjects(bool SelectionChanged) mActions[LC_PIECE_DELETE]->setEnabled(Flags & LC_SEL_SELECTED); mActions[LC_PIECE_DUPLICATE]->setEnabled(Flags & LC_SEL_SELECTED); mActions[LC_PIECE_RESET_PIVOT_POINT]->setEnabled(Flags & LC_SEL_SELECTED); + mActions[LC_PIECE_REMOVE_KEY_FRAMES]->setEnabled(Flags & LC_SEL_SELECTED); mActions[LC_PIECE_ARRAY]->setEnabled(Flags & LC_SEL_PIECE); mActions[LC_PIECE_CONTROL_POINT_INSERT]->setEnabled(Flags & LC_SEL_CAN_ADD_CONTROL_POINT); mActions[LC_PIECE_CONTROL_POINT_REMOVE]->setEnabled(Flags & LC_SEL_CAN_REMOVE_CONTROL_POINT); @@ -2523,6 +2525,10 @@ void lcMainWindow::HandleCommand(lcCommandId CommandId) lcGetActiveModel()->ResetSelectedPiecesPivotPoint(); break; + case LC_PIECE_REMOVE_KEY_FRAMES: + lcGetActiveModel()->RemoveSelectedPiecesKeyFrames(); + break; + case LC_PIECE_CONTROL_POINT_INSERT: lcGetActiveModel()->InsertControlPoint(); break; diff --git a/common/lc_model.cpp b/common/lc_model.cpp index 94040ad2..633db99c 100644 --- a/common/lc_model.cpp +++ b/common/lc_model.cpp @@ -2152,6 +2152,24 @@ void lcModel::ResetSelectedPiecesPivotPoint() gMainWindow->UpdateAllViews(); } +void lcModel::RemoveSelectedPiecesKeyFrames() +{ + for (lcPiece* Piece : mPieces) + if (Piece->IsSelected()) + Piece->RemoveKeyFrames(); + + for (lcCamera* Camera : mCameras) + if (Camera->IsSelected()) + Camera->RemoveKeyFrames(); + + for (lcLight* Light : mLights) + if (Light->IsSelected()) + Light->RemoveKeyFrames(); + + gMainWindow->UpdateAllViews(); + SaveCheckpoint(tr("Removing Key Frames")); +} + void lcModel::InsertControlPoint() { lcObject* Focus = GetFocusObject(); diff --git a/common/lc_model.h b/common/lc_model.h index 14175f56..7b6bb9ab 100644 --- a/common/lc_model.h +++ b/common/lc_model.h @@ -190,6 +190,7 @@ public: void DeleteAllCameras(); void DeleteSelectedObjects(); void ResetSelectedPiecesPivotPoint(); + void RemoveSelectedPiecesKeyFrames(); void InsertControlPoint(); void RemoveFocusedControlPoint(); void ShowSelectedPiecesEarlier(); diff --git a/common/light.cpp b/common/light.cpp index 49145fd0..44dd78db 100644 --- a/common/light.cpp +++ b/common/light.cpp @@ -524,6 +524,33 @@ void lcLight::DrawPointLight(lcContext* Context) const Context->DrawIndexedPrimitives(GL_TRIANGLES, NumIndices, GL_UNSIGNED_SHORT, 0); } +void lcLight::RemoveKeyFrames() +{ + mPositionKeys.RemoveAll(); + ChangeKey(mPositionKeys, mPosition, 1, true); + + mTargetPositionKeys.RemoveAll(); + ChangeKey(mTargetPositionKeys, mTargetPosition, 1, true); + + mAmbientColorKeys.RemoveAll(); + ChangeKey(mAmbientColorKeys, mAmbientColor, 1, true); + + mDiffuseColorKeys.RemoveAll(); + ChangeKey(mDiffuseColorKeys, mDiffuseColor, 1, true); + + mSpecularColorKeys.RemoveAll(); + ChangeKey(mSpecularColorKeys, mSpecularColor, 1, true); + + mAttenuationKeys.RemoveAll(); + ChangeKey(mAttenuationKeys, mAttenuation, 1, true); + + mSpotCutoffKeys.RemoveAll(); + ChangeKey(mSpotCutoffKeys, mSpotCutoff, 1, true); + + mSpotExponentKeys.RemoveAll(); + ChangeKey(mSpotExponentKeys, mSpotExponent, 1, true); +} + bool lcLight::Setup(int LightIndex) { Q_UNUSED(LightIndex); diff --git a/common/light.h b/common/light.h index 5c9a767f..ccda1b42 100644 --- a/common/light.h +++ b/common/light.h @@ -178,6 +178,7 @@ public: virtual void RayTest(lcObjectRayTest& ObjectRayTest) const override; virtual void BoxTest(lcObjectBoxTest& ObjectBoxTest) const override; virtual void DrawInterface(lcContext* Context) const override; + virtual void RemoveKeyFrames() override; void InsertTime(lcStep Start, lcStep Time); void RemoveTime(lcStep Start, lcStep Time); diff --git a/common/object.h b/common/object.h index 8822bc98..702c4f73 100644 --- a/common/object.h +++ b/common/object.h @@ -95,6 +95,7 @@ public: virtual void RayTest(lcObjectRayTest& ObjectRayTest) const = 0; virtual void BoxTest(lcObjectBoxTest& ObjectBoxTest) const = 0; virtual void DrawInterface(lcContext* Context) const = 0; + virtual void RemoveKeyFrames() = 0; virtual const char* GetName() const = 0; protected: diff --git a/common/piece.cpp b/common/piece.cpp index 0c0ef12d..603b5655 100644 --- a/common/piece.cpp +++ b/common/piece.cpp @@ -637,6 +637,15 @@ void lcPiece::DrawInterface(lcContext* Context) const } } +void lcPiece::RemoveKeyFrames() +{ + mPositionKeys.RemoveAll(); + ChangeKey(mPositionKeys, mModelWorld.GetTranslation(), 1, true); + + mRotationKeys.RemoveAll(); + ChangeKey(mRotationKeys, lcMatrix33(mModelWorld), 1, true); +} + void lcPiece::AddRenderMeshes(lcScene& Scene, bool DrawInterface, bool Highlight) const { bool Focused, Selected; diff --git a/common/piece.h b/common/piece.h index 7386980f..ebed6727 100644 --- a/common/piece.h +++ b/common/piece.h @@ -344,6 +344,7 @@ public: virtual void RayTest(lcObjectRayTest& ObjectRayTest) const override; virtual void BoxTest(lcObjectBoxTest& ObjectBoxTest) const override; virtual void DrawInterface(lcContext* Context) const override; + virtual void RemoveKeyFrames() override; void AddRenderMeshes(lcScene& Scene, bool DrawInterface, bool Highlight) const; void SubModelAddRenderMeshes(lcScene& Scene, const lcMatrix44& WorldMatrix, int DefaultColorIndex, bool Focused, bool Selected) const;