From a1bd6e1bbcbc8c7d025418cfa2f20b9133991ef6 Mon Sep 17 00:00:00 2001 From: maelstrom Date: Tue, 6 May 2025 18:58:14 +0200 Subject: [PATCH] feat(editor): added buttons for hinge and motor --- core/src/objects/workspace.cpp | 2 +- editor/mainwindow.cpp | 4 ++++ editor/mainwindow.h | 2 ++ editor/mainwindow.ui | 36 ++++++++++++++++++++++++++++++++++ 4 files changed, 43 insertions(+), 1 deletion(-) diff --git a/core/src/objects/workspace.cpp b/core/src/objects/workspace.cpp index 925039e..1b67767 100644 --- a/core/src/objects/workspace.cpp +++ b/core/src/objects/workspace.cpp @@ -111,7 +111,7 @@ void Workspace::PhysicsStep(float deltaTime) { if (joint.expired() || !joint.lock()->IsA("RotateV")) continue; std::shared_ptr motor = joint.lock()->CastTo().expect(); - float rate = motor->part0.lock()->GetSurfaceParamB(motor->c0.LookVector().Unit()) * 30; + float rate = motor->part0.lock()->GetSurfaceParamB(-motor->c0.LookVector().Unit()) * 30; // part->rigidBody->enableGravity(false); part->rigidBody->setAngularVelocity(-(motor->part0.lock()->cframe * motor->c0).LookVector() * rate); } diff --git a/editor/mainwindow.cpp b/editor/mainwindow.cpp index dbb339c..3974bd4 100644 --- a/editor/mainwindow.cpp +++ b/editor/mainwindow.cpp @@ -193,6 +193,8 @@ void MainWindow::connectActionHandlers() { connect(ui->actionToolStuds, &QAction::triggered, this, [&](bool state) { selectedTool = state ? TOOL_STUDS : TOOL_SELECT; updateToolbars(); }); connect(ui->actionToolInlets, &QAction::triggered, this, [&](bool state) { selectedTool = state ? TOOL_INLETS : TOOL_SELECT; updateToolbars(); }); connect(ui->actionToolUniversal, &QAction::triggered, this, [&](bool state) { selectedTool = state ? TOOL_UNIVERSAL : TOOL_SELECT; updateToolbars(); }); + connect(ui->actionToolHinge, &QAction::triggered, this, [&](bool state) { selectedTool = state ? TOOL_HINGE : TOOL_SELECT; updateToolbars(); }); + connect(ui->actionToolMotor, &QAction::triggered, this, [&](bool state) { selectedTool = state ? TOOL_MOTOR : TOOL_SELECT; updateToolbars(); }); ui->actionToolSelect->setChecked(true); selectedTool = TOOL_SELECT; @@ -447,6 +449,8 @@ void MainWindow::updateToolbars() { ui->actionToolStuds->setChecked(selectedTool == TOOL_STUDS); ui->actionToolInlets->setChecked(selectedTool == TOOL_INLETS); ui->actionToolUniversal->setChecked(selectedTool == TOOL_UNIVERSAL); + ui->actionToolHinge->setChecked(selectedTool == TOOL_HINGE); + ui->actionToolMotor->setChecked(selectedTool == TOOL_MOTOR); ui->actionGridSnap1->setChecked(snappingMode == GridSnappingMode::SNAP_1_STUD); ui->actionGridSnap05->setChecked(snappingMode == GridSnappingMode::SNAP_05_STUDS); diff --git a/editor/mainwindow.h b/editor/mainwindow.h index e38c06e..214143b 100644 --- a/editor/mainwindow.h +++ b/editor/mainwindow.h @@ -22,6 +22,8 @@ enum SelectedTool { TOOL_STUDS, TOOL_INLETS, TOOL_UNIVERSAL, + TOOL_HINGE, + TOOL_MOTOR, }; enum GridSnappingMode { diff --git a/editor/mainwindow.ui b/editor/mainwindow.ui index cee0e8b..f4bbbdf 100644 --- a/editor/mainwindow.ui +++ b/editor/mainwindow.ui @@ -221,6 +221,8 @@ + + @@ -673,6 +675,40 @@ QAction::MenuRole::NoRole + + + true + + + + + + Hinge + + + Hinge + + + QAction::MenuRole::NoRole + + + + + true + + + + + + Motor + + + Motor + + + QAction::MenuRole::NoRole + + true