diff --git a/common/camera.cpp b/common/camera.cpp index 1680d43c..6a7d6075 100644 --- a/common/camera.cpp +++ b/common/camera.cpp @@ -628,6 +628,68 @@ bool lcCamera::HasKeyFrame(lcObjectPropertyId PropertyId, lcStep Time) const return false; } +bool lcCamera::SetKeyFrame(lcObjectPropertyId PropertyId, lcStep Time, bool KeyFrame) +{ + switch (PropertyId) + { + case lcObjectPropertyId::PieceId: + case lcObjectPropertyId::PieceColor: + case lcObjectPropertyId::PieceStepShow: + case lcObjectPropertyId::PieceStepHide: + case lcObjectPropertyId::CameraName: + case lcObjectPropertyId::CameraType: + case lcObjectPropertyId::CameraFOV: + case lcObjectPropertyId::CameraNear: + case lcObjectPropertyId::CameraFar: + return false; + + case lcObjectPropertyId::CameraPositionX: + case lcObjectPropertyId::CameraPositionY: + case lcObjectPropertyId::CameraPositionZ: + return mPosition.SetKeyFrame(Time, KeyFrame); + + case lcObjectPropertyId::CameraTargetX: + case lcObjectPropertyId::CameraTargetY: + case lcObjectPropertyId::CameraTargetZ: + return mTargetPosition.SetKeyFrame(Time, KeyFrame); + + case lcObjectPropertyId::CameraUpX: + case lcObjectPropertyId::CameraUpY: + case lcObjectPropertyId::CameraUpZ: + return mUpVector.SetKeyFrame(Time, KeyFrame); + + case lcObjectPropertyId::LightName: + case lcObjectPropertyId::LightType: + case lcObjectPropertyId::LightColor: + case lcObjectPropertyId::LightPower: + case lcObjectPropertyId::LightCastShadow: + case lcObjectPropertyId::LightAttenuationDistance: + case lcObjectPropertyId::LightAttenuationPower: + case lcObjectPropertyId::LightPointSize: + case lcObjectPropertyId::LightSpotSize: + case lcObjectPropertyId::LightDirectionalSize: + case lcObjectPropertyId::LightAreaSize: + case lcObjectPropertyId::LightAreaSizeX: + case lcObjectPropertyId::LightAreaSizeY: + case lcObjectPropertyId::LightSpotConeAngle: + case lcObjectPropertyId::LightSpotPenumbraAngle: + case lcObjectPropertyId::LightSpotTightness: + case lcObjectPropertyId::LightAreaShape: + case lcObjectPropertyId::LightAreaGridX: + case lcObjectPropertyId::LightAreaGridY: + case lcObjectPropertyId::ObjectPositionX: + case lcObjectPropertyId::ObjectPositionY: + case lcObjectPropertyId::ObjectPositionZ: + case lcObjectPropertyId::ObjectRotationX: + case lcObjectPropertyId::ObjectRotationY: + case lcObjectPropertyId::ObjectRotationZ: + case lcObjectPropertyId::Count: + return false; + } + + return false; +} + void lcCamera::RemoveKeyFrames() { mPosition.RemoveAllKeys(); diff --git a/common/camera.h b/common/camera.h index e13c5630..6834b528 100644 --- a/common/camera.h +++ b/common/camera.h @@ -272,6 +272,7 @@ public: void BoxTest(lcObjectBoxTest& ObjectBoxTest) const override; void DrawInterface(lcContext* Context, const lcScene& Scene) const override; bool HasKeyFrame(lcObjectPropertyId PropertyId, lcStep Time) const override; + bool SetKeyFrame(lcObjectPropertyId PropertyId, lcStep Time, bool KeyFrame) override; void RemoveKeyFrames() override; void InsertTime(lcStep Start, lcStep Time); @@ -280,7 +281,7 @@ public: static bool FileLoad(lcFile& file); void CompareBoundingBox(lcVector3& Min, lcVector3& Max); - void UpdatePosition(lcStep Step); + void UpdatePosition(lcStep Step) override; void CopyPosition(const lcCamera* Camera); void CopySettings(const lcCamera* Camera); diff --git a/common/lc_array.h b/common/lc_array.h index d655feda..2afe5cda 100644 --- a/common/lc_array.h +++ b/common/lc_array.h @@ -21,6 +21,13 @@ public: *this = Array; } + lcArray(std::initializer_list Init) + : lcArray((int)Init.size()) + { + for (const T& Element : Init) + Add(Element); + } + ~lcArray() { delete[] mData; diff --git a/common/lc_keyframewidget.cpp b/common/lc_keyframewidget.cpp index 49da7531..06c24f65 100644 --- a/common/lc_keyframewidget.cpp +++ b/common/lc_keyframewidget.cpp @@ -2,7 +2,7 @@ #include "lc_keyframewidget.h" lcKeyFrameWidget::lcKeyFrameWidget(QWidget* Parent) - : QAbstractButton(Parent) + : QCheckBox(Parent) { setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); setCheckable(true); @@ -17,11 +17,14 @@ void lcKeyFrameWidget::paintEvent(QPaintEvent* PaintEvent) QRect Rect = rect(); Painter.fillRect(Rect, palette().brush(QPalette::Window)); + Qt::CheckState State = checkState(); Painter.setPen(hasFocus() ? palette().color(QPalette::Highlight) : palette().color(QPalette::Shadow)); - Painter.setBrush(palette().color(QPalette::Text)); - Rect = isChecked() ? QRect(1, 1, 13, 13) : QRect(4, 4, 7, 7); - QPoint Center = Rect.center(); + if (State != Qt::PartiallyChecked) + Painter.setBrush(palette().color(QPalette::Text)); + + Rect = (State != Qt::Unchecked) ? QRect(1, 1, 13, 13) : QRect(4, 4, 7, 7); + const QPoint Center = Rect.center(); QPoint Points[4] = { diff --git a/common/lc_keyframewidget.h b/common/lc_keyframewidget.h index 42d2fefb..02ffd325 100644 --- a/common/lc_keyframewidget.h +++ b/common/lc_keyframewidget.h @@ -1,6 +1,6 @@ #pragma once -class lcKeyFrameWidget : public QAbstractButton +class lcKeyFrameWidget : public QCheckBox { Q_OBJECT diff --git a/common/lc_model.cpp b/common/lc_model.cpp index 999aefb5..9ba7b8c7 100644 --- a/common/lc_model.cpp +++ b/common/lc_model.cpp @@ -2973,6 +2973,24 @@ void lcModel::TransformSelectedObjects(lcTransformType TransformType, const lcVe } } +void lcModel::SetObjectsKeyFrame(const lcArray& Objects, lcObjectPropertyId PropertyId, bool KeyFrame) +{ + bool Modified = false; + + for (lcObject* Object : Objects) + { + Modified |= Object->SetKeyFrame(PropertyId, mCurrentStep, KeyFrame); + Object->UpdatePosition(mCurrentStep); + } + + if (Modified) + { + SaveCheckpoint(tr("Changing Key Frame")); + gMainWindow->UpdateSelectedObjects(false); + UpdateAllViews(); + } +} + void lcModel::SetSelectedPiecesColorIndex(int ColorIndex) { bool Modified = false; diff --git a/common/lc_model.h b/common/lc_model.h index a54e433e..e4501d8a 100644 --- a/common/lc_model.h +++ b/common/lc_model.h @@ -4,6 +4,8 @@ #include "lc_commands.h" #include "lc_array.h" +enum class lcObjectPropertyId; + #define LC_SEL_NO_PIECES 0x0001 // No pieces in model #define LC_SEL_PIECE 0x0002 // At least 1 piece selected #define LC_SEL_CAMERA 0x0004 // At least 1 camera selected @@ -357,6 +359,7 @@ public: void RotateSelectedObjects(const lcVector3& Angles, bool Relative, bool RotatePivotPoint, bool Update, bool Checkpoint); void ScaleSelectedPieces(const float Scale, bool Update, bool Checkpoint); void TransformSelectedObjects(lcTransformType TransformType, const lcVector3& Transform); + void SetObjectsKeyFrame(const lcArray& Objects, lcObjectPropertyId PropertyId, bool KeyFrame); void SetSelectedPiecesColorIndex(int ColorIndex); void SetSelectedPiecesPieceInfo(PieceInfo* Info); void SetSelectedPiecesStepShow(lcStep Step); diff --git a/common/lc_objectproperty.cpp b/common/lc_objectproperty.cpp index 26c75152..8966883a 100644 --- a/common/lc_objectproperty.cpp +++ b/common/lc_objectproperty.cpp @@ -8,6 +8,7 @@ template void lcObjectProperty::InsertTime(lcStep Start, lcStep Time); \ template void lcObjectProperty::RemoveTime(lcStep Start, lcStep Time); \ template bool lcObjectProperty::HasKeyFrame(lcStep Time) const; \ + template bool lcObjectProperty::SetKeyFrame(lcStep Time, bool KeyFrame); \ template void lcObjectProperty::Save(QTextStream& Stream, const char* ObjectName, const char* VariableName, bool SaveEmpty) const; \ template bool lcObjectProperty::Load(QTextStream& Stream, const QString& Token, const char* VariableName); @@ -176,6 +177,46 @@ bool lcObjectProperty::HasKeyFrame(lcStep Time) const return false; } +template +bool lcObjectProperty::SetKeyFrame(lcStep Time, bool KeyFrame) +{ + if (KeyFrame) + { + typename std::vector>::const_iterator KeyIt; + + for (KeyIt = mKeys.begin(); KeyIt != mKeys.end(); KeyIt++) + { + if (KeyIt->Step == Time) + return false; + else if (KeyIt->Step > Time) + break; + } + + mKeys.insert(KeyIt, lcObjectPropertyKey{ Time, mValue }); + + return true; + } + else + { + for (typename std::vector>::const_iterator KeyIt = mKeys.begin(); KeyIt != mKeys.end(); KeyIt++) + { + if (KeyIt->Step == Time) + { + if (mKeys.size() == 1) + mValue = KeyIt->Value; + + mKeys.erase(KeyIt); + + return true; + } + else if (KeyIt->Step > Time) + return false; + } + } + + return false; +} + template void lcObjectProperty::Save(QTextStream& Stream, const char* ObjectName, const char* VariableName, bool SaveEmpty) const { diff --git a/common/lc_objectproperty.h b/common/lc_objectproperty.h index 72f07864..944f566d 100644 --- a/common/lc_objectproperty.h +++ b/common/lc_objectproperty.h @@ -86,6 +86,7 @@ public: void InsertTime(lcStep Start, lcStep Time); void RemoveTime(lcStep Start, lcStep Time); bool HasKeyFrame(lcStep Time) const; + bool SetKeyFrame(lcStep Time, bool KeyFrame); void Save(QTextStream& Stream, const char* ObjectName, const char* VariableName, bool SaveEmpty) const; bool Load(QTextStream& Stream, const QString& Token, const char* VariableName); diff --git a/common/lc_propertieswidget.cpp b/common/lc_propertieswidget.cpp index a2d0d330..57c91599 100644 --- a/common/lc_propertieswidget.cpp +++ b/common/lc_propertieswidget.cpp @@ -101,7 +101,10 @@ void lcPropertiesWidget::KeyFrameChanged() if (!Model) return; - // todo: toggle keys in model + if (mFocusObject) + Model->SetObjectsKeyFrame({ mFocusObject }, PropertyId, Widget->isChecked()); + else + Model->SetObjectsKeyFrame(mSelection, PropertyId, Widget->isChecked()); } void lcPropertiesWidget::UpdateKeyFrameWidget(lcObjectPropertyId PropertyId) @@ -113,7 +116,30 @@ void lcPropertiesWidget::UpdateKeyFrameWidget(lcObjectPropertyId PropertyId) QSignalBlocker Blocker(Widget); lcModel* Model = gMainWindow->GetActiveModel(); - Widget->setChecked(mFocusObject && Model && mFocusObject->HasKeyFrame(PropertyId, Model->GetCurrentStep())); + if (Model) + { + const lcStep Step = Model->GetCurrentStep(); + + if (mFocusObject) + Widget->setChecked(mFocusObject->HasKeyFrame(PropertyId, Step)); + else + { + int KeyFrameCount = 0, NonKeyFrameCount = 0; + + for (const lcObject* Object : mSelection) + { + if (Object->HasKeyFrame(PropertyId, Step)) + KeyFrameCount++; + else + NonKeyFrameCount++; + } + + if (KeyFrameCount && NonKeyFrameCount) + Widget->setCheckState(Qt::PartiallyChecked); + else + Widget->setCheckState(KeyFrameCount != 0 ? Qt::Checked : Qt::Unchecked); + } + } } } @@ -122,7 +148,7 @@ void lcPropertiesWidget::AddKeyFrameWidget(lcObjectPropertyId PropertyId) lcKeyFrameWidget* Widget = new lcKeyFrameWidget(this); Widget->setToolTip(tr("Toggle Key Frame")); - connect(Widget, &QCheckBox::toggled, this, &lcPropertiesWidget::KeyFrameChanged); + connect(Widget, &QCheckBox::stateChanged, this, &lcPropertiesWidget::KeyFrameChanged); mLayout->addWidget(Widget, mLayoutRow, 3); @@ -1029,6 +1055,7 @@ void lcPropertiesWidget::SetEmpty() SetLayoutMode(LayoutMode::Empty); mFocusObject = nullptr; + mSelection.RemoveAll(); } void lcPropertiesWidget::SetPiece(const lcArray& Selection, lcObject* Focus) @@ -1036,6 +1063,7 @@ void lcPropertiesWidget::SetPiece(const lcArray& Selection, lcObject* SetLayoutMode(LayoutMode::Piece); lcPiece* Piece = dynamic_cast(Focus); + mSelection = Selection; mFocusObject = Piece; lcVector3 Position; @@ -1117,11 +1145,12 @@ void lcPropertiesWidget::SetPiece(const lcArray& Selection, lcObject* UpdateStepNumber(lcObjectPropertyId::PieceStepHide, StepHide ? StepHide : LC_STEP_MAX, StepShow + 1, LC_STEP_MAX); } -void lcPropertiesWidget::SetCamera(lcObject* Focus) +void lcPropertiesWidget::SetCamera(const lcArray& Selection, lcObject* Focus) { SetLayoutMode(LayoutMode::Camera); lcCamera* Camera = dynamic_cast(Focus); + mSelection = Selection; mFocusObject = Camera; lcVector3 Position(0.0f, 0.0f, 0.0f); @@ -1166,11 +1195,12 @@ void lcPropertiesWidget::SetCamera(lcObject* Focus) UpdateFloat(lcObjectPropertyId::CameraUpZ, UpVector[2]); } -void lcPropertiesWidget::SetLight(lcObject* Focus) +void lcPropertiesWidget::SetLight(const lcArray& Selection, lcObject* Focus) { SetLayoutMode(LayoutMode::Light); lcLight* Light = dynamic_cast(Focus); + mSelection = Selection; mFocusObject = Light; QString Name; @@ -1276,6 +1306,9 @@ void lcPropertiesWidget::SetLight(lcObject* Focus) void lcPropertiesWidget::Update(const lcArray& Selection, lcObject* Focus) { + mFocusObject = nullptr; + mSelection.RemoveAll(); + LayoutMode Mode = LayoutMode::Empty; if (Focus) @@ -1353,11 +1386,11 @@ void lcPropertiesWidget::Update(const lcArray& Selection, lcObject* F break; case LayoutMode::Camera: - SetCamera(Focus); + SetCamera(Selection, Focus); break; case LayoutMode::Light: - SetLight(Focus); + SetLight(Selection, Focus); break; } } diff --git a/common/lc_propertieswidget.h b/common/lc_propertieswidget.h index 93f9f4db..8b53b5fe 100644 --- a/common/lc_propertieswidget.h +++ b/common/lc_propertieswidget.h @@ -108,8 +108,8 @@ protected: void SetEmpty(); void SetPiece(const lcArray& Selection, lcObject* Focus); - void SetCamera(lcObject* Focus); - void SetLight(lcObject* Focus); + void SetCamera(const lcArray& Selection, lcObject* Focus); + void SetLight(const lcArray& Selection, lcObject* Focus); void CreateWidgets(); void SetLayoutMode(LayoutMode Mode); @@ -117,6 +117,7 @@ protected: void SetCategoryVisible(CategoryIndex Index, bool Visible); void SetCategoryWidgetsVisible(CategoryWidgets& Category, bool Visible); + lcArray mSelection; lcObject* mFocusObject = nullptr; std::array(lcObjectPropertyId::Count)> mPropertyWidgets = {}; diff --git a/common/light.cpp b/common/light.cpp index 526c38ed..91c11811 100644 --- a/common/light.cpp +++ b/common/light.cpp @@ -1120,6 +1120,88 @@ bool lcLight::HasKeyFrame(lcObjectPropertyId PropertyId, lcStep Time) const return false; } +bool lcLight::SetKeyFrame(lcObjectPropertyId PropertyId, lcStep Time, bool KeyFrame) +{ + switch (PropertyId) + { + case lcObjectPropertyId::PieceId: + case lcObjectPropertyId::PieceColor: + case lcObjectPropertyId::PieceStepShow: + case lcObjectPropertyId::PieceStepHide: + case lcObjectPropertyId::CameraName: + case lcObjectPropertyId::CameraType: + case lcObjectPropertyId::CameraFOV: + case lcObjectPropertyId::CameraNear: + case lcObjectPropertyId::CameraFar: + case lcObjectPropertyId::CameraPositionX: + case lcObjectPropertyId::CameraPositionY: + case lcObjectPropertyId::CameraPositionZ: + case lcObjectPropertyId::CameraTargetX: + case lcObjectPropertyId::CameraTargetY: + case lcObjectPropertyId::CameraTargetZ: + case lcObjectPropertyId::CameraUpX: + case lcObjectPropertyId::CameraUpY: + case lcObjectPropertyId::CameraUpZ: + case lcObjectPropertyId::LightName: + case lcObjectPropertyId::LightType: + return false; + + case lcObjectPropertyId::LightColor: + return mColor.SetKeyFrame(Time, KeyFrame); + + case lcObjectPropertyId::LightPower: + return mPower.SetKeyFrame(Time, KeyFrame); + + case lcObjectPropertyId::LightCastShadow: + return false; + + case lcObjectPropertyId::LightAttenuationDistance: + return mAttenuationDistance.SetKeyFrame(Time, KeyFrame); + + case lcObjectPropertyId::LightAttenuationPower: + return mAttenuationPower.SetKeyFrame(Time, KeyFrame); + + case lcObjectPropertyId::LightPointSize: + case lcObjectPropertyId::LightSpotSize: + case lcObjectPropertyId::LightDirectionalSize: + case lcObjectPropertyId::LightAreaSize: + case lcObjectPropertyId::LightAreaSizeX: + case lcObjectPropertyId::LightAreaSizeY: + return mSize.SetKeyFrame(Time, KeyFrame); + + case lcObjectPropertyId::LightSpotConeAngle: + return mSpotConeAngle.SetKeyFrame(Time, KeyFrame); + + case lcObjectPropertyId::LightSpotPenumbraAngle: + return mSpotPenumbraAngle.SetKeyFrame(Time, KeyFrame); + + case lcObjectPropertyId::LightSpotTightness: + return mSpotTightness.SetKeyFrame(Time, KeyFrame); + + case lcObjectPropertyId::LightAreaShape: + return false; + + case lcObjectPropertyId::LightAreaGridX: + case lcObjectPropertyId::LightAreaGridY: + return mAreaGrid.SetKeyFrame(Time, KeyFrame); + + case lcObjectPropertyId::ObjectPositionX: + case lcObjectPropertyId::ObjectPositionY: + case lcObjectPropertyId::ObjectPositionZ: + return mPosition.SetKeyFrame(Time, KeyFrame); + + case lcObjectPropertyId::ObjectRotationX: + case lcObjectPropertyId::ObjectRotationY: + case lcObjectPropertyId::ObjectRotationZ: + return mRotation.SetKeyFrame(Time, KeyFrame); + + case lcObjectPropertyId::Count: + return false; + } + + return false; +} + void lcLight::RemoveKeyFrames() { mPosition.RemoveAllKeys(); diff --git a/common/light.h b/common/light.h index 00ba54fe..d3a05f09 100644 --- a/common/light.h +++ b/common/light.h @@ -214,6 +214,7 @@ public: void BoxTest(lcObjectBoxTest& ObjectBoxTest) const override; void DrawInterface(lcContext* Context, const lcScene& Scene) const override; bool HasKeyFrame(lcObjectPropertyId PropertyId, lcStep Time) const override; + bool SetKeyFrame(lcObjectPropertyId PropertyId, lcStep Time, bool KeyFrame) override; void RemoveKeyFrames() override; void InsertTime(lcStep Start, lcStep Time); @@ -312,7 +313,7 @@ public: } void CompareBoundingBox(lcVector3& Min, lcVector3& Max); - void UpdatePosition(lcStep Step); + void UpdatePosition(lcStep Step) override; void MoveSelected(lcStep Step, bool AddKey, const lcVector3& Distance, bool FirstMove); void Rotate(lcStep Step, bool AddKey, const lcMatrix33& RotationMatrix, const lcVector3& Center, const lcMatrix33& RotationFrame); void CreateName(const lcArray& Lights); diff --git a/common/object.h b/common/object.h index 7fb91bc9..2150802a 100644 --- a/common/object.h +++ b/common/object.h @@ -97,12 +97,14 @@ public: virtual void SetFocused(quint32 Section, bool Focused) = 0; virtual quint32 GetFocusSection() const = 0; + virtual void UpdatePosition(lcStep Step) = 0; virtual quint32 GetAllowedTransforms() const = 0; virtual lcVector3 GetSectionPosition(quint32 Section) const = 0; virtual void RayTest(lcObjectRayTest& ObjectRayTest) const = 0; virtual void BoxTest(lcObjectBoxTest& ObjectBoxTest) const = 0; virtual void DrawInterface(lcContext* Context, const lcScene& Scene) const = 0; virtual bool HasKeyFrame(lcObjectPropertyId PropertyId, lcStep Time) const = 0; + virtual bool SetKeyFrame(lcObjectPropertyId PropertyId, lcStep Time, bool KeyFrame) = 0; virtual void RemoveKeyFrames() = 0; virtual QString GetName() const = 0; diff --git a/common/piece.cpp b/common/piece.cpp index a5aa189a..c38eb604 100644 --- a/common/piece.cpp +++ b/common/piece.cpp @@ -706,6 +706,66 @@ bool lcPiece::HasKeyFrame(lcObjectPropertyId PropertyId, lcStep Time) const return false; } +bool lcPiece::SetKeyFrame(lcObjectPropertyId PropertyId, lcStep Time, bool KeyFrame) +{ + switch (PropertyId) + { + case lcObjectPropertyId::PieceId: + case lcObjectPropertyId::PieceColor: + case lcObjectPropertyId::PieceStepShow: + case lcObjectPropertyId::PieceStepHide: + case lcObjectPropertyId::CameraName: + case lcObjectPropertyId::CameraType: + case lcObjectPropertyId::CameraFOV: + case lcObjectPropertyId::CameraNear: + case lcObjectPropertyId::CameraFar: + case lcObjectPropertyId::CameraPositionX: + case lcObjectPropertyId::CameraPositionY: + case lcObjectPropertyId::CameraPositionZ: + case lcObjectPropertyId::CameraTargetX: + case lcObjectPropertyId::CameraTargetY: + case lcObjectPropertyId::CameraTargetZ: + case lcObjectPropertyId::CameraUpX: + case lcObjectPropertyId::CameraUpY: + case lcObjectPropertyId::CameraUpZ: + case lcObjectPropertyId::LightName: + case lcObjectPropertyId::LightType: + case lcObjectPropertyId::LightColor: + case lcObjectPropertyId::LightPower: + case lcObjectPropertyId::LightCastShadow: + case lcObjectPropertyId::LightAttenuationDistance: + case lcObjectPropertyId::LightAttenuationPower: + case lcObjectPropertyId::LightPointSize: + case lcObjectPropertyId::LightSpotSize: + case lcObjectPropertyId::LightDirectionalSize: + case lcObjectPropertyId::LightAreaSize: + case lcObjectPropertyId::LightAreaSizeX: + case lcObjectPropertyId::LightAreaSizeY: + case lcObjectPropertyId::LightSpotConeAngle: + case lcObjectPropertyId::LightSpotPenumbraAngle: + case lcObjectPropertyId::LightSpotTightness: + case lcObjectPropertyId::LightAreaShape: + case lcObjectPropertyId::LightAreaGridX: + case lcObjectPropertyId::LightAreaGridY: + return false; + + case lcObjectPropertyId::ObjectPositionX: + case lcObjectPropertyId::ObjectPositionY: + case lcObjectPropertyId::ObjectPositionZ: + return mPosition.SetKeyFrame(Time, KeyFrame); + + case lcObjectPropertyId::ObjectRotationX: + case lcObjectPropertyId::ObjectRotationY: + case lcObjectPropertyId::ObjectRotationZ: + return mRotation.SetKeyFrame(Time, KeyFrame); + + case lcObjectPropertyId::Count: + return false; + } + + return false; +} + void lcPiece::RemoveKeyFrames() { mPosition.RemoveAllKeys(); diff --git a/common/piece.h b/common/piece.h index 8d813cff..6b14ea10 100644 --- a/common/piece.h +++ b/common/piece.h @@ -131,6 +131,7 @@ public: void BoxTest(lcObjectBoxTest& ObjectBoxTest) const override; void DrawInterface(lcContext* Context, const lcScene& Scene) const override; bool HasKeyFrame(lcObjectPropertyId PropertyId, lcStep Time) const override; + bool SetKeyFrame(lcObjectPropertyId PropertyId, lcStep Time, bool KeyFrame) override; void RemoveKeyFrames() override; void AddMainModelRenderMeshes(lcScene* Scene, bool Highlight, bool Fade) const; @@ -185,7 +186,7 @@ public: void SetPieceInfo(PieceInfo* Info, const QString& ID, bool Wait); bool FileLoad(lcFile& file); - void UpdatePosition(lcStep Step); + void UpdatePosition(lcStep Step) override; void MoveSelected(lcStep Step, bool AddKey, const lcVector3& Distance); void Rotate(lcStep Step, bool AddKey, const lcMatrix33& RotationMatrix, const lcVector3& Center, const lcMatrix33& RotationFrame); void MovePivotPoint(const lcVector3& Distance);