操作优化

This commit is contained in:
Rowland 2026-06-30 11:05:34 +08:00
parent 49bedde67b
commit 2012ab74d1
5 changed files with 23 additions and 10 deletions

View File

@ -1869,7 +1869,17 @@ void MetaCoreEditorApp::DrawEditorFrame() {
MetaCoreDrawInfernuxStatusBar(*EditorContext_, statusPosition, statusSize);
const MetaCoreId selectedObjectId = EditorContext_->GetSelectedObjectId();
if (selectedObjectId != LastInspectorFocusedSelectionId_) {
LastInspectorFocusedSelectionId_ = selectedObjectId;
if (selectedObjectId != 0) {
ModuleRegistry_.AccessPanelOpenState("Inspector") = true;
PendingInspectorPanelFocus_ = true;
}
}
for (const auto& panelProvider : ModuleRegistry_.GetPanelProviders()) {
const std::string panelId = panelProvider->GetPanelId();
bool& panelOpen = ModuleRegistry_.AccessPanelOpenState(panelProvider->GetPanelId());
if (!panelOpen) {
continue;
@ -1891,7 +1901,14 @@ void MetaCoreEditorApp::DrawEditorFrame() {
}
const ImGuiWindowFlags panelWindowFlags = static_cast<ImGuiWindowFlags>(panelProvider->GetWindowFlags());
if (PendingInspectorPanelFocus_ && panelId == "Inspector") {
ImGui::SetNextWindowFocus();
}
ImGui::Begin(panelProvider->GetPanelTitle().c_str(), &panelOpen, panelWindowFlags);
if (PendingInspectorPanelFocus_ && panelId == "Inspector") {
ImGui::SetWindowFocus();
PendingInspectorPanelFocus_ = false;
}
panelProvider->DrawPanel(*EditorContext_);
ImGui::End();

View File

@ -39,14 +39,14 @@ void MetaCoreEditorCameraController::Update(
// Orbit: Alt + Left Drag
if (viewportState.Hovered && altDown && ImGui::IsMouseDragging(ImGuiMouseButton_Left)) {
YawDegrees_ -= io.MouseDelta.x * 0.35F; // 逆时针
YawDegrees_ += io.MouseDelta.x * 0.35F;
PitchDegrees_ -= io.MouseDelta.y * 0.35F;
PitchDegrees_ = std::clamp(PitchDegrees_, -85.0F, 85.0F);
}
// Look Around: Right Drag (without Alt)
else if (viewportState.Hovered && !altDown && ImGui::IsMouseDragging(ImGuiMouseButton_Right)) {
const glm::vec3 oldPosition = GetCameraPosition();
YawDegrees_ -= io.MouseDelta.x * 0.35F;
YawDegrees_ += io.MouseDelta.x * 0.35F;
PitchDegrees_ -= io.MouseDelta.y * 0.35F;
PitchDegrees_ = std::clamp(PitchDegrees_, -85.0F, 85.0F);

View File

@ -960,11 +960,9 @@ void MetaCoreSceneInteractionService::HandleShortcuts(MetaCoreEditorContext& edi
return;
}
// Q, W, E, R for Tool Selection
// Keep WASD reserved for scene camera movement. Tool changes are available from the viewport toolbar.
if (ImGui::IsKeyPressed(ImGuiKey_Q)) {
editorContext.SetGizmoOperation(MetaCoreGizmoOperation::None);
} else if (ImGui::IsKeyPressed(ImGuiKey_W)) {
editorContext.SetGizmoOperation(MetaCoreGizmoOperation::Translate);
} else if (ImGui::IsKeyPressed(ImGuiKey_E)) {
editorContext.SetGizmoOperation(MetaCoreGizmoOperation::Rotate);
} else if (ImGui::IsKeyPressed(ImGuiKey_R)) {
@ -984,10 +982,6 @@ void MetaCoreSceneInteractionService::HandleShortcuts(MetaCoreEditorContext& edi
FocusSelectedObject(editorContext);
}
if (ImGui::IsKeyPressed(ImGuiKey_A)) {
FocusVisibleScene(editorContext);
}
if (ImGui::IsKeyPressed(ImGuiKey_G)) {
editorContext.SetShowViewportGrid(!editorContext.GetShowViewportGrid());
}

View File

@ -43,6 +43,8 @@ private:
MetaCoreSceneInteractionService SceneInteractionService_{};
std::vector<std::unique_ptr<MetaCoreIModule>> Modules_{};
std::unique_ptr<MetaCoreEditorContext> EditorContext_{};
MetaCoreId LastInspectorFocusedSelectionId_ = 0;
bool PendingInspectorPanelFocus_ = false;
bool Initialized_ = false;
};

View File

@ -207,7 +207,7 @@ private:
MetaCoreId SelectionAnchorId_ = 0;
MetaCoreGizmoOperation GizmoOperation_ = MetaCoreGizmoOperation::Translate;
MetaCoreGizmoMode GizmoMode_ = MetaCoreGizmoMode::Local;
bool ShowViewportGrid_ = true;
bool ShowViewportGrid_ = false;
bool ShowWorldOrigin_ = true;
MetaCoreReparentTransformRule ReparentTransformRule_ = MetaCoreReparentTransformRule::KeepWorld;
MetaCoreEditorCommandService CommandService_{};