Physics updates, lua bindings (#554)

* physics updates, lua bindings

* velocity setters

* fix softbody gravity

* gui things

* colliders cpu and gpu separation

* terrain prop check for missing assets

* lua internal put in function
This commit is contained in:
Turánszki János
2022-09-04 16:34:50 +02:00
committed by GitHub
parent c359395cea
commit 03fe5dcce8
29 changed files with 802 additions and 92 deletions
+37 -1
View File
@@ -10,7 +10,7 @@ void ColliderWindow::Create(EditorComponent* _editor)
editor = _editor;
wi::gui::Window::Create(ICON_COLLIDER " Collider", wi::gui::Window::WindowControls::COLLAPSE | wi::gui::Window::WindowControls::CLOSE);
SetSize(XMFLOAT2(670, 280));
SetSize(XMFLOAT2(670, 340));
closeButton.SetTooltip("Delete ColliderComponent");
OnClose([=](wi::gui::EventArgs args) {
@@ -32,6 +32,37 @@ void ColliderWindow::Create(EditorComponent* _editor)
float step = hei + 2;
float wid = 220;
infoLabel.Create("");
infoLabel.SetText("Colliders are used for simple fake physics, without using the physics engine. They are only used in specific CPU/GPU systems.");
infoLabel.SetSize(XMFLOAT2(100, 50));
AddWidget(&infoLabel);
cpuCheckBox.Create("CPU: ");
cpuCheckBox.SetTooltip("Enable for use on the CPU. CPU usage includes: springs.");
cpuCheckBox.SetSize(XMFLOAT2(hei, hei));
cpuCheckBox.OnClick([=](wi::gui::EventArgs args) {
wi::scene::Scene& scene = editor->GetCurrentScene();
ColliderComponent* collider = scene.colliders.GetComponent(entity);
if (collider == nullptr)
return;
collider->SetCPUEnabled(args.bValue);
});
AddWidget(&cpuCheckBox);
gpuCheckBox.Create("GPU: ");
gpuCheckBox.SetTooltip("Enable for use on the GPU. GPU usage includes: emitter and hair particle systems.\nNote that GPU can support only a limited amount of colliders.");
gpuCheckBox.SetSize(XMFLOAT2(hei, hei));
gpuCheckBox.OnClick([=](wi::gui::EventArgs args) {
wi::scene::Scene& scene = editor->GetCurrentScene();
ColliderComponent* collider = scene.colliders.GetComponent(entity);
if (collider == nullptr)
return;
collider->SetGPUEnabled(args.bValue);
});
AddWidget(&gpuCheckBox);
shapeCombo.Create("Shape: ");
shapeCombo.SetSize(XMFLOAT2(wid, hei));
shapeCombo.SetPos(XMFLOAT2(x, y));
@@ -167,6 +198,8 @@ void ColliderWindow::SetEntity(Entity entity)
if (collider != nullptr)
{
cpuCheckBox.SetCheck(collider->IsCPUEnabled());
gpuCheckBox.SetCheck(collider->IsGPUEnabled());
shapeCombo.SetSelectedByUserdataWithoutCallback((uint64_t)collider->shape);
radiusSlider.SetValue(collider->radius);
offsetX.SetValue(collider->offset.x);
@@ -215,6 +248,9 @@ void ColliderWindow::ResizeLayout()
y += padding;
};
add_fullwidth(infoLabel);
add_right(cpuCheckBox);
gpuCheckBox.SetPos(XMFLOAT2(cpuCheckBox.GetPos().x - 100, cpuCheckBox.GetPos().y));
add(shapeCombo);
add(radiusSlider);