diff --git a/Editor/CameraComponentWindow.cpp b/Editor/CameraComponentWindow.cpp index 558cb5032..ce1ff2c42 100644 --- a/Editor/CameraComponentWindow.cpp +++ b/Editor/CameraComponentWindow.cpp @@ -103,8 +103,8 @@ void CameraComponentWindow::Create(EditorComponent* _editor) float step = hei + 2; float wid = 120; - auto forAllSelectedCameraComponents = [&](auto /* void(nonnull CameraComponent*, wi::gui::EventArgs) */ func) { - return [&](wi::gui::EventArgs args) { + auto forEachSelectedCameraComponent = [this](auto /* void(nonnull CameraComponent*, wi::gui::EventArgs) */ func) { + return [this, func](wi::gui::EventArgs args) { wi::scene::Scene& scene = editor->GetCurrentScene(); for (auto& x : editor->translator.selected) { @@ -122,7 +122,7 @@ void CameraComponentWindow::Create(EditorComponent* _editor) farPlaneSlider.SetSize(XMFLOAT2(wid, hei)); farPlaneSlider.SetPos(XMFLOAT2(x, y)); farPlaneSlider.SetValue(editor->GetCurrentEditorScene().camera.zFarP); - farPlaneSlider.OnSlide(forAllSelectedCameraComponents([&](auto camera, auto args) { + farPlaneSlider.OnSlide(forEachSelectedCameraComponent([](auto camera, auto args) { camera->zFarP = args.fValue; })); AddWidget(&farPlaneSlider); @@ -132,7 +132,7 @@ void CameraComponentWindow::Create(EditorComponent* _editor) nearPlaneSlider.SetSize(XMFLOAT2(wid, hei)); nearPlaneSlider.SetPos(XMFLOAT2(x, y += step)); nearPlaneSlider.SetValue(editor->GetCurrentEditorScene().camera.zNearP); - nearPlaneSlider.OnSlide(forAllSelectedCameraComponents([&](auto camera, auto args) { + nearPlaneSlider.OnSlide(forEachSelectedCameraComponent([](auto camera, auto args) { camera->zNearP = args.fValue; })); AddWidget(&nearPlaneSlider); @@ -142,7 +142,7 @@ void CameraComponentWindow::Create(EditorComponent* _editor) fovSlider.SetSize(XMFLOAT2(wid, hei)); fovSlider.SetPos(XMFLOAT2(x, y += step)); fovSlider.SetValue(editor->GetCurrentEditorScene().camera.fov / XM_PI * 180.f); - fovSlider.OnSlide(forAllSelectedCameraComponents([&](auto camera, auto args) { + fovSlider.OnSlide(forEachSelectedCameraComponent([](auto camera, auto args) { camera->fov = args.fValue / 180.f * XM_PI; })); AddWidget(&fovSlider); @@ -151,7 +151,7 @@ void CameraComponentWindow::Create(EditorComponent* _editor) focalLengthSlider.SetTooltip("Controls the depth of field effect's focus distance"); focalLengthSlider.SetSize(XMFLOAT2(wid, hei)); focalLengthSlider.SetPos(XMFLOAT2(x, y += step)); - focalLengthSlider.OnSlide(forAllSelectedCameraComponents([&](auto camera, auto args) { + focalLengthSlider.OnSlide(forEachSelectedCameraComponent([](auto camera, auto args) { camera->focal_length = args.fValue; })); AddWidget(&focalLengthSlider); @@ -160,7 +160,7 @@ void CameraComponentWindow::Create(EditorComponent* _editor) apertureSizeSlider.SetTooltip("Controls the depth of field effect's strength"); apertureSizeSlider.SetSize(XMFLOAT2(wid, hei)); apertureSizeSlider.SetPos(XMFLOAT2(x, y += step)); - apertureSizeSlider.OnSlide(forAllSelectedCameraComponents([&](auto camera, auto args) { + apertureSizeSlider.OnSlide(forEachSelectedCameraComponent([](auto camera, auto args) { camera->aperture_size = args.fValue; })); AddWidget(&apertureSizeSlider); @@ -169,7 +169,7 @@ void CameraComponentWindow::Create(EditorComponent* _editor) apertureShapeXSlider.SetTooltip("Controls the depth of field effect's bokeh shape"); apertureShapeXSlider.SetSize(XMFLOAT2(wid, hei)); apertureShapeXSlider.SetPos(XMFLOAT2(x, y += step)); - apertureShapeXSlider.OnSlide(forAllSelectedCameraComponents([&](auto camera, auto args) { + apertureShapeXSlider.OnSlide(forEachSelectedCameraComponent([](auto camera, auto args) { camera->aperture_shape.x = args.fValue; })); AddWidget(&apertureShapeXSlider); @@ -178,7 +178,7 @@ void CameraComponentWindow::Create(EditorComponent* _editor) apertureShapeYSlider.SetTooltip("Controls the depth of field effect's bokeh shape"); apertureShapeYSlider.SetSize(XMFLOAT2(wid, hei)); apertureShapeYSlider.SetPos(XMFLOAT2(x, y += step)); - apertureShapeYSlider.OnSlide(forAllSelectedCameraComponents([&](auto camera, auto args) { + apertureShapeYSlider.OnSlide(forEachSelectedCameraComponent([](auto camera, auto args) { camera->aperture_shape.y = args.fValue; })); AddWidget(&apertureShapeYSlider); @@ -223,21 +223,21 @@ void CameraComponentWindow::Create(EditorComponent* _editor) resolutionXSlider.Create(128, 2048, 256, 2048 - 128, "Render Width: "); resolutionXSlider.SetTooltip("Set the render resolution Width"); - resolutionXSlider.OnSlide(forAllSelectedCameraComponents([&](auto camera, auto args) { + resolutionXSlider.OnSlide(forEachSelectedCameraComponent([](auto camera, auto args) { camera->render_to_texture.resolution.x = (uint32_t)args.iValue; })); AddWidget(&resolutionXSlider); resolutionYSlider.Create(128, 2048, 256, 2048 - 128, "Render Height: "); resolutionYSlider.SetTooltip("Set the render resolution Height"); - resolutionYSlider.OnSlide(forAllSelectedCameraComponents([&](auto camera, auto args) { + resolutionYSlider.OnSlide(forEachSelectedCameraComponent([](auto camera, auto args) { camera->render_to_texture.resolution.y = (uint32_t)args.iValue; })); AddWidget(&resolutionYSlider); samplecountSlider.Create(1, 8, 1, 7, "Sample count: "); samplecountSlider.SetTooltip("Set the render resolution sample count (MSAA)"); - samplecountSlider.OnSlide(forAllSelectedCameraComponents([&](auto camera, auto args) { + samplecountSlider.OnSlide(forEachSelectedCameraComponent([](auto camera, auto args) { camera->render_to_texture.sample_count = wi::math::GetNextPowerOfTwo((uint32_t)args.iValue); })); AddWidget(&samplecountSlider); diff --git a/Editor/CameraWindow.cpp b/Editor/CameraWindow.cpp index e21cec847..ff1ff5609 100644 --- a/Editor/CameraWindow.cpp +++ b/Editor/CameraWindow.cpp @@ -50,8 +50,8 @@ void CameraWindow::Create(EditorComponent* _editor) ResetCam(); - auto updateCamera = [&](auto func) { - return [&](wi::gui::EventArgs args) { + auto updateCamera = [this](auto func) { + return [this, func](wi::gui::EventArgs args) { Scene& scene = editor->GetCurrentScene(); CameraComponent& camera = editor->GetCurrentEditorScene().camera; func(camera, args); diff --git a/Editor/ColliderWindow.cpp b/Editor/ColliderWindow.cpp index dcee2001b..19524060d 100644 --- a/Editor/ColliderWindow.cpp +++ b/Editor/ColliderWindow.cpp @@ -36,8 +36,8 @@ void ColliderWindow::Create(EditorComponent* _editor) infoLabel.SetFitTextEnabled(true); AddWidget(&infoLabel); - auto forEachSelectedCollider = [&](auto func) { - return [&, func](wi::gui::EventArgs args) { + auto forEachSelectedCollider = [this](auto func) { + return [this, func](wi::gui::EventArgs args) { wi::scene::Scene& scene = editor->GetCurrentScene(); for (auto& x : editor->translator.selected) { @@ -51,7 +51,7 @@ void ColliderWindow::Create(EditorComponent* _editor) cpuCheckBox.Create("CPU: "); cpuCheckBox.SetTooltip("Enable for use on the CPU. CPU usage includes: springs."); cpuCheckBox.SetSize(XMFLOAT2(hei, hei)); - cpuCheckBox.OnClick(forEachSelectedCollider([&](auto collider, auto args) { + cpuCheckBox.OnClick(forEachSelectedCollider([](auto collider, auto args) { collider->SetCPUEnabled(args.bValue); })); AddWidget(&cpuCheckBox); @@ -59,7 +59,7 @@ void ColliderWindow::Create(EditorComponent* _editor) 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(forEachSelectedCollider([&](auto collider, auto args) { + gpuCheckBox.OnClick(forEachSelectedCollider([](auto collider, auto args) { collider->SetGPUEnabled(args.bValue); })); AddWidget(&gpuCheckBox); @@ -70,7 +70,7 @@ void ColliderWindow::Create(EditorComponent* _editor) shapeCombo.AddItem("Sphere", (uint64_t)ColliderComponent::Shape::Sphere); shapeCombo.AddItem("Capsule", (uint64_t)ColliderComponent::Shape::Capsule); shapeCombo.AddItem("Plane", (uint64_t)ColliderComponent::Shape::Plane); - shapeCombo.OnSelect(forEachSelectedCollider([&](auto collider, auto args) { + shapeCombo.OnSelect(forEachSelectedCollider([](auto collider, auto args) { collider->shape = (ColliderComponent::Shape)args.userdata; })); AddWidget(&shapeCombo); @@ -78,7 +78,7 @@ void ColliderWindow::Create(EditorComponent* _editor) radiusSlider.Create(0, 10, 0, 100000, "Radius: "); radiusSlider.SetSize(XMFLOAT2(wid, hei)); radiusSlider.SetPos(XMFLOAT2(x, y += step)); - radiusSlider.OnSlide(forEachSelectedCollider([&](auto collider, auto args) { + radiusSlider.OnSlide(forEachSelectedCollider([](auto collider, auto args) { collider->radius = args.fValue; })); AddWidget(&radiusSlider); @@ -90,7 +90,7 @@ void ColliderWindow::Create(EditorComponent* _editor) offsetX.Create(-10, 10, 0, 10000, "Offset X: "); offsetX.SetSize(XMFLOAT2(wid, hei)); offsetX.SetPos(XMFLOAT2(x, y += step)); - offsetX.OnSlide(forEachSelectedCollider([&](auto collider, auto args) { + offsetX.OnSlide(forEachSelectedCollider([](auto collider, auto args) { collider->offset.x = args.fValue; })); AddWidget(&offsetX); @@ -98,7 +98,7 @@ void ColliderWindow::Create(EditorComponent* _editor) offsetY.Create(-10, 10, 0, 10000, "Offset Y: "); offsetY.SetSize(XMFLOAT2(wid, hei)); offsetY.SetPos(XMFLOAT2(x, y += step)); - offsetY.OnSlide(forEachSelectedCollider([&](auto collider, auto args) { + offsetY.OnSlide(forEachSelectedCollider([](auto collider, auto args) { collider->offset.y = args.fValue; })); AddWidget(&offsetY); @@ -106,7 +106,7 @@ void ColliderWindow::Create(EditorComponent* _editor) offsetZ.Create(-10, 10, 0, 10000, "Offset Z: "); offsetZ.SetSize(XMFLOAT2(wid, hei)); offsetZ.SetPos(XMFLOAT2(x, y += step)); - offsetZ.OnSlide(forEachSelectedCollider([&](auto collider, auto args) { + offsetZ.OnSlide(forEachSelectedCollider([](auto collider, auto args) { collider->offset.z = args.fValue; })); AddWidget(&offsetZ); @@ -118,7 +118,7 @@ void ColliderWindow::Create(EditorComponent* _editor) tailX.Create(-10, 10, 0, 10000, "Tail X: "); tailX.SetSize(XMFLOAT2(wid, hei)); tailX.SetPos(XMFLOAT2(x, y += step)); - tailX.OnSlide(forEachSelectedCollider([&](auto collider, auto args) { + tailX.OnSlide(forEachSelectedCollider([](auto collider, auto args) { collider->tail.x = args.fValue; })); AddWidget(&tailX); @@ -126,7 +126,7 @@ void ColliderWindow::Create(EditorComponent* _editor) tailY.Create(-10, 10, 0, 10000, "Tail Y: "); tailY.SetSize(XMFLOAT2(wid, hei)); tailY.SetPos(XMFLOAT2(x, y += step)); - tailY.OnSlide(forEachSelectedCollider([&](auto collider, auto args) { + tailY.OnSlide(forEachSelectedCollider([](auto collider, auto args) { collider->tail.y = args.fValue; })); AddWidget(&tailY); @@ -134,7 +134,7 @@ void ColliderWindow::Create(EditorComponent* _editor) tailZ.Create(-10, 10, 0, 10000, "Tail Z: "); tailZ.SetSize(XMFLOAT2(wid, hei)); tailZ.SetPos(XMFLOAT2(x, y += step)); - tailZ.OnSlide(forEachSelectedCollider([&](auto collider, auto args) { + tailZ.OnSlide(forEachSelectedCollider([](auto collider, auto args) { collider->tail.z = args.fValue; })); AddWidget(&tailZ); diff --git a/Editor/ConstraintWindow.cpp b/Editor/ConstraintWindow.cpp index b2b3f2adc..8ae4cf4fa 100644 --- a/Editor/ConstraintWindow.cpp +++ b/Editor/ConstraintWindow.cpp @@ -40,8 +40,8 @@ void ConstraintWindow::Create(EditorComponent* _editor) physicsDebugCheckBox.SetCheck(wi::physics::IsDebugDrawEnabled()); AddWidget(&physicsDebugCheckBox); - auto forEachSelected = [&](auto func) { - return [&, func](auto args) { + auto forEachSelected = [this](auto func) { + return [this, func](auto args) { wi::scene::Scene& scene = editor->GetCurrentScene(); for (auto& x : editor->translator.selected) { @@ -53,19 +53,19 @@ void ConstraintWindow::Create(EditorComponent* _editor) }; }; - auto forEachSelectedWithRefresh = [&](auto func) { - return [&, func](auto args) { - forEachSelected([&, func](auto physicscomponent, auto args) { + auto forEachSelectedWithRefresh = [this, forEachSelected](auto func) { + return [this, forEachSelected, func](auto args) { + forEachSelected([this, func](auto physicscomponent, auto args) { func(physicscomponent, args); physicscomponent->SetRefreshParametersNeeded(true); - }); + })(args); }; }; collisionCheckBox.Create("Disable self collision: "); collisionCheckBox.SetTooltip("Disable collision between the two bodies that this constraint targets.\nNote: changing this will recreate the constraint in the current pose relative to the bodies."); - collisionCheckBox.OnClick(forEachSelected([&] (auto physicscomponent, auto args) { + collisionCheckBox.OnClick(forEachSelected([] (auto physicscomponent, auto args) { physicscomponent->SetDisableSelfCollision(args.bValue); physicscomponent->physicsobject = nullptr; })); @@ -79,7 +79,7 @@ void ConstraintWindow::Create(EditorComponent* _editor) AddWidget(&constraintDebugSlider); rebindButton.Create("Rebind Constraint"); - rebindButton.OnClick(forEachSelected([&](auto physicscomponent, auto args) { + rebindButton.OnClick(forEachSelected([](auto physicscomponent, auto args) { physicscomponent->physicsobject = nullptr; })); AddWidget(&rebindButton); @@ -93,7 +93,7 @@ void ConstraintWindow::Create(EditorComponent* _editor) typeComboBox.AddItem("Six DOF", (uint64_t)PhysicsConstraintComponent::Type::SixDOF); typeComboBox.AddItem("Swing Twist", (uint64_t)PhysicsConstraintComponent::Type::SwingTwist); typeComboBox.AddItem("Slider", (uint64_t)PhysicsConstraintComponent::Type::Slider); - typeComboBox.OnSelect(forEachSelected([&](auto physicscomponent, auto args) { + typeComboBox.OnSelect(forEachSelected([](auto physicscomponent, auto args) { PhysicsConstraintComponent::Type type = (PhysicsConstraintComponent::Type)args.userdata; if (physicscomponent->type != type) { @@ -107,21 +107,21 @@ void ConstraintWindow::Create(EditorComponent* _editor) AddWidget(&typeComboBox); bodyAComboBox.Create("Body A: "); - bodyAComboBox.OnSelect(forEachSelected([&](auto physicscomponent, auto args) { + bodyAComboBox.OnSelect(forEachSelected([](auto physicscomponent, auto args) { physicscomponent->bodyA = args.userdata; physicscomponent->physicsobject = nullptr; })); AddWidget(&bodyAComboBox); bodyBComboBox.Create("Body B: "); - bodyBComboBox.OnSelect(forEachSelected([&](auto physicscomponent, auto args) { + bodyBComboBox.OnSelect(forEachSelected([](auto physicscomponent, auto args) { physicscomponent->bodyB = args.userdata; physicscomponent->physicsobject = nullptr; })); AddWidget(&bodyBComboBox); minSlider.Create(0, 10, 1, 100000, "minSlider"); - minSlider.OnSlide(forEachSelected([&](auto physicscomponent, auto args) { + minSlider.OnSlide(forEachSelected([](auto physicscomponent, auto args) { switch (physicscomponent->type) { case PhysicsConstraintComponent::Type::Distance: @@ -147,7 +147,7 @@ void ConstraintWindow::Create(EditorComponent* _editor) AddWidget(&minSlider); maxSlider.Create(0, 10, 1, 100000, "maxSlider"); - maxSlider.OnSlide(forEachSelected([&](auto physicscomponent, auto args) { + maxSlider.OnSlide(forEachSelected([](auto physicscomponent, auto args) { switch (physicscomponent->type) { case PhysicsConstraintComponent::Type::Distance: @@ -171,13 +171,13 @@ void ConstraintWindow::Create(EditorComponent* _editor) breakSlider.Create(0, 10, 1, 1000, "Break distance: "); breakSlider.SetTooltip("How much the constraint is allowed to be exerted before breaking, calculated as relative distance. Set to FLT_MAX to disable breaking."); - breakSlider.OnSlide(forEachSelected([&] (auto physicscomponent, auto args) { + breakSlider.OnSlide(forEachSelected([] (auto physicscomponent, auto args) { physicscomponent->break_distance = args.fValue; })); AddWidget(&breakSlider); motorSlider1.Create(0, 10, 1, 100000, "motorSlider1"); - motorSlider1.OnSlide(forEachSelected([&](auto physicscomponent, auto args) { + motorSlider1.OnSlide(forEachSelected([](auto physicscomponent, auto args) { switch (physicscomponent->type) { case PhysicsConstraintComponent::Type::Hinge: @@ -194,7 +194,7 @@ void ConstraintWindow::Create(EditorComponent* _editor) AddWidget(&motorSlider1); motorSlider2.Create(0, 10, 1, 100000, "motorSlider2"); - motorSlider2.OnSlide(forEachSelected([&](auto physicscomponent, auto args) { + motorSlider2.OnSlide(forEachSelected([](auto physicscomponent, auto args) { switch (physicscomponent->type) { case PhysicsConstraintComponent::Type::Slider: @@ -209,134 +209,134 @@ void ConstraintWindow::Create(EditorComponent* _editor) normalConeSlider.Create(0, 90, 1, 90, "Normal Angle: "); - normalConeSlider.OnSlide(forEachSelected([&](auto physicscomponent, auto args) { + normalConeSlider.OnSlide(forEachSelected([](auto physicscomponent, auto args) { physicscomponent->swing_twist.normal_half_cone_angle = wi::math::DegreesToRadians(args.fValue); physicscomponent->SetRefreshParametersNeeded(true); })); AddWidget(&normalConeSlider); planeConeSlider.Create(0, 90, 1, 90, "Plane Angle: "); - planeConeSlider.OnSlide(forEachSelected([&](auto physicscomponent, auto args) { + planeConeSlider.OnSlide(forEachSelected([](auto physicscomponent, auto args) { physicscomponent->swing_twist.plane_half_cone_angle = wi::math::DegreesToRadians(args.fValue); physicscomponent->SetRefreshParametersNeeded(true); })); AddWidget(&planeConeSlider); - auto fixXYZ = [&](auto func) { - return [&](auto args) { - forEachSelectedWithRefresh([&](auto physicscomponent, auto args) { + auto fixXYZ = [this, forEachSelectedWithRefresh](auto func) { + return [this, forEachSelectedWithRefresh, func](auto args) { + forEachSelectedWithRefresh([func](auto physicscomponent, auto args) { func(physicscomponent); - }); + })(args); SetEntity(entity); }; }; fixedXButton.Create("Fix X"); - fixedXButton.OnClick(fixXYZ([&](auto physicscomponent) { + fixedXButton.OnClick(fixXYZ([](auto physicscomponent) { physicscomponent->six_dof.SetFixedX(); })); AddWidget(&fixedXButton); fixedYButton.Create("Fix Y"); - fixedYButton.OnClick(fixXYZ([&](auto physicscomponent) { + fixedYButton.OnClick(fixXYZ([](auto physicscomponent) { physicscomponent->six_dof.SetFixedY(); })); AddWidget(&fixedYButton); fixedZButton.Create("Fix Z"); - fixedZButton.OnClick(fixXYZ([&](auto physicscomponent) { + fixedZButton.OnClick(fixXYZ([](auto physicscomponent) { physicscomponent->six_dof.SetFixedZ(); })); AddWidget(&fixedZButton); fixedXRotationButton.Create("Fix Rot X"); - fixedXRotationButton.OnClick(fixXYZ([&](auto physicscomponent) { + fixedXRotationButton.OnClick(fixXYZ([](auto physicscomponent) { physicscomponent->six_dof.SetFixedRotationX(); })); AddWidget(&fixedXRotationButton); fixedYRotationButton.Create("Fix Rot Y"); - fixedYRotationButton.OnClick(fixXYZ([&](auto physicscomponent) { + fixedYRotationButton.OnClick(fixXYZ([](auto physicscomponent) { physicscomponent->six_dof.SetFixedRotationY(); })); AddWidget(&fixedYRotationButton); fixedZRotationButton.Create("Fix Rot Z"); - fixedZRotationButton.OnClick(fixXYZ([&](auto physicscomponent) { + fixedZRotationButton.OnClick(fixXYZ([](auto physicscomponent) { physicscomponent->six_dof.SetFixedRotationZ(); })); AddWidget(&fixedZRotationButton); minTranslationXSlider.Create(-10, 0, 1, 100000, "Min Translation X: "); - minTranslationXSlider.OnSlide(forEachSelectedWithRefresh([&](auto physicscomponent, auto args) { + minTranslationXSlider.OnSlide(forEachSelectedWithRefresh([](auto physicscomponent, auto args) { physicscomponent->six_dof.minTranslationAxes.x = args.fValue; })); AddWidget(&minTranslationXSlider); minTranslationYSlider.Create(-10, 0, 1, 100000, "Min Translation Y: "); - minTranslationYSlider.OnSlide(forEachSelectedWithRefresh([&](auto physicscomponent, auto args) { + minTranslationYSlider.OnSlide(forEachSelectedWithRefresh([](auto physicscomponent, auto args) { physicscomponent->six_dof.minTranslationAxes.y = args.fValue; })); AddWidget(&minTranslationYSlider); minTranslationZSlider.Create(-10, 0, 1, 100000, "Min Translation Z: "); - minTranslationZSlider.OnSlide(forEachSelectedWithRefresh([&](auto physicscomponent, auto args) { + minTranslationZSlider.OnSlide(forEachSelectedWithRefresh([](auto physicscomponent, auto args) { physicscomponent->six_dof.minTranslationAxes.z = args.fValue; })); AddWidget(&minTranslationZSlider); maxTranslationXSlider.Create(0, 10, 1, 100000, "Max Translation X: "); - maxTranslationXSlider.OnSlide(forEachSelectedWithRefresh([&](auto physicscomponent, auto args) { + maxTranslationXSlider.OnSlide(forEachSelectedWithRefresh([](auto physicscomponent, auto args) { physicscomponent->six_dof.maxTranslationAxes.x = args.fValue; })); AddWidget(&maxTranslationXSlider); maxTranslationYSlider.Create(0, 10, 1, 100000, "Max Translation Y: "); - maxTranslationYSlider.OnSlide(forEachSelectedWithRefresh([&](auto physicscomponent, auto args) { + maxTranslationYSlider.OnSlide(forEachSelectedWithRefresh([](auto physicscomponent, auto args) { physicscomponent->six_dof.maxTranslationAxes.y = args.fValue; })); AddWidget(&maxTranslationYSlider); maxTranslationZSlider.Create(0, 10, 1, 100000, "Max Translation Z: "); - maxTranslationZSlider.OnSlide(forEachSelectedWithRefresh([&](auto physicscomponent, auto args) { + maxTranslationZSlider.OnSlide(forEachSelectedWithRefresh([](auto physicscomponent, auto args) { physicscomponent->six_dof.maxTranslationAxes.z = args.fValue; })); AddWidget(&maxTranslationZSlider); minRotationXSlider.Create(-180, 0, 1, 100000, "Min Rotation X: "); - minRotationXSlider.OnSlide(forEachSelectedWithRefresh([&](auto physicscomponent, auto args) { + minRotationXSlider.OnSlide(forEachSelectedWithRefresh([](auto physicscomponent, auto args) { physicscomponent->six_dof.minRotationAxes.x = wi::math::DegreesToRadians(args.fValue); })); AddWidget(&minRotationXSlider); minRotationYSlider.Create(-180, 0, 1, 100000, "Min Rotation Y: "); - minRotationYSlider.OnSlide(forEachSelectedWithRefresh([&](auto physicscomponent, auto args) { + minRotationYSlider.OnSlide(forEachSelectedWithRefresh([](auto physicscomponent, auto args) { physicscomponent->six_dof.minRotationAxes.y = wi::math::DegreesToRadians(args.fValue); })); AddWidget(&minRotationYSlider); minRotationZSlider.Create(-180, 0, 1, 100000, "Min Rotation Z: "); - minRotationZSlider.OnSlide(forEachSelectedWithRefresh([&](auto physicscomponent, auto args) { + minRotationZSlider.OnSlide(forEachSelectedWithRefresh([](auto physicscomponent, auto args) { physicscomponent->six_dof.minRotationAxes.z = wi::math::DegreesToRadians(args.fValue); })); AddWidget(&minRotationZSlider); maxRotationXSlider.Create(0, 180, 1, 100000, "Max Rotation X: "); - maxRotationXSlider.OnSlide(forEachSelectedWithRefresh([&](auto physicscomponent, auto args) { + maxRotationXSlider.OnSlide(forEachSelectedWithRefresh([](auto physicscomponent, auto args) { physicscomponent->six_dof.maxRotationAxes.x = wi::math::DegreesToRadians(args.fValue); })); AddWidget(&maxRotationXSlider); maxRotationYSlider.Create(0, 180, 1, 100000, "Max Rotation Y: "); - maxRotationYSlider.OnSlide(forEachSelectedWithRefresh([&](auto physicscomponent, auto args) { + maxRotationYSlider.OnSlide(forEachSelectedWithRefresh([](auto physicscomponent, auto args) { physicscomponent->six_dof.maxRotationAxes.y = wi::math::DegreesToRadians(args.fValue); })); AddWidget(&maxRotationYSlider); maxRotationZSlider.Create(0, 180, 1, 100000, "Max Rotation Z: "); - maxRotationZSlider.OnSlide(forEachSelectedWithRefresh([&](auto physicscomponent, auto args) { + maxRotationZSlider.OnSlide(forEachSelectedWithRefresh([](auto physicscomponent, auto args) { physicscomponent->six_dof.maxRotationAxes.z = wi::math::DegreesToRadians(args.fValue); })); AddWidget(&maxRotationZSlider); diff --git a/Editor/DecalWindow.cpp b/Editor/DecalWindow.cpp index 43da8ae45..d126840f7 100644 --- a/Editor/DecalWindow.cpp +++ b/Editor/DecalWindow.cpp @@ -30,8 +30,8 @@ void DecalWindow::Create(EditorComponent* _editor) placementCheckBox.SetTooltip("Enable decal placement. Use the left mouse button to place decals to the scene."); AddWidget(&placementCheckBox); - auto forEachSelected = [&] (auto func) { - return [&, func] (auto args) { + auto forEachSelected = [this] (auto func) { + return [this, func] (auto args) { wi::scene::Scene& scene = editor->GetCurrentScene(); for (auto& x : editor->translator.selected) { @@ -46,14 +46,14 @@ void DecalWindow::Create(EditorComponent* _editor) onlyalphaCheckBox.Create("Alpha only basecolor: "); onlyalphaCheckBox.SetTooltip("You can enable this to only use alpha channel from basecolor map. Useful for blending normalmap-only decals."); - onlyalphaCheckBox.OnClick(forEachSelected([&] (auto decal, auto args) { + onlyalphaCheckBox.OnClick(forEachSelected([] (auto decal, auto args) { decal->SetBaseColorOnlyAlpha(args.bValue); })); AddWidget(&onlyalphaCheckBox); slopeBlendPowerSlider.Create(0, 8, 0, 1000, "Slope Blend: "); slopeBlendPowerSlider.SetTooltip("Set a power factor for blending on surface slopes. 0 = no slope blend, increasing = more slope blend"); - slopeBlendPowerSlider.OnSlide(forEachSelected([&] (auto decal, auto args) { + slopeBlendPowerSlider.OnSlide(forEachSelected([] (auto decal, auto args) { decal->slopeBlendPower = args.fValue; })); AddWidget(&slopeBlendPowerSlider); diff --git a/Editor/EmitterWindow.cpp b/Editor/EmitterWindow.cpp index 79fba7450..ef53e1fd6 100644 --- a/Editor/EmitterWindow.cpp +++ b/Editor/EmitterWindow.cpp @@ -30,8 +30,8 @@ void EmitterWindow::Create(EditorComponent* _editor) float step = itemheight + 2; float wid = 140; - auto forEachSelected = [&](auto func) { - return [&, func](auto args) { + auto forEachSelected = [this](auto func) { + return [this, func](auto args) { wi::scene::Scene& scene = editor->GetCurrentScene(); for (auto& x : editor->translator.selected) { @@ -46,14 +46,14 @@ void EmitterWindow::Create(EditorComponent* _editor) restartButton.Create("Restart Emitter"); restartButton.SetPos(XMFLOAT2(x, y)); restartButton.SetSize(XMFLOAT2(wid, itemheight)); - restartButton.OnClick(forEachSelected([&](auto emitter, auto args) { + restartButton.OnClick(forEachSelected([](auto emitter, auto args) { emitter->Restart(); })); restartButton.SetTooltip("Restart particle system emitter"); AddWidget(&restartButton); burstButton.Create("Burst"); - burstButton.OnClick(forEachSelected([&](auto emitter, auto args) { + burstButton.OnClick(forEachSelected([this](auto emitter, auto args) { emitter->Burst(std::atoi(burstCountInput.GetValue().c_str())); })); burstButton.SetTooltip("Emit a set number of particles at once."); @@ -70,7 +70,7 @@ void EmitterWindow::Create(EditorComponent* _editor) meshComboBox.SetSize(XMFLOAT2(wid, itemheight)); meshComboBox.SetPos(XMFLOAT2(x, y += step)); meshComboBox.SetEnabled(false); - meshComboBox.OnSelect(forEachSelected([&](auto emitter, auto args) { + meshComboBox.OnSelect(forEachSelected([this](auto emitter, auto args) { if (args.iValue == 0) { emitter->meshID = INVALID_ENTITY; @@ -91,7 +91,7 @@ void EmitterWindow::Create(EditorComponent* _editor) shaderTypeComboBox.AddItem("SOFT", wi::EmittedParticleSystem::PARTICLESHADERTYPE::SOFT); shaderTypeComboBox.AddItem("DISTORTION", wi::EmittedParticleSystem::PARTICLESHADERTYPE::SOFT_DISTORTION); shaderTypeComboBox.AddItem("LIGHTING", wi::EmittedParticleSystem::PARTICLESHADERTYPE::SOFT_LIGHTING); - shaderTypeComboBox.OnSelect(forEachSelected([&](auto emitter, auto args) { + shaderTypeComboBox.OnSelect(forEachSelected([](auto emitter, auto args) { emitter->shaderType = (wi::EmittedParticleSystem::PARTICLESHADERTYPE)args.userdata; })); shaderTypeComboBox.SetEnabled(false); @@ -102,7 +102,7 @@ void EmitterWindow::Create(EditorComponent* _editor) sortCheckBox.Create("Sorting: "); sortCheckBox.SetPos(XMFLOAT2(x, y += step)); sortCheckBox.SetSize(XMFLOAT2(itemheight, itemheight)); - sortCheckBox.OnClick(forEachSelected([&](auto emitter, auto args) { + sortCheckBox.OnClick(forEachSelected([](auto emitter, auto args) { emitter->SetSorted(args.bValue); })); sortCheckBox.SetCheck(false); @@ -113,7 +113,7 @@ void EmitterWindow::Create(EditorComponent* _editor) depthCollisionsCheckBox.Create("Depth Buffer: "); depthCollisionsCheckBox.SetPos(XMFLOAT2(x, y += step)); depthCollisionsCheckBox.SetSize(XMFLOAT2(itemheight, itemheight)); - depthCollisionsCheckBox.OnClick(forEachSelected([&](auto emitter, auto args) { + depthCollisionsCheckBox.OnClick(forEachSelected([](auto emitter, auto args) { emitter->SetDepthCollisionEnabled(args.bValue); })); depthCollisionsCheckBox.SetCheck(false); @@ -124,7 +124,7 @@ void EmitterWindow::Create(EditorComponent* _editor) sphCheckBox.Create("SPH - FluidSim: "); sphCheckBox.SetPos(XMFLOAT2(x, y += step)); sphCheckBox.SetSize(XMFLOAT2(itemheight, itemheight)); - sphCheckBox.OnClick(forEachSelected([&](auto emitter, auto args) { + sphCheckBox.OnClick(forEachSelected([](auto emitter, auto args) { emitter->SetSPHEnabled(args.bValue); })); sphCheckBox.SetCheck(false); @@ -135,7 +135,7 @@ void EmitterWindow::Create(EditorComponent* _editor) pauseCheckBox.Create("PAUSE: "); pauseCheckBox.SetPos(XMFLOAT2(x, y += step)); pauseCheckBox.SetSize(XMFLOAT2(itemheight, itemheight)); - pauseCheckBox.OnClick(forEachSelected([&](auto emitter, auto args) { + pauseCheckBox.OnClick(forEachSelected([](auto emitter, auto args) { emitter->SetPaused(args.bValue); })); pauseCheckBox.SetCheck(false); @@ -157,7 +157,7 @@ void EmitterWindow::Create(EditorComponent* _editor) volumeCheckBox.Create("Volume: "); volumeCheckBox.SetPos(XMFLOAT2(x, y += step)); volumeCheckBox.SetSize(XMFLOAT2(itemheight, itemheight)); - volumeCheckBox.OnClick(forEachSelected([&](auto emitter, auto args) { + volumeCheckBox.OnClick(forEachSelected([](auto emitter, auto args) { emitter->SetVolumeEnabled(args.bValue); })); volumeCheckBox.SetCheck(false); @@ -168,7 +168,7 @@ void EmitterWindow::Create(EditorComponent* _editor) frameBlendingCheckBox.Create("Frame Blending: "); frameBlendingCheckBox.SetPos(XMFLOAT2(x, y += step)); frameBlendingCheckBox.SetSize(XMFLOAT2(itemheight, itemheight)); - frameBlendingCheckBox.OnClick(forEachSelected([&](auto emitter, auto args) { + frameBlendingCheckBox.OnClick(forEachSelected([](auto emitter, auto args) { emitter->SetFrameBlendingEnabled(args.bValue); })); frameBlendingCheckBox.SetCheck(false); @@ -179,7 +179,7 @@ void EmitterWindow::Create(EditorComponent* _editor) collidersDisabledCheckBox.Create("Colliders disabled: "); collidersDisabledCheckBox.SetPos(XMFLOAT2(x, y += step)); collidersDisabledCheckBox.SetSize(XMFLOAT2(itemheight, itemheight)); - collidersDisabledCheckBox.OnClick(forEachSelected([&](auto emitter, auto args) { + collidersDisabledCheckBox.OnClick(forEachSelected([](auto emitter, auto args) { emitter->SetCollidersDisabled(args.bValue); })); collidersDisabledCheckBox.SetCheck(false); @@ -190,7 +190,7 @@ void EmitterWindow::Create(EditorComponent* _editor) takeColorCheckBox.Create("Take color from mesh: "); takeColorCheckBox.SetPos(XMFLOAT2(x, y += step)); takeColorCheckBox.SetSize(XMFLOAT2(itemheight, itemheight)); - takeColorCheckBox.OnClick(forEachSelected([&](auto emitter, auto args) { + takeColorCheckBox.OnClick(forEachSelected([](auto emitter, auto args) { emitter->SetTakeColorFromMesh(args.bValue); })); takeColorCheckBox.SetCheck(false); @@ -212,7 +212,7 @@ void EmitterWindow::Create(EditorComponent* _editor) frameRateInput.SetText(""); frameRateInput.SetTooltip("Enter a value to enable looping sprite sheet animation (frames per second). Set 0 for exactly one complete animation along particle lifetime."); frameRateInput.SetDescription("Frame Rate: "); - frameRateInput.OnInputAccepted(forEachSelected([&](auto emitter, auto args) { + frameRateInput.OnInputAccepted(forEachSelected([](auto emitter, auto args) { emitter->frameRate = args.fValue; })); AddWidget(&frameRateInput); @@ -223,7 +223,7 @@ void EmitterWindow::Create(EditorComponent* _editor) framesXInput.SetText(""); framesXInput.SetTooltip("How many horizontal frames there are in the spritesheet."); framesXInput.SetDescription("Frames: "); - framesXInput.OnInputAccepted(forEachSelected([&](auto emitter, auto args) { + framesXInput.OnInputAccepted(forEachSelected([](auto emitter, auto args) { emitter->framesX = (uint32_t)args.iValue; })); AddWidget(&framesXInput); @@ -233,7 +233,7 @@ void EmitterWindow::Create(EditorComponent* _editor) framesYInput.SetSize(XMFLOAT2(38, 18)); framesYInput.SetText(""); framesYInput.SetTooltip("How many vertical frames there are in the spritesheet."); - framesYInput.OnInputAccepted(forEachSelected([&](auto emitter, auto args) { + framesYInput.OnInputAccepted(forEachSelected([](auto emitter, auto args) { emitter->framesY = (uint32_t)args.iValue; })); AddWidget(&framesYInput); @@ -244,7 +244,7 @@ void EmitterWindow::Create(EditorComponent* _editor) frameCountInput.SetText(""); frameCountInput.SetTooltip("The total number of frames in the sprite sheet animation."); frameCountInput.SetDescription("Frame Count: "); - frameCountInput.OnInputAccepted(forEachSelected([&](auto emitter, auto args) { + frameCountInput.OnInputAccepted(forEachSelected([](auto emitter, auto args) { emitter->frameCount = (uint32_t)args.iValue; })); AddWidget(&frameCountInput); @@ -255,7 +255,7 @@ void EmitterWindow::Create(EditorComponent* _editor) frameStartInput.SetText(""); frameStartInput.SetTooltip("Specifies the starting frame of the animation."); frameStartInput.SetDescription("Start Frame: "); - frameStartInput.OnInputAccepted(forEachSelected([&](auto emitter, auto args) { + frameStartInput.OnInputAccepted(forEachSelected([](auto emitter, auto args) { emitter->frameStart = (uint32_t)args.iValue; })); AddWidget(&frameStartInput); @@ -269,7 +269,7 @@ void EmitterWindow::Create(EditorComponent* _editor) VelocityXInput.SetTooltip("Vector X component"); VelocityXInput.SetPos(XMFLOAT2(x, y += step)); VelocityXInput.SetSize(XMFLOAT2(38, itemheight)); - VelocityXInput.OnInputAccepted(forEachSelected([&](auto emitter, auto args) { + VelocityXInput.OnInputAccepted(forEachSelected([](auto emitter, auto args) { emitter->velocity.x = args.fValue; })); AddWidget(&VelocityXInput); @@ -279,7 +279,7 @@ void EmitterWindow::Create(EditorComponent* _editor) VelocityYInput.SetTooltip("Vector Y component"); VelocityYInput.SetPos(XMFLOAT2(x + 40, y)); VelocityYInput.SetSize(XMFLOAT2(38, itemheight)); - VelocityYInput.OnInputAccepted(forEachSelected([&](auto emitter, auto args) { + VelocityYInput.OnInputAccepted(forEachSelected([](auto emitter, auto args) { emitter->velocity.y = args.fValue; })); AddWidget(&VelocityYInput); @@ -289,7 +289,7 @@ void EmitterWindow::Create(EditorComponent* _editor) VelocityZInput.SetTooltip("Vector Z component"); VelocityZInput.SetPos(XMFLOAT2(x + 80, y)); VelocityZInput.SetSize(XMFLOAT2(38, itemheight)); - VelocityZInput.OnInputAccepted(forEachSelected([&](auto emitter, auto args) { + VelocityZInput.OnInputAccepted(forEachSelected([](auto emitter, auto args) { emitter->velocity.z = args.fValue; })); AddWidget(&VelocityZInput); @@ -302,7 +302,7 @@ void EmitterWindow::Create(EditorComponent* _editor) GravityXInput.SetTooltip("Vector X component"); GravityXInput.SetPos(XMFLOAT2(x, y += step)); GravityXInput.SetSize(XMFLOAT2(38, itemheight)); - GravityXInput.OnInputAccepted(forEachSelected([&](auto emitter, auto args) { + GravityXInput.OnInputAccepted(forEachSelected([](auto emitter, auto args) { emitter->gravity.x = args.fValue; })); AddWidget(&GravityXInput); @@ -312,7 +312,7 @@ void EmitterWindow::Create(EditorComponent* _editor) GravityYInput.SetTooltip("Vector Y component"); GravityYInput.SetPos(XMFLOAT2(x + 40, y)); GravityYInput.SetSize(XMFLOAT2(38, itemheight)); - GravityYInput.OnInputAccepted(forEachSelected([&](auto emitter, auto args) { + GravityYInput.OnInputAccepted(forEachSelected([](auto emitter, auto args) { emitter->gravity.y = args.fValue; })); AddWidget(&GravityYInput); @@ -322,7 +322,7 @@ void EmitterWindow::Create(EditorComponent* _editor) GravityZInput.SetTooltip("Vector Z component"); GravityZInput.SetPos(XMFLOAT2(x + 80, y)); GravityZInput.SetSize(XMFLOAT2(38, itemheight)); - GravityZInput.OnInputAccepted(forEachSelected([&](auto emitter, auto args) { + GravityZInput.OnInputAccepted(forEachSelected([](auto emitter, auto args) { emitter->gravity.z = args.fValue; })); AddWidget(&GravityZInput); @@ -330,7 +330,7 @@ void EmitterWindow::Create(EditorComponent* _editor) maxParticlesSlider.Create(100.0f, 1000000.0f, 10000, 100000, "Max count: "); maxParticlesSlider.SetSize(XMFLOAT2(wid, itemheight)); maxParticlesSlider.SetPos(XMFLOAT2(x, y += step)); - maxParticlesSlider.OnSlide(forEachSelected([&](auto emitter, auto args) { + maxParticlesSlider.OnSlide(forEachSelected([](auto emitter, auto args) { emitter->SetMaxParticleCount((uint32_t)args.iValue); })); maxParticlesSlider.SetEnabled(false); @@ -340,7 +340,7 @@ void EmitterWindow::Create(EditorComponent* _editor) emitCountSlider.Create(0.0f, 10000.0f, 1.0f, 100000, "Emit: "); emitCountSlider.SetSize(XMFLOAT2(wid, itemheight)); emitCountSlider.SetPos(XMFLOAT2(x, y += step)); - emitCountSlider.OnSlide(forEachSelected([&](auto emitter, auto args) { + emitCountSlider.OnSlide(forEachSelected([](auto emitter, auto args) { emitter->count = args.fValue; })); emitCountSlider.SetEnabled(false); @@ -350,7 +350,7 @@ void EmitterWindow::Create(EditorComponent* _editor) emitSizeSlider.Create(0.01f, 10.0f, 1.0f, 100000, "Size: "); emitSizeSlider.SetSize(XMFLOAT2(wid, itemheight)); emitSizeSlider.SetPos(XMFLOAT2(x, y += step)); - emitSizeSlider.OnSlide(forEachSelected([&](auto emitter, auto args) { + emitSizeSlider.OnSlide(forEachSelected([](auto emitter, auto args) { emitter->size = args.fValue; })); emitSizeSlider.SetEnabled(false); @@ -360,7 +360,7 @@ void EmitterWindow::Create(EditorComponent* _editor) emitRotationSlider.Create(0.0f, 1.0f, 0.0f, 100000, "Rotation: "); emitRotationSlider.SetSize(XMFLOAT2(wid, itemheight)); emitRotationSlider.SetPos(XMFLOAT2(x, y += step)); - emitRotationSlider.OnSlide(forEachSelected([&](auto emitter, auto args) { + emitRotationSlider.OnSlide(forEachSelected([](auto emitter, auto args) { emitter->rotation = args.fValue; })); emitRotationSlider.SetEnabled(false); @@ -370,7 +370,7 @@ void EmitterWindow::Create(EditorComponent* _editor) emitNormalSlider.Create(0.0f, 100.0f, 1.0f, 100000, "Normal factor: "); emitNormalSlider.SetSize(XMFLOAT2(wid, itemheight)); emitNormalSlider.SetPos(XMFLOAT2(x, y += step)); - emitNormalSlider.OnSlide(forEachSelected([&](auto emitter, auto args) { + emitNormalSlider.OnSlide(forEachSelected([](auto emitter, auto args) { emitter->normal_factor = args.fValue; })); emitNormalSlider.SetEnabled(false); @@ -380,7 +380,7 @@ void EmitterWindow::Create(EditorComponent* _editor) emitScalingSlider.Create(0.0f, 100.0f, 1.0f, 100000, "Scaling: "); emitScalingSlider.SetSize(XMFLOAT2(wid, itemheight)); emitScalingSlider.SetPos(XMFLOAT2(x, y += step)); - emitScalingSlider.OnSlide(forEachSelected([&](auto emitter, auto args) { + emitScalingSlider.OnSlide(forEachSelected([](auto emitter, auto args) { emitter->scaleX = args.fValue; })); emitScalingSlider.SetEnabled(false); @@ -390,7 +390,7 @@ void EmitterWindow::Create(EditorComponent* _editor) emitLifeSlider.Create(0.0f, 100.0f, 1.0f, 10000, "Life span: "); emitLifeSlider.SetSize(XMFLOAT2(wid, itemheight)); emitLifeSlider.SetPos(XMFLOAT2(x, y += step)); - emitLifeSlider.OnSlide(forEachSelected([&](auto emitter, auto args) { + emitLifeSlider.OnSlide(forEachSelected([](auto emitter, auto args) { emitter->life = args.fValue; })); emitLifeSlider.SetEnabled(false); @@ -398,7 +398,7 @@ void EmitterWindow::Create(EditorComponent* _editor) AddWidget(&emitLifeSlider); emitOpacityCurveStartSlider.Create(0.0f, 1.0f, 0.0f, 10000, "Opacity Start: "); - emitOpacityCurveStartSlider.OnSlide(forEachSelected([&](auto emitter, auto args) { + emitOpacityCurveStartSlider.OnSlide(forEachSelected([](auto emitter, auto args) { emitter->SetOpacityCurveControl(args.fValue, emitter->opacityCurveControlPeakEnd); })); emitOpacityCurveStartSlider.SetEnabled(false); @@ -406,7 +406,7 @@ void EmitterWindow::Create(EditorComponent* _editor) AddWidget(&emitOpacityCurveStartSlider); emitOpacityCurveEndSlider.Create(0.0f, 1.0f, 0.0f, 10000, "Opacity End: "); - emitOpacityCurveEndSlider.OnSlide(forEachSelected([&](auto emitter, auto args) { + emitOpacityCurveEndSlider.OnSlide(forEachSelected([](auto emitter, auto args) { emitter->SetOpacityCurveControl(emitter->opacityCurveControlPeakStart, args.fValue); })); emitOpacityCurveEndSlider.SetEnabled(false); @@ -416,7 +416,7 @@ void EmitterWindow::Create(EditorComponent* _editor) emitRandomnessSlider.Create(0.0f, 1.0f, 1.0f, 100000, "Randomness: "); emitRandomnessSlider.SetSize(XMFLOAT2(wid, itemheight)); emitRandomnessSlider.SetPos(XMFLOAT2(x, y += step)); - emitRandomnessSlider.OnSlide(forEachSelected([&](auto emitter, auto args) { + emitRandomnessSlider.OnSlide(forEachSelected([](auto emitter, auto args) { emitter->random_factor = args.fValue; })); emitRandomnessSlider.SetEnabled(false); @@ -426,7 +426,7 @@ void EmitterWindow::Create(EditorComponent* _editor) emitLifeRandomnessSlider.Create(0.0f, 2.0f, 0.0f, 100000, "Life randomness: "); emitLifeRandomnessSlider.SetSize(XMFLOAT2(wid, itemheight)); emitLifeRandomnessSlider.SetPos(XMFLOAT2(x, y += step)); - emitLifeRandomnessSlider.OnSlide(forEachSelected([&](auto emitter, auto args) { + emitLifeRandomnessSlider.OnSlide(forEachSelected([](auto emitter, auto args) { emitter->random_life = args.fValue; })); emitLifeRandomnessSlider.SetEnabled(false); @@ -436,7 +436,7 @@ void EmitterWindow::Create(EditorComponent* _editor) emitColorRandomnessSlider.Create(0.0f, 2.0f, 0.0f, 100000, "Color randomness: "); emitColorRandomnessSlider.SetSize(XMFLOAT2(wid, itemheight)); emitColorRandomnessSlider.SetPos(XMFLOAT2(x, y += step)); - emitColorRandomnessSlider.OnSlide(forEachSelected([&](auto emitter, auto args) { + emitColorRandomnessSlider.OnSlide(forEachSelected([](auto emitter, auto args) { emitter->random_color = args.fValue; })); emitColorRandomnessSlider.SetEnabled(false); @@ -446,7 +446,7 @@ void EmitterWindow::Create(EditorComponent* _editor) emitMotionBlurSlider.Create(0.0f, 1.0f, 1.0f, 100000, "Motion blur: "); emitMotionBlurSlider.SetSize(XMFLOAT2(wid, itemheight)); emitMotionBlurSlider.SetPos(XMFLOAT2(x, y += step)); - emitMotionBlurSlider.OnSlide(forEachSelected([&](auto emitter, auto args) { + emitMotionBlurSlider.OnSlide(forEachSelected([](auto emitter, auto args) { emitter->motionBlurAmount = args.fValue; })); emitMotionBlurSlider.SetEnabled(false); @@ -456,7 +456,7 @@ void EmitterWindow::Create(EditorComponent* _editor) emitMassSlider.Create(0.1f, 100.0f, 1.0f, 100000, "Mass: "); emitMassSlider.SetSize(XMFLOAT2(wid, itemheight)); emitMassSlider.SetPos(XMFLOAT2(x, y += step)); - emitMassSlider.OnSlide(forEachSelected([&](auto emitter, auto args) { + emitMassSlider.OnSlide(forEachSelected([](auto emitter, auto args) { emitter->mass = args.fValue; })); emitMassSlider.SetEnabled(false); @@ -468,7 +468,7 @@ void EmitterWindow::Create(EditorComponent* _editor) timestepSlider.Create(-1, 0.016f, -1, 100000, "Timestep: "); timestepSlider.SetSize(XMFLOAT2(wid, itemheight)); timestepSlider.SetPos(XMFLOAT2(x, y += step)); - timestepSlider.OnSlide(forEachSelected([&](auto emitter, auto args) { + timestepSlider.OnSlide(forEachSelected([](auto emitter, auto args) { emitter->FIXED_TIMESTEP = args.fValue; })); timestepSlider.SetEnabled(false); @@ -480,7 +480,7 @@ void EmitterWindow::Create(EditorComponent* _editor) dragSlider.Create(0, 1, 1, 100000, "Drag: "); dragSlider.SetSize(XMFLOAT2(wid, itemheight)); dragSlider.SetPos(XMFLOAT2(x, y += step)); - dragSlider.OnSlide(forEachSelected([&](auto emitter, auto args) { + dragSlider.OnSlide(forEachSelected([](auto emitter, auto args) { emitter->drag = args.fValue; })); dragSlider.SetEnabled(false); @@ -490,7 +490,7 @@ void EmitterWindow::Create(EditorComponent* _editor) restitutionSlider.Create(0, 1, 1, 100000, "Restitution: "); restitutionSlider.SetSize(XMFLOAT2(wid, itemheight)); restitutionSlider.SetPos(XMFLOAT2(x, y += step)); - restitutionSlider.OnSlide(forEachSelected([&](auto emitter, auto args) { + restitutionSlider.OnSlide(forEachSelected([](auto emitter, auto args) { emitter->restitution = args.fValue; })); restitutionSlider.SetEnabled(false); @@ -504,7 +504,7 @@ void EmitterWindow::Create(EditorComponent* _editor) sph_h_Slider.Create(0.1f, 100.0f, 1.0f, 100000, "SPH (h): "); sph_h_Slider.SetSize(XMFLOAT2(wid, itemheight)); sph_h_Slider.SetPos(XMFLOAT2(x, y += step)); - sph_h_Slider.OnSlide(forEachSelected([&](auto emitter, auto args) { + sph_h_Slider.OnSlide(forEachSelected([](auto emitter, auto args) { emitter->SPH_h = args.fValue; })); sph_h_Slider.SetEnabled(false); @@ -514,7 +514,7 @@ void EmitterWindow::Create(EditorComponent* _editor) sph_K_Slider.Create(0.1f, 100.0f, 1.0f, 100000, "SPH (K): "); sph_K_Slider.SetSize(XMFLOAT2(wid, itemheight)); sph_K_Slider.SetPos(XMFLOAT2(x, y += step)); - sph_K_Slider.OnSlide(forEachSelected([&](auto emitter, auto args) { + sph_K_Slider.OnSlide(forEachSelected([](auto emitter, auto args) { emitter->SPH_K = args.fValue; })); sph_K_Slider.SetEnabled(false); @@ -524,7 +524,7 @@ void EmitterWindow::Create(EditorComponent* _editor) sph_p0_Slider.Create(0.1f, 100.0f, 1.0f, 100000, "SPH (p0): "); sph_p0_Slider.SetSize(XMFLOAT2(wid, itemheight)); sph_p0_Slider.SetPos(XMFLOAT2(x, y += step)); - sph_p0_Slider.OnSlide(forEachSelected([&](auto emitter, auto args) { + sph_p0_Slider.OnSlide(forEachSelected([](auto emitter, auto args) { emitter->SPH_p0 = args.fValue; })); sph_p0_Slider.SetEnabled(false); @@ -534,7 +534,7 @@ void EmitterWindow::Create(EditorComponent* _editor) sph_e_Slider.Create(0, 10, 1.0f, 100000, "SPH (e): "); sph_e_Slider.SetSize(XMFLOAT2(wid, itemheight)); sph_e_Slider.SetPos(XMFLOAT2(x, y += step)); - sph_e_Slider.OnSlide(forEachSelected([&](auto emitter, auto args) { + sph_e_Slider.OnSlide(forEachSelected([](auto emitter, auto args) { emitter->SPH_e = args.fValue; })); sph_e_Slider.SetEnabled(false); diff --git a/Editor/EnvProbeWindow.cpp b/Editor/EnvProbeWindow.cpp index b5ac0a44e..81f433fbb 100644 --- a/Editor/EnvProbeWindow.cpp +++ b/Editor/EnvProbeWindow.cpp @@ -31,8 +31,8 @@ void EnvProbeWindow::Create(EditorComponent* _editor) infoLabel.SetFitTextEnabled(true); AddWidget(&infoLabel); - auto forAllSelected = [&] (auto func) { - return [&, func] (auto args) { + auto forEachSelected = [this] (auto func) { + return [this, func] (auto args) { wi::scene::Scene& scene = editor->GetCurrentScene(); for (auto& x : editor->translator.selected) { @@ -48,7 +48,7 @@ void EnvProbeWindow::Create(EditorComponent* _editor) realTimeCheckBox.Create("RealTime: "); realTimeCheckBox.SetTooltip("Enable continuous rendering of the probe in every frame."); realTimeCheckBox.SetEnabled(false); - realTimeCheckBox.OnClick(forAllSelected([&] (auto probe, auto args) { + realTimeCheckBox.OnClick(forEachSelected([] (auto probe, auto args) { probe->SetRealTime(args.bValue); probe->SetDirty(); })); @@ -57,7 +57,7 @@ void EnvProbeWindow::Create(EditorComponent* _editor) msaaCheckBox.Create("MSAA: "); msaaCheckBox.SetTooltip("Enable Multi Sampling Anti Aliasing for the probe, this will improve its quality."); msaaCheckBox.SetEnabled(false); - msaaCheckBox.OnClick(forAllSelected([&] (auto probe, auto args) { + msaaCheckBox.OnClick(forEachSelected([] (auto probe, auto args) { probe->SetMSAA(args.bValue); probe->SetDirty(); })); @@ -66,7 +66,7 @@ void EnvProbeWindow::Create(EditorComponent* _editor) refreshButton.Create("Refresh"); refreshButton.SetTooltip("Re-renders the selected probe."); refreshButton.SetEnabled(false); - refreshButton.OnClick(forAllSelected([&] (auto probe, auto args) { + refreshButton.OnClick(forEachSelected([] (auto probe, auto args) { probe->SetDirty(); })); AddWidget(&refreshButton); @@ -74,7 +74,7 @@ void EnvProbeWindow::Create(EditorComponent* _editor) refreshAllButton.Create("Refresh All"); refreshAllButton.SetTooltip("Re-renders all probes in the scene."); refreshAllButton.SetEnabled(true); - refreshAllButton.OnClick(forAllSelected([&] (auto probe, auto args) { + refreshAllButton.OnClick(forEachSelected([] (auto probe, auto args) { probe->SetDirty(); })); AddWidget(&refreshAllButton); @@ -82,7 +82,7 @@ void EnvProbeWindow::Create(EditorComponent* _editor) importButton.Create("Import Cubemap"); importButton.SetTooltip("Import a DDS texture file into the selected environment probe."); importButton.SetEnabled(false); - importButton.OnClick(forAllSelected([&] (auto probe, auto args) { + importButton.OnClick(forEachSelected([] (auto probe, auto args) { if (probe != nullptr && probe->texture.IsValid()) { wi::helper::FileDialogParams params; @@ -113,14 +113,14 @@ void EnvProbeWindow::Create(EditorComponent* _editor) exportButton.Create("Export Cubemap"); exportButton.SetTooltip("Export the selected probe into a DDS cubemap texture file."); exportButton.SetEnabled(false); - exportButton.OnClick(forAllSelected([&] (auto probe, auto args) { + exportButton.OnClick(forEachSelected([this] (auto probe, auto args) { if (probe != nullptr && probe->texture.IsValid()) { wi::helper::FileDialogParams params; params.type = wi::helper::FileDialogParams::SAVE; params.description = "DDS"; params.extensions = { "DDS" }; - wi::helper::FileDialog(params, [=](std::string fileName) { + wi::helper::FileDialog(params, [this, probe](std::string fileName) { wi::eventhandler::Subscribe_Once(wi::eventhandler::EVENT_THREAD_SAFE_POINT, [=](uint64_t userdata) { std::string extension = wi::helper::toUpper(wi::helper::GetExtensionFromFileName(fileName)); @@ -155,7 +155,7 @@ void EnvProbeWindow::Create(EditorComponent* _editor) resolutionCombo.AddItem("512", 512); resolutionCombo.AddItem("1024", 1024); resolutionCombo.AddItem("2048", 2048); - resolutionCombo.OnSelect(forAllSelected([&] (auto probe, auto args) { + resolutionCombo.OnSelect(forEachSelected([] (auto probe, auto args) { probe->resolution = (uint32_t)args.userdata; probe->CreateRenderData(); })); diff --git a/Editor/ExpressionWindow.cpp b/Editor/ExpressionWindow.cpp index fbe627b80..3e046f454 100644 --- a/Editor/ExpressionWindow.cpp +++ b/Editor/ExpressionWindow.cpp @@ -30,8 +30,8 @@ void ExpressionWindow::Create(EditorComponent* _editor) infoLabel.SetFitTextEnabled(true); AddWidget(&infoLabel); - auto handleExpr = [&] (auto func) { - return [&] (auto args) { + auto handleExpr = [this] (auto func) { + return [this, func] (auto args) { wi::scene::Scene& scene = editor->GetCurrentScene(); ExpressionComponent* expression_mastering = scene.expressions.GetComponent(entity); if (expression_mastering != nullptr) { diff --git a/Editor/FontWindow.cpp b/Editor/FontWindow.cpp index 142621d61..d1da041ce 100644 --- a/Editor/FontWindow.cpp +++ b/Editor/FontWindow.cpp @@ -31,8 +31,8 @@ void FontWindow::Create(EditorComponent* _editor) float siz = 250; float hei = 20; - auto forEachSelectedFont = [&] (auto func) { - return [&, func](auto args) { + auto forEachSelectedFont = [this] (auto func) { + return [this, func](auto args) { wi::scene::Scene& scene = editor->GetCurrentScene(); for (auto& x : editor->translator.selected) { @@ -46,7 +46,7 @@ void FontWindow::Create(EditorComponent* _editor) textInput.Create(""); textInput.SetPos(XMFLOAT2(x, y)); - textInput.OnInput(forEachSelectedFont([&] (auto font, auto args) { + textInput.OnInput(forEachSelectedFont([] (auto font, auto args) { font->SetText(args.sValue); })); AddWidget(&textInput); @@ -80,7 +80,7 @@ void FontWindow::Create(EditorComponent* _editor) fontStyleButton.Create(""); fontStyleButton.SetDescription("Style: "); fontStyleButton.SetTooltip("Load a font style from file (.TTF) to apply to this font."); - fontStyleButton.OnClick(forEachSelectedFont([&] (auto font, auto args) { + fontStyleButton.OnClick(forEachSelectedFont([this] (auto font, auto args) { if (font->fontStyleResource.IsValid()) { wi::Archive& archive = editor->AdvanceHistory(); @@ -129,7 +129,7 @@ void FontWindow::Create(EditorComponent* _editor) fontSizeCombo.AddItem("84", 84); fontSizeCombo.AddItem("96", 96); fontSizeCombo.AddItem("108", 108); - fontSizeCombo.OnSelect(forEachSelectedFont([&] (auto font, auto args) { + fontSizeCombo.OnSelect(forEachSelectedFont([] (auto font, auto args) { font->params.size = int(args.userdata); })); AddWidget(&fontSizeCombo); @@ -139,7 +139,7 @@ void FontWindow::Create(EditorComponent* _editor) hAlignCombo.AddItem("Left", wi::font::WIFALIGN_LEFT); hAlignCombo.AddItem("Center", wi::font::WIFALIGN_CENTER); hAlignCombo.AddItem("Right", wi::font::WIFALIGN_RIGHT); - hAlignCombo.OnSelect(forEachSelectedFont([&] (auto font, auto args) { + hAlignCombo.OnSelect(forEachSelectedFont([] (auto font, auto args) { font->params.h_align = wi::font::Alignment(args.userdata); })); AddWidget(&hAlignCombo); @@ -149,97 +149,97 @@ void FontWindow::Create(EditorComponent* _editor) vAlignCombo.AddItem("Top", wi::font::WIFALIGN_TOP); vAlignCombo.AddItem("Center", wi::font::WIFALIGN_CENTER); vAlignCombo.AddItem("Bottom", wi::font::WIFALIGN_BOTTOM); - vAlignCombo.OnSelect(forEachSelectedFont([&] (auto font, auto args) { + vAlignCombo.OnSelect(forEachSelectedFont([] (auto font, auto args) { font->params.v_align = wi::font::Alignment(args.userdata); })); AddWidget(&vAlignCombo); rotationSlider.Create(0, 360, 0, 10000, "Rotation: "); rotationSlider.SetTooltip("Z Rotation around alignment center point. The editor input is in degrees."); - rotationSlider.OnSlide(forEachSelectedFont([&] (auto font, auto args) { + rotationSlider.OnSlide(forEachSelectedFont([] (auto font, auto args) { font->params.rotation = wi::math::DegreesToRadians(args.fValue); })); AddWidget(&rotationSlider); spacingSlider.Create(0, 10, 0, 10000, "Spacing: "); spacingSlider.SetTooltip("Horizontal spacing between characters."); - spacingSlider.OnSlide(forEachSelectedFont([&] (auto font, auto args) { + spacingSlider.OnSlide(forEachSelectedFont([] (auto font, auto args) { font->params.spacingX = args.fValue; })); AddWidget(&spacingSlider); softnessSlider.Create(0, 1, 0, 10000, "Softness: "); - softnessSlider.OnSlide(forEachSelectedFont([&] (auto font, auto args) { + softnessSlider.OnSlide(forEachSelectedFont([] (auto font, auto args) { font->params.softness = args.fValue; })); AddWidget(&softnessSlider); boldenSlider.Create(0, 1, 0, 10000, "Bolden: "); - boldenSlider.OnSlide(forEachSelectedFont([&] (auto font, auto args) { + boldenSlider.OnSlide(forEachSelectedFont([] (auto font, auto args) { font->params.bolden = args.fValue; })); AddWidget(&boldenSlider); shadowSoftnessSlider.Create(0, 1, 0, 10000, "Shadow Softness: "); - shadowSoftnessSlider.OnSlide(forEachSelectedFont([&] (auto font, auto args) { + shadowSoftnessSlider.OnSlide(forEachSelectedFont([] (auto font, auto args) { font->params.shadow_softness = args.fValue; })); AddWidget(&shadowSoftnessSlider); shadowBoldenSlider.Create(0, 1, 0, 10000, "Shadow Bolden: "); - shadowBoldenSlider.OnSlide(forEachSelectedFont([&] (auto font, auto args) { + shadowBoldenSlider.OnSlide(forEachSelectedFont([] (auto font, auto args) { font->params.shadow_bolden = args.fValue; })); AddWidget(&shadowBoldenSlider); shadowOffsetXSlider.Create(-2, 2, 0, 10000, "Shadow Offset X: "); - shadowOffsetXSlider.OnSlide(forEachSelectedFont([&] (auto font, auto args) { + shadowOffsetXSlider.OnSlide(forEachSelectedFont([] (auto font, auto args) { font->params.shadow_offset_x = args.fValue; })); AddWidget(&shadowOffsetXSlider); shadowOffsetYSlider.Create(-2, 2, 0, 10000, "Shadow Offset Y: "); - shadowOffsetYSlider.OnSlide(forEachSelectedFont([&] (auto font, auto args) { + shadowOffsetYSlider.OnSlide(forEachSelectedFont([] (auto font, auto args) { font->params.shadow_offset_y = args.fValue; })); AddWidget(&shadowOffsetYSlider); intensitySlider.Create(0, 100, 1, 10000, "Intensity: "); - intensitySlider.OnSlide(forEachSelectedFont([&] (auto font, auto args) { + intensitySlider.OnSlide(forEachSelectedFont([] (auto font, auto args) { font->params.intensity = args.fValue; })); AddWidget(&intensitySlider); shadowIntensitySlider.Create(0, 100, 1, 10000, "Shadow Intensity: "); - shadowIntensitySlider.OnSlide(forEachSelectedFont([&] (auto font, auto args) { + shadowIntensitySlider.OnSlide(forEachSelectedFont([] (auto font, auto args) { font->params.shadow_intensity = args.fValue; })); AddWidget(&shadowIntensitySlider); hiddenCheckBox.Create("Hidden: "); hiddenCheckBox.SetTooltip("Hide / unhide the font"); - hiddenCheckBox.OnClick(forEachSelectedFont([&] (auto font, auto args) { + hiddenCheckBox.OnClick(forEachSelectedFont([] (auto font, auto args) { font->SetHidden(args.bValue); })); AddWidget(&hiddenCheckBox); cameraFacingCheckBox.Create("Camera Facing: "); cameraFacingCheckBox.SetTooltip("Camera facing fonts will always rotate towards the camera."); - cameraFacingCheckBox.OnClick(forEachSelectedFont([&] (auto font, auto args) { + cameraFacingCheckBox.OnClick(forEachSelectedFont([] (auto font, auto args) { font->SetCameraFacing(args.bValue); })); AddWidget(&cameraFacingCheckBox); cameraScalingCheckBox.Create("Camera Scaling: "); cameraScalingCheckBox.SetTooltip("Camera scaling fonts will always keep the same size on screen, irrespective of the distance to the camera."); - cameraScalingCheckBox.OnClick(forEachSelectedFont([&] (auto font, auto args) { + cameraScalingCheckBox.OnClick(forEachSelectedFont([] (auto font, auto args) { font->SetCameraScaling(args.bValue); })); AddWidget(&cameraScalingCheckBox); depthTestCheckBox.Create("Depth Test: "); depthTestCheckBox.SetTooltip("Depth tested fonts will be clipped against geometry."); - depthTestCheckBox.OnClick(forEachSelectedFont([&] (auto font, auto args) { + depthTestCheckBox.OnClick(forEachSelectedFont([] (auto font, auto args) { if (args.bValue) { font->params.enableDepthTest(); @@ -253,7 +253,7 @@ void FontWindow::Create(EditorComponent* _editor) sdfCheckBox.Create("SDF: "); sdfCheckBox.SetTooltip("Signed Distance Field rendering is used for improved font upscaling, softness, boldness and soft shadow effects."); - sdfCheckBox.OnClick(forEachSelectedFont([&] (auto font, auto args) { + sdfCheckBox.OnClick(forEachSelectedFont([] (auto font, auto args) { if (args.bValue) { font->params.enableSDFRendering(); @@ -271,7 +271,7 @@ void FontWindow::Create(EditorComponent* _editor) colorModeCombo.AddItem("Font color"); colorModeCombo.AddItem("Shadow color"); colorModeCombo.SetTooltip("Choose the destination data of the color picker."); - colorModeCombo.OnSelect(forEachSelectedFont([&] (auto font, auto args) { + colorModeCombo.OnSelect(forEachSelectedFont([this] (auto font, auto args) { if (args.iValue == 0) { colorPicker.SetPickColor(font->params.color); @@ -284,7 +284,7 @@ void FontWindow::Create(EditorComponent* _editor) AddWidget(&colorModeCombo); colorPicker.Create("Color", wi::gui::Window::WindowControls::NONE); - colorPicker.OnColorChanged(forEachSelectedFont([&] (auto font, auto args) { + colorPicker.OnColorChanged(forEachSelectedFont([this] (auto font, auto args) { switch (colorModeCombo.GetSelected()) { default: @@ -304,14 +304,14 @@ void FontWindow::Create(EditorComponent* _editor) typewriterTimeSlider.Create(0, 10, 0, 10000, "Typewriter time: "); typewriterTimeSlider.SetTooltip("Time to complete typewriter animation (0 = disable)."); - typewriterTimeSlider.OnSlide(forEachSelectedFont([&] (auto font, auto args) { + typewriterTimeSlider.OnSlide(forEachSelectedFont([] (auto font, auto args) { font->anim.typewriter.time = args.fValue; })); AddWidget(&typewriterTimeSlider); typewriterLoopedCheckBox.Create("Typewriter Looped: "); typewriterLoopedCheckBox.SetTooltip("Whether typewriter animation is looped or not."); - typewriterLoopedCheckBox.OnClick(forEachSelectedFont([&] (auto font, auto args) { + typewriterLoopedCheckBox.OnClick(forEachSelectedFont([] (auto font, auto args) { font->anim.typewriter.looped = args.bValue; })); AddWidget(&typewriterLoopedCheckBox); @@ -321,7 +321,7 @@ void FontWindow::Create(EditorComponent* _editor) typewriterStartInput.SetTooltip("Set the starting character for typewriter animation (0 = first)."); typewriterStartInput.SetPos(XMFLOAT2(x, y)); typewriterStartInput.SetSize(XMFLOAT2(siz, hei)); - typewriterStartInput.OnInputAccepted(forEachSelectedFont([&] (auto font, auto args) { + typewriterStartInput.OnInputAccepted(forEachSelectedFont([] (auto font, auto args) { font->anim.typewriter.character_start = (size_t)args.iValue; })); AddWidget(&typewriterStartInput); diff --git a/Editor/ForceFieldWindow.cpp b/Editor/ForceFieldWindow.cpp index 6703a95e3..d74f1b1a7 100644 --- a/Editor/ForceFieldWindow.cpp +++ b/Editor/ForceFieldWindow.cpp @@ -60,8 +60,8 @@ void ForceFieldWindow::Create(EditorComponent* _editor) typeComboBox.SetTooltip("Choose the force field type."); AddWidget(&typeComboBox); - auto forEachSelected = [&](auto func) { - return [&, func](auto args) { + auto forEachSelected = [this](auto func) { + return [this, func](auto args) { wi::scene::Scene& scene = editor->GetCurrentScene(); for (auto& x : editor->translator.selected) { @@ -76,7 +76,7 @@ void ForceFieldWindow::Create(EditorComponent* _editor) gravitySlider.Create(-10, 10, 0, 100000, "Gravity: "); gravitySlider.SetSize(XMFLOAT2(wid, hei)); gravitySlider.SetPos(XMFLOAT2(x, y += step)); - gravitySlider.OnSlide(forEachSelected([&] (auto force, auto args) { + gravitySlider.OnSlide(forEachSelected([] (auto force, auto args) { force->gravity = args.fValue; })); gravitySlider.SetEnabled(false); @@ -87,7 +87,7 @@ void ForceFieldWindow::Create(EditorComponent* _editor) rangeSlider.Create(0.0f, 100.0f, 10, 100000, "Range: "); rangeSlider.SetSize(XMFLOAT2(wid, hei)); rangeSlider.SetPos(XMFLOAT2(x, y += step)); - rangeSlider.OnSlide(forEachSelected([&](auto force, auto args) { + rangeSlider.OnSlide(forEachSelected([](auto force, auto args) { force->range = args.fValue; })); rangeSlider.SetEnabled(false); diff --git a/Editor/HairParticleWindow.cpp b/Editor/HairParticleWindow.cpp index 45ac258b9..49483f3ae 100644 --- a/Editor/HairParticleWindow.cpp +++ b/Editor/HairParticleWindow.cpp @@ -28,8 +28,8 @@ void HairParticleWindow::Create(EditorComponent* _editor) infoLabel.SetFitTextEnabled(true); AddWidget(&infoLabel); - auto forEachSelected = [&] (auto func) { - return [&, func] (auto args) { + auto forEachSelected = [this] (auto func) { + return [this, func] (auto args) { wi::scene::Scene& scene = editor->GetCurrentScene(); for (auto& x : editor->translator.selected) { @@ -44,7 +44,7 @@ void HairParticleWindow::Create(EditorComponent* _editor) meshComboBox.Create("Mesh: "); meshComboBox.SetEnabled(false); - meshComboBox.OnSelect(forEachSelected([&] (auto hair, auto args) { + meshComboBox.OnSelect(forEachSelected([this] (auto hair, auto args) { if (args.iValue == 0) { hair->meshID = INVALID_ENTITY; @@ -60,13 +60,13 @@ void HairParticleWindow::Create(EditorComponent* _editor) cameraBendCheckbox.Create("Camera Bend: "); cameraBendCheckbox.SetTooltip("Enable a slight bending in camera view, that can help hide the card look when looking from above."); - cameraBendCheckbox.OnClick(forEachSelected([&] (auto hair, auto args) { + cameraBendCheckbox.OnClick(forEachSelected([] (auto hair, auto args) { hair->SetCameraBendEnabled(args.bValue); })); AddWidget(&cameraBendCheckbox); countSlider.Create(0, 100000, 1000, 100000, "Strand Count: "); - countSlider.OnSlide(forEachSelected([&] (auto hair, auto args) { + countSlider.OnSlide(forEachSelected([] (auto hair, auto args) { hair->strandCount = (uint32_t)args.iValue; })); countSlider.SetEnabled(false); @@ -74,7 +74,7 @@ void HairParticleWindow::Create(EditorComponent* _editor) AddWidget(&countSlider); lengthSlider.Create(0, 4, 1, 1000, "Length: "); - lengthSlider.OnSlide(forEachSelected([&] (auto hair, auto args) { + lengthSlider.OnSlide(forEachSelected([] (auto hair, auto args) { hair->length = args.fValue; })); lengthSlider.SetEnabled(false); @@ -82,7 +82,7 @@ void HairParticleWindow::Create(EditorComponent* _editor) AddWidget(&lengthSlider); widthSlider.Create(0, 2, 1, 1000, "Width: "); - widthSlider.OnSlide(forEachSelected([&] (auto hair, auto args) { + widthSlider.OnSlide(forEachSelected([] (auto hair, auto args) { hair->width = args.fValue; })); widthSlider.SetEnabled(false); @@ -90,7 +90,7 @@ void HairParticleWindow::Create(EditorComponent* _editor) AddWidget(&widthSlider); stiffnessSlider.Create(0, 10, 0.5f, 100, "Stiffness: "); - stiffnessSlider.OnSlide(forEachSelected([&] (auto hair, auto args) { + stiffnessSlider.OnSlide(forEachSelected([] (auto hair, auto args) { hair->stiffness = args.fValue; })); stiffnessSlider.SetEnabled(false); @@ -98,7 +98,7 @@ void HairParticleWindow::Create(EditorComponent* _editor) AddWidget(&stiffnessSlider); dragSlider.Create(0, 1, 0.5f, 100, "Drag: "); - dragSlider.OnSlide(forEachSelected([&] (auto hair, auto args) { + dragSlider.OnSlide(forEachSelected([] (auto hair, auto args) { hair->drag = args.fValue; })); dragSlider.SetEnabled(false); @@ -106,7 +106,7 @@ void HairParticleWindow::Create(EditorComponent* _editor) AddWidget(&dragSlider); gravityPowerSlider.Create(0, 1, 0.5f, 100, "Gravity Power: "); - gravityPowerSlider.OnSlide(forEachSelected([&] (auto hair, auto args) { + gravityPowerSlider.OnSlide(forEachSelected([] (auto hair, auto args) { hair->gravityPower = args.fValue; })); gravityPowerSlider.SetEnabled(false); @@ -114,7 +114,7 @@ void HairParticleWindow::Create(EditorComponent* _editor) AddWidget(&gravityPowerSlider); randomnessSlider.Create(0, 1, 0.2f, 1000, "Randomness: "); - randomnessSlider.OnSlide(forEachSelected([&] (auto hair, auto args) { + randomnessSlider.OnSlide(forEachSelected([] (auto hair, auto args) { hair->randomness = args.fValue; })); randomnessSlider.SetEnabled(false); @@ -122,7 +122,7 @@ void HairParticleWindow::Create(EditorComponent* _editor) AddWidget(&randomnessSlider); segmentcountSlider.Create(1, 10, 1, 9, "Segments: "); - segmentcountSlider.OnSlide(forEachSelected([&] (auto hair, auto args) { + segmentcountSlider.OnSlide(forEachSelected([] (auto hair, auto args) { hair->segmentCount = (uint32_t)args.iValue; })); segmentcountSlider.SetEnabled(false); @@ -130,7 +130,7 @@ void HairParticleWindow::Create(EditorComponent* _editor) AddWidget(&segmentcountSlider); billboardcountSlider.Create(1, 10, 1, 9, "Billboards: "); - billboardcountSlider.OnSlide(forEachSelected([&] (auto hair, auto args) { + billboardcountSlider.OnSlide(forEachSelected([] (auto hair, auto args) { hair->billboardCount = (uint32_t)args.iValue; })); billboardcountSlider.SetEnabled(false); @@ -138,7 +138,7 @@ void HairParticleWindow::Create(EditorComponent* _editor) AddWidget(&billboardcountSlider); randomSeedSlider.Create(1, 12345, 1, 12344, "Random seed: "); - randomSeedSlider.OnSlide(forEachSelected([&] (auto hair, auto args) { + randomSeedSlider.OnSlide(forEachSelected([] (auto hair, auto args) { hair->randomSeed = (uint32_t)args.iValue; })); randomSeedSlider.SetEnabled(false); @@ -146,7 +146,7 @@ void HairParticleWindow::Create(EditorComponent* _editor) AddWidget(&randomSeedSlider); viewDistanceSlider.Create(0, 1000, 100, 10000, "View distance: "); - viewDistanceSlider.OnSlide(forEachSelected([&] (auto hair, auto args) { + viewDistanceSlider.OnSlide(forEachSelected([] (auto hair, auto args) { hair->viewDistance = args.fValue; })); viewDistanceSlider.SetEnabled(false); @@ -154,7 +154,7 @@ void HairParticleWindow::Create(EditorComponent* _editor) AddWidget(&viewDistanceSlider); uniformitySlider.Create(0.01f, 2.0f, 0.1f, 1000, "Uniformity: "); - uniformitySlider.OnSlide(forEachSelected([&] (auto hair, auto args) { + uniformitySlider.OnSlide(forEachSelected([] (auto hair, auto args) { hair->uniformity = args.fValue; })); uniformitySlider.SetTooltip("How much the sprite selection distribution noise is modulated by particle positions."); diff --git a/Editor/HumanoidWindow.cpp b/Editor/HumanoidWindow.cpp index 91c7fc281..367ee9a9d 100644 --- a/Editor/HumanoidWindow.cpp +++ b/Editor/HumanoidWindow.cpp @@ -30,8 +30,8 @@ void HumanoidWindow::Create(EditorComponent* _editor) infoLabel.SetFitTextEnabled(true); AddWidget(&infoLabel); - auto forEachSelected = [&] (auto func) { - return [&, func] (auto args) { + auto forEachSelected = [this] (auto func) { + return [this, func] (auto args) { wi::scene::Scene& scene = editor->GetCurrentScene(); HumanoidComponent* humanoid = scene.humanoids.GetComponent(entity); if (humanoid != nullptr) { @@ -42,7 +42,7 @@ void HumanoidWindow::Create(EditorComponent* _editor) lookatCheckBox.Create("Look At: "); lookatCheckBox.SetTooltip("Enable updating the lookAt direction. If enabled, head will turn to face the lookAt point.\nA sample lookAt point can be generated by the editor if you enable the Follow mouse option."); - lookatCheckBox.OnClick(forEachSelected([&] (auto humanoid, auto args) { + lookatCheckBox.OnClick(forEachSelected([] (auto humanoid, auto args) { humanoid->SetLookAtEnabled(args.bValue); })); AddWidget(&lookatCheckBox); @@ -54,42 +54,42 @@ void HumanoidWindow::Create(EditorComponent* _editor) lookatEntityCombo.Create("Look At Entity: "); lookatEntityCombo.SetTooltip("If this is set to an entity with TransformComponent, it will override the lookAt position that was set directly and it will also be saved with the scene."); - lookatEntityCombo.OnSelect(forEachSelected([&] (auto humanoid, auto args) { + lookatEntityCombo.OnSelect(forEachSelected([] (auto humanoid, auto args) { humanoid->lookAtEntity = (Entity)args.userdata; })); AddWidget(&lookatEntityCombo); ragdollCheckBox.Create("Ragdoll: "); ragdollCheckBox.SetTooltip("Activate dynamic ragdoll physics.\nNote that kinematic ragdoll physics is always active (ragdoll is animation-driven/kinematic by default).\nNote that scaling humanoid will disable ragdoll physics and you need to re-enable if you want to."); - ragdollCheckBox.OnClick(forEachSelected([&] (auto humanoid, auto args) { + ragdollCheckBox.OnClick(forEachSelected([] (auto humanoid, auto args) { humanoid->SetRagdollPhysicsEnabled(args.bValue); })); AddWidget(&ragdollCheckBox); capsuleShadowCheckBox.Create("Capsule Shadow Disabled: "); capsuleShadowCheckBox.SetTooltip("Disable capsule shadow for this specific humanoid."); - capsuleShadowCheckBox.OnClick(forEachSelected([&] (auto humanoid, auto args) { + capsuleShadowCheckBox.OnClick(forEachSelected([] (auto humanoid, auto args) { humanoid->SetCapsuleShadowDisabled(args.bValue); })); AddWidget(&capsuleShadowCheckBox); headRotMaxXSlider.Create(0, 90, 60, 180, "Head horizontal: "); headRotMaxXSlider.SetTooltip("Limit horizontal head movement (input in degrees)"); - headRotMaxXSlider.OnSlide(forEachSelected([&] (auto humanoid, auto args) { + headRotMaxXSlider.OnSlide(forEachSelected([] (auto humanoid, auto args) { humanoid->head_rotation_max.x = wi::math::DegreesToRadians(args.fValue); })); AddWidget(&headRotMaxXSlider); headRotMaxYSlider.Create(0, 60, 30, 60, "Head vertical: "); headRotMaxYSlider.SetTooltip("Limit vertical head movement (input in degrees)"); - headRotMaxYSlider.OnSlide(forEachSelected([&] (auto humanoid, auto args) { + headRotMaxYSlider.OnSlide(forEachSelected([] (auto humanoid, auto args) { humanoid->head_rotation_max.y = wi::math::DegreesToRadians(args.fValue); })); AddWidget(&headRotMaxYSlider); headRotSpeedSlider.Create(0.05f, 1, 0.1f, 1000, "Head speed: "); headRotSpeedSlider.SetTooltip("Adjust head turning speed."); - headRotSpeedSlider.OnSlide(forEachSelected([&] (auto humanoid, auto args) { + headRotSpeedSlider.OnSlide(forEachSelected([] (auto humanoid, auto args) { humanoid->head_rotation_speed = args.fValue; })); AddWidget(&headRotSpeedSlider); @@ -97,28 +97,28 @@ void HumanoidWindow::Create(EditorComponent* _editor) eyeRotMaxXSlider.Create(0, 40, 20, 40, "Eye horizontal: "); eyeRotMaxXSlider.SetTooltip("Limit horizontal eye movement (input in degrees)"); - eyeRotMaxXSlider.OnSlide(forEachSelected([&] (auto humanoid, auto args) { + eyeRotMaxXSlider.OnSlide(forEachSelected([] (auto humanoid, auto args) { humanoid->eye_rotation_max.x = wi::math::DegreesToRadians(args.fValue); })); AddWidget(&eyeRotMaxXSlider); eyeRotMaxYSlider.Create(0, 30, 15, 30, "Eye vertical: "); eyeRotMaxYSlider.SetTooltip("Limit vertical eye movement (input in degrees)"); - eyeRotMaxYSlider.OnSlide(forEachSelected([&] (auto humanoid, auto args) { + eyeRotMaxYSlider.OnSlide(forEachSelected([] (auto humanoid, auto args) { humanoid->eye_rotation_max.y = wi::math::DegreesToRadians(args.fValue); })); AddWidget(&eyeRotMaxYSlider); eyeRotSpeedSlider.Create(0.05f, 1, 0.2f, 1000, "Eye speed: "); eyeRotSpeedSlider.SetTooltip("Adjust eye turning speed."); - eyeRotSpeedSlider.OnSlide(forEachSelected([&] (auto humanoid, auto args) { + eyeRotSpeedSlider.OnSlide(forEachSelected([] (auto humanoid, auto args) { humanoid->eye_rotation_speed = args.fValue; })); AddWidget(&eyeRotSpeedSlider); headSizeSlider.Create(0.5f, 2, 1, 1000, "Head size: "); headSizeSlider.SetTooltip("Adjust head size."); - headSizeSlider.OnSlide(forEachSelected([&] (auto humanoid, auto args) { + headSizeSlider.OnSlide(forEachSelected([this] (auto humanoid, auto args) { Entity bone = humanoid->bones[size_t(HumanoidComponent::HumanoidBone::Head)]; wi::scene::Scene& scene = editor->GetCurrentScene(); TransformComponent* transform = scene.transforms.GetComponent(bone); @@ -134,7 +134,7 @@ void HumanoidWindow::Create(EditorComponent* _editor) ragdollFatnessSlider.Create(0.5f, 2, 1, 1000, "Ragdoll fatness: "); ragdollFatnessSlider.SetTooltip("Adjust overall fatness of ragdoll physics skeleton."); - ragdollFatnessSlider.OnSlide(forEachSelected([&] (auto humanoid, auto args) { + ragdollFatnessSlider.OnSlide(forEachSelected([] (auto humanoid, auto args) { humanoid->ragdoll_fatness = args.fValue; humanoid->ragdoll = {}; // request recreate })); @@ -142,7 +142,7 @@ void HumanoidWindow::Create(EditorComponent* _editor) ragdollHeadSizeSlider.Create(0.5f, 2, 1, 1000, "Ragdoll head: "); ragdollHeadSizeSlider.SetTooltip("Adjust overall size of ragdoll physics head."); - ragdollHeadSizeSlider.OnSlide(forEachSelected([&] (auto humanoid, auto args) { + ragdollHeadSizeSlider.OnSlide(forEachSelected([] (auto humanoid, auto args) { humanoid->ragdoll_headsize = args.fValue; humanoid->ragdoll = {}; // request recreate })); diff --git a/Editor/IKWindow.cpp b/Editor/IKWindow.cpp index b3602e903..abcc0fc4e 100644 --- a/Editor/IKWindow.cpp +++ b/Editor/IKWindow.cpp @@ -30,8 +30,8 @@ void IKWindow::Create(EditorComponent* _editor) float hei = 18; float step = hei + 2; - auto forEachSelected = [&] (auto func) { - return [&, func] (auto args) { + auto forEachSelected = [this] (auto func) { + return [this, func] (auto args) { wi::scene::Scene& scene = editor->GetCurrentScene(); for (auto& x : editor->translator.selected) { @@ -48,7 +48,7 @@ void IKWindow::Create(EditorComponent* _editor) targetCombo.SetSize(XMFLOAT2(siz, hei)); targetCombo.SetPos(XMFLOAT2(x, y)); targetCombo.SetEnabled(false); - targetCombo.OnSelect(forEachSelected([&] (auto ik, auto args) { + targetCombo.OnSelect(forEachSelected([this] (auto ik, auto args) { if (args.iValue == 0) { ik->target = INVALID_ENTITY; @@ -65,7 +65,7 @@ void IKWindow::Create(EditorComponent* _editor) disabledCheckBox.SetTooltip("Disable simulation."); disabledCheckBox.SetPos(XMFLOAT2(x, y += step)); disabledCheckBox.SetSize(XMFLOAT2(hei, hei)); - disabledCheckBox.OnClick(forEachSelected([&] (auto ik, auto args) { + disabledCheckBox.OnClick(forEachSelected([] (auto ik, auto args) { ik->SetDisabled(args.bValue); })); AddWidget(&disabledCheckBox); @@ -74,7 +74,7 @@ void IKWindow::Create(EditorComponent* _editor) chainLengthSlider.SetTooltip("How far the hierarchy chain is simulated backwards from this entity"); chainLengthSlider.SetPos(XMFLOAT2(x, y += step)); chainLengthSlider.SetSize(XMFLOAT2(siz, hei)); - chainLengthSlider.OnSlide(forEachSelected([&] (auto ik, auto args) { + chainLengthSlider.OnSlide(forEachSelected([] (auto ik, auto args) { ik->chain_length = args.iValue; })); AddWidget(&chainLengthSlider); @@ -83,7 +83,7 @@ void IKWindow::Create(EditorComponent* _editor) iterationCountSlider.SetTooltip("How many iterations to compute the inverse kinematics for. Higher values are slower but more accurate."); iterationCountSlider.SetPos(XMFLOAT2(x, y += step)); iterationCountSlider.SetSize(XMFLOAT2(siz, hei)); - iterationCountSlider.OnSlide(forEachSelected([&] (auto ik, auto args) { + iterationCountSlider.OnSlide(forEachSelected([] (auto ik, auto args) { ik->iteration_count = args.iValue; })); AddWidget(&iterationCountSlider); diff --git a/Editor/LayerWindow.cpp b/Editor/LayerWindow.cpp index 8ab2ed96b..2af922b8e 100644 --- a/Editor/LayerWindow.cpp +++ b/Editor/LayerWindow.cpp @@ -56,8 +56,8 @@ void LayerWindow::Create(EditorComponent* _editor) AddWidget(&layers[i]); } - auto forEachLayer = [&] (auto func) { - return [&, func] (auto args) { + auto forEachLayer = [this] (auto func) { + return [this, func] (auto args) { wi::scene::Scene& scene = editor->GetCurrentScene(); for (auto& x : editor->translator.selected) { @@ -75,13 +75,13 @@ void LayerWindow::Create(EditorComponent* _editor) }; enableAllButton.Create("ALL " ICON_CHECK); - enableAllButton.OnClick(forEachLayer([&] (auto layer, auto args) { + enableAllButton.OnClick(forEachLayer([] (auto layer, auto args) { layer->layerMask = ~0; })); AddWidget(&enableAllButton); enableNoneButton.Create("NONE " ICON_DISABLED); - enableNoneButton.OnClick(forEachLayer([&] (auto layer, auto args) { + enableNoneButton.OnClick(forEachLayer([] (auto layer, auto args) { layer->layerMask = 0; })); AddWidget(&enableNoneButton); diff --git a/Editor/LightWindow.cpp b/Editor/LightWindow.cpp index 893d803e6..d582caa0f 100644 --- a/Editor/LightWindow.cpp +++ b/Editor/LightWindow.cpp @@ -34,8 +34,8 @@ void LightWindow::Create(EditorComponent* _editor) float mod_x = 10; - auto forEachSelected = [&] (auto func) { - return [&, func] (auto args) { + auto forEachSelected = [this] (auto func) { + return [this, func] (auto args) { wi::scene::Scene& scene = editor->GetCurrentScene(); for (auto& x : editor->translator.selected) { @@ -49,7 +49,7 @@ void LightWindow::Create(EditorComponent* _editor) colorPicker.SetPos(XMFLOAT2(mod_x, y)); colorPicker.SetVisible(true); colorPicker.SetEnabled(false); - colorPicker.OnColorChanged(forEachSelected([&] (auto light, auto args) { + colorPicker.OnColorChanged(forEachSelected([] (auto light, auto args) { light->color = args.color.toFloat3(); })); AddWidget(&colorPicker); @@ -58,7 +58,7 @@ void LightWindow::Create(EditorComponent* _editor) y += colorPicker.GetScale().y + 5; intensitySlider.Create(0, 1000, 0, 100000, "Intensity: "); - intensitySlider.OnSlide(forEachSelected([&] (auto light, auto args) { + intensitySlider.OnSlide(forEachSelected([] (auto light, auto args) { light->intensity = args.fValue; })); intensitySlider.SetEnabled(false); @@ -66,7 +66,7 @@ void LightWindow::Create(EditorComponent* _editor) AddWidget(&intensitySlider); rangeSlider.Create(1, 1000, 0, 100000, "Range: "); - rangeSlider.OnSlide(forEachSelected([&] (auto light, auto args) { + rangeSlider.OnSlide(forEachSelected([] (auto light, auto args) { light->range = args.fValue; })); rangeSlider.SetEnabled(false); @@ -74,7 +74,7 @@ void LightWindow::Create(EditorComponent* _editor) AddWidget(&rangeSlider); radiusSlider.Create(0, 10, 0, 100000, "Radius: "); - radiusSlider.OnSlide(forEachSelected([&] (auto light, auto args) { + radiusSlider.OnSlide(forEachSelected([] (auto light, auto args) { light->radius = args.fValue; })); radiusSlider.SetEnabled(false); @@ -82,7 +82,7 @@ void LightWindow::Create(EditorComponent* _editor) AddWidget(&radiusSlider); lengthSlider.Create(0, 10, 0, 100000, "Length: "); - lengthSlider.OnSlide(forEachSelected([&] (auto light, auto args) { + lengthSlider.OnSlide(forEachSelected([] (auto light, auto args) { light->length = args.fValue; })); lengthSlider.SetEnabled(false); @@ -90,7 +90,7 @@ void LightWindow::Create(EditorComponent* _editor) AddWidget(&lengthSlider); heightSlider.Create(0, 10, 0, 100000, "Height: "); - heightSlider.OnSlide(forEachSelected([&] (auto light, auto args) { + heightSlider.OnSlide(forEachSelected([] (auto light, auto args) { light->height = args.fValue; })); heightSlider.SetEnabled(false); @@ -98,7 +98,7 @@ void LightWindow::Create(EditorComponent* _editor) AddWidget(&heightSlider); outerConeAngleSlider.Create(0.1f, XM_PIDIV2 - 0.01f, 0, 100000, "Outer Cone Angle: "); - outerConeAngleSlider.OnSlide(forEachSelected([&] (auto light, auto args) { + outerConeAngleSlider.OnSlide(forEachSelected([] (auto light, auto args) { light->outerConeAngle = args.fValue; })); outerConeAngleSlider.SetEnabled(false); @@ -106,7 +106,7 @@ void LightWindow::Create(EditorComponent* _editor) AddWidget(&outerConeAngleSlider); innerConeAngleSlider.Create(0, XM_PI - 0.01f, 0, 100000, "Inner Cone Angle: "); - innerConeAngleSlider.OnSlide(forEachSelected([&] (auto light, auto args) { + innerConeAngleSlider.OnSlide(forEachSelected([] (auto light, auto args) { light->innerConeAngle = args.fValue; })); innerConeAngleSlider.SetEnabled(false); @@ -114,14 +114,14 @@ void LightWindow::Create(EditorComponent* _editor) AddWidget(&innerConeAngleSlider); volumetricBoostSlider.Create(0, 10, 0, 1000, "Volumetric boost: "); - volumetricBoostSlider.OnSlide(forEachSelected([&] (auto light, auto args) { + volumetricBoostSlider.OnSlide(forEachSelected([] (auto light, auto args) { light->volumetric_boost = args.fValue; })); volumetricBoostSlider.SetTooltip("Adjust the volumetric fog effect's strength just for this light"); AddWidget(&volumetricBoostSlider); shadowCheckBox.Create("Shadow: "); - shadowCheckBox.OnClick(forEachSelected([&] (auto light, auto args) { + shadowCheckBox.OnClick(forEachSelected([] (auto light, auto args) { light->SetCastShadow(args.bValue); })); shadowCheckBox.SetEnabled(false); @@ -129,7 +129,7 @@ void LightWindow::Create(EditorComponent* _editor) AddWidget(&shadowCheckBox); volumetricsCheckBox.Create("Volumetric: "); - volumetricsCheckBox.OnClick(forEachSelected([&] (auto light, auto args) { + volumetricsCheckBox.OnClick(forEachSelected([] (auto light, auto args) { light->SetVolumetricsEnabled(args.bValue); })); volumetricsCheckBox.SetEnabled(false); @@ -137,7 +137,7 @@ void LightWindow::Create(EditorComponent* _editor) AddWidget(&volumetricsCheckBox); haloCheckBox.Create("Visualizer: "); - haloCheckBox.OnClick(forEachSelected([&] (auto light, auto args) { + haloCheckBox.OnClick(forEachSelected([] (auto light, auto args) { light->SetVisualizerEnabled(args.bValue); })); haloCheckBox.SetEnabled(false); @@ -145,7 +145,7 @@ void LightWindow::Create(EditorComponent* _editor) AddWidget(&haloCheckBox); staticCheckBox.Create("Static: "); - staticCheckBox.OnClick(forEachSelected([&] (auto light, auto args) { + staticCheckBox.OnClick(forEachSelected([] (auto light, auto args) { light->SetStatic(args.bValue); })); staticCheckBox.SetEnabled(false); @@ -153,7 +153,7 @@ void LightWindow::Create(EditorComponent* _editor) AddWidget(&staticCheckBox); volumetricCloudsCheckBox.Create("Volumetric Clouds: "); - volumetricCloudsCheckBox.OnClick(forEachSelected([&] (auto light, auto args) { + volumetricCloudsCheckBox.OnClick(forEachSelected([] (auto light, auto args) { light->SetVolumetricCloudsEnabled(args.bValue); })); volumetricCloudsCheckBox.SetEnabled(false); @@ -195,7 +195,7 @@ void LightWindow::Create(EditorComponent* _editor) shadowResolutionComboBox.AddItem("2048", 2048); shadowResolutionComboBox.AddItem("4096", 4096); shadowResolutionComboBox.AddItem("8192", 8192); - shadowResolutionComboBox.OnSelect(forEachSelected([&] (auto light, auto args) { + shadowResolutionComboBox.OnSelect(forEachSelected([] (auto light, auto args) { light->forced_shadow_resolution = int(args.userdata); })); shadowResolutionComboBox.SetSelected(0); diff --git a/Editor/MaterialWindow.cpp b/Editor/MaterialWindow.cpp index 553faee64..b13785a24 100644 --- a/Editor/MaterialWindow.cpp +++ b/Editor/MaterialWindow.cpp @@ -50,7 +50,7 @@ void MaterialWindow::Create(EditorComponent* _editor) float x = 150, y = 0; float wid = 130; - auto forEachSelected = [&] (auto func) { + auto forEachSelected = [this] (auto func) { return [=] (auto args) { wi::scene::Scene& scene = editor->GetCurrentScene(); for (auto& x : editor->translator.selected) @@ -66,7 +66,7 @@ void MaterialWindow::Create(EditorComponent* _editor) shadowReceiveCheckBox.SetTooltip("Receives shadow or not?"); shadowReceiveCheckBox.SetPos(XMFLOAT2(x, y)); shadowReceiveCheckBox.SetSize(XMFLOAT2(hei, hei)); - shadowReceiveCheckBox.OnClick(forEachSelected([&] (auto material, auto args) { + shadowReceiveCheckBox.OnClick(forEachSelected([] (auto material, auto args) { material->SetReceiveShadow(args.bValue); })); AddWidget(&shadowReceiveCheckBox); @@ -75,7 +75,7 @@ void MaterialWindow::Create(EditorComponent* _editor) shadowCasterCheckBox.SetTooltip("The subset will contribute to the scene shadows if enabled."); shadowCasterCheckBox.SetPos(XMFLOAT2(x, y += step)); shadowCasterCheckBox.SetSize(XMFLOAT2(hei, hei)); - shadowCasterCheckBox.OnClick(forEachSelected([&] (auto material, auto args) { + shadowCasterCheckBox.OnClick(forEachSelected([] (auto material, auto args) { material->SetCastShadow(args.bValue); })); AddWidget(&shadowCasterCheckBox); @@ -84,7 +84,7 @@ void MaterialWindow::Create(EditorComponent* _editor) useVertexColorsCheckBox.SetTooltip("Enable if you want to render the mesh with vertex colors (must have appropriate vertex buffer)"); useVertexColorsCheckBox.SetPos(XMFLOAT2(x, y += step)); useVertexColorsCheckBox.SetSize(XMFLOAT2(hei, hei)); - useVertexColorsCheckBox.OnClick(forEachSelected([&] (auto material, auto args) { + useVertexColorsCheckBox.OnClick(forEachSelected([] (auto material, auto args) { material->SetUseVertexColors(args.bValue); })); AddWidget(&useVertexColorsCheckBox); @@ -93,7 +93,7 @@ void MaterialWindow::Create(EditorComponent* _editor) specularGlossinessCheckBox.SetTooltip("If enabled, surface map will be viewed like it contains specular color (RGB) and smoothness (A)"); specularGlossinessCheckBox.SetPos(XMFLOAT2(x, y += step)); specularGlossinessCheckBox.SetSize(XMFLOAT2(hei, hei)); - specularGlossinessCheckBox.OnClick(forEachSelected([&] (auto material, auto args) { + specularGlossinessCheckBox.OnClick(forEachSelected([] (auto material, auto args) { material->SetUseSpecularGlossinessWorkflow(args.bValue); })); AddWidget(&specularGlossinessCheckBox); @@ -102,7 +102,7 @@ void MaterialWindow::Create(EditorComponent* _editor) occlusionPrimaryCheckBox.SetTooltip("If enabled, surface map's RED channel will be used as occlusion map"); occlusionPrimaryCheckBox.SetPos(XMFLOAT2(x, y += step)); occlusionPrimaryCheckBox.SetSize(XMFLOAT2(hei, hei)); - occlusionPrimaryCheckBox.OnClick(forEachSelected([&] (auto material, auto args) { + occlusionPrimaryCheckBox.OnClick(forEachSelected([] (auto material, auto args) { material->SetOcclusionEnabled_Primary(args.bValue); })); AddWidget(&occlusionPrimaryCheckBox); @@ -111,7 +111,7 @@ void MaterialWindow::Create(EditorComponent* _editor) occlusionSecondaryCheckBox.SetTooltip("If enabled, occlusion map's RED channel will be used as occlusion map"); occlusionSecondaryCheckBox.SetPos(XMFLOAT2(x, y += step)); occlusionSecondaryCheckBox.SetSize(XMFLOAT2(hei, hei)); - occlusionSecondaryCheckBox.OnClick(forEachSelected([&] (auto material, auto args) { + occlusionSecondaryCheckBox.OnClick(forEachSelected([] (auto material, auto args) { material->SetOcclusionEnabled_Secondary(args.bValue); })); AddWidget(&occlusionSecondaryCheckBox); @@ -120,7 +120,7 @@ void MaterialWindow::Create(EditorComponent* _editor) vertexAOCheckBox.SetTooltip("If enabled, vertex ambient occlusion will be enabled (if it exists)"); vertexAOCheckBox.SetPos(XMFLOAT2(x, y += step)); vertexAOCheckBox.SetSize(XMFLOAT2(hei, hei)); - vertexAOCheckBox.OnClick(forEachSelected([&] (auto material, auto args) { + vertexAOCheckBox.OnClick(forEachSelected([] (auto material, auto args) { material->SetVertexAODisabled(!args.bValue); })); AddWidget(&vertexAOCheckBox); @@ -129,7 +129,7 @@ void MaterialWindow::Create(EditorComponent* _editor) windCheckBox.SetTooltip("If enabled, vertex wind weights will affect how much wind offset affects the subset."); windCheckBox.SetPos(XMFLOAT2(x, y += step)); windCheckBox.SetSize(XMFLOAT2(hei, hei)); - windCheckBox.OnClick(forEachSelected([&] (auto material, auto args) { + windCheckBox.OnClick(forEachSelected([] (auto material, auto args) { material->SetUseWind(args.bValue); })); AddWidget(&windCheckBox); @@ -138,7 +138,7 @@ void MaterialWindow::Create(EditorComponent* _editor) doubleSidedCheckBox.SetTooltip("Decide whether to render both sides of the material (It's also possible to set this behaviour per mesh)."); doubleSidedCheckBox.SetPos(XMFLOAT2(x, y += step)); doubleSidedCheckBox.SetSize(XMFLOAT2(hei, hei)); - doubleSidedCheckBox.OnClick(forEachSelected([&] (auto material, auto args) { + doubleSidedCheckBox.OnClick(forEachSelected([] (auto material, auto args) { material->SetDoubleSided(args.bValue); })); AddWidget(&doubleSidedCheckBox); @@ -147,7 +147,7 @@ void MaterialWindow::Create(EditorComponent* _editor) outlineCheckBox.SetTooltip("Enable cartoon outline. The Cartoon Outline graphics setting also needs to be enabled for it to show up."); outlineCheckBox.SetPos(XMFLOAT2(x, y += step)); outlineCheckBox.SetSize(XMFLOAT2(hei, hei)); - outlineCheckBox.OnClick(forEachSelected([&] (auto material, auto args) { + outlineCheckBox.OnClick(forEachSelected([] (auto material, auto args) { material->SetOutlineEnabled(args.bValue); })); AddWidget(&outlineCheckBox); @@ -156,7 +156,7 @@ void MaterialWindow::Create(EditorComponent* _editor) preferUncompressedCheckBox.SetTooltip("For uncompressed textures (jpg, png, etc.) here it is possible to enable/disable auto block compression on importing. \nBlock compression can reduce GPU memory usage and improve performance, but it can result in degraded quality."); preferUncompressedCheckBox.SetPos(XMFLOAT2(x, y += step)); preferUncompressedCheckBox.SetSize(XMFLOAT2(hei, hei)); - preferUncompressedCheckBox.OnClick(forEachSelected([&] (auto material, auto args) { + preferUncompressedCheckBox.OnClick(forEachSelected([this] (auto material, auto args) { material->SetPreferUncompressedTexturesEnabled(args.bValue); textureSlotComboBox.SetSelected(textureSlotComboBox.GetSelected()); // update })); @@ -166,7 +166,7 @@ void MaterialWindow::Create(EditorComponent* _editor) disableStreamingCheckBox.SetTooltip("Disable texture streaming for this material only."); disableStreamingCheckBox.SetPos(XMFLOAT2(x, y += step)); disableStreamingCheckBox.SetSize(XMFLOAT2(hei, hei)); - disableStreamingCheckBox.OnClick(forEachSelected([&] (auto material, auto args) { + disableStreamingCheckBox.OnClick(forEachSelected([this] (auto material, auto args) { material->SetTextureStreamingDisabled(args.bValue); material->CreateRenderData(true); textureSlotComboBox.SetSelected(textureSlotComboBox.GetSelected()); // update @@ -177,7 +177,7 @@ void MaterialWindow::Create(EditorComponent* _editor) coplanarCheckBox.SetTooltip("If polygons are coplanar to an opaque surface, then the blending can be done in the opaque pass.\nThis can enable some benefits of opaque render pass to a specific transparent surface."); coplanarCheckBox.SetPos(XMFLOAT2(x, y += step)); coplanarCheckBox.SetSize(XMFLOAT2(hei, hei)); - coplanarCheckBox.OnClick(forEachSelected([&] (auto material, auto args) { + coplanarCheckBox.OnClick(forEachSelected([] (auto material, auto args) { material->SetCoplanarBlending(args.bValue); })); AddWidget(&coplanarCheckBox); @@ -186,7 +186,7 @@ void MaterialWindow::Create(EditorComponent* _editor) capsuleShadowCheckBox.SetTooltip("Disable receiving capsule shadows for this material."); capsuleShadowCheckBox.SetPos(XMFLOAT2(x, y += step)); capsuleShadowCheckBox.SetSize(XMFLOAT2(hei, hei)); - capsuleShadowCheckBox.OnClick(forEachSelected([&] (auto material, auto args) { + capsuleShadowCheckBox.OnClick(forEachSelected([] (auto material, auto args) { material->SetCapsuleShadowDisabled(args.bValue); })); AddWidget(&capsuleShadowCheckBox); @@ -196,7 +196,7 @@ void MaterialWindow::Create(EditorComponent* _editor) shaderTypeComboBox.SetTooltip("Select a shader for this material. \nCustom shaders (*) will also show up here (see wi::renderer:RegisterCustomShader() for more info.)\nNote that custom shaders (*) can't select between blend modes, as they are created with an explicit blend mode."); shaderTypeComboBox.SetPos(XMFLOAT2(x, y += step)); shaderTypeComboBox.SetSize(XMFLOAT2(wid, hei)); - shaderTypeComboBox.OnSelect(forEachSelected([&] (auto material, auto args) { + shaderTypeComboBox.OnSelect(forEachSelected([this] (auto material, auto args) { if (args.iValue >= MaterialComponent::SHADERTYPE_COUNT) { material->SetCustomShaderID(args.iValue - MaterialComponent::SHADERTYPE_COUNT); @@ -216,7 +216,7 @@ void MaterialWindow::Create(EditorComponent* _editor) blendModeComboBox.Create("Blend mode: "); blendModeComboBox.SetPos(XMFLOAT2(x, y += step)); blendModeComboBox.SetSize(XMFLOAT2(wid, hei)); - blendModeComboBox.OnSelect(forEachSelected([&] (auto material, auto args) { + blendModeComboBox.OnSelect(forEachSelected([] (auto material, auto args) { material->userBlendMode = (wi::enums::BLENDMODE)args.userdata; })); blendModeComboBox.AddItem("Opaque", wi::enums::BLENDMODE_OPAQUE); @@ -233,7 +233,7 @@ void MaterialWindow::Create(EditorComponent* _editor) shadingRateComboBox.SetTooltip("Select shading rate for this material. \nSelecting larger shading rate will decrease rendering quality of this material, \nbut increases performance.\nRequires hardware support for variable shading rate"); shadingRateComboBox.SetPos(XMFLOAT2(x, y += step)); shadingRateComboBox.SetSize(XMFLOAT2(wid, hei)); - shadingRateComboBox.OnSelect(forEachSelected([&] (auto material, auto args) { + shadingRateComboBox.OnSelect(forEachSelected([] (auto material, auto args) { material->shadingRate = (ShadingRate)args.iValue; })); shadingRateComboBox.AddItem("1X1"); @@ -250,7 +250,7 @@ void MaterialWindow::Create(EditorComponent* _editor) cameraComboBox.Create("Camera source: "); cameraComboBox.SetTooltip("Select a camera to use as texture"); - cameraComboBox.OnSelect(forEachSelected([&] (auto material, auto args) { + cameraComboBox.OnSelect(forEachSelected([this] (auto material, auto args) { material->cameraSource = (Entity)args.userdata; auto& scene = editor->GetCurrentScene(); @@ -271,7 +271,7 @@ void MaterialWindow::Create(EditorComponent* _editor) normalMapSlider.SetTooltip("How much the normal map should distort the face normals (bumpiness)."); normalMapSlider.SetSize(XMFLOAT2(wid, hei)); normalMapSlider.SetPos(XMFLOAT2(x, y += step)); - normalMapSlider.OnSlide(forEachSelected([&] (auto material, auto args) { + normalMapSlider.OnSlide(forEachSelected([] (auto material, auto args) { material->SetNormalMapStrength(args.fValue); })); AddWidget(&normalMapSlider); @@ -280,7 +280,7 @@ void MaterialWindow::Create(EditorComponent* _editor) roughnessSlider.SetTooltip("Adjust the surface roughness. Rough surfaces are less shiny, more matte."); roughnessSlider.SetSize(XMFLOAT2(wid, hei)); roughnessSlider.SetPos(XMFLOAT2(x, y += step)); - roughnessSlider.OnSlide(forEachSelected([&] (auto material, auto args) { + roughnessSlider.OnSlide(forEachSelected([] (auto material, auto args) { material->SetRoughness(args.fValue); })); AddWidget(&roughnessSlider); @@ -289,7 +289,7 @@ void MaterialWindow::Create(EditorComponent* _editor) reflectanceSlider.SetTooltip("Adjust the surface [non-metal] reflectivity (also called specularFactor).\nNote: this is not available in specular-glossiness workflow"); reflectanceSlider.SetSize(XMFLOAT2(wid, hei)); reflectanceSlider.SetPos(XMFLOAT2(x, y += step)); - reflectanceSlider.OnSlide(forEachSelected([&] (auto material, auto args) { + reflectanceSlider.OnSlide(forEachSelected([] (auto material, auto args) { material->SetReflectance(args.fValue); })); AddWidget(&reflectanceSlider); @@ -298,7 +298,7 @@ void MaterialWindow::Create(EditorComponent* _editor) metalnessSlider.SetTooltip("The more metal-like the surface is, the more the its color will contribute to the reflection color.\nNote: this is not available in specular-glossiness workflow"); metalnessSlider.SetSize(XMFLOAT2(wid, hei)); metalnessSlider.SetPos(XMFLOAT2(x, y += step)); - metalnessSlider.OnSlide(forEachSelected([&] (auto material, auto args) { + metalnessSlider.OnSlide(forEachSelected([] (auto material, auto args) { material->SetMetalness(args.fValue); })); AddWidget(&metalnessSlider); @@ -307,7 +307,7 @@ void MaterialWindow::Create(EditorComponent* _editor) alphaRefSlider.SetTooltip("Adjust the alpha cutoff threshold. Alpha cutout can affect performance"); alphaRefSlider.SetSize(XMFLOAT2(wid, hei)); alphaRefSlider.SetPos(XMFLOAT2(x, y += step)); - alphaRefSlider.OnSlide(forEachSelected([&] (auto material, auto args) { + alphaRefSlider.OnSlide(forEachSelected([] (auto material, auto args) { material->SetAlphaRef(args.fValue); })); AddWidget(&alphaRefSlider); @@ -316,7 +316,7 @@ void MaterialWindow::Create(EditorComponent* _editor) emissiveSlider.SetTooltip("Adjust the light emission of the surface. The color of the light emitted is that of the color of the material."); emissiveSlider.SetSize(XMFLOAT2(wid, hei)); emissiveSlider.SetPos(XMFLOAT2(x, y += step)); - emissiveSlider.OnSlide(forEachSelected([&] (auto material, auto args) { + emissiveSlider.OnSlide(forEachSelected([] (auto material, auto args) { material->SetEmissiveStrength(args.fValue); })); AddWidget(&emissiveSlider); @@ -325,7 +325,7 @@ void MaterialWindow::Create(EditorComponent* _editor) saturationSlider.SetTooltip("Adjust the saturation of the material."); saturationSlider.SetSize(XMFLOAT2(wid, hei)); saturationSlider.SetPos(XMFLOAT2(x, y += step)); - saturationSlider.OnSlide(forEachSelected([&] (auto material, auto args) { + saturationSlider.OnSlide(forEachSelected([] (auto material, auto args) { material->SetSaturation(args.fValue); })); AddWidget(&saturationSlider); @@ -334,7 +334,7 @@ void MaterialWindow::Create(EditorComponent* _editor) cloakSlider.SetTooltip("The cloak effect is a combination of transmission, refraction and roughness, without color tinging."); cloakSlider.SetSize(XMFLOAT2(wid, hei)); cloakSlider.SetPos(XMFLOAT2(x, y += step)); - cloakSlider.OnSlide(forEachSelected([&] (auto material, auto args) { + cloakSlider.OnSlide(forEachSelected([] (auto material, auto args) { material->SetCloakAmount(args.fValue); })); AddWidget(&cloakSlider); @@ -343,7 +343,7 @@ void MaterialWindow::Create(EditorComponent* _editor) chromaticAberrationSlider.SetTooltip("Separation of RGB colors inside transmissive material."); chromaticAberrationSlider.SetSize(XMFLOAT2(wid, hei)); chromaticAberrationSlider.SetPos(XMFLOAT2(x, y += step)); - chromaticAberrationSlider.OnSlide(forEachSelected([&] (auto material, auto args) { + chromaticAberrationSlider.OnSlide(forEachSelected([] (auto material, auto args) { material->SetChromaticAberrationAmount(args.fValue); })); AddWidget(&chromaticAberrationSlider); @@ -352,7 +352,7 @@ void MaterialWindow::Create(EditorComponent* _editor) transmissionSlider.SetTooltip("Adjust the transmissiveness. More transmissiveness means more diffuse light is transmitted instead of absorbed."); transmissionSlider.SetSize(XMFLOAT2(wid, hei)); transmissionSlider.SetPos(XMFLOAT2(x, y += step)); - transmissionSlider.OnSlide(forEachSelected([&] (auto material, auto args) { + transmissionSlider.OnSlide(forEachSelected([] (auto material, auto args) { material->SetTransmissionAmount(args.fValue); })); AddWidget(&transmissionSlider); @@ -361,7 +361,7 @@ void MaterialWindow::Create(EditorComponent* _editor) refractionSlider.SetTooltip("Adjust the refraction amount for transmissive materials."); refractionSlider.SetSize(XMFLOAT2(wid, hei)); refractionSlider.SetPos(XMFLOAT2(x, y += step)); - refractionSlider.OnSlide(forEachSelected([&] (auto material, auto args) { + refractionSlider.OnSlide(forEachSelected([] (auto material, auto args) { material->SetRefractionAmount(args.fValue); })); AddWidget(&refractionSlider); @@ -370,7 +370,7 @@ void MaterialWindow::Create(EditorComponent* _editor) pomSlider.SetTooltip("[Parallax Occlusion Mapping] Adjust how much the bump map should modulate the surface parallax effect. \nOnly works with PBR + Parallax shader."); pomSlider.SetSize(XMFLOAT2(wid, hei)); pomSlider.SetPos(XMFLOAT2(x, y += step)); - pomSlider.OnSlide(forEachSelected([&] (auto material, auto args) { + pomSlider.OnSlide(forEachSelected([] (auto material, auto args) { material->SetParallaxOcclusionMapping(args.fValue); })); AddWidget(&pomSlider); @@ -379,7 +379,7 @@ void MaterialWindow::Create(EditorComponent* _editor) anisotropyStrengthSlider.SetTooltip("Adjust anisotropy specular effect's strength. \nOnly works with PBR + Anisotropic shader."); anisotropyStrengthSlider.SetSize(XMFLOAT2(wid, hei)); anisotropyStrengthSlider.SetPos(XMFLOAT2(x, y += step)); - anisotropyStrengthSlider.OnSlide(forEachSelected([&] (auto material, auto args) { + anisotropyStrengthSlider.OnSlide(forEachSelected([] (auto material, auto args) { material->anisotropy_strength = args.fValue; })); AddWidget(&anisotropyStrengthSlider); @@ -388,7 +388,7 @@ void MaterialWindow::Create(EditorComponent* _editor) anisotropyRotationSlider.SetTooltip("Adjust anisotropy specular effect's rotation. \nOnly works with PBR + Anisotropic shader."); anisotropyRotationSlider.SetSize(XMFLOAT2(wid, hei)); anisotropyRotationSlider.SetPos(XMFLOAT2(x, y += step)); - anisotropyRotationSlider.OnSlide(forEachSelected([&] (auto material, auto args) { + anisotropyRotationSlider.OnSlide(forEachSelected([] (auto material, auto args) { material->anisotropy_rotation = wi::math::DegreesToRadians(args.fValue); })); AddWidget(&anisotropyRotationSlider); @@ -398,7 +398,7 @@ void MaterialWindow::Create(EditorComponent* _editor) displacementMappingSlider.SetTooltip("Adjust how much the bump map should modulate the geometry when using tessellation."); displacementMappingSlider.SetSize(XMFLOAT2(wid, hei)); displacementMappingSlider.SetPos(XMFLOAT2(x, y += step)); - displacementMappingSlider.OnSlide(forEachSelected([&] (auto material, auto args) { + displacementMappingSlider.OnSlide(forEachSelected([] (auto material, auto args) { material->SetDisplacementMapping(args.fValue); })); AddWidget(&displacementMappingSlider); @@ -407,7 +407,7 @@ void MaterialWindow::Create(EditorComponent* _editor) subsurfaceScatteringSlider.SetTooltip("Subsurface scattering amount. \nYou can also adjust the subsurface color by selecting it in the color picker"); subsurfaceScatteringSlider.SetSize(XMFLOAT2(wid, hei)); subsurfaceScatteringSlider.SetPos(XMFLOAT2(x, y += step)); - subsurfaceScatteringSlider.OnSlide(forEachSelected([&] (auto material, auto args) { + subsurfaceScatteringSlider.OnSlide(forEachSelected([] (auto material, auto args) { material->SetSubsurfaceScatteringAmount(args.fValue); })); AddWidget(&subsurfaceScatteringSlider); @@ -416,7 +416,7 @@ void MaterialWindow::Create(EditorComponent* _editor) texAnimFrameRateSlider.SetTooltip("Adjust the texture animation frame rate (frames per second). Any value above 0 will make the material dynamic."); texAnimFrameRateSlider.SetSize(XMFLOAT2(wid, hei)); texAnimFrameRateSlider.SetPos(XMFLOAT2(x, y += step)); - texAnimFrameRateSlider.OnSlide(forEachSelected([&] (auto material, auto args) { + texAnimFrameRateSlider.OnSlide(forEachSelected([] (auto material, auto args) { material->texAnimFrameRate = args.fValue; })); AddWidget(&texAnimFrameRateSlider); @@ -425,7 +425,7 @@ void MaterialWindow::Create(EditorComponent* _editor) texAnimDirectionSliderU.SetTooltip("Adjust the texture animation speed along the U direction in texture space."); texAnimDirectionSliderU.SetSize(XMFLOAT2(wid, hei)); texAnimDirectionSliderU.SetPos(XMFLOAT2(x, y += step)); - texAnimDirectionSliderU.OnSlide(forEachSelected([&] (auto material, auto args) { + texAnimDirectionSliderU.OnSlide(forEachSelected([] (auto material, auto args) { material->texAnimDirection.x = args.fValue; })); AddWidget(&texAnimDirectionSliderU); @@ -434,7 +434,7 @@ void MaterialWindow::Create(EditorComponent* _editor) texAnimDirectionSliderV.SetTooltip("Adjust the texture animation speed along the V direction in texture space."); texAnimDirectionSliderV.SetSize(XMFLOAT2(wid, hei)); texAnimDirectionSliderV.SetPos(XMFLOAT2(x, y += step)); - texAnimDirectionSliderV.OnSlide(forEachSelected([&] (auto material, auto args) { + texAnimDirectionSliderV.OnSlide(forEachSelected([] (auto material, auto args) { material->texAnimDirection.y = args.fValue; })); AddWidget(&texAnimDirectionSliderV); @@ -443,7 +443,7 @@ void MaterialWindow::Create(EditorComponent* _editor) texMulSliderX.SetTooltip("Adjust the texture mapping size."); texMulSliderX.SetSize(XMFLOAT2(wid, hei)); texMulSliderX.SetPos(XMFLOAT2(x, y += step)); - texMulSliderX.OnSlide(forEachSelected([&] (auto material, auto args) { + texMulSliderX.OnSlide(forEachSelected([] (auto material, auto args) { material->SetDirty(); material->texMulAdd.x = args.fValue; })); @@ -453,7 +453,7 @@ void MaterialWindow::Create(EditorComponent* _editor) texMulSliderY.SetTooltip("Adjust the texture mapping size."); texMulSliderY.SetSize(XMFLOAT2(wid, hei)); texMulSliderY.SetPos(XMFLOAT2(x, y += step)); - texMulSliderY.OnSlide(forEachSelected([&] (auto material, auto args) { + texMulSliderY.OnSlide(forEachSelected([] (auto material, auto args) { material->SetDirty(); material->texMulAdd.y = args.fValue; })); @@ -464,7 +464,7 @@ void MaterialWindow::Create(EditorComponent* _editor) sheenRoughnessSlider.SetTooltip("This affects roughness of sheen layer for cloth shading."); sheenRoughnessSlider.SetSize(XMFLOAT2(wid, hei)); sheenRoughnessSlider.SetPos(XMFLOAT2(x, y += step)); - sheenRoughnessSlider.OnSlide(forEachSelected([&] (auto material, auto args) { + sheenRoughnessSlider.OnSlide(forEachSelected([] (auto material, auto args) { material->SetSheenRoughness(args.fValue); })); AddWidget(&sheenRoughnessSlider); @@ -473,7 +473,7 @@ void MaterialWindow::Create(EditorComponent* _editor) clearcoatSlider.SetTooltip("This affects clearcoat layer blending."); clearcoatSlider.SetSize(XMFLOAT2(wid, hei)); clearcoatSlider.SetPos(XMFLOAT2(x, y += step)); - clearcoatSlider.OnSlide(forEachSelected([&] (auto material, auto args) { + clearcoatSlider.OnSlide(forEachSelected([] (auto material, auto args) { material->SetClearcoatFactor(args.fValue); })); AddWidget(&clearcoatSlider); @@ -482,7 +482,7 @@ void MaterialWindow::Create(EditorComponent* _editor) clearcoatRoughnessSlider.SetTooltip("This affects roughness of clear coat layer."); clearcoatRoughnessSlider.SetSize(XMFLOAT2(wid, hei)); clearcoatRoughnessSlider.SetPos(XMFLOAT2(x, y += step)); - clearcoatRoughnessSlider.OnSlide(forEachSelected([&] (auto material, auto args) { + clearcoatRoughnessSlider.OnSlide(forEachSelected([] (auto material, auto args) { material->SetClearcoatRoughness(args.fValue); })); AddWidget(&clearcoatRoughnessSlider); @@ -491,56 +491,56 @@ void MaterialWindow::Create(EditorComponent* _editor) blendTerrainSlider.SetTooltip("Blend with terrain height."); blendTerrainSlider.SetSize(XMFLOAT2(wid, hei)); blendTerrainSlider.SetPos(XMFLOAT2(x, y += step)); - blendTerrainSlider.OnSlide(forEachSelected([&] (auto material, auto args) { + blendTerrainSlider.OnSlide(forEachSelected([] (auto material, auto args) { material->SetBlendWithTerrainHeight(args.fValue); })); AddWidget(&blendTerrainSlider); interiorScaleXSlider.Create(1, 10, 1, 1000, "Interior Scale X: "); interiorScaleXSlider.SetTooltip("Set the cubemap scale for the interior mapping (if material uses interior mapping shader)"); - interiorScaleXSlider.OnSlide(forEachSelected([&] (auto material, auto args) { + interiorScaleXSlider.OnSlide(forEachSelected([] (auto material, auto args) { material->SetInteriorMappingScale(XMFLOAT3(args.fValue, material->interiorMappingScale.y, material->interiorMappingScale.z)); })); AddWidget(&interiorScaleXSlider); interiorScaleYSlider.Create(1, 10, 1, 1000, "Interior Scale Y: "); interiorScaleYSlider.SetTooltip("Set the cubemap scale for the interior mapping (if material uses interior mapping shader)"); - interiorScaleYSlider.OnSlide(forEachSelected([&] (auto material, auto args) { + interiorScaleYSlider.OnSlide(forEachSelected([] (auto material, auto args) { material->SetInteriorMappingScale(XMFLOAT3(material->interiorMappingScale.x, args.fValue, material->interiorMappingScale.z)); })); AddWidget(&interiorScaleYSlider); interiorScaleZSlider.Create(1, 10, 1, 1000, "Interior Scale Z: "); interiorScaleZSlider.SetTooltip("Set the cubemap scale for the interior mapping (if material uses interior mapping shader)"); - interiorScaleZSlider.OnSlide(forEachSelected([&] (auto material, auto args) { + interiorScaleZSlider.OnSlide(forEachSelected([] (auto material, auto args) { material->SetInteriorMappingScale(XMFLOAT3(material->interiorMappingScale.x, material->interiorMappingScale.y, args.fValue)); })); AddWidget(&interiorScaleZSlider); interiorOffsetXSlider.Create(-10, 10, 0, 2000, "Interior Offset X: "); interiorOffsetXSlider.SetTooltip("Set the cubemap offset for the interior mapping (if material uses interior mapping shader)"); - interiorOffsetXSlider.OnSlide(forEachSelected([&] (auto material, auto args) { + interiorOffsetXSlider.OnSlide(forEachSelected([] (auto material, auto args) { material->SetInteriorMappingOffset(XMFLOAT3(args.fValue, material->interiorMappingOffset.y, material->interiorMappingOffset.z)); })); AddWidget(&interiorOffsetXSlider); interiorOffsetYSlider.Create(-10, 10, 0, 2000, "Interior Offset Y: "); interiorOffsetYSlider.SetTooltip("Set the cubemap offset for the interior mapping (if material uses interior mapping shader)"); - interiorOffsetYSlider.OnSlide(forEachSelected([&] (auto material, auto args) { + interiorOffsetYSlider.OnSlide(forEachSelected([] (auto material, auto args) { material->SetInteriorMappingOffset(XMFLOAT3(material->interiorMappingOffset.x, args.fValue, material->interiorMappingOffset.z)); })); AddWidget(&interiorOffsetYSlider); interiorOffsetZSlider.Create(-10, 10, 0, 2000, "Interior Offset Z: "); interiorOffsetZSlider.SetTooltip("Set the cubemap offset for the interior mapping (if material uses interior mapping shader)"); - interiorOffsetZSlider.OnSlide(forEachSelected([&] (auto material, auto args) { + interiorOffsetZSlider.OnSlide(forEachSelected([] (auto material, auto args) { material->SetInteriorMappingOffset(XMFLOAT3(material->interiorMappingOffset.x, material->interiorMappingOffset.y, args.fValue)); })); AddWidget(&interiorOffsetZSlider); interiorRotationSlider.Create(0, 360, 0, 360, "Interior Rotation: "); interiorRotationSlider.SetTooltip("Set the cubemap horizontal rotation for the interior mapping (if material uses interior mapping shader)"); - interiorRotationSlider.OnSlide(forEachSelected([&] (auto material, auto args) { + interiorRotationSlider.OnSlide(forEachSelected([] (auto material, auto args) { float radians = wi::math::DegreesToRadians(args.fValue); material->SetInteriorMappingRotation(radians); })); @@ -585,7 +585,7 @@ void MaterialWindow::Create(EditorComponent* _editor) colorPicker.SetPos(XMFLOAT2(10, y += step)); colorPicker.SetVisible(true); colorPicker.SetEnabled(true); - colorPicker.OnColorChanged(forEachSelected([&] (auto material, auto args) { + colorPicker.OnColorChanged(forEachSelected([this] (auto material, auto args) { switch (colorComboBox.GetSelected()) { default: @@ -823,7 +823,7 @@ void MaterialWindow::Create(EditorComponent* _editor) textureSlotUvsetField.SetTooltip("uv set number"); textureSlotUvsetField.SetPos(XMFLOAT2(x + textureSlotLabel.GetScale().x + 2, y)); textureSlotUvsetField.SetSize(XMFLOAT2(hei, hei)); - textureSlotUvsetField.OnInputAccepted(forEachSelected([&] (auto material, auto args) { + textureSlotUvsetField.OnInputAccepted(forEachSelected([this] (auto material, auto args) { int slot = textureSlotComboBox.GetSelected(); material->textures[slot].uvset = (uint32_t)args.iValue; })); diff --git a/Editor/MeshWindow.cpp b/Editor/MeshWindow.cpp index ad41e6212..acf725ab7 100644 --- a/Editor/MeshWindow.cpp +++ b/Editor/MeshWindow.cpp @@ -137,8 +137,8 @@ void MeshWindow::Create(EditorComponent* _editor) }); AddWidget(&subsetLastButton); - auto forEachSelected = [&] (auto func) { - return [&, func] (auto args) { + auto forEachSelected = [this] (auto func) { + return [this, func] (auto args) { wi::scene::Scene& scene = editor->GetCurrentScene(); for (auto& x : editor->translator.selected) { @@ -151,28 +151,28 @@ void MeshWindow::Create(EditorComponent* _editor) doubleSidedCheckBox.Create("Double Sided: "); doubleSidedCheckBox.SetTooltip("If enabled, the inside of the mesh will be visible."); - doubleSidedCheckBox.OnClick(forEachSelected([&] (auto mesh, auto args) { + doubleSidedCheckBox.OnClick(forEachSelected([] (auto mesh, auto args) { mesh->SetDoubleSided(args.bValue); })); AddWidget(&doubleSidedCheckBox); doubleSidedShadowCheckBox.Create("Double Sided Shadow: "); doubleSidedShadowCheckBox.SetTooltip("If enabled, the shadow rendering will be forced to use double sided mode.\nThis can help fix some shadow artifacts without enabling double sided mode for the main rendering of this mesh."); - doubleSidedShadowCheckBox.OnClick(forEachSelected([&] (auto mesh, auto args) { + doubleSidedShadowCheckBox.OnClick(forEachSelected([] (auto mesh, auto args) { mesh->SetDoubleSidedShadow(args.bValue); })); AddWidget(&doubleSidedShadowCheckBox); bvhCheckBox.Create("Enable BVH: "); bvhCheckBox.SetTooltip("Whether to generate BVH (Bounding Volume Hierarchy) for the mesh or not.\nBVH will be used to optimize intersections with the mesh at an additional memory cost.\nIt is recommended to use a BVH for high polygon count meshes that will be used for intersections.\nThis CPU BVH does not support skinned or morphed geometry."); - bvhCheckBox.OnClick(forEachSelected([&] (auto mesh, auto args) { + bvhCheckBox.OnClick(forEachSelected([] (auto mesh, auto args) { mesh->SetBVHEnabled(args.bValue); })); AddWidget(&bvhCheckBox); quantizeCheckBox.Create("Quantization Disabled: "); quantizeCheckBox.SetTooltip("Disable quantization of vertex positions if you notice inaccuracy errors with UNORM position formats."); - quantizeCheckBox.OnClick(forEachSelected([&] (auto mesh, auto args) { + quantizeCheckBox.OnClick(forEachSelected([] (auto mesh, auto args) { mesh->SetQuantizedPositionsDisabled(args.bValue); mesh->CreateRenderData(); if (!mesh->BLASes.empty()) @@ -213,7 +213,7 @@ void MeshWindow::Create(EditorComponent* _editor) tessellationFactorSlider.Create(0, 100, 0, 10000, "Tess Factor: "); tessellationFactorSlider.SetTooltip("Set the dynamic tessellation amount. Tessellation should be enabled in the Renderer window and your GPU must support it!"); - tessellationFactorSlider.OnSlide(forEachSelected([&] (auto mesh, auto args) { + tessellationFactorSlider.OnSlide(forEachSelected([] (auto mesh, auto args) { mesh->tessellationFactor = args.fValue; })); AddWidget(&tessellationFactorSlider); @@ -240,8 +240,8 @@ void MeshWindow::Create(EditorComponent* _editor) }); AddWidget(&instanceSelectButton); - auto changeSelectedMesh = [&] (auto func) { - return [&] (auto args) { + auto changeSelectedMesh = [this] (auto func) { + return [this, func] (auto args) { wi::scene::Scene& scene = editor->GetCurrentScene(); wi::unordered_set visited_meshes; // fix double visit (straight mesh + object->mesh) for (auto& x : editor->translator.selected) @@ -748,7 +748,7 @@ void MeshWindow::Create(EditorComponent* _editor) morphTargetSlider.Create(0, 1, 0, 100000, "Weight: "); morphTargetSlider.SetTooltip("Set the weight for morph target"); - morphTargetSlider.OnSlide(forEachSelected([&] (auto mesh, auto args) { + morphTargetSlider.OnSlide(forEachSelected([this] (auto mesh, auto args) { if (morphTargetCombo.GetSelected() < (int)mesh->morph_targets.size()) { mesh->morph_targets[morphTargetCombo.GetSelected()].weight = args.fValue; @@ -758,8 +758,8 @@ void MeshWindow::Create(EditorComponent* _editor) lodgenButton.Create("LOD Gen"); lodgenButton.SetTooltip("Generate LODs (levels of detail)."); - lodgenButton.OnClick([=] (auto args) { - forEachSelected([&] (auto mesh, auto args) { + lodgenButton.OnClick([this, forEachSelected] (auto args) { + forEachSelected([this] (auto mesh, auto args) { if (mesh->subsets_per_lod == 0) { // if there were no lods before, record the subset count without lods: diff --git a/Editor/MetadataWindow.cpp b/Editor/MetadataWindow.cpp index 109d00897..df3d0028d 100644 --- a/Editor/MetadataWindow.cpp +++ b/Editor/MetadataWindow.cpp @@ -24,8 +24,8 @@ void MetadataWindow::Create(EditorComponent* _editor) editor->componentsWnd.RefreshEntityTree(); }); - auto forEachSelected = [&] (auto func) { - return [&, func] (auto args) { + auto forEachSelected = [this] (auto func) { + return [this, func] (auto args) { wi::scene::Scene& scene = editor->GetCurrentScene(); for (auto& x : editor->translator.selected) { @@ -46,7 +46,7 @@ void MetadataWindow::Create(EditorComponent* _editor) presetCombo.AddItem("Npc", (uint64_t)MetadataComponent::Preset::NPC); presetCombo.AddItem("Pickup", (uint64_t)MetadataComponent::Preset::Pickup); presetCombo.AddItem("Vehicle", (uint64_t)MetadataComponent::Preset::Vehicle); - presetCombo.OnSelect(forEachSelected([&] (auto metadata, auto args) { + presetCombo.OnSelect(forEachSelected([] (auto metadata, auto args) { metadata->preset = (MetadataComponent::Preset)args.userdata; })); AddWidget(&presetCombo); @@ -148,8 +148,8 @@ void MetadataWindow::RefreshEntries() ); - auto forEachSelectedWithRefresh = [&] (auto name, auto func) { - return [&, func] (auto args) { + auto forEachSelectedWithRefresh = [this] (auto name, auto func) { + return [this, func, name] (auto args) { wi::scene::Scene& scene = editor->GetCurrentScene(); for (auto& x : editor->translator.selected) { @@ -172,7 +172,7 @@ void MetadataWindow::RefreshEntries() Entry& entry = entries.emplace_back(); entry.name.Create(""); entry.name.SetText(name); - entry.name.OnInputAccepted(forEachSelectedWithRefresh(name, [&] (auto metadata, auto args) { + entry.name.OnInputAccepted(forEachSelectedWithRefresh(name, [&name] (auto metadata, auto args) { if (!metadata->bool_values.has(name)) return; auto value = metadata->bool_values.get(name); @@ -185,7 +185,7 @@ void MetadataWindow::RefreshEntries() entry.check.Create(""); entry.check.SetText(" = (bool) "); entry.check.SetCheck(metadata->bool_values.get(name)); - entry.check.OnClick(forEachSelectedWithRefresh(name, [&] (auto metadata, auto args) { + entry.check.OnClick(forEachSelectedWithRefresh(name, [&name] (auto metadata, auto args) { metadata->bool_values.set(name, args.bValue); })); AddWidget(&entry.check); @@ -193,7 +193,7 @@ void MetadataWindow::RefreshEntries() entry.remove.Create(""); entry.remove.SetText("X"); entry.remove.SetSize(XMFLOAT2(entry.remove.GetSize().y, entry.remove.GetSize().y)); - entry.remove.OnClick(forEachSelectedWithRefresh(name, [&] (auto metadata, auto args) { + entry.remove.OnClick(forEachSelectedWithRefresh(name, [&name] (auto metadata, auto args) { metadata->bool_values.erase(name); })); AddWidget(&entry.remove); @@ -204,7 +204,7 @@ void MetadataWindow::RefreshEntries() Entry& entry = entries.emplace_back(); entry.name.Create(""); entry.name.SetText(name); - entry.name.OnInputAccepted(forEachSelectedWithRefresh(name, [&] (auto metadata, auto args) { + entry.name.OnInputAccepted(forEachSelectedWithRefresh(name, [&name] (auto metadata, auto args) { auto value = metadata->int_values.get(name); metadata->int_values.erase(name); metadata->int_values.set(args.sValue, value); @@ -216,7 +216,7 @@ void MetadataWindow::RefreshEntries() entry.value.SetDescription(" = (int) "); entry.value.SetSize(XMFLOAT2(60, entry.value.GetSize().y)); entry.value.SetValue(metadata->int_values.get(name)); - entry.value.OnInputAccepted(forEachSelectedWithRefresh(name, [&] (auto metadata, auto args) { + entry.value.OnInputAccepted(forEachSelectedWithRefresh(name, [&name] (auto metadata, auto args) { metadata->int_values.set(name, args.iValue); })); AddWidget(&entry.value); @@ -224,7 +224,7 @@ void MetadataWindow::RefreshEntries() entry.remove.Create(""); entry.remove.SetText("X"); entry.remove.SetSize(XMFLOAT2(entry.remove.GetSize().y, entry.remove.GetSize().y)); - entry.remove.OnClick(forEachSelectedWithRefresh(name, [&] (auto metadata, auto args) { + entry.remove.OnClick(forEachSelectedWithRefresh(name, [&name] (auto metadata, auto args) { metadata->int_values.erase(name); })); AddWidget(&entry.remove); @@ -235,7 +235,7 @@ void MetadataWindow::RefreshEntries() Entry& entry = entries.emplace_back(); entry.name.Create(""); entry.name.SetText(name); - entry.name.OnInputAccepted(forEachSelectedWithRefresh(name, [&] (auto metadata, auto args) { + entry.name.OnInputAccepted(forEachSelectedWithRefresh(name, [&name] (auto metadata, auto args) { auto value = metadata->float_values.get(name); metadata->float_values.erase(name); metadata->float_values.set(args.sValue, value); @@ -247,7 +247,7 @@ void MetadataWindow::RefreshEntries() entry.value.SetDescription(" = (float) "); entry.value.SetSize(XMFLOAT2(60, entry.value.GetSize().y)); entry.value.SetValue(metadata->float_values.get(name)); - entry.value.OnInputAccepted(forEachSelectedWithRefresh(name, [&] (auto metadata, auto args) { + entry.value.OnInputAccepted(forEachSelectedWithRefresh(name, [&name] (auto metadata, auto args) { metadata->float_values.set(name, args.fValue); })); AddWidget(&entry.value); @@ -255,7 +255,7 @@ void MetadataWindow::RefreshEntries() entry.remove.Create(""); entry.remove.SetText("X"); entry.remove.SetSize(XMFLOAT2(entry.remove.GetSize().y, entry.remove.GetSize().y)); - entry.remove.OnClick(forEachSelectedWithRefresh(name, [&] (auto metadata, auto args) { + entry.remove.OnClick(forEachSelectedWithRefresh(name, [&name] (auto metadata, auto args) { metadata->float_values.erase(name); })); AddWidget(&entry.remove); @@ -266,7 +266,7 @@ void MetadataWindow::RefreshEntries() Entry& entry = entries.emplace_back(); entry.name.Create(""); entry.name.SetText(name); - entry.name.OnInputAccepted(forEachSelectedWithRefresh(name, [&] (auto metadata, auto args) { + entry.name.OnInputAccepted(forEachSelectedWithRefresh(name, [&name] (auto metadata, auto args) { auto value = metadata->string_values.get(name); metadata->string_values.erase(name); metadata->string_values.set(args.sValue, value); @@ -278,7 +278,7 @@ void MetadataWindow::RefreshEntries() entry.value.SetDescription(" = (string) "); entry.value.SetSize(XMFLOAT2(120, entry.value.GetSize().y)); entry.value.SetValue(metadata->string_values.get(name)); - entry.value.OnInputAccepted(forEachSelectedWithRefresh(name, [&] (auto metadata, auto args) { + entry.value.OnInputAccepted(forEachSelectedWithRefresh(name, [&name] (auto metadata, auto args) { metadata->string_values.set(name, args.sValue); })); AddWidget(&entry.value); @@ -286,7 +286,7 @@ void MetadataWindow::RefreshEntries() entry.remove.Create(""); entry.remove.SetText("X"); entry.remove.SetSize(XMFLOAT2(entry.remove.GetSize().y, entry.remove.GetSize().y)); - entry.remove.OnClick(forEachSelectedWithRefresh(name, [&] (auto metadata, auto args) { + entry.remove.OnClick(forEachSelectedWithRefresh(name, [&name] (auto metadata, auto args) { metadata->string_values.erase(name); })); AddWidget(&entry.remove); diff --git a/Editor/ObjectWindow.cpp b/Editor/ObjectWindow.cpp index 0b5ca6604..8ae00dbc8 100644 --- a/Editor/ObjectWindow.cpp +++ b/Editor/ObjectWindow.cpp @@ -365,8 +365,8 @@ void ObjectWindow::Create(EditorComponent* _editor) }); AddWidget(&meshCombo); - auto forEachSelected = [&] (auto func) { - return [&, func] (auto args) { + auto forEachSelected = [this] (auto func) { + return [this, func] (auto args) { wi::scene::Scene& scene = editor->GetCurrentScene(); for (auto& x : editor->translator.selected) { @@ -383,7 +383,7 @@ void ObjectWindow::Create(EditorComponent* _editor) renderableCheckBox.SetSize(XMFLOAT2(hei, hei)); renderableCheckBox.SetPos(XMFLOAT2(x, y)); renderableCheckBox.SetCheck(true); - renderableCheckBox.OnClick(forEachSelected([&] (auto object, auto args) { + renderableCheckBox.OnClick(forEachSelected([] (auto object, auto args) { object->SetRenderable(args.bValue); })); AddWidget(&renderableCheckBox); @@ -393,7 +393,7 @@ void ObjectWindow::Create(EditorComponent* _editor) shadowCheckBox.SetSize(XMFLOAT2(hei, hei)); shadowCheckBox.SetPos(XMFLOAT2(x, y += step)); shadowCheckBox.SetCheck(true); - shadowCheckBox.OnClick(forEachSelected([&] (auto object, auto args) { + shadowCheckBox.OnClick(forEachSelected([] (auto object, auto args) { object->SetCastShadow(args.bValue); })); AddWidget(&shadowCheckBox); @@ -403,7 +403,7 @@ void ObjectWindow::Create(EditorComponent* _editor) navmeshCheckBox.SetSize(XMFLOAT2(hei, hei)); navmeshCheckBox.SetPos(XMFLOAT2(x, y += step)); navmeshCheckBox.SetCheck(true); - navmeshCheckBox.OnClick(forEachSelected([&] (auto object, auto args) { + navmeshCheckBox.OnClick(forEachSelected([this] (auto object, auto args) { if (args.bValue) { object->filterMask |= wi::enums::FILTER_NAVIGATION_MESH; @@ -427,7 +427,7 @@ void ObjectWindow::Create(EditorComponent* _editor) foregroundCheckBox.SetSize(XMFLOAT2(hei, hei)); foregroundCheckBox.SetPos(XMFLOAT2(x, y += step)); foregroundCheckBox.SetCheck(true); - foregroundCheckBox.OnClick(forEachSelected([&] (auto object, auto args) { + foregroundCheckBox.OnClick(forEachSelected([] (auto object, auto args) { object->SetForeground(args.bValue); })); AddWidget(&foregroundCheckBox); @@ -437,7 +437,7 @@ void ObjectWindow::Create(EditorComponent* _editor) notVisibleInMainCameraCheckBox.SetSize(XMFLOAT2(hei, hei)); notVisibleInMainCameraCheckBox.SetPos(XMFLOAT2(x, y += step)); notVisibleInMainCameraCheckBox.SetCheck(true); - notVisibleInMainCameraCheckBox.OnClick(forEachSelected([&] (auto object, auto args) { + notVisibleInMainCameraCheckBox.OnClick(forEachSelected([] (auto object, auto args) { object->SetNotVisibleInMainCamera(args.bValue); })); AddWidget(¬VisibleInMainCameraCheckBox); @@ -447,7 +447,7 @@ void ObjectWindow::Create(EditorComponent* _editor) notVisibleInReflectionsCheckBox.SetSize(XMFLOAT2(hei, hei)); notVisibleInReflectionsCheckBox.SetPos(XMFLOAT2(x, y += step)); notVisibleInReflectionsCheckBox.SetCheck(true); - notVisibleInReflectionsCheckBox.OnClick(forEachSelected([&] (auto object, auto args) { + notVisibleInReflectionsCheckBox.OnClick(forEachSelected([] (auto object, auto args) { object->SetNotVisibleInReflections(args.bValue); })); AddWidget(¬VisibleInReflectionsCheckBox); @@ -457,7 +457,7 @@ void ObjectWindow::Create(EditorComponent* _editor) wetmapCheckBox.SetSize(XMFLOAT2(hei, hei)); wetmapCheckBox.SetPos(XMFLOAT2(x, y += step)); wetmapCheckBox.SetCheck(true); - wetmapCheckBox.OnClick(forEachSelected([&] (auto object, auto args) { + wetmapCheckBox.OnClick(forEachSelected([] (auto object, auto args) { object->SetWetmapEnabled(args.bValue); })); AddWidget(&wetmapCheckBox); @@ -466,7 +466,7 @@ void ObjectWindow::Create(EditorComponent* _editor) ditherSlider.SetTooltip("Adjust transparency of the object. Opaque materials will use dithered transparency in this case!"); ditherSlider.SetSize(XMFLOAT2(wid, hei)); ditherSlider.SetPos(XMFLOAT2(x, y += step)); - ditherSlider.OnSlide(forEachSelected([&] (auto object, auto args) { + ditherSlider.OnSlide(forEachSelected([] (auto object, auto args) { object->color.w = 1 - args.fValue; })); AddWidget(&ditherSlider); @@ -475,7 +475,7 @@ void ObjectWindow::Create(EditorComponent* _editor) alphaRefSlider.SetTooltip("Adjust alpha ref per instance.\nThis is an additional value on top of material's alpha ref, used for alpha testing (alpha cutout)."); alphaRefSlider.SetSize(XMFLOAT2(wid, hei)); alphaRefSlider.SetPos(XMFLOAT2(x, y += step)); - alphaRefSlider.OnSlide(forEachSelected([&] (auto object, auto args) { + alphaRefSlider.OnSlide(forEachSelected([] (auto object, auto args) { object->alphaRef = args.fValue; })); AddWidget(&alphaRefSlider); @@ -484,7 +484,7 @@ void ObjectWindow::Create(EditorComponent* _editor) rimHighlightIntesitySlider.SetTooltip("Strength of the rim highlight color."); rimHighlightIntesitySlider.SetSize(XMFLOAT2(wid, hei)); rimHighlightIntesitySlider.SetPos(XMFLOAT2(x, y += step)); - rimHighlightIntesitySlider.OnSlide(forEachSelected([&] (auto object, auto args) { + rimHighlightIntesitySlider.OnSlide(forEachSelected([] (auto object, auto args) { object->rimHighlightColor.w = args.fValue; })); AddWidget(&rimHighlightIntesitySlider); @@ -493,7 +493,7 @@ void ObjectWindow::Create(EditorComponent* _editor) rimHighlightFalloffSlider.SetTooltip("Rim falloff power of the rim highlight effect."); rimHighlightFalloffSlider.SetSize(XMFLOAT2(wid, hei)); rimHighlightFalloffSlider.SetPos(XMFLOAT2(x, y += step)); - rimHighlightFalloffSlider.OnSlide(forEachSelected([&] (auto object, auto args) { + rimHighlightFalloffSlider.OnSlide(forEachSelected([] (auto object, auto args) { object->rimHighlightFalloff = args.fValue; })); AddWidget(&rimHighlightFalloffSlider); @@ -502,7 +502,7 @@ void ObjectWindow::Create(EditorComponent* _editor) cascadeMaskSlider.SetTooltip("How many shadow cascades to skip when rendering this object into shadow maps? (0: skip none, it will be in all cascades, 1: skip first (biggest cascade), ...etc..."); cascadeMaskSlider.SetSize(XMFLOAT2(wid, hei)); cascadeMaskSlider.SetPos(XMFLOAT2(x, y += step)); - cascadeMaskSlider.OnSlide(forEachSelected([&] (auto object, auto args) { + cascadeMaskSlider.OnSlide(forEachSelected([] (auto object, auto args) { object->cascadeMask = (uint32_t)args.iValue; })); AddWidget(&cascadeMaskSlider); @@ -511,7 +511,7 @@ void ObjectWindow::Create(EditorComponent* _editor) lodSlider.SetTooltip("Increase or decrease the LOD selection"); lodSlider.SetSize(XMFLOAT2(wid, hei)); lodSlider.SetPos(XMFLOAT2(x, y += step)); - lodSlider.OnSlide(forEachSelected([&] (auto object, auto args) { + lodSlider.OnSlide(forEachSelected([] (auto object, auto args) { object->lod_bias = args.fValue; })); AddWidget(&lodSlider); @@ -520,7 +520,7 @@ void ObjectWindow::Create(EditorComponent* _editor) drawdistanceSlider.SetTooltip("Specify the draw distance of the object"); drawdistanceSlider.SetSize(XMFLOAT2(wid, hei)); drawdistanceSlider.SetPos(XMFLOAT2(x, y += step)); - drawdistanceSlider.OnSlide(forEachSelected([&] (auto object, auto args) { + drawdistanceSlider.OnSlide(forEachSelected([] (auto object, auto args) { object->draw_distance = args.fValue; })); AddWidget(&drawdistanceSlider); @@ -529,7 +529,7 @@ void ObjectWindow::Create(EditorComponent* _editor) sortPrioritySlider.SetTooltip("Set to larger value to draw earlier (most useful for transparents with alpha blending, if the sorting order by distance is not good enough)"); sortPrioritySlider.SetSize(XMFLOAT2(wid, hei)); sortPrioritySlider.SetPos(XMFLOAT2(x, y += step)); - sortPrioritySlider.OnSlide(forEachSelected([&] (auto object, auto args) { + sortPrioritySlider.OnSlide(forEachSelected([] (auto object, auto args) { object->sort_priority = (uint8_t)args.iValue; })); AddWidget(&sortPrioritySlider); @@ -558,7 +558,7 @@ void ObjectWindow::Create(EditorComponent* _editor) lightmapBlockCompressionCheckBox.SetSize(XMFLOAT2(hei, hei)); lightmapBlockCompressionCheckBox.SetPos(XMFLOAT2(x, y += step)); lightmapBlockCompressionCheckBox.SetCheck(true); - lightmapBlockCompressionCheckBox.OnClick(forEachSelected([&] (auto object, auto args) { + lightmapBlockCompressionCheckBox.OnClick(forEachSelected([] (auto object, auto args) { object->SetLightmapDisableBlockCompression(!args.bValue); })); AddWidget(&lightmapBlockCompressionCheckBox); @@ -658,7 +658,7 @@ void ObjectWindow::Create(EditorComponent* _editor) stopLightmapGenButton.SetTooltip("Stop the lightmap rendering and save the lightmap.\nIf denoiser is enabled, this is the point at which lightmap will be denoised, which could take a while."); stopLightmapGenButton.SetPos(XMFLOAT2(x, y += step)); stopLightmapGenButton.SetSize(XMFLOAT2(wid, hei)); - stopLightmapGenButton.OnClick(forEachSelected([&] (auto object, auto args) { + stopLightmapGenButton.OnClick(forEachSelected([] (auto object, auto args) { object->SetLightmapRenderRequest(false); object->SaveLightmap(); })); @@ -668,7 +668,7 @@ void ObjectWindow::Create(EditorComponent* _editor) clearLightmapButton.SetTooltip("Clear the lightmap from this object."); clearLightmapButton.SetPos(XMFLOAT2(x, y += step)); clearLightmapButton.SetSize(XMFLOAT2(wid, hei)); - clearLightmapButton.OnClick(forEachSelected([&] (auto object, auto args) { + clearLightmapButton.OnClick(forEachSelected([] (auto object, auto args) { object->ClearLightmap(); })); AddWidget(&clearLightmapButton); diff --git a/Editor/RigidBodyWindow.cpp b/Editor/RigidBodyWindow.cpp index 737073fe0..ed4cefb45 100644 --- a/Editor/RigidBodyWindow.cpp +++ b/Editor/RigidBodyWindow.cpp @@ -25,8 +25,8 @@ void RigidBodyWindow::Create(EditorComponent* _editor) editor->componentsWnd.RefreshEntityTree(); }); - auto forEachSelectedPhysicsComponent = [&](auto /* void(RigidBodyPhysicsComponent*, wi::gui::EventArgs) */ func) { - return [&, func](wi::gui::EventArgs args) { + auto forEachSelectedPhysicsComponent = [this](auto /* void(RigidBodyPhysicsComponent*, wi::gui::EventArgs) */ func) { + return [this, func](wi::gui::EventArgs args) { wi::scene::Scene& scene = editor->GetCurrentScene(); for (auto& x : editor->translator.selected) { @@ -39,8 +39,8 @@ void RigidBodyWindow::Create(EditorComponent* _editor) }; }; - auto forEachSelectedPhysicsComponentWithRefresh = [&](auto /* void(RigidBodyPhysicsComponent*, wi::gui::EventArgs) */ func) { - return forEachSelectedPhysicsComponent([&](auto physicscomponent, auto args) { + auto forEachSelectedPhysicsComponentWithRefresh = [this, forEachSelectedPhysicsComponent](auto /* void(RigidBodyPhysicsComponent*, wi::gui::EventArgs) */ func) { + return forEachSelectedPhysicsComponent([this, func](auto physicscomponent, auto args) { func(physicscomponent, args); physicscomponent->SetRefreshParametersNeeded(); }); @@ -72,7 +72,7 @@ void RigidBodyWindow::Create(EditorComponent* _editor) AddWidget(&collisionShapeComboBox); XSlider.Create(0, 10, 1, 100000, "XSlider"); - XSlider.OnSlide(forEachSelectedPhysicsComponent([&](auto physicscomponent, auto args) { + XSlider.OnSlide(forEachSelectedPhysicsComponent([](auto physicscomponent, auto args) { switch (physicscomponent->shape) { default: @@ -94,7 +94,7 @@ void RigidBodyWindow::Create(EditorComponent* _editor) AddWidget(&XSlider); YSlider.Create(0, 10, 1, 100000, "YSlider"); - YSlider.OnSlide(forEachSelectedPhysicsComponent([&](auto physicsComponent, auto args) { + YSlider.OnSlide(forEachSelectedPhysicsComponent([](auto physicsComponent, auto args) { switch (physicsComponent->shape) { default: @@ -112,7 +112,7 @@ void RigidBodyWindow::Create(EditorComponent* _editor) AddWidget(&YSlider); ZSlider.Create(0, 10, 1, 100000, "ZSlider"); - ZSlider.OnSlide(forEachSelectedPhysicsComponent([&](auto physicscomponent, auto args) { + ZSlider.OnSlide(forEachSelectedPhysicsComponent([](auto physicscomponent, auto args) { switch (physicscomponent->shape) { default: @@ -128,49 +128,49 @@ void RigidBodyWindow::Create(EditorComponent* _editor) massSlider.Create(0, 10, 1, 100000, "Mass: "); massSlider.SetTooltip("Set the mass amount for the physics engine."); - massSlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([&](auto physicscomponent, auto args) { + massSlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([](auto physicscomponent, auto args) { physicscomponent->mass = args.fValue; })); AddWidget(&massSlider); frictionSlider.Create(0, 1, 0.5f, 100000, "Friction: "); frictionSlider.SetTooltip("Set the friction amount for the physics engine."); - frictionSlider.OnSlide(forEachSelectedPhysicsComponent([&](auto physicscomponent, auto args) { + frictionSlider.OnSlide(forEachSelectedPhysicsComponent([](auto physicscomponent, auto args) { physicscomponent->friction = args.fValue; })); AddWidget(&frictionSlider); restitutionSlider.Create(0, 1, 0, 100000, "Restitution: "); restitutionSlider.SetTooltip("Set the restitution amount for the physics engine."); - restitutionSlider.OnSlide(forEachSelectedPhysicsComponent([&](auto physicscomponent, auto args) { + restitutionSlider.OnSlide(forEachSelectedPhysicsComponent([](auto physicscomponent, auto args) { physicscomponent->restitution = args.fValue; })); AddWidget(&restitutionSlider); lineardampingSlider.Create(0, 1, 0, 100000, "Linear Damping: "); lineardampingSlider.SetTooltip("Set the linear damping amount for the physics engine."); - lineardampingSlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([&](auto physicscomponent, auto args) { + lineardampingSlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([](auto physicscomponent, auto args) { physicscomponent->damping_linear = args.fValue; })); AddWidget(&lineardampingSlider); angulardampingSlider.Create(0, 1, 0, 100000, "Angular Damping: "); angulardampingSlider.SetTooltip("Set the angular damping amount for the physics engine."); - angulardampingSlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([&](auto physicscomponent, auto args) { + angulardampingSlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([](auto physicscomponent, auto args) { physicscomponent->damping_angular = args.fValue; })); AddWidget(&angulardampingSlider); buoyancySlider.Create(0, 2, 0, 1000, "Buoyancy: "); buoyancySlider.SetTooltip("Higher buoyancy will make the bodies float up faster in water."); - buoyancySlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([&](auto physicscomponent, auto args) { + buoyancySlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([](auto physicscomponent, auto args) { physicscomponent->buoyancy = args.fValue; })); AddWidget(&buoyancySlider); physicsMeshLODSlider.Create(0, 6, 0, 6, "Use Mesh LOD: "); physicsMeshLODSlider.SetTooltip("Specify which LOD to use for triangle mesh physics."); - physicsMeshLODSlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([&](auto physicscomponent, auto args) { + physicsMeshLODSlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([](auto physicscomponent, auto args) { if (physicscomponent->mesh_lod != uint32_t(args.iValue)) { physicscomponent->physicsobject = nullptr; // will be recreated automatically @@ -183,7 +183,7 @@ void RigidBodyWindow::Create(EditorComponent* _editor) kinematicCheckBox.Create("Kinematic: "); kinematicCheckBox.SetTooltip("Toggle kinematic behaviour."); kinematicCheckBox.SetCheck(false); - kinematicCheckBox.OnClick(forEachSelectedPhysicsComponentWithRefresh([&](auto physicscomponent, auto args) { + kinematicCheckBox.OnClick(forEachSelectedPhysicsComponentWithRefresh([](auto physicscomponent, auto args) { physicscomponent->SetKinematic(args.bValue); })); AddWidget(&kinematicCheckBox); @@ -191,7 +191,7 @@ void RigidBodyWindow::Create(EditorComponent* _editor) disabledeactivationCheckBox.Create("Disable Deactivation: "); disabledeactivationCheckBox.SetTooltip("Toggle kinematic behaviour."); disabledeactivationCheckBox.SetCheck(false); - disabledeactivationCheckBox.OnClick(forEachSelectedPhysicsComponentWithRefresh([&](auto physicscomponent, auto args) { + disabledeactivationCheckBox.OnClick(forEachSelectedPhysicsComponentWithRefresh([](auto physicscomponent, auto args) { physicscomponent->SetDisableDeactivation(args.bValue); })); AddWidget(&disabledeactivationCheckBox); @@ -199,28 +199,28 @@ void RigidBodyWindow::Create(EditorComponent* _editor) startDeactivatedCheckBox.Create("Start deactivated: "); startDeactivatedCheckBox.SetTooltip("If enabled, the rigid body will start in a deactivated state.\nEven if the body is dynamic (non-kinematic, mass > 0), it will not fall unless interacted with."); startDeactivatedCheckBox.SetCheck(false); - startDeactivatedCheckBox.OnClick(forEachSelectedPhysicsComponentWithRefresh([&](auto physicscomponent, auto args) { + startDeactivatedCheckBox.OnClick(forEachSelectedPhysicsComponentWithRefresh([](auto physicscomponent, auto args) { physicscomponent->SetStartDeactivated(args.bValue); })); AddWidget(&startDeactivatedCheckBox); offsetXSlider.Create(-10, 10, 0, 100000, "Local Offset X: "); offsetXSlider.SetTooltip("Set a local offset relative to the object transform"); - offsetXSlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([&](auto physicscomponent, auto args) { + offsetXSlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([](auto physicscomponent, auto args) { physicscomponent->local_offset.x = args.fValue; })); AddWidget(&offsetXSlider); offsetYSlider.Create(-10, 10, 0, 100000, "Local Offset Y: "); offsetYSlider.SetTooltip("Set a local offset relative to the object transform"); - offsetYSlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([&](auto physicscomponent, auto args) { + offsetYSlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([](auto physicscomponent, auto args) { physicscomponent->local_offset.y = args.fValue; })); AddWidget(&offsetYSlider); offsetZSlider.Create(-10, 10, 0, 100000, "Local Offset Z: "); offsetZSlider.SetTooltip("Set a local offset relative to the object transform"); - offsetZSlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([&](auto physicscomponent, auto args) { + offsetZSlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([](auto physicscomponent, auto args) { physicscomponent->local_offset.z = args.fValue; })); AddWidget(&offsetZSlider); @@ -239,7 +239,7 @@ void RigidBodyWindow::Create(EditorComponent* _editor) characterCheckBox.Create(ICON_PHYSICS_CHARACTER " Character physics: "); characterCheckBox.SetTooltip("Enable physics-driven character"); - characterCheckBox.OnClick(forEachSelectedPhysicsComponentWithRefresh([&](auto physicscomponent, auto args) { + characterCheckBox.OnClick(forEachSelectedPhysicsComponentWithRefresh([](auto physicscomponent, auto args) { physicscomponent->SetCharacterPhysics(args.bValue); })); AddWidget(&characterCheckBox); @@ -251,14 +251,14 @@ void RigidBodyWindow::Create(EditorComponent* _editor) characterSlopeSlider.Create(0, 90, 50, 90, "Max slope angle: "); characterSlopeSlider.SetTooltip("Specify the slope angle that the character can stand on."); - characterSlopeSlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([&](auto physicscomponent, auto args) { + characterSlopeSlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([](auto physicscomponent, auto args) { physicscomponent->character.maxSlopeAngle = wi::math::DegreesToRadians(args.fValue); })); AddWidget(&characterSlopeSlider); characterGravitySlider.Create(0, 4, 1, 100, "Gravity factor: "); characterGravitySlider.SetTooltip("Specify the strength of gravity acting on the character."); - characterGravitySlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([&](auto physicscomponent, auto args) { + characterGravitySlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([](auto physicscomponent, auto args) { physicscomponent->character.gravityFactor = args.fValue; })); AddWidget(&characterGravitySlider); @@ -281,7 +281,7 @@ void RigidBodyWindow::Create(EditorComponent* _editor) vehicleCombo.AddItem("None", (uint64_t)RigidBodyPhysicsComponent::Vehicle::Type::None); vehicleCombo.AddItem("Car", (uint64_t)RigidBodyPhysicsComponent::Vehicle::Type::Car); vehicleCombo.AddItem("Motorcycle", (uint64_t)RigidBodyPhysicsComponent::Vehicle::Type::Motorcycle); - vehicleCombo.OnSelect(forEachSelectedPhysicsComponentWithRefresh([&](auto physicscomponent, auto args) { + vehicleCombo.OnSelect(forEachSelectedPhysicsComponentWithRefresh([](auto physicscomponent, auto args) { physicscomponent->vehicle.type = (RigidBodyPhysicsComponent::Vehicle::Type)args.userdata; })); AddWidget(&vehicleCombo); @@ -291,154 +291,154 @@ void RigidBodyWindow::Create(EditorComponent* _editor) vehicleCollisionCombo.AddItem("Ray", (uint64_t)RigidBodyPhysicsComponent::Vehicle::CollisionMode::Ray); vehicleCollisionCombo.AddItem("Sphere", (uint64_t)RigidBodyPhysicsComponent::Vehicle::CollisionMode::Sphere); vehicleCollisionCombo.AddItem("Cylinder", (uint64_t)RigidBodyPhysicsComponent::Vehicle::CollisionMode::Cylinder); - vehicleCollisionCombo.OnSelect(forEachSelectedPhysicsComponentWithRefresh([&](auto physicscomponent, auto args) { + vehicleCollisionCombo.OnSelect(forEachSelectedPhysicsComponentWithRefresh([](auto physicscomponent, auto args) { physicscomponent->vehicle.collision_mode = (RigidBodyPhysicsComponent::Vehicle::CollisionMode)args.userdata; })); AddWidget(&vehicleCollisionCombo); wheelRadiusSlider.Create(0.001f, 10, 1, 1000, "Wheel radius: "); - wheelRadiusSlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([&](auto physicscomponent, auto args) { + wheelRadiusSlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([](auto physicscomponent, auto args) { physicscomponent->vehicle.wheel_radius = args.fValue; })); AddWidget(&wheelRadiusSlider); wheelWidthSlider.Create(0.001f, 10, 1, 1000, "Wheel width: "); - wheelWidthSlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([&](auto physicscomponent, auto args) { + wheelWidthSlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([](auto physicscomponent, auto args) { physicscomponent->vehicle.wheel_width = args.fValue; })); AddWidget(&wheelWidthSlider); chassisHalfWidthSlider.Create(0, 10, 1, 1000, "Chassis width: "); - chassisHalfWidthSlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([&](auto physicscomponent, auto args) { + chassisHalfWidthSlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([](auto physicscomponent, auto args) { physicscomponent->vehicle.chassis_half_width = args.fValue; })); AddWidget(&chassisHalfWidthSlider); chassisHalfHeightSlider.Create(-10, 10, 1, 1000, "Chassis height: "); - chassisHalfHeightSlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([&](auto physicscomponent, auto args) { + chassisHalfHeightSlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([](auto physicscomponent, auto args) { physicscomponent->vehicle.chassis_half_height = args.fValue; })); AddWidget(&chassisHalfHeightSlider); chassisHalfLengthSlider.Create(0, 10, 1, 1000, "Chassis length: "); - chassisHalfLengthSlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([&](auto physicscomponent, auto args) { + chassisHalfLengthSlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([](auto physicscomponent, auto args) { physicscomponent->vehicle.chassis_half_length = args.fValue; })); AddWidget(&chassisHalfLengthSlider); frontWheelOffsetSlider.Create(-10, 10, 0, 1000, "Front wheel offset: "); - frontWheelOffsetSlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([&](auto physicscomponent, auto args) { + frontWheelOffsetSlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([](auto physicscomponent, auto args) { physicscomponent->vehicle.front_wheel_offset = args.fValue; })); AddWidget(&frontWheelOffsetSlider); rearWheelOffsetSlider.Create(-10, 10, 0, 1000, "Rear wheel offset: "); - rearWheelOffsetSlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([&](auto physicscomponent, auto args) { + rearWheelOffsetSlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([](auto physicscomponent, auto args) { physicscomponent->vehicle.rear_wheel_offset = args.fValue; })); AddWidget(&rearWheelOffsetSlider); maxTorqueSlider.Create(0, 1000, 0, 1000, "Max Torque: "); - maxTorqueSlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([&](auto physicscomponent, auto args) { + maxTorqueSlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([](auto physicscomponent, auto args) { physicscomponent->vehicle.max_engine_torque = args.fValue; })); AddWidget(&maxTorqueSlider); clutchStrengthSlider.Create(0, 100, 0, 1000, "Clutch Strength: "); - clutchStrengthSlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([&](auto physicscomponent, auto args) { + clutchStrengthSlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([](auto physicscomponent, auto args) { physicscomponent->vehicle.clutch_strength = args.fValue; })); AddWidget(&clutchStrengthSlider); maxRollAngleSlider.Create(0, 180, 0, 180, "Max Roll Angle: "); - maxRollAngleSlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([&](auto physicscomponent, auto args) { + maxRollAngleSlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([](auto physicscomponent, auto args) { physicscomponent->vehicle.max_roll_angle = wi::math::DegreesToRadians(args.fValue); })); AddWidget(&maxRollAngleSlider); maxSteeringAngleSlider.Create(0, 90, 0, 90, "Max Steering Angle: "); - maxSteeringAngleSlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([&](auto physicscomponent, auto args) { + maxSteeringAngleSlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([](auto physicscomponent, auto args) { physicscomponent->vehicle.max_steering_angle = wi::math::DegreesToRadians(args.fValue); })); AddWidget(&maxSteeringAngleSlider); fSuspensionMinSlider.Create(0, 2, 0, 200, "F. Susp. Min Length: "); - fSuspensionMinSlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([&](auto physicscomponent, auto args) { + fSuspensionMinSlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([](auto physicscomponent, auto args) { physicscomponent->vehicle.front_suspension.min_length = args.fValue; })); AddWidget(&fSuspensionMinSlider); fSuspensionMaxSlider.Create(0, 2, 0, 200, "F. Susp. Max Length: "); - fSuspensionMaxSlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([&](auto physicscomponent, auto args) { + fSuspensionMaxSlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([](auto physicscomponent, auto args) { physicscomponent->vehicle.front_suspension.max_length = args.fValue; physicscomponent->SetRefreshParametersNeeded(); })); AddWidget(&fSuspensionMaxSlider); fSuspensionFrequencySlider.Create(0, 2, 0, 200, "F. Susp. Frequency: "); - fSuspensionFrequencySlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([&](auto physicscomponent, auto args) { + fSuspensionFrequencySlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([](auto physicscomponent, auto args) { physicscomponent->vehicle.front_suspension.frequency = args.fValue; })); AddWidget(&fSuspensionFrequencySlider); fSuspensionDampingSlider.Create(0, 2, 0, 200, "F. Susp. Damping: "); - fSuspensionDampingSlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([&](auto physicscomponent, auto args) { + fSuspensionDampingSlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([](auto physicscomponent, auto args) { physicscomponent->vehicle.front_suspension.damping = args.fValue; })); AddWidget(&fSuspensionDampingSlider); rSuspensionMinSlider.Create(0, 2, 0, 200, "R. Susp. Min Length: "); - rSuspensionMinSlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([&](auto physicscomponent, auto args) { + rSuspensionMinSlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([](auto physicscomponent, auto args) { physicscomponent->vehicle.rear_suspension.min_length = args.fValue; })); AddWidget(&rSuspensionMinSlider); rSuspensionMaxSlider.Create(0, 2, 0, 200, "R. Susp. Max Length: "); - rSuspensionMaxSlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([&](auto physicscomponent, auto args) { + rSuspensionMaxSlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([](auto physicscomponent, auto args) { physicscomponent->vehicle.rear_suspension.max_length = args.fValue; })); AddWidget(&rSuspensionMaxSlider); rSuspensionFrequencySlider.Create(0, 2, 0, 200, "R. Susp. Frequency: "); - rSuspensionFrequencySlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([&](auto physicscomponent, auto args) { + rSuspensionFrequencySlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([](auto physicscomponent, auto args) { physicscomponent->vehicle.rear_suspension.frequency = args.fValue; })); AddWidget(&rSuspensionFrequencySlider); rSuspensionDampingSlider.Create(0, 2, 0, 200, "R. Susp. Damping: "); - rSuspensionDampingSlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([&](auto physicscomponent, auto args) { + rSuspensionDampingSlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([](auto physicscomponent, auto args) { physicscomponent->vehicle.rear_suspension.damping = args.fValue; })); AddWidget(&rSuspensionDampingSlider); motorcycleFBrakeSuspensionAngleSlider.Create(0, 90, 0, 90, "F. Brake Susp. Angle: "); - motorcycleFBrakeSuspensionAngleSlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([&](auto physicscomponent, auto args) { + motorcycleFBrakeSuspensionAngleSlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([](auto physicscomponent, auto args) { physicscomponent->vehicle.motorcycle.front_suspension_angle = wi::math::DegreesToRadians(args.fValue); })); AddWidget(&motorcycleFBrakeSuspensionAngleSlider); motorcycleFBrakeTorqueSlider.Create(0, 2000, 0, 2000, "F. Brake Torque: "); - motorcycleFBrakeTorqueSlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([&](auto physicscomponent, auto args) { + motorcycleFBrakeTorqueSlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([](auto physicscomponent, auto args) { physicscomponent->vehicle.motorcycle.front_brake_torque = args.fValue; })); AddWidget(&motorcycleFBrakeTorqueSlider); motorcycleRBrakeTorqueSlider.Create(0, 2000, 0, 2000, "R. Brake Torque: "); - motorcycleRBrakeTorqueSlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([&](auto physicscomponent, auto args) { + motorcycleRBrakeTorqueSlider.OnSlide(forEachSelectedPhysicsComponentWithRefresh([](auto physicscomponent, auto args) { physicscomponent->vehicle.motorcycle.rear_brake_torque = args.fValue; })); AddWidget(&motorcycleRBrakeTorqueSlider); fourwheelCheckbox.Create("4-wheel drive: "); - fourwheelCheckbox.OnClick(forEachSelectedPhysicsComponentWithRefresh([&](auto physicscomponent, auto args) { + fourwheelCheckbox.OnClick(forEachSelectedPhysicsComponentWithRefresh([](auto physicscomponent, auto args) { physicscomponent->vehicle.car.four_wheel_drive = args.bValue; })); AddWidget(&fourwheelCheckbox); motorleanCheckbox.Create("Motorcycle lean control: "); // Here we don't need to recreate physics!! - motorleanCheckbox.OnClick(forEachSelectedPhysicsComponent([&](auto physicscomponent, auto args) { + motorleanCheckbox.OnClick(forEachSelectedPhysicsComponent([](auto physicscomponent, auto args) { physicscomponent->vehicle.motorcycle.lean_control = args.bValue; })); AddWidget(&motorleanCheckbox); @@ -460,28 +460,28 @@ void RigidBodyWindow::Create(EditorComponent* _editor) wheelEntityFrontLeftCombo.Create("Front Left Wheel: "); wheelEntityFrontLeftCombo.SetTooltip("Map an entity transform to this wheel, so the wheel graphics can be animated by physics (optional).\nThe entity name must contain the word wheel to be displayed here."); - wheelEntityFrontLeftCombo.OnSelect(forEachSelectedPhysicsComponent([&](auto physicscomponent, auto args) { + wheelEntityFrontLeftCombo.OnSelect(forEachSelectedPhysicsComponent([](auto physicscomponent, auto args) { physicscomponent->vehicle.wheel_entity_front_left = args.userdata; })); AddWidget(&wheelEntityFrontLeftCombo); wheelEntityFrontRightCombo.Create("Front Right Wheel: "); wheelEntityFrontRightCombo.SetTooltip("Map an entity transform to this wheel, so the wheel graphics can be animated by physics (optional).\nThe entity name must contain the word wheel to be displayed here."); - wheelEntityFrontRightCombo.OnSelect(forEachSelectedPhysicsComponent([&](auto physicscomponent, auto args) { + wheelEntityFrontRightCombo.OnSelect(forEachSelectedPhysicsComponent([](auto physicscomponent, auto args) { physicscomponent->vehicle.wheel_entity_front_right = args.userdata; })); AddWidget(&wheelEntityFrontRightCombo); wheelEntityRearLeftCombo.Create("Rear Left Wheel: "); wheelEntityRearLeftCombo.SetTooltip("Map an entity transform to this wheel, so the wheel graphics can be animated by physics (optional).\nThe entity name must contain the word wheel to be displayed here."); - wheelEntityRearLeftCombo.OnSelect(forEachSelectedPhysicsComponent([&](auto physicscomponent, auto args) { + wheelEntityRearLeftCombo.OnSelect(forEachSelectedPhysicsComponent([](auto physicscomponent, auto args) { physicscomponent->vehicle.wheel_entity_rear_left = args.userdata; })); AddWidget(&wheelEntityRearLeftCombo); wheelEntityRearRightCombo.Create("Rear Right Wheel: "); wheelEntityRearRightCombo.SetTooltip("Map an entity transform to this wheel, so the wheel graphics can be animated by physics (optional).\nThe entity name must contain the word wheel to be displayed here."); - wheelEntityRearRightCombo.OnSelect(forEachSelectedPhysicsComponent([&](auto physicscomponent, auto args) { + wheelEntityRearRightCombo.OnSelect(forEachSelectedPhysicsComponent([](auto physicscomponent, auto args) { physicscomponent->vehicle.wheel_entity_rear_right = args.userdata; })); AddWidget(&wheelEntityRearRightCombo); diff --git a/Editor/SoftBodyWindow.cpp b/Editor/SoftBodyWindow.cpp index ba6a276f1..b01baf129 100644 --- a/Editor/SoftBodyWindow.cpp +++ b/Editor/SoftBodyWindow.cpp @@ -41,8 +41,8 @@ void SoftBodyWindow::Create(EditorComponent* _editor) infoLabel.SetFitTextEnabled(true); AddWidget(&infoLabel); - auto forEachSelected = [&] (auto func) { - return [&, func] (auto args) { + auto forEachSelected = [this] (auto func) { + return [this, func] (auto args) { wi::scene::Scene& scene = editor->GetCurrentScene(); for (auto& x : editor->translator.selected) { @@ -66,21 +66,21 @@ void SoftBodyWindow::Create(EditorComponent* _editor) resetButton.Create("Reset"); resetButton.SetTooltip("Set the detail to keep between simulation and graphics mesh.\nLower = less detailed, higher = more detailed."); - resetButton.OnClick(forEachSelected([&] (auto physicscomponent, auto args) { + resetButton.OnClick(forEachSelected([] (auto physicscomponent, auto args) { physicscomponent->Reset(); })); AddWidget(&resetButton); detailSlider.Create(0.001f, 1, 1, 1000, "LOD Detail: "); detailSlider.SetTooltip("Set the detail to keep between simulation and graphics mesh.\nLower = less detailed, higher = more detailed."); - detailSlider.OnSlide(forEachSelected([&] (auto physicscomponent, auto args) { + detailSlider.OnSlide(forEachSelected([] (auto physicscomponent, auto args) { physicscomponent->SetDetail(args.fValue); })); AddWidget(&detailSlider); massSlider.Create(0, 100, 1, 100000, "Mass: "); massSlider.SetTooltip("Set the mass amount for the physics engine."); - massSlider.OnSlide(forEachSelected([&] (auto physicscomponent, auto args) { + massSlider.OnSlide(forEachSelected([] (auto physicscomponent, auto args) { physicscomponent->physicsobject = {}; physicscomponent->mass = args.fValue; })); @@ -88,21 +88,21 @@ void SoftBodyWindow::Create(EditorComponent* _editor) frictionSlider.Create(0, 1, 0.5f, 100000, "Friction: "); frictionSlider.SetTooltip("Set the friction amount for the physics engine."); - frictionSlider.OnSlide(forEachSelected([&] (auto physicscomponent, auto args) { + frictionSlider.OnSlide(forEachSelected([] (auto physicscomponent, auto args) { physicscomponent->friction = args.fValue; })); AddWidget(&frictionSlider); restitutionSlider.Create(0, 1, 0, 100000, "Restitution: "); restitutionSlider.SetTooltip("Set the restitution amount for the physics engine."); - restitutionSlider.OnSlide(forEachSelected([&] (auto physicscomponent, auto args) { + restitutionSlider.OnSlide(forEachSelected([] (auto physicscomponent, auto args) { physicscomponent->restitution = args.fValue; })); AddWidget(&restitutionSlider); pressureSlider.Create(0, 100000, 0, 100000, "Pressure: "); pressureSlider.SetTooltip("Set the pressure amount for the physics engine."); - pressureSlider.OnSlide(forEachSelected([&] (auto physicscomponent, auto args) { + pressureSlider.OnSlide(forEachSelected([] (auto physicscomponent, auto args) { physicscomponent->pressure = args.fValue; physicscomponent->physicsobject = {}; })); @@ -110,7 +110,7 @@ void SoftBodyWindow::Create(EditorComponent* _editor) vertexRadiusSlider.Create(0, 1, 0, 100000, "Vertex Radius: "); vertexRadiusSlider.SetTooltip("Set how much distance vertices should keep from other physics bodies."); - vertexRadiusSlider.OnSlide(forEachSelected([&] (auto physicscomponent, auto args) { + vertexRadiusSlider.OnSlide(forEachSelected([] (auto physicscomponent, auto args) { physicscomponent->physicsobject = {}; physicscomponent->vertex_radius = args.fValue; })); @@ -118,7 +118,7 @@ void SoftBodyWindow::Create(EditorComponent* _editor) windCheckbox.Create("Wind: "); windCheckbox.SetTooltip("Enable/disable wind force on this soft body."); - windCheckbox.OnClick(forEachSelected([&] (auto physicscomponent, auto args) { + windCheckbox.OnClick(forEachSelected([] (auto physicscomponent, auto args) { physicscomponent->SetWindEnabled(args.bValue); })); AddWidget(&windCheckbox); diff --git a/Editor/SoundWindow.cpp b/Editor/SoundWindow.cpp index 6a2c5e681..25ab11122 100644 --- a/Editor/SoundWindow.cpp +++ b/Editor/SoundWindow.cpp @@ -94,8 +94,8 @@ void SoundWindow::Create(EditorComponent* _editor) filenameLabel.SetSize(XMFLOAT2(wid, hei)); AddWidget(&filenameLabel); - auto forEachSelected = [&] (auto func) { - return [&, func] (auto args) { + auto forEachSelected = [this] (auto func) { + return [this, func] (auto args) { wi::scene::Scene& scene = editor->GetCurrentScene(); for (auto& x : editor->translator.selected) { @@ -112,7 +112,7 @@ void SoundWindow::Create(EditorComponent* _editor) playstopButton.SetTooltip("Play/Stop selected sound instance."); playstopButton.SetPos(XMFLOAT2(x, y += step)); playstopButton.SetSize(XMFLOAT2(wid, hei)); - playstopButton.OnClick(forEachSelected([&] (auto sound, auto args) { + playstopButton.OnClick(forEachSelected([this] (auto sound, auto args) { if (sound->IsPlaying()) { sound->Stop(); @@ -132,7 +132,7 @@ void SoundWindow::Create(EditorComponent* _editor) loopedCheckbox.SetPos(XMFLOAT2(x, y += step)); loopedCheckbox.SetSize(XMFLOAT2(hei, hei)); loopedCheckbox.SetCheckText(ICON_LOOP); - loopedCheckbox.OnClick(forEachSelected([&] (auto sound, auto args) { + loopedCheckbox.OnClick(forEachSelected([] (auto sound, auto args) { sound->SetLooped(args.bValue); })); AddWidget(&loopedCheckbox); @@ -142,7 +142,7 @@ void SoundWindow::Create(EditorComponent* _editor) reverbCheckbox.SetTooltip("Enable/disable reverb."); reverbCheckbox.SetPos(XMFLOAT2(x, y += step)); reverbCheckbox.SetSize(XMFLOAT2(hei, hei)); - reverbCheckbox.OnClick(forEachSelected([&] (auto sound, auto args) { + reverbCheckbox.OnClick(forEachSelected([] (auto sound, auto args) { sound->soundinstance.SetEnableReverb(args.bValue); wi::audio::CreateSoundInstance(&sound->soundResource.GetSound(), &sound->soundinstance); })); @@ -153,7 +153,7 @@ void SoundWindow::Create(EditorComponent* _editor) disable3dCheckbox.SetTooltip("Sounds in the scene are 3D spatial by default. Select this to disable 3D effect."); disable3dCheckbox.SetPos(XMFLOAT2(x, y += step)); disable3dCheckbox.SetSize(XMFLOAT2(hei, hei)); - disable3dCheckbox.OnClick(forEachSelected([&] (auto sound, auto args) { + disable3dCheckbox.OnClick(forEachSelected([] (auto sound, auto args) { sound->SetDisable3D(args.bValue); })); AddWidget(&disable3dCheckbox); @@ -163,7 +163,7 @@ void SoundWindow::Create(EditorComponent* _editor) volumeSlider.SetTooltip("Set volume level for the selected sound instance."); volumeSlider.SetPos(XMFLOAT2(x, y += step)); volumeSlider.SetSize(XMFLOAT2(wid, hei)); - volumeSlider.OnSlide(forEachSelected([&] (auto sound, auto args) { + volumeSlider.OnSlide(forEachSelected([] (auto sound, auto args) { sound->volume = args.fValue; })); AddWidget(&volumeSlider); @@ -172,7 +172,7 @@ void SoundWindow::Create(EditorComponent* _editor) submixComboBox.Create("Submix: "); submixComboBox.SetPos(XMFLOAT2(x, y += step)); submixComboBox.SetSize(XMFLOAT2(wid, hei)); - submixComboBox.OnSelect(forEachSelected([&] (auto sound, auto args) { + submixComboBox.OnSelect(forEachSelected([] (auto sound, auto args) { sound->soundinstance.type = (wi::audio::SUBMIX_TYPE)args.iValue; wi::audio::CreateSoundInstance(&sound->soundResource.GetSound(), &sound->soundinstance); })); @@ -231,7 +231,7 @@ void SoundWindow::Create(EditorComponent* _editor) beginInput.SetDescription("Begin: "); beginInput.SetTooltip("Beginning of the playback in seconds, relative to the Sound it will be created from (0 = from beginning)."); beginInput.SetSize(XMFLOAT2(wid, hei)); - beginInput.OnInputAccepted(forEachSelected([&] (auto sound, auto args) { + beginInput.OnInputAccepted(forEachSelected([] (auto sound, auto args) { sound->soundinstance.begin = args.fValue; wi::audio::CreateSoundInstance(&sound->soundResource.GetSound(), &sound->soundinstance); })); @@ -241,7 +241,7 @@ void SoundWindow::Create(EditorComponent* _editor) lengthInput.SetDescription("Length: "); lengthInput.SetTooltip("Length in seconds (0 = until end)"); lengthInput.SetSize(XMFLOAT2(wid, hei)); - lengthInput.OnInputAccepted(forEachSelected([&] (auto sound, auto args) { + lengthInput.OnInputAccepted(forEachSelected([] (auto sound, auto args) { sound->soundinstance.length = args.fValue; wi::audio::CreateSoundInstance(&sound->soundResource.GetSound(), &sound->soundinstance); })); @@ -251,7 +251,7 @@ void SoundWindow::Create(EditorComponent* _editor) loopBeginInput.SetDescription("Loop Begin: "); loopBeginInput.SetTooltip("Loop region begin in seconds, relative to the instance begin time (0 = from beginning)"); loopBeginInput.SetSize(XMFLOAT2(wid, hei)); - loopBeginInput.OnInputAccepted(forEachSelected([&] (auto sound, auto args) { + loopBeginInput.OnInputAccepted(forEachSelected([] (auto sound, auto args) { sound->soundinstance.loop_begin = args.fValue; wi::audio::CreateSoundInstance(&sound->soundResource.GetSound(), &sound->soundinstance); })); @@ -261,7 +261,7 @@ void SoundWindow::Create(EditorComponent* _editor) loopLengthInput.SetDescription("Loop Length: "); loopLengthInput.SetTooltip("Loop region length in seconds (0 = until the end)"); loopLengthInput.SetSize(XMFLOAT2(wid, hei)); - loopLengthInput.OnInputAccepted(forEachSelected([&] (auto sound, auto args) { + loopLengthInput.OnInputAccepted(forEachSelected([] (auto sound, auto args) { sound->soundinstance.loop_length = args.fValue; wi::audio::CreateSoundInstance(&sound->soundResource.GetSound(), &sound->soundinstance); })); diff --git a/Editor/SplineWindow.cpp b/Editor/SplineWindow.cpp index 9cde61522..ddda7631d 100644 --- a/Editor/SplineWindow.cpp +++ b/Editor/SplineWindow.cpp @@ -31,8 +31,8 @@ void SplineWindow::Create(EditorComponent* _editor) infoLabel.SetFitTextEnabled(true); AddWidget(&infoLabel); - auto forAllSelectedAndIndirect = [&] (auto func) { - return [=] (auto args) { + auto forEachSelectedAndIndirect = [this] (auto func) { + return [this, func] (auto args) { wi::scene::Scene& scene = editor->GetCurrentScene(); for (auto& x : editor->translator.selected) { @@ -52,35 +52,35 @@ void SplineWindow::Create(EditorComponent* _editor) }; }; - auto forAllSelectedAndIndirectWithRefresh = [&] (auto func) { - return [&] (auto args) { - forAllSelectedAndIndirect(func); + auto forEachSelectedAndIndirectWithRefresh = [this, forEachSelectedAndIndirect] (auto func) { + return [this, &forEachSelectedAndIndirect, func] (auto args) { + forEachSelectedAndIndirect(func); editor->componentsWnd.RefreshEntityTree(); }; }; loopedCheck.Create("Looped: "); - loopedCheck.OnClick(forAllSelectedAndIndirect([&] (auto spline, auto args) { + loopedCheck.OnClick(forEachSelectedAndIndirect([] (auto spline, auto args) { spline->SetLooped(args.bValue); })); AddWidget(&loopedCheck); alignedCheck.Create("Draw Aligned: "); - alignedCheck.OnClick(forAllSelectedAndIndirect([&] (auto spline, auto args) { + alignedCheck.OnClick(forEachSelectedAndIndirect([] (auto spline, auto args) { spline->SetDrawAligned(args.bValue); })); AddWidget(&alignedCheck); widthSlider.Create(0.001f, 4, 0, 1000, "Width: "); widthSlider.SetTooltip("Set overall width multiplier for all nodes, used in mesh generation."); - widthSlider.OnSlide(forAllSelectedAndIndirectWithRefresh([&] (auto spline, auto args) { + widthSlider.OnSlide(forEachSelectedAndIndirectWithRefresh([] (auto spline, auto args) { spline->width = args.fValue; })); AddWidget(&widthSlider); rotSlider.Create(0, 360, 0, 360, "Rotation: "); rotSlider.SetTooltip("Set overall rotation for all nodes, used in mesh generation."); - rotSlider.OnSlide(forAllSelectedAndIndirectWithRefresh([&] (auto spline, auto args) { + rotSlider.OnSlide(forEachSelectedAndIndirectWithRefresh([] (auto spline, auto args) { float rad = wi::math::DegreesToRadians(args.fValue); spline->rotation = rad; })); @@ -88,35 +88,35 @@ void SplineWindow::Create(EditorComponent* _editor) subdivSlider.Create(0, 100, 0, 100, "Mesh subdivision: "); subdivSlider.SetTooltip("Set subdivision count for mesh generation. \nIncreasing this above 0 will enable mesh generation and higher values mean higher quality."); - subdivSlider.OnSlide(forAllSelectedAndIndirectWithRefresh([&] (auto spline, auto args) { + subdivSlider.OnSlide(forEachSelectedAndIndirectWithRefresh([] (auto spline, auto args) { spline->mesh_generation_subdivision = args.iValue; })); AddWidget(&subdivSlider); subdivVerticalSlider.Create(0, 36, 0, 36, "Vertical subdivision: "); subdivVerticalSlider.SetTooltip("Set subdivision count for mesh generation's vertical axis to create a corridoor or a tunnel."); - subdivVerticalSlider.OnSlide(forAllSelectedAndIndirectWithRefresh([&] (auto spline, auto args) { + subdivVerticalSlider.OnSlide(forEachSelectedAndIndirectWithRefresh([] (auto spline, auto args) { spline->mesh_generation_vertical_subdivision = args.iValue; })); AddWidget(&subdivVerticalSlider); terrainSlider.Create(0, 1, 0, 100, "Terrain modifier: "); terrainSlider.SetTooltip("Set terrain modification strength (0 to turn it off, higher values mean more sharpness)."); - terrainSlider.OnSlide(forAllSelectedAndIndirectWithRefresh([&] (auto spline, auto args) { + terrainSlider.OnSlide(forEachSelectedAndIndirectWithRefresh([] (auto spline, auto args) { spline->terrain_modifier_amount = args.fValue; })); AddWidget(&terrainSlider); terrainTexSlider.Create(0, 1, 0, 100, "Terrain texture falloff: "); terrainTexSlider.SetTooltip("Affects the terrain texturing falloff when spline is terrain modifying."); - terrainTexSlider.OnSlide(forAllSelectedAndIndirectWithRefresh([&] (auto spline, auto args) { + terrainTexSlider.OnSlide(forEachSelectedAndIndirectWithRefresh([] (auto spline, auto args) { spline->terrain_texture_falloff = args.fValue; })); AddWidget(&terrainTexSlider); terrainPushdownSlider.Create(0, 10, 0, 100, "Terrain push down: "); terrainPushdownSlider.SetTooltip("Push down the terrain genetry from the spline plane by an amount."); - terrainPushdownSlider.OnSlide(forAllSelectedAndIndirectWithRefresh([&] (auto spline, auto args) { + terrainPushdownSlider.OnSlide(forEachSelectedAndIndirectWithRefresh([] (auto spline, auto args) { spline->terrain_pushdown = args.fValue; })); AddWidget(&terrainPushdownSlider); diff --git a/Editor/SpringWindow.cpp b/Editor/SpringWindow.cpp index a0a02ee00..3a28c744f 100644 --- a/Editor/SpringWindow.cpp +++ b/Editor/SpringWindow.cpp @@ -43,8 +43,8 @@ void SpringWindow::Create(EditorComponent* _editor) }); AddWidget(&resetAllButton); - auto forEachSelected = [&] (auto func) { - return [&, func] (auto args) { + auto forEachSelected = [this] (auto func) { + return [this, func] (auto args) { wi::scene::Scene& scene = editor->GetCurrentScene(); for (auto& x : editor->translator.selected) { @@ -61,7 +61,7 @@ void SpringWindow::Create(EditorComponent* _editor) disabledCheckBox.SetTooltip("Disable simulation."); disabledCheckBox.SetPos(XMFLOAT2(x, y += step)); disabledCheckBox.SetSize(XMFLOAT2(hei, hei)); - disabledCheckBox.OnClick(forEachSelected([&] (auto spring, auto args) { + disabledCheckBox.OnClick(forEachSelected([] (auto spring, auto args) { spring->SetDisabled(args.bValue); })); AddWidget(&disabledCheckBox); @@ -70,7 +70,7 @@ void SpringWindow::Create(EditorComponent* _editor) gravityCheckBox.SetTooltip("Whether global gravity should affect the spring"); gravityCheckBox.SetPos(XMFLOAT2(x, y += step)); gravityCheckBox.SetSize(XMFLOAT2(hei, hei)); - gravityCheckBox.OnClick(forEachSelected([&] (auto spring, auto args) { + gravityCheckBox.OnClick(forEachSelected([] (auto spring, auto args) { spring->SetGravityEnabled(args.bValue); })); AddWidget(&gravityCheckBox); @@ -79,7 +79,7 @@ void SpringWindow::Create(EditorComponent* _editor) stiffnessSlider.SetTooltip("The stiffness affects how strongly the spring tries to orient itself to rest pose (higher values increase the jiggliness)"); stiffnessSlider.SetPos(XMFLOAT2(x, y += step)); stiffnessSlider.SetSize(XMFLOAT2(siz, hei)); - stiffnessSlider.OnSlide(forEachSelected([&] (auto spring, auto args) { + stiffnessSlider.OnSlide(forEachSelected([] (auto spring, auto args) { spring->stiffnessForce = args.fValue; })); AddWidget(&stiffnessSlider); @@ -88,7 +88,7 @@ void SpringWindow::Create(EditorComponent* _editor) dragSlider.SetTooltip("The drag affects how fast energy is lost (higher values make the spring come to rest faster)"); dragSlider.SetPos(XMFLOAT2(x, y += step)); dragSlider.SetSize(XMFLOAT2(siz, hei)); - dragSlider.OnSlide(forEachSelected([&] (auto spring, auto args) { + dragSlider.OnSlide(forEachSelected([] (auto spring, auto args) { spring->dragForce = args.fValue; })); AddWidget(&dragSlider); @@ -97,7 +97,7 @@ void SpringWindow::Create(EditorComponent* _editor) windSlider.SetTooltip("How much the global wind effect affects the spring"); windSlider.SetPos(XMFLOAT2(x, y += step)); windSlider.SetSize(XMFLOAT2(siz, hei)); - windSlider.OnSlide(forEachSelected([&] (auto spring, auto args) { + windSlider.OnSlide(forEachSelected([] (auto spring, auto args) { spring->windForce = args.fValue; })); AddWidget(&windSlider); @@ -106,7 +106,7 @@ void SpringWindow::Create(EditorComponent* _editor) gravitySlider.SetTooltip("How much the global gravity effect affects the spring"); gravitySlider.SetPos(XMFLOAT2(x, y += step)); gravitySlider.SetSize(XMFLOAT2(siz, hei)); - gravitySlider.OnSlide(forEachSelected([&] (auto spring, auto args) { + gravitySlider.OnSlide(forEachSelected([] (auto spring, auto args) { spring->gravityPower = args.fValue; })); AddWidget(&gravitySlider); @@ -115,7 +115,7 @@ void SpringWindow::Create(EditorComponent* _editor) hitradiusSlider.SetTooltip("The radius of the spring's collision sphere, that will be checked against colliders."); hitradiusSlider.SetPos(XMFLOAT2(x, y += step)); hitradiusSlider.SetSize(XMFLOAT2(siz, hei)); - hitradiusSlider.OnSlide(forEachSelected([&] (auto spring, auto args) { + hitradiusSlider.OnSlide(forEachSelected([] (auto spring, auto args) { spring->hitRadius = args.fValue; })); AddWidget(&hitradiusSlider); diff --git a/Editor/SpriteWindow.cpp b/Editor/SpriteWindow.cpp index a3068d236..93b8909e5 100644 --- a/Editor/SpriteWindow.cpp +++ b/Editor/SpriteWindow.cpp @@ -13,7 +13,7 @@ void SpriteWindow::Create(EditorComponent* _editor) SetSize(XMFLOAT2(670, 1540)); closeButton.SetTooltip("Delete Sprite"); - OnClose([=](wi::gui::EventArgs args) { + OnClose([this](wi::gui::EventArgs args) { wi::Archive& archive = editor->AdvanceHistory(); archive << EditorComponent::HISTORYOP_COMPONENT_DATA; @@ -26,8 +26,8 @@ void SpriteWindow::Create(EditorComponent* _editor) editor->componentsWnd.RefreshEntityTree(); }); - auto forEachSelected = [&] (auto func) { - return [&, func] (auto args) { + auto forEachSelected = [this] (auto func) { + return [this, func] (auto args) { wi::scene::Scene& scene = editor->GetCurrentScene(); for (auto& x : editor->translator.selected) { @@ -46,7 +46,7 @@ void SpriteWindow::Create(EditorComponent* _editor) textureButton.sprites[wi::gui::FOCUS].params.color = wi::Color::Gray(); textureButton.sprites[wi::gui::ACTIVE].params.color = wi::Color::White(); textureButton.sprites[wi::gui::DEACTIVATING].params.color = wi::Color::Gray(); - textureButton.OnClick(forEachSelected([&] (auto sprite, auto args) { + textureButton.OnClick(forEachSelected([this] (auto sprite, auto args) { if (sprite->textureResource.IsValid()) { wi::Archive& archive = editor->AdvanceHistory(); @@ -90,7 +90,7 @@ void SpriteWindow::Create(EditorComponent* _editor) maskButton.sprites[wi::gui::FOCUS].params.color = wi::Color::Gray(); maskButton.sprites[wi::gui::ACTIVE].params.color = wi::Color::White(); maskButton.sprites[wi::gui::DEACTIVATING].params.color = wi::Color::Gray(); - maskButton.OnClick(forEachSelected([&] (auto sprite, auto args) { + maskButton.OnClick(forEachSelected([this] (auto sprite, auto args) { if (sprite->maskResource.IsValid()) { wi::Archive& archive = editor->AdvanceHistory(); @@ -119,84 +119,84 @@ void SpriteWindow::Create(EditorComponent* _editor) pivotXSlider.Create(0, 1, 0, 10000, "Pivot X: "); pivotXSlider.SetTooltip("Horizontal pivot: 0: left, 0.5: center, 1: right"); - pivotXSlider.OnSlide(forEachSelected([&] (auto sprite, auto args) { + pivotXSlider.OnSlide(forEachSelected([] (auto sprite, auto args) { sprite->params.pivot.x = args.fValue; })); AddWidget(&pivotXSlider); pivotYSlider.Create(0, 1, 0, 10000, "Pivot Y: "); pivotYSlider.SetTooltip("Vertical pivot: 0: top, 0.5: center, 1: bottom"); - pivotYSlider.OnSlide(forEachSelected([&] (auto sprite, auto args) { + pivotYSlider.OnSlide(forEachSelected([] (auto sprite, auto args) { sprite->params.pivot.y = args.fValue; })); AddWidget(&pivotYSlider); intensitySlider.Create(0, 100, 1, 10000, "Intensity: "); intensitySlider.SetTooltip("Color multiplier"); - intensitySlider.OnSlide(forEachSelected([&] (auto sprite, auto args) { + intensitySlider.OnSlide(forEachSelected([] (auto sprite, auto args) { sprite->params.intensity = args.fValue; })); AddWidget(&intensitySlider); rotationSlider.Create(0, 360, 0, 10000, "Rotation: "); rotationSlider.SetTooltip("Z Rotation around pivot point. The editor input is in degrees."); - rotationSlider.OnSlide(forEachSelected([&] (auto sprite, auto args) { + rotationSlider.OnSlide(forEachSelected([] (auto sprite, auto args) { sprite->params.rotation = wi::math::DegreesToRadians(args.fValue); })); AddWidget(&rotationSlider); saturationSlider.Create(0, 2, 1, 1000, "Saturation: "); saturationSlider.SetTooltip("Modify saturation of the image."); - saturationSlider.OnSlide(forEachSelected([&] (auto sprite, auto args) { + saturationSlider.OnSlide(forEachSelected([] (auto sprite, auto args) { sprite->params.saturation = args.fValue; })); AddWidget(&saturationSlider); alphaStartSlider.Create(0, 1, 0, 10000, "Mask Alpha Start: "); alphaStartSlider.SetTooltip("Constrain mask alpha to not go below this level."); - alphaStartSlider.OnSlide(forEachSelected([&] (auto sprite, auto args) { + alphaStartSlider.OnSlide(forEachSelected([] (auto sprite, auto args) { sprite->params.mask_alpha_range_start = args.fValue; })); AddWidget(&alphaStartSlider); alphaEndSlider.Create(0, 1, 1, 10000, "Mask Alpha End: "); alphaEndSlider.SetTooltip("Constrain mask alpha to not go above this level."); - alphaEndSlider.OnSlide(forEachSelected([&] (auto sprite, auto args) { + alphaEndSlider.OnSlide(forEachSelected([] (auto sprite, auto args) { sprite->params.mask_alpha_range_end = args.fValue; })); AddWidget(&alphaEndSlider); borderSoftenSlider.Create(0, 1, 0, 10000, "Border Soften: "); borderSoftenSlider.SetTooltip("Soften the borders of the sprite."); - borderSoftenSlider.OnSlide(forEachSelected([&] (auto sprite, auto args) { + borderSoftenSlider.OnSlide(forEachSelected([] (auto sprite, auto args) { sprite->params.border_soften = args.fValue; })); AddWidget(&borderSoftenSlider); cornerRounding0Slider.Create(0, 0.5f, 1, 10000, "Rounding 0: "); cornerRounding0Slider.SetTooltip("Enable corner rounding for the lop left corner."); - cornerRounding0Slider.OnSlide(forEachSelected([&] (auto sprite, auto args) { + cornerRounding0Slider.OnSlide(forEachSelected([] (auto sprite, auto args) { sprite->params.corners_rounding[0].radius = args.fValue; })); AddWidget(&cornerRounding0Slider); cornerRounding1Slider.Create(0, 0.5f, 0, 10000, "Rounding 1: "); cornerRounding1Slider.SetTooltip("Enable corner rounding for the lop right corner."); - cornerRounding1Slider.OnSlide(forEachSelected([&] (auto sprite, auto args) { + cornerRounding1Slider.OnSlide(forEachSelected([] (auto sprite, auto args) { sprite->params.corners_rounding[1].radius = args.fValue; })); AddWidget(&cornerRounding1Slider); cornerRounding2Slider.Create(0, 0.5f, 0, 10000, "Rounding 2: "); cornerRounding2Slider.SetTooltip("Enable corner rounding for the bottom left corner."); - cornerRounding2Slider.OnSlide(forEachSelected([&] (auto sprite, auto args) { + cornerRounding2Slider.OnSlide(forEachSelected([] (auto sprite, auto args) { sprite->params.corners_rounding[2].radius = args.fValue; })); AddWidget(&cornerRounding2Slider); cornerRounding3Slider.Create(0, 0.5f, 0, 10000, "Rounding 3: "); cornerRounding3Slider.SetTooltip("Enable corner rounding for the bottom right corner."); - cornerRounding3Slider.OnSlide(forEachSelected([&] (auto sprite, auto args) { + cornerRounding3Slider.OnSlide(forEachSelected([] (auto sprite, auto args) { sprite->params.corners_rounding[3].radius = args.fValue; })); AddWidget(&cornerRounding3Slider); @@ -205,7 +205,7 @@ void SpriteWindow::Create(EditorComponent* _editor) qualityCombo.AddItem("Nearest Neighbor", wi::image::QUALITY_NEAREST); qualityCombo.AddItem("Linear", wi::image::QUALITY_LINEAR); qualityCombo.AddItem("Anisotropic", wi::image::QUALITY_ANISOTROPIC); - qualityCombo.OnSelect(forEachSelected([&] (auto sprite, auto args) { + qualityCombo.OnSelect(forEachSelected([] (auto sprite, auto args) { sprite->params.quality = (wi::image::QUALITY)args.userdata; })); AddWidget(&qualityCombo); @@ -214,7 +214,7 @@ void SpriteWindow::Create(EditorComponent* _editor) samplemodeCombo.AddItem("Clamp", wi::image::SAMPLEMODE_CLAMP); samplemodeCombo.AddItem("Mirror", wi::image::SAMPLEMODE_MIRROR); samplemodeCombo.AddItem("Wrap", wi::image::SAMPLEMODE_WRAP); - samplemodeCombo.OnSelect(forEachSelected([&] (auto sprite, auto args) { + samplemodeCombo.OnSelect(forEachSelected([] (auto sprite, auto args) { sprite->params.sampleFlag = (wi::image::SAMPLEMODE)args.userdata; })); AddWidget(&samplemodeCombo); @@ -226,35 +226,35 @@ void SpriteWindow::Create(EditorComponent* _editor) blendModeCombo.AddItem("Additive", wi::enums::BLENDMODE_ADDITIVE); blendModeCombo.AddItem("Multiply", wi::enums::BLENDMODE_MULTIPLY); blendModeCombo.AddItem("Inverse", wi::enums::BLENDMODE_INVERSE); - blendModeCombo.OnSelect(forEachSelected([&] (auto sprite, auto args) { + blendModeCombo.OnSelect(forEachSelected([] (auto sprite, auto args) { sprite->params.blendFlag = (wi::enums::BLENDMODE)args.userdata; })); AddWidget(&blendModeCombo); hiddenCheckBox.Create("Hidden: "); hiddenCheckBox.SetTooltip("Hide / unhide the sprite"); - hiddenCheckBox.OnClick(forEachSelected([&] (auto sprite, auto args) { + hiddenCheckBox.OnClick(forEachSelected([] (auto sprite, auto args) { sprite->SetHidden(args.bValue); })); AddWidget(&hiddenCheckBox); cameraFacingCheckBox.Create("Camera Facing: "); cameraFacingCheckBox.SetTooltip("Camera facing sprites will always rotate towards the camera."); - cameraFacingCheckBox.OnClick(forEachSelected([&] (auto sprite, auto args) { + cameraFacingCheckBox.OnClick(forEachSelected([] (auto sprite, auto args) { sprite->SetCameraFacing(args.bValue); })); AddWidget(&cameraFacingCheckBox); cameraScalingCheckBox.Create("Camera Scaling: "); cameraScalingCheckBox.SetTooltip("Camera scaling sprites will always keep the same size on screen, irrespective of the distance to the camera."); - cameraScalingCheckBox.OnClick(forEachSelected([&] (auto sprite, auto args) { + cameraScalingCheckBox.OnClick(forEachSelected([] (auto sprite, auto args) { sprite->SetCameraScaling(args.bValue); })); AddWidget(&cameraScalingCheckBox); depthTestCheckBox.Create("Depth Test: "); depthTestCheckBox.SetTooltip("Depth tested sprites will be clipped against geometry."); - depthTestCheckBox.OnClick(forEachSelected([&] (auto sprite, auto args) { + depthTestCheckBox.OnClick(forEachSelected([] (auto sprite, auto args) { if (args.bValue) { sprite->params.enableDepthTest(); @@ -268,7 +268,7 @@ void SpriteWindow::Create(EditorComponent* _editor) distortionCheckBox.Create("Distortion: "); distortionCheckBox.SetTooltip("The distortion effect will use the sprite as a normal map to distort the rendered image.\nUse the color alpha to control distortion amount."); - distortionCheckBox.OnClick(forEachSelected([&] (auto sprite, auto args) { + distortionCheckBox.OnClick(forEachSelected([] (auto sprite, auto args) { if (args.bValue) { sprite->params.enableExtractNormalMap(); @@ -281,28 +281,28 @@ void SpriteWindow::Create(EditorComponent* _editor) AddWidget(&distortionCheckBox); colorPicker.Create("Color", wi::gui::Window::WindowControls::NONE); - colorPicker.OnColorChanged(forEachSelected([&] (auto sprite, auto args) { + colorPicker.OnColorChanged(forEachSelected([] (auto sprite, auto args) { sprite->params.color = args.color; })); AddWidget(&colorPicker); movingTexXSlider.Create(-1000, 1000, 0, 10000, "Scrolling X: "); movingTexXSlider.SetTooltip("Scrolling animation's speed in X direction."); - movingTexXSlider.OnSlide(forEachSelected([&] (auto sprite, auto args) { + movingTexXSlider.OnSlide(forEachSelected([] (auto sprite, auto args) { sprite->anim.movingTexAnim.speedX = args.fValue; })); AddWidget(&movingTexXSlider); movingTexYSlider.Create(-1000, 1000, 0, 10000, "Scrolling Y: "); movingTexYSlider.SetTooltip("Scrolling animation's speed in Y direction."); - movingTexYSlider.OnSlide(forEachSelected([&] (auto sprite, auto args) { + movingTexYSlider.OnSlide(forEachSelected([] (auto sprite, auto args) { sprite->anim.movingTexAnim.speedY = args.fValue; })); AddWidget(&movingTexYSlider); drawrectFrameRateSlider.Create(0, 60, 0, 60, "Spritesheet FPS: "); drawrectFrameRateSlider.SetTooltip("Sprite Sheet animation's frame rate per second."); - drawrectFrameRateSlider.OnSlide(forEachSelected([&] (auto sprite, auto args) { + drawrectFrameRateSlider.OnSlide(forEachSelected([this] (auto sprite, auto args) { sprite->anim.drawRectAnim.frameRate = args.fValue; UpdateSpriteDrawRectParams(sprite); })); @@ -311,7 +311,7 @@ void SpriteWindow::Create(EditorComponent* _editor) drawrectFrameCountInput.Create(""); drawrectFrameCountInput.SetDescription("frames: "); drawrectFrameCountInput.SetTooltip("Set the total frame count of the sprite sheet animation (1 = only 1 frame, no animation)."); - drawrectFrameCountInput.OnInputAccepted(forEachSelected([&] (auto sprite, auto args) { + drawrectFrameCountInput.OnInputAccepted(forEachSelected([this] (auto sprite, auto args) { sprite->anim.drawRectAnim.frameCount = args.iValue; UpdateSpriteDrawRectParams(sprite); })); @@ -320,7 +320,7 @@ void SpriteWindow::Create(EditorComponent* _editor) drawrectHorizontalFrameCountInput.Create(""); drawrectHorizontalFrameCountInput.SetDescription("Horiz. frames: "); drawrectHorizontalFrameCountInput.SetTooltip("Set the horizontal frame count of the sprite sheet animation.\n(optional, use if sprite sheet contains multiple rows, default = 0)."); - drawrectHorizontalFrameCountInput.OnInputAccepted(forEachSelected([&] (auto sprite, auto args) { + drawrectHorizontalFrameCountInput.OnInputAccepted(forEachSelected([this] (auto sprite, auto args) { sprite->anim.drawRectAnim.horizontalFrameCount = args.iValue; UpdateSpriteDrawRectParams(sprite); })); @@ -328,21 +328,21 @@ void SpriteWindow::Create(EditorComponent* _editor) wobbleXSlider.Create(0, 1, 0, 10000, "Wobble X: "); wobbleXSlider.SetTooltip("Wobble animation's amount in X direction."); - wobbleXSlider.OnSlide(forEachSelected([&] (auto sprite, auto args) { + wobbleXSlider.OnSlide(forEachSelected([] (auto sprite, auto args) { sprite->anim.wobbleAnim.amount.x = args.fValue; })); AddWidget(&wobbleXSlider); wobbleYSlider.Create(0, 1, 0, 10000, "Wobble Y: "); wobbleYSlider.SetTooltip("Wobble animation's amount in X direction."); - wobbleYSlider.OnSlide(forEachSelected([&] (auto sprite, auto args) { + wobbleYSlider.OnSlide(forEachSelected([] (auto sprite, auto args) { sprite->anim.wobbleAnim.amount.y = args.fValue; })); AddWidget(&wobbleYSlider); wobbleSpeedSlider.Create(0, 4, 0, 10000, "Wobble Speed: "); wobbleSpeedSlider.SetTooltip("Wobble animation's speed."); - wobbleSpeedSlider.OnSlide(forEachSelected([&] (auto sprite, auto args) { + wobbleSpeedSlider.OnSlide(forEachSelected([] (auto sprite, auto args) { sprite->anim.wobbleAnim.speed = args.fValue; })); AddWidget(&wobbleSpeedSlider); diff --git a/Editor/main_SDL2.cpp b/Editor/main_SDL2.cpp index 2bea1088a..49db6f906 100644 --- a/Editor/main_SDL2.cpp +++ b/Editor/main_SDL2.cpp @@ -168,7 +168,7 @@ void crash_handler(int sig) fflush(logfile); backtrace_symbols_fd(btbuf, size, fileno(logfile)); fputs("\nBacklog:\n", logfile); - wi::backlog::_forEachLogEntry_unsafe([&] (auto&& entry) { + wi::backlog::_forEachLogEntry_unsafe([&logfile] (auto&& entry) { fputs(entry.text.c_str(), logfile); fflush(logfile); });