diff --git a/common/camera.cpp b/common/camera.cpp index f1e14b02..8d363ca6 100644 --- a/common/camera.cpp +++ b/common/camera.cpp @@ -397,16 +397,19 @@ void lcCamera::MoveSelected(lcStep Step, bool AddKey, const lcVector3& Distance) if (IsSimple()) AddKey = false; - if (IsSelected(LC_CAMERA_SECTION_POSITION)) + const quint32 FocusSection = GetFocusSection(); + + if (FocusSection == LC_CAMERA_SECTION_POSITION || FocusSection == LC_CAMERA_SECTION_INVALID) { mPosition.ChangeKey(mPosition + Distance, Step, AddKey); } - if (IsSelected(LC_CAMERA_SECTION_TARGET)) + if (FocusSection == LC_CAMERA_SECTION_TARGET || FocusSection == LC_CAMERA_SECTION_INVALID) { mTargetPosition.ChangeKey(mTargetPosition + Distance, Step, AddKey); } - else if (IsSelected(LC_CAMERA_SECTION_UPVECTOR)) + + if (FocusSection == LC_CAMERA_SECTION_UPVECTOR) { mUpVector.ChangeKey(lcNormalize(mUpVector + Distance), Step, AddKey); } diff --git a/common/camera.h b/common/camera.h index 64ca322e..31cf0083 100644 --- a/common/camera.h +++ b/common/camera.h @@ -181,23 +181,23 @@ public: { case LC_CAMERA_SECTION_POSITION: if (Focus) - mState |= LC_CAMERA_POSITION_SELECTED | LC_CAMERA_POSITION_FOCUSED; + mState |= LC_CAMERA_SELECTION_MASK | LC_CAMERA_POSITION_FOCUSED; else - mState &= ~(LC_CAMERA_POSITION_SELECTED | LC_CAMERA_POSITION_FOCUSED); + mState &= ~LC_CAMERA_POSITION_FOCUSED; break; case LC_CAMERA_SECTION_TARGET: if (Focus) - mState |= LC_CAMERA_TARGET_SELECTED | LC_CAMERA_TARGET_FOCUSED; + mState |= LC_CAMERA_SELECTION_MASK | LC_CAMERA_TARGET_FOCUSED; else - mState &= ~(LC_CAMERA_TARGET_SELECTED | LC_CAMERA_TARGET_FOCUSED); + mState &= ~LC_CAMERA_TARGET_FOCUSED; break; case LC_CAMERA_SECTION_UPVECTOR: if (Focus) - mState |= LC_CAMERA_UPVECTOR_SELECTED | LC_CAMERA_UPVECTOR_FOCUSED; + mState |= LC_CAMERA_SELECTION_MASK | LC_CAMERA_UPVECTOR_FOCUSED; else - mState &= ~(LC_CAMERA_UPVECTOR_SELECTED | LC_CAMERA_UPVECTOR_FOCUSED); + mState &= ~LC_CAMERA_UPVECTOR_FOCUSED; break; } } diff --git a/common/lc_propertieswidget.cpp b/common/lc_propertieswidget.cpp index bf50a7a6..023f226c 100644 --- a/common/lc_propertieswidget.cpp +++ b/common/lc_propertieswidget.cpp @@ -311,51 +311,114 @@ void lcPropertiesWidget::FloatChanged() if (PropertyId == lcObjectPropertyId::CameraPositionX || PropertyId == lcObjectPropertyId::CameraPositionY || PropertyId == lcObjectPropertyId::CameraPositionZ) { - lcVector3 Center = Camera->mPosition; - lcVector3 Position = Center; + quint32 FocusSection = LC_CAMERA_SECTION_INVALID; + lcVector3 Start; + + if (Camera) + { + FocusSection = Camera->GetFocusSection(); + Camera->SetFocused(FocusSection, false); + Camera->SetFocused(LC_CAMERA_SECTION_POSITION, true); + + Start = Camera->mPosition; + } + else + { + Start = lcVector3(0.0f, 0.0f, 0.0f); + } + + lcVector3 End = Start; if (PropertyId == lcObjectPropertyId::CameraPositionX) - Position[0] = Value; + End[0] = Value; else if (PropertyId == lcObjectPropertyId::CameraPositionY) - Position[1] = Value; + End[1] = Value; else if (PropertyId == lcObjectPropertyId::CameraPositionZ) - Position[2] = Value; + End[2] = Value; - lcVector3 Distance = Position - Center; + lcVector3 Distance = End - Start; Model->MoveSelectedObjects(Distance, false, false, true, true, true); + + if (Camera) + { + Camera->SetFocused(LC_CAMERA_SECTION_POSITION, false); + Camera->SetFocused(FocusSection, true); + } } else if (PropertyId == lcObjectPropertyId::CameraTargetX || PropertyId == lcObjectPropertyId::CameraTargetY || PropertyId == lcObjectPropertyId::CameraTargetZ) { - lcVector3 Center = Camera->mTargetPosition; - lcVector3 Position = Center; + quint32 FocusSection = LC_CAMERA_SECTION_INVALID; + lcVector3 Start; + + if (Camera) + { + FocusSection = Camera->GetFocusSection(); + Camera->SetFocused(FocusSection, false); + Camera->SetFocused(LC_CAMERA_SECTION_TARGET, true); + + Start = Camera->mTargetPosition; + } + else + { + Start = lcVector3(0.0f, 0.0f, 0.0f); + } + + lcVector3 End = Start; if (PropertyId == lcObjectPropertyId::CameraTargetX) - Position[0] = Value; + End[0] = Value; else if (PropertyId == lcObjectPropertyId::CameraTargetY) - Position[1] = Value; + End[1] = Value; else if (PropertyId == lcObjectPropertyId::CameraTargetZ) - Position[2] = Value; + End[2] = Value; - lcVector3 Distance = Position - Center; + lcVector3 Distance = End - Start; Model->MoveSelectedObjects(Distance, false, false, true, true, true); + + if (Camera) + { + Camera->SetFocused(LC_CAMERA_SECTION_TARGET, false); + Camera->SetFocused(FocusSection, true); + } } else if (PropertyId == lcObjectPropertyId::CameraUpX || PropertyId == lcObjectPropertyId::CameraUpY || PropertyId == lcObjectPropertyId::CameraUpZ) { - lcVector3 Center = Camera->mUpVector; - lcVector3 Position = Center; + quint32 FocusSection = LC_CAMERA_SECTION_INVALID; + lcVector3 Start; + + if (Camera) + { + FocusSection = Camera->GetFocusSection(); + Camera->SetFocused(FocusSection, false); + Camera->SetFocused(LC_CAMERA_SECTION_UPVECTOR, true); + + Start = Camera->mUpVector; + } + else + { + Start = lcVector3(0.0f, 0.0f, 0.0f); + } + + lcVector3 End = Start; if (PropertyId == lcObjectPropertyId::CameraUpX) - Position[0] = Value; + End[0] = Value; else if (PropertyId == lcObjectPropertyId::CameraUpY) - Position[1] = Value; + End[1] = Value; else if (PropertyId == lcObjectPropertyId::CameraUpZ) - Position[2] = Value; + End[2] = Value; - lcVector3 Distance = Position - Center; + lcVector3 Distance = End - Start; Model->MoveSelectedObjects(Distance, false, false, true, true, true); + + if (Camera) + { + Camera->SetFocused(LC_CAMERA_SECTION_UPVECTOR, false); + Camera->SetFocused(FocusSection, true); + } } else if (Camera) {