feat(editor): added buttons for hinge and motor

This commit is contained in:
maelstrom 2025-05-06 18:58:14 +02:00
parent 621ae30464
commit a1bd6e1bbc
4 changed files with 43 additions and 1 deletions

View file

@ -111,7 +111,7 @@ void Workspace::PhysicsStep(float deltaTime) {
if (joint.expired() || !joint.lock()->IsA("RotateV")) continue;
std::shared_ptr<JointInstance> motor = joint.lock()->CastTo<JointInstance>().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);
}

View file

@ -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);

View file

@ -22,6 +22,8 @@ enum SelectedTool {
TOOL_STUDS,
TOOL_INLETS,
TOOL_UNIVERSAL,
TOOL_HINGE,
TOOL_MOTOR,
};
enum GridSnappingMode {

View file

@ -221,6 +221,8 @@
<addaction name="actionToolStuds"/>
<addaction name="actionToolInlets"/>
<addaction name="actionToolUniversal"/>
<addaction name="actionToolHinge"/>
<addaction name="actionToolMotor"/>
</widget>
<widget class="QToolBar" name="toolBar">
<property name="windowTitle">
@ -673,6 +675,40 @@
<enum>QAction::MenuRole::NoRole</enum>
</property>
</action>
<action name="actionToolHinge">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset theme="surface-weld"/>
</property>
<property name="text">
<string>Hinge</string>
</property>
<property name="toolTip">
<string>Hinge</string>
</property>
<property name="menuRole">
<enum>QAction::MenuRole::NoRole</enum>
</property>
</action>
<action name="actionToolMotor">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset theme="surface-weld"/>
</property>
<property name="text">
<string>Motor</string>
</property>
<property name="toolTip">
<string>Motor</string>
</property>
<property name="menuRole">
<enum>QAction::MenuRole::NoRole</enum>
</property>
</action>
<action name="actionToggleEditSounds">
<property name="checkable">
<bool>true</bool>