diff --git a/Editor/MeshWindow.cpp b/Editor/MeshWindow.cpp index 0f4506a81..f2c5ea9dc 100644 --- a/Editor/MeshWindow.cpp +++ b/Editor/MeshWindow.cpp @@ -16,7 +16,7 @@ MeshWindow::MeshWindow(wiGUI* gui) : GUI(gui) meshWindow = new wiWindow(GUI, "Mesh Window"); - meshWindow->SetSize(XMFLOAT2(800, 600)); + meshWindow->SetSize(XMFLOAT2(800, 640)); meshWindow->SetEnabled(false); GUI->AddWidget(meshWindow); @@ -43,6 +43,34 @@ MeshWindow::MeshWindow(wiGUI* gui) : GUI(gui) }); meshWindow->AddWidget(doubleSidedCheckBox); + softbodyCheckBox = new wiCheckBox("Soft body: "); + softbodyCheckBox->SetTooltip("Enable soft body simulation."); + softbodyCheckBox->SetPos(XMFLOAT2(x, y += step)); + softbodyCheckBox->OnClick([&](wiEventArgs args) { + + Scene& scene = wiRenderer::GetScene(); + SoftBodyPhysicsComponent* physicscomponent = scene.softbodies.GetComponent(entity); + + if (args.bValue) + { + if (physicscomponent == nullptr) + { + SoftBodyPhysicsComponent& softbody = scene.softbodies.Create(entity); + softbody.friction = frictionSlider->GetValue(); + softbody.mass = massSlider->GetValue(); + } + } + else + { + if (physicscomponent != nullptr) + { + scene.softbodies.Remove(entity); + } + } + + }); + meshWindow->AddWidget(softbodyCheckBox); + massSlider = new wiSlider(0, 5000, 0, 100000, "Mass: "); massSlider->SetTooltip("Set the mass amount for the physics engine."); massSlider->SetSize(XMFLOAT2(100, 30)); diff --git a/Editor/MeshWindow.h b/Editor/MeshWindow.h index 46b579042..8d1eb5fc6 100644 --- a/Editor/MeshWindow.h +++ b/Editor/MeshWindow.h @@ -21,6 +21,7 @@ public: wiWindow* meshWindow; wiLabel* meshInfoLabel; wiCheckBox* doubleSidedCheckBox; + wiCheckBox* softbodyCheckBox; wiSlider* massSlider; wiSlider* frictionSlider; wiButton* impostorCreateButton; diff --git a/Editor/ModelImporter_OBJ.cpp b/Editor/ModelImporter_OBJ.cpp index f4a7d9593..1ff635a4d 100644 --- a/Editor/ModelImporter_OBJ.cpp +++ b/Editor/ModelImporter_OBJ.cpp @@ -121,9 +121,7 @@ void ImportModel_OBJ(const std::string& fileName) for (auto& index : reordered_indices) { - XMFLOAT3 pos; - - pos = XMFLOAT3( + XMFLOAT3 pos = XMFLOAT3( obj_attrib.vertices[index.vertex_index * 3 + 0], obj_attrib.vertices[index.vertex_index * 3 + 1], obj_attrib.vertices[index.vertex_index * 3 + 2] diff --git a/WickedEngine/wiPhysics_Bullet.cpp b/WickedEngine/wiPhysics_Bullet.cpp index 1b84732ba..da7205e2a 100644 --- a/WickedEngine/wiPhysics_Bullet.cpp +++ b/WickedEngine/wiPhysics_Bullet.cpp @@ -440,6 +440,13 @@ namespace wiPhysics } assert(id >= 0 && id <= dynamicsWorld->getCollisionObjectArray().size()); + btCollisionObject* obj = dynamicsWorld->getCollisionObjectArray()[id]; + btSoftBody* body = btSoftBody::upcast(obj); + if (body != nullptr) + { + body->setWindVelocity(wind); + } + } // Tidy: