From 2645b69ec0da1f3522d784aea606f1f634226da0 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Fri, 14 Jul 2023 17:10:28 +0200 Subject: [PATCH] Tweak air lif/drag coeffs to properly simulate wind on cloth --- Source/Engine/Physics/Actors/Cloth.h | 4 ++-- Source/Engine/Physics/PhysX/PhysicsBackendPhysX.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/Engine/Physics/Actors/Cloth.h b/Source/Engine/Physics/Actors/Cloth.h index fc5eaea63..9ce500147 100644 --- a/Source/Engine/Physics/Actors/Cloth.h +++ b/Source/Engine/Physics/Actors/Cloth.h @@ -62,12 +62,12 @@ API_CLASS(Attributes="ActorContextMenu(\"New/Physics/Cloth\"), ActorToolbox(\"Ph /// /// Defines how much drag air applies to the cloth particles. Set to 0 to disable wind. /// - API_FIELD(Attributes="Limit(0, 1)") float AirDragCoefficient = 0.0f; + API_FIELD(Attributes="Limit(0, 1)") float AirDragCoefficient = 0.02f; /// /// Defines how much lift air applies to the cloth particles. Set to 0 to disable wind. /// - API_FIELD(Attributes="Limit(0, 1)") float AirLiftCoefficient = 0.0f; + API_FIELD(Attributes="Limit(0, 1)") float AirLiftCoefficient = 0.02f; /// /// Defines fluid density of air used for drag and lift calculations. diff --git a/Source/Engine/Physics/PhysX/PhysicsBackendPhysX.cpp b/Source/Engine/Physics/PhysX/PhysicsBackendPhysX.cpp index a93ab0292..e47fad0b3 100644 --- a/Source/Engine/Physics/PhysX/PhysicsBackendPhysX.cpp +++ b/Source/Engine/Physics/PhysX/PhysicsBackendPhysX.cpp @@ -3450,8 +3450,8 @@ void PhysicsBackend::SetClothForceSettings(void* cloth, const void* settingsPtr) clothPhysX->setLinearInertia(PxVec3(settings.LinearInertia)); clothPhysX->setAngularInertia(PxVec3(settings.AngularInertia)); clothPhysX->setCentrifugalInertia(PxVec3(settings.CentrifugalInertia)); - clothPhysX->setDragCoefficient(Math::Saturate(settings.AirDragCoefficient)); - clothPhysX->setLiftCoefficient(Math::Saturate(settings.AirLiftCoefficient)); + clothPhysX->setDragCoefficient(Math::Saturate(settings.AirDragCoefficient) * 0.01f); + clothPhysX->setLiftCoefficient(Math::Saturate(settings.AirLiftCoefficient) * 0.01f); clothPhysX->setFluidDensity(Math::Max(settings.AirDensity, ZeroTolerance)); auto& clothSettings = Cloths[clothPhysX]; clothSettings.GravityScale = settings.GravityScale;