diff --git a/Editor/ComponentsWindow.cpp b/Editor/ComponentsWindow.cpp index 71f73fba9..7eada2785 100644 --- a/Editor/ComponentsWindow.cpp +++ b/Editor/ComponentsWindow.cpp @@ -308,7 +308,11 @@ void ComponentsWindow::Create(EditorComponent* _editor) scene.scripts.Create(entity); break; case ADD_RIGIDBODY: - scene.rigidbodies.Create(entity); + { + RigidBodyPhysicsComponent& rigidbody = scene.rigidbodies.Create(entity); + rigidbody.SetKinematic(true); // Set it to kinematic so that it doesn't immediately fall + rigidbody.SetDisableDeactivation(true); + } break; case ADD_SOFTBODY: scene.softbodies.Create(entity); diff --git a/Editor/Editor.cpp b/Editor/Editor.cpp index a2f0f74d7..fa77ae607 100644 --- a/Editor/Editor.cpp +++ b/Editor/Editor.cpp @@ -187,8 +187,6 @@ void EditorComponent::Load() }); GetGUI().AddWidget(&newSceneButton); - - translateButton.Create(ICON_TRANSLATE); rotateButton.Create(ICON_ROTATE); scaleButton.Create(ICON_SCALE); @@ -224,6 +222,20 @@ void EditorComponent::Load() GetGUI().AddWidget(&translateButton); } + physicsButton.Create(ICON_RIGIDBODY); + physicsButton.SetShadowRadius(2); + physicsButton.SetTooltip("Toggle Physics Simulation On/Off"); + if (main->config.GetSection("options").Has("physics")) + { + wi::physics::SetSimulationEnabled(main->config.GetSection("options").GetBool("physics")); + } + physicsButton.OnClick([&](wi::gui::EventArgs args) { + wi::physics::SetSimulationEnabled(!wi::physics::IsSimulationEnabled()); + main->config.GetSection("options").Set("physics", wi::physics::IsSimulationEnabled()); + main->config.Commit(); + }); + GetGUI().AddWidget(&physicsButton); + dummyButton.Create(ICON_DUMMY); dummyButton.SetShadowRadius(2); dummyButton.SetTooltip("Toggle reference dummy visualizer\n - Use the reference dummy to get an idea about object sizes compared to a human character size.\n - Position the dummy by clicking on something with the left mouse button while the dummy is active and nothing is selected.\n - Pressing this button while Ctrl key is held down will reset dummy position to the origin.\n - Pressing this button while the Shift key is held down will switch between male and female dummies."); @@ -3781,8 +3793,11 @@ void EditorComponent::UpdateTopMenuAnimation() dummyButton.SetSize(XMFLOAT2(wid_idle * 0.75f, hei)); dummyButton.SetPos(XMFLOAT2(static_pos - dummyButton.GetSize().x - 20, 0)); + physicsButton.SetSize(XMFLOAT2(wid_idle * 0.75f, hei)); + physicsButton.SetPos(XMFLOAT2(dummyButton.GetPos().x - physicsButton.GetSize().x - 20, 0)); + stopButton.SetSize(XMFLOAT2(wid_idle * 0.75f, hei)); - stopButton.SetPos(XMFLOAT2(dummyButton.GetPos().x - stopButton.GetSize().x - 20, 0)); + stopButton.SetPos(XMFLOAT2(physicsButton.GetPos().x - stopButton.GetSize().x - 20, 0)); playButton.SetSize(XMFLOAT2(wid_idle * 0.75f, hei)); playButton.SetPos(XMFLOAT2(stopButton.GetPos().x - playButton.GetSize().x - padding, 0)); @@ -3825,6 +3840,15 @@ void EditorComponent::UpdateTopMenuAnimation() dummyButton.sprites[wi::gui::IDLE].params.color = color_off; } + if (wi::physics::IsSimulationEnabled()) + { + physicsButton.sprites[wi::gui::IDLE].params.color = color_on; + } + else + { + physicsButton.sprites[wi::gui::IDLE].params.color = color_off; + } + float ofs = screenW - 2; float y = exitButton.GetPos().y + exitButton.GetSize().y + 5; hei = 18; diff --git a/Editor/Editor.h b/Editor/Editor.h index 224ce79ed..fa214e176 100644 --- a/Editor/Editor.h +++ b/Editor/Editor.h @@ -28,6 +28,8 @@ public: wi::gui::Button rotateButton; wi::gui::Button scaleButton; + wi::gui::Button physicsButton; + wi::gui::Button dummyButton; bool dummy_enabled = false; bool dummy_male = false; diff --git a/Editor/GeneralWindow.cpp b/Editor/GeneralWindow.cpp index 622ba7f8b..98e137451 100644 --- a/Editor/GeneralWindow.cpp +++ b/Editor/GeneralWindow.cpp @@ -15,20 +15,6 @@ void GeneralWindow::Create(EditorComponent* _editor) SetSize(XMFLOAT2(580, 680)); - physicsEnabledCheckBox.Create("Physics: "); - physicsEnabledCheckBox.SetTooltip("Toggle Physics Simulation On/Off"); - if (editor->main->config.GetSection("options").Has("physics")) - { - wi::physics::SetSimulationEnabled(editor->main->config.GetSection("options").GetBool("physics")); - } - physicsEnabledCheckBox.OnClick([&](wi::gui::EventArgs args) { - wi::physics::SetSimulationEnabled(args.bValue); - editor->main->config.GetSection("options").Set("physics", args.bValue); - editor->main->config.Commit(); - }); - physicsEnabledCheckBox.SetCheck(wi::physics::IsSimulationEnabled()); - AddWidget(&physicsEnabledCheckBox); - physicsDebugCheckBox.Create("Physics visualizer: "); physicsDebugCheckBox.SetTooltip("Visualize the physics world"); physicsDebugCheckBox.OnClick([](wi::gui::EventArgs args) { @@ -543,10 +529,13 @@ void GeneralWindow::Create(EditorComponent* _editor) editor->scaleButton.sprites[i].params.enableCornerRounding(); editor->scaleButton.sprites[i].params.corners_rounding[3].radius = 40; - editor->dummyButton.sprites[i].params.enableCornerRounding(); editor->dummyButton.sprites[i].params.corners_rounding[2].radius = 40; editor->dummyButton.sprites[i].params.corners_rounding[3].radius = 40; + + editor->physicsButton.sprites[i].params.enableCornerRounding(); + editor->physicsButton.sprites[i].params.corners_rounding[2].radius = 40; + editor->physicsButton.sprites[i].params.corners_rounding[3].radius = 40; } editor->componentsWnd.weatherWnd.default_sky_horizon = dark_point; editor->componentsWnd.weatherWnd.default_sky_zenith = theme_color_idle; @@ -732,9 +721,8 @@ void GeneralWindow::ResizeLayout() add_fullwidth(localizationButton); - physicsEnabledCheckBox.SetPos(XMFLOAT2(width - physicsEnabledCheckBox.GetSize().x, y)); - physicsDebugCheckBox.SetPos(XMFLOAT2(physicsEnabledCheckBox.GetPos().x - physicsDebugCheckBox.GetSize().x - 70, y)); - y += physicsEnabledCheckBox.GetSize().y; + physicsDebugCheckBox.SetPos(XMFLOAT2(width - physicsDebugCheckBox.GetSize().x, y)); + y += physicsDebugCheckBox.GetSize().y; y += padding; nameDebugCheckBox.SetPos(XMFLOAT2(width - nameDebugCheckBox.GetSize().x, y)); diff --git a/Editor/GeneralWindow.h b/Editor/GeneralWindow.h index a812dec8a..03fa5438c 100644 --- a/Editor/GeneralWindow.h +++ b/Editor/GeneralWindow.h @@ -14,7 +14,6 @@ public: wi::gui::ComboBox saveModeComboBox; wi::gui::ComboBox languageCombo; - wi::gui::CheckBox physicsEnabledCheckBox; wi::gui::CheckBox physicsDebugCheckBox; wi::gui::CheckBox nameDebugCheckBox; wi::gui::CheckBox gridHelperCheckBox;