[Bf-blender-cvs] [54a2fcc0f33] blender-v2.90-release: Fix Cloth Brush global Sculpt gravity applied in the wrong falloff

Pablo Dobarro noreply at git.blender.org
Wed Jul 29 17:22:17 CEST 2020


Commit: 54a2fcc0f331b8971e8a105382e9a8f67e1859e3
Author: Pablo Dobarro
Date:   Tue Jul 28 01:16:31 2020 +0200
Branches: blender-v2.90-release
https://developer.blender.org/rB54a2fcc0f331b8971e8a105382e9a8f67e1859e3

Fix Cloth Brush global Sculpt gravity applied in the wrong falloff

Previously, gravity was only applied in the real brush radius, not in
the whole simulation radius. For most deformation modes, applying
gravity to the entire simulation instead of just to the brush radius and
scaled by the radius (like a regular sculpt brush) makes more sense.
After this fix and with the cloth collisions patch applied, it is possible
to do things like this with the cloth grab brush.

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D8406

===================================================================

M	source/blender/editors/sculpt_paint/sculpt_cloth.c

===================================================================

diff --git a/source/blender/editors/sculpt_paint/sculpt_cloth.c b/source/blender/editors/sculpt_paint/sculpt_cloth.c
index 115d6f665a3..4232be91034 100644
--- a/source/blender/editors/sculpt_paint/sculpt_cloth.c
+++ b/source/blender/editors/sculpt_paint/sculpt_cloth.c
@@ -254,8 +254,7 @@ static void do_cloth_brush_apply_forces_task_cb_ex(void *__restrict userdata,
   /* Gravity */
   float gravity[3] = {0.0f};
   if (ss->cache->supports_gravity) {
-    madd_v3_v3fl(
-        gravity, ss->cache->gravity_direction, -ss->cache->radius * data->sd->gravity_factor);
+    madd_v3_v3fl(gravity, ss->cache->gravity_direction, -data->sd->gravity_factor);
   }
 
   /* Original data for deform brushes. */
@@ -279,6 +278,11 @@ static void do_cloth_brush_apply_forces_task_cb_ex(void *__restrict userdata,
       copy_v3_v3(current_vertex_location, vd.co);
     }
 
+    /* Apply gravity in the entire simulation area. */
+    float vertex_gravity[3];
+    mul_v3_v3fl(vertex_gravity, gravity, sim_factor);
+    cloth_brush_apply_force_to_vertex(ss, ss->cache->cloth_sim, vertex_gravity, vd.index);
+
     /* When using the plane falloff mode the falloff is not constrained by the brush radius. */
     if (sculpt_brush_test_sq_fn(&test, current_vertex_location) || use_falloff_plane) {
 
@@ -356,8 +360,6 @@ static void do_cloth_brush_apply_forces_task_cb_ex(void *__restrict userdata,
           break;
       }
 
-      madd_v3_v3fl(force, gravity, fade);
-
       cloth_brush_apply_force_to_vertex(ss, ss->cache->cloth_sim, force, vd.index);
     }
   }



More information about the Bf-blender-cvs mailing list