diff options
-rw-r--r-- | release/scripts/startup/bl_ui/properties_physics_cloth.py | 226 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_blender_version.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_cloth.h | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/cloth.c | 74 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/collision.c | 130 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/particle_system.c | 3 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_280.c | 29 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_cloth_types.h | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_cloth.c | 71 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_particle.c | 2 | ||||
-rw-r--r-- | source/blender/physics/intern/BPH_mass_spring.cpp | 20 |
11 files changed, 298 insertions, 265 deletions
diff --git a/release/scripts/startup/bl_ui/properties_physics_cloth.py b/release/scripts/startup/bl_ui/properties_physics_cloth.py index bcb0382f8c3..983e2910bce 100644 --- a/release/scripts/startup/bl_ui/properties_physics_cloth.py +++ b/release/scripts/startup/bl_ui/properties_physics_cloth.py @@ -73,63 +73,112 @@ class PHYSICS_PT_cloth(PhysicButtonsPanel, Panel): col = flow.column() col.prop(cloth, "quality", text="Quality Steps") + col = flow.column() col.prop(cloth, "time_scale", text="Speed Multiplier") - col.prop(cloth, "bending_model") - col.separator() +class PHYSICS_PT_cloth_physical_properties(PhysicButtonsPanel, Panel): + bl_label = "Physical Properties" + bl_parent_id = 'PHYSICS_PT_cloth' + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} + + def draw(self, context): + layout = self.layout + layout.use_property_split = True + + md = context.cloth + cloth = md.settings + + layout.active = cloth_panel_enabled(md) + + flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=True) + + col = flow.column() + col.prop(cloth, "mass", text="Mass") col = flow.column() - col.prop(cloth, "mass", text="Material Mass") - col.prop(cloth, "air_damping", text="Air") - col.prop(cloth, "vel_damping", text="Velocity") + col.prop(cloth, "air_damping", text="Air Viscosity") + col = flow.column() + col.prop(cloth, "bending_model") - col.separator() + +class PHYSICS_PT_cloth_stiffness(PhysicButtonsPanel, Panel): + bl_label = "Stiffness" + bl_parent_id = 'PHYSICS_PT_cloth_physical_properties' + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} + + def draw(self, context): + layout = self.layout + layout.use_property_split = True + + md = context.cloth + cloth = md.settings + + layout.active = cloth_panel_enabled(md) + + flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=True) col = flow.column() + if cloth.bending_model == 'ANGULAR': - col.prop(cloth, "tension_stiffness", text="Stiffness Tension") + col.prop(cloth, "tension_stiffness", text="Tension") + col = flow.column() col.prop(cloth, "compression_stiffness", text="Compression") else: - col.prop(cloth, "tension_stiffness", text="Stiffness Structural") + col.prop(cloth, "tension_stiffness", text="Structural") + col = flow.column() col.prop(cloth, "shear_stiffness", text="Shear") + col = flow.column() col.prop(cloth, "bending_stiffness", text="Bending") - col.separator() + +class PHYSICS_PT_cloth_damping(PhysicButtonsPanel, Panel): + bl_label = "Damping" + bl_parent_id = 'PHYSICS_PT_cloth_physical_properties' + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} + + def draw(self, context): + layout = self.layout + layout.use_property_split = True + + md = context.cloth + cloth = md.settings + + layout.active = cloth_panel_enabled(md) + + flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=True) col = flow.column() + if cloth.bending_model == 'ANGULAR': - col.prop(cloth, "tension_damping", text="Damping Tension") + col.prop(cloth, "tension_damping", text="Tension") + col = flow.column() col.prop(cloth, "compression_damping", text="Compression") else: - col.prop(cloth, "tension_damping", text="Damping Structural") + col.prop(cloth, "tension_damping", text="Structural") + col = flow.column() col.prop(cloth, "shear_damping", text="Shear") - col.prop(cloth, "bending_damping", text="Bending") - col = flow.column() - col.prop(cloth, "use_dynamic_mesh", text="Dynamic Mesh") - - key = ob.data.shape_keys - - if key: - row = col.row(align=True) - row.active = not cloth.use_dynamic_mesh - row.prop_search(cloth, "rest_shape_key", key, "key_blocks", text="Rest Shape Key") + col.prop(cloth, "bending_damping", text="Bending") -class PHYSICS_PT_cloth_pinning(PhysicButtonsPanel, Panel): - bl_label = "Pinning" +class PHYSICS_PT_cloth_cache(PhysicButtonsPanel, Panel): + bl_label = "Cache" bl_parent_id = 'PHYSICS_PT_cloth' bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} - def draw_header(self, context): + def draw(self, context): md = context.cloth - cloth = md.settings + point_cache_ui(self, context, md.point_cache, cloth_panel_enabled(md), 'CLOTH') + - self.layout.active = cloth_panel_enabled(md) - self.layout.prop(cloth, "use_pin_cloth", text="") +class PHYSICS_PT_cloth_shape(PhysicButtonsPanel, Panel): + bl_label = "Shape" + bl_parent_id = 'PHYSICS_PT_cloth' + bl_options = {'DEFAULT_CLOSED'} + COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw(self, context): layout = self.layout @@ -139,40 +188,44 @@ class PHYSICS_PT_cloth_pinning(PhysicButtonsPanel, Panel): ob = context.object cloth = md.settings - layout.active = cloth_panel_enabled(md) and cloth.use_pin_cloth + layout.active = cloth_panel_enabled(md) flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=True) - col = flow.column() + col = flow.column(align=True) + col.prop_search(cloth, "vertex_group_mass", ob, "vertex_groups", text="Pin Group") - col.prop_search(cloth, "vertex_group_mass", ob, "vertex_groups", text="Mass Group") + sub = col.column(align=True) + sub.active = cloth.vertex_group_mass != "" + sub.prop(cloth, "pin_stiffness", text="Stiffness") - col = flow.column() - col.prop(cloth, "pin_stiffness", text="Stiffness") + col.separator() - # Disabled for now. - """ - if cloth.vertex_group_mass: - col = flow.column() - col.prop(cloth, "goal_default", text="Goal Default") - col.prop(cloth, "goal_spring", text="Stiffness") - col.prop(cloth, "goal_friction", text="Friction") - """ + col = flow.column(align=True) + col.prop(cloth, "use_sewing_springs", text="Sewing") + sub = col.column(align=True) + sub.active = cloth.use_sewing_springs + sub.prop(cloth, "sewing_force_max", text="Max Sewing Force") -class PHYSICS_PT_cloth_cache(PhysicButtonsPanel, Panel): - bl_label = "Cache" - bl_parent_id = 'PHYSICS_PT_cloth' - bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} + col.separator() - def draw(self, context): - md = context.cloth - point_cache_ui(self, context, md.point_cache, cloth_panel_enabled(md), 'CLOTH') + col = flow.column() + col.prop(cloth, "shrink_min", text="Shrinking Factor") + col = flow.column() + col.prop(cloth, "use_dynamic_mesh", text="Dynamic Mesh") + + key = ob.data.shape_keys -class PHYSICS_PT_cloth_collision(PhysicButtonsPanel, Panel): - bl_label = "Collision" + if key: + col = flow.column() + col.active = not cloth.use_dynamic_mesh + col.prop_search(cloth, "rest_shape_key", key, "key_blocks", text="Rest Shape Key") + + +class PHYSICS_PT_cloth_object_collision(PhysicButtonsPanel, Panel): + bl_label = "Object Collision" bl_parent_id = 'PHYSICS_PT_cloth' bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} @@ -207,14 +260,14 @@ class PHYSICS_PT_cloth_collision(PhysicButtonsPanel, Panel): class PHYSICS_PT_cloth_self_collision(PhysicButtonsPanel, Panel): bl_label = "Self Collision" - bl_parent_id = 'PHYSICS_PT_cloth_collision' + bl_parent_id = 'PHYSICS_PT_cloth' bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} def draw_header(self, context): cloth = context.cloth.collision_settings - self.layout.active = cloth_panel_enabled(context.cloth) and cloth.use_self_collision + self.layout.active = cloth_panel_enabled(context.cloth) self.layout.prop(cloth, "use_self_collision", text="") def draw(self, context): @@ -225,7 +278,7 @@ class PHYSICS_PT_cloth_self_collision(PhysicButtonsPanel, Panel): md = context.cloth ob = context.object - layout.active = cloth.use_collision and cloth_panel_enabled(md) and cloth.use_self_collision + layout.active = cloth.use_self_collision and cloth_panel_enabled(md) flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=True) @@ -237,18 +290,12 @@ class PHYSICS_PT_cloth_self_collision(PhysicButtonsPanel, Panel): col.prop_search(cloth, "vertex_group_self_collisions", ob, "vertex_groups", text="Vertex Group") -class PHYSICS_PT_cloth_stiffness(PhysicButtonsPanel, Panel): - bl_label = "Stiffness Scaling" +class PHYSICS_PT_cloth_property_weights(PhysicButtonsPanel, Panel): + bl_label = "Property Weights" bl_parent_id = 'PHYSICS_PT_cloth' bl_options = {'DEFAULT_CLOSED'} COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} - def draw_header(self, context): - cloth = context.cloth.settings - - self.layout.active = cloth_panel_enabled(context.cloth) - self.layout.prop(cloth, "use_stiffness_scale", text="") - def draw(self, context): layout = self.layout layout.use_property_split = True @@ -257,7 +304,7 @@ class PHYSICS_PT_cloth_stiffness(PhysicButtonsPanel, Panel): ob = context.object cloth = context.cloth.settings - layout.active = (cloth.use_stiffness_scale and cloth_panel_enabled(md)) + layout.active = cloth_panel_enabled(md) flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=True) @@ -267,7 +314,7 @@ class PHYSICS_PT_cloth_stiffness(PhysicButtonsPanel, Panel): text="Structural Group" ) col.prop(cloth, "tension_stiffness_max", text="Max Tension") - col.prop(cloth, "compression_stiffness_max", text="Compression") + col.prop(cloth, "compression_stiffness_max", text="Max Compression") col.separator() @@ -276,7 +323,7 @@ class PHYSICS_PT_cloth_stiffness(PhysicButtonsPanel, Panel): cloth, "vertex_group_shear_stiffness", ob, "vertex_groups", text="Shear Group" ) - col.prop(cloth, "shear_stiffness_max", text="Max") + col.prop(cloth, "shear_stiffness_max", text="Max Shearing") col.separator() @@ -285,43 +332,16 @@ class PHYSICS_PT_cloth_stiffness(PhysicButtonsPanel, Panel): cloth, "vertex_group_bending", ob, "vertex_groups", text="Bending Group" ) - col.prop(cloth, "bending_stiffness_max", text="Max") - - -class PHYSICS_PT_cloth_sewing(PhysicButtonsPanel, Panel): - bl_label = "Sewing Springs" - bl_parent_id = 'PHYSICS_PT_cloth' - bl_options = {'DEFAULT_CLOSED'} - COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} - - def draw_header(self, context): - cloth = context.cloth.settings - - self.layout.active = cloth_panel_enabled(context.cloth) - self.layout.prop(cloth, "use_sewing_springs", text="") - - def draw(self, context): - layout = self.layout - layout.use_property_split = True - - md = context.cloth - ob = context.object - cloth = context.cloth.settings - - layout.active = (cloth.use_sewing_springs and cloth_panel_enabled(md)) - flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=True) - - col = flow.column() - col.prop(cloth, "sewing_force_max", text="Sewing Force") + col.prop(cloth, "bending_stiffness_max", text="Max Bending") col.separator() - col = col.column() - col.prop_search(cloth, "vertex_group_shrink", ob, "vertex_groups", text="Shrinking Group") - - col = flow.column(align=True) - col.prop(cloth, "shrink_min", text="Min") - col.prop(cloth, "shrink_max", text="Max") + col = flow.column() + col.prop_search( + cloth, "vertex_group_shrink", ob, "vertex_groups", + text="Shrinking Group" + ) + col.prop(cloth, "shrink_max", text="Max Shrinking") class PHYSICS_PT_cloth_field_weights(PhysicButtonsPanel, Panel): @@ -338,12 +358,14 @@ class PHYSICS_PT_cloth_field_weights(PhysicButtonsPanel, Panel): classes = ( CLOTH_PT_presets, PHYSICS_PT_cloth, + PHYSICS_PT_cloth_physical_properties, + PHYSICS_PT_cloth_stiffness, + PHYSICS_PT_cloth_damping, PHYSICS_PT_cloth_cache, - PHYSICS_PT_cloth_collision, + PHYSICS_PT_cloth_shape, + PHYSICS_PT_cloth_object_collision, PHYSICS_PT_cloth_self_collision, - PHYSICS_PT_cloth_pinning, - PHYSICS_PT_cloth_stiffness, - PHYSICS_PT_cloth_sewing, + PHYSICS_PT_cloth_property_weights, PHYSICS_PT_cloth_field_weights, ) diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h index 79ae904c73d..1b31688d461 100644 --- a/source/blender/blenkernel/BKE_blender_version.h +++ b/source/blender/blenkernel/BKE_blender_version.h @@ -28,7 +28,7 @@ * and keep comment above the defines. * Use STRINGIFY() rather than defining with quotes */ #define BLENDER_VERSION 280 -#define BLENDER_SUBVERSION 21 +#define BLENDER_SUBVERSION 22 /* Several breakages with 280, e.g. collections vs layers */ #define BLENDER_MINVERSION 280 #define BLENDER_MINSUBVERSION 0 diff --git a/source/blender/blenkernel/BKE_cloth.h b/source/blender/blenkernel/BKE_cloth.h index baf60397504..423d7014918 100644 --- a/source/blender/blenkernel/BKE_cloth.h +++ b/source/blender/blenkernel/BKE_cloth.h @@ -169,9 +169,9 @@ ClothSpring; /* These are the bits used in SimSettings.flags. */ typedef enum { CLOTH_SIMSETTINGS_FLAG_COLLOBJ = ( 1 << 2 ),// object is only collision object, no cloth simulation is done - CLOTH_SIMSETTINGS_FLAG_GOAL = ( 1 << 3 ), // we have goals enabled + CLOTH_SIMSETTINGS_FLAG_GOAL = ( 1 << 3 ), /* DEPRECATED, for versioning only. */ CLOTH_SIMSETTINGS_FLAG_TEARING = ( 1 << 4 ),// true if tearing is enabled - CLOTH_SIMSETTINGS_FLAG_SCALING = ( 1 << 8 ), /* is advanced scaling active? */ + CLOTH_SIMSETTINGS_FLAG_SCALING = ( 1 << 8 ), /* DEPRECATED, for versioning only. */ CLOTH_SIMSETTINGS_FLAG_CCACHE_EDIT = (1 << 12), /* edit cache in editmode */ CLOTH_SIMSETTINGS_FLAG_RESIST_SPRING_COMPRESS = (1 << 13), /* don't allow spring compression */ CLOTH_SIMSETTINGS_FLAG_SEW = (1 << 14), /* pull ends of loose edges together */ diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index 53894431fc3..a0475e98037 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -117,7 +117,6 @@ void cloth_init(ClothModifierData *clmd ) clmd->sim_parms->timescale = 1.0f; /* speed factor, describes how fast cloth moves */ clmd->sim_parms->time_scale = 1.0f; /* multiplies cloth speed */ clmd->sim_parms->reset = 0; - clmd->sim_parms->vel_damping = 1.0f; /* 1.0 = no damping, 0.0 = fully dampened */ clmd->coll_parms->self_friction = 5.0; clmd->coll_parms->friction = 5.0; @@ -396,8 +395,11 @@ static int do_step_cloth(Depsgraph *depsgraph, Object *ob, ClothModifierData *cl /* Support for dynamic vertex groups, changing from frame to frame */ cloth_apply_vgroup ( clmd, result ); - if ( clmd->sim_parms->flags & (CLOTH_SIMSETTINGS_FLAG_SEW | CLOTH_SIMSETTINGS_FLAG_DYNAMIC_BASEMESH) ) + if ((clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_DYNAMIC_BASEMESH) || + (clmd->sim_parms->vgroup_shrink > 0) || (clmd->sim_parms->shrink_min > 0.0f)) + { cloth_update_spring_lengths ( clmd, result ); + } cloth_update_springs( clmd ); @@ -679,15 +681,11 @@ static void cloth_to_object (Object *ob, ClothModifierData *clmd, float (*verte int cloth_uses_vgroup(ClothModifierData *clmd) { - return (((clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_SCALING ) || - (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL ) || - (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_SEW) || - (clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_SELF)) && - ((clmd->sim_parms->vgroup_mass>0) || - (clmd->sim_parms->vgroup_struct>0)|| - (clmd->sim_parms->vgroup_bend>0) || - (clmd->sim_parms->vgroup_shrink>0) || - (clmd->coll_parms->vgroup_selfcol>0))); + return (((clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_SELF) && (clmd->coll_parms->vgroup_selfcol > 0)) || + (clmd->sim_parms->vgroup_struct > 0) || + (clmd->sim_parms->vgroup_bend > 0) || + (clmd->sim_parms->vgroup_shrink > 0) || + (clmd->sim_parms->vgroup_mass > 0)); } /** @@ -717,7 +715,7 @@ static void cloth_apply_vgroup ( ClothModifierData *clmd, Mesh *mesh ) for (i = 0; i < mvert_num; i++, verts++) { /* Reset Goal values to standard */ - if ( clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL ) + if (clmd->sim_parms->vgroup_mass > 0) verts->goal= clmd->sim_parms->defgoal; else verts->goal= 0.0f; @@ -732,7 +730,7 @@ static void cloth_apply_vgroup ( ClothModifierData *clmd, Mesh *mesh ) dvert = CustomData_get(&mesh->vdata, i, CD_MDEFORMVERT); if ( dvert ) { for ( j = 0; j < dvert->totweight; j++ ) { - if (( dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_mass-1)) && (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL )) { + if (dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_mass - 1)) { verts->goal = dvert->dw [j].weight; /* goalfac= 1.0f; */ /* UNUSED */ @@ -745,18 +743,16 @@ static void cloth_apply_vgroup ( ClothModifierData *clmd, Mesh *mesh ) verts->flags |= CLOTH_VERT_FLAG_PINNED; } - if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_SCALING ) { - if ( dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_struct-1)) { - verts->struct_stiff = dvert->dw [j].weight; - } + if (dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_struct - 1)) { + verts->struct_stiff = dvert->dw[j].weight; + } - if ( dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_shear-1)) { - verts->shear_stiff = dvert->dw [j].weight; - } + if (dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_shear - 1)) { + verts->shear_stiff = dvert->dw[j].weight; + } - if ( dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_bend-1)) { - verts->bend_stiff = dvert->dw [j].weight; - } + if (dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_bend - 1)) { + verts->bend_stiff = dvert->dw[j].weight; } if (clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_SELF ) { @@ -766,12 +762,10 @@ static void cloth_apply_vgroup ( ClothModifierData *clmd, Mesh *mesh ) } } } - if ( clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_SEW ) { - if (clmd->sim_parms->vgroup_shrink > 0) { - if (dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_shrink - 1)) { - /* used for linear interpolation between min and max shrink factor based on weight */ - verts->shrink_factor = dvert->dw[j].weight; - } + if (clmd->sim_parms->vgroup_shrink > 0) { + if (dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_shrink - 1)) { + /* Used for linear interpolation between min and max shrink factor based on weight. */ + verts->shrink_factor = dvert->dw[j].weight; } } } @@ -782,20 +776,16 @@ static void cloth_apply_vgroup ( ClothModifierData *clmd, Mesh *mesh ) static float cloth_shrink_factor(ClothModifierData *clmd, ClothVertex *verts, int i1, int i2) { - if ( clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_SEW ) { - /* linear interpolation between min and max shrink factor based on weight */ - float base = 1.0f - clmd->sim_parms->shrink_min; - float delta = clmd->sim_parms->shrink_min - clmd->sim_parms->shrink_max; + /* Linear interpolation between min and max shrink factor based on weight. */ + float base = 1.0f - clmd->sim_parms->shrink_min; + float delta = clmd->sim_parms->shrink_min - clmd->sim_parms->shrink_max; - float k1 = base + delta * verts[i1].shrink_factor; - float k2 = base + delta * verts[i2].shrink_factor; + float k1 = base + delta * verts[i1].shrink_factor; + float k2 = base + delta * verts[i2].shrink_factor; - /* Use geometrical mean to average two factors since it behaves better - for diagonals when a rectangle transforms into a trapezoid. */ - return sqrtf(k1 * k2); - } - else - return 1.0f; + /* Use geometrical mean to average two factors since it behaves better + for diagonals when a rectangle transforms into a trapezoid. */ + return sqrtf(k1 * k2); } static int cloth_from_object(Object *ob, ClothModifierData *clmd, Mesh *mesh, float UNUSED(framenr), int first) @@ -864,7 +854,7 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, Mesh *mesh, fl verts->mass = clmd->sim_parms->mass; verts->impulse_count = 0; - if ( clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL ) + if (clmd->sim_parms->vgroup_mass > 0) verts->goal= clmd->sim_parms->defgoal; else verts->goal= 0.0f; diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index d7fab317105..183a4f9a181 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -708,88 +708,96 @@ int cloth_bvh_objcollision(Depsgraph *depsgraph, Object *ob, ClothModifierData * // static collisions //////////////////////////////////////////////////////////// - // update cloth bvh - bvhtree_update_from_cloth ( clmd, 1 ); // 0 means STATIC, 1 means MOVING (see later in this function) - bvhselftree_update_from_cloth ( clmd, 0 ); // 0 means STATIC, 1 means MOVING (see later in this function) + if (clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_ENABLED) { + bvhtree_update_from_cloth(clmd, true); - collobjs = BKE_collision_objects_create(depsgraph, ob, clmd->coll_parms->group, &numcollobj, eModifierType_Collision); + collobjs = BKE_collision_objects_create(depsgraph, ob, clmd->coll_parms->group, &numcollobj, eModifierType_Collision); - if (!collobjs) - return 0; + if (!collobjs) { + return 0; + } - /* move object to position (step) in time */ - for (i = 0; i < numcollobj; i++) { - Object *collob= collobjs[i]; - CollisionModifierData *collmd = (CollisionModifierData *)modifiers_findByType(collob, eModifierType_Collision); + /* Move object to position (step) in time. */ + for (i = 0; i < numcollobj; i++) { + Object *collob = collobjs[i]; + CollisionModifierData *collmd = (CollisionModifierData *)modifiers_findByType(collob, eModifierType_Collision); - if (!collmd->bvhtree) - continue; + if (!collmd->bvhtree) { + continue; + } - /* move object to position (step) in time */ - collision_move_object ( collmd, step + dt, step ); + /* Move object to position (step) in time. */ + collision_move_object(collmd, step + dt, step); + } } - do { - CollPair **collisions, **collisions_index; + if (clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_SELF) { + bvhselftree_update_from_cloth(clmd, false); + } + do { ret2 = 0; - collisions = MEM_callocN(sizeof(CollPair *) *numcollobj, "CollPair"); - collisions_index = MEM_callocN(sizeof(CollPair *) *numcollobj, "CollPair"); + if (clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_ENABLED) { + CollPair **collisions, **collisions_index; - // check all collision objects - for (i = 0; i < numcollobj; i++) { - Object *collob= collobjs[i]; - CollisionModifierData *collmd = (CollisionModifierData *)modifiers_findByType(collob, eModifierType_Collision); - BVHTreeOverlap *overlap = NULL; - unsigned int result = 0; + collisions = MEM_callocN(sizeof(CollPair *) *numcollobj, "CollPair"); + collisions_index = MEM_callocN(sizeof(CollPair *) *numcollobj, "CollPair"); - if (!collmd->bvhtree) - continue; + /* Check all collision objects. */ + for (i = 0; i < numcollobj; i++) { + Object *collob= collobjs[i]; + CollisionModifierData *collmd = (CollisionModifierData *)modifiers_findByType(collob, eModifierType_Collision); + BVHTreeOverlap *overlap = NULL; + unsigned int result = 0; - /* search for overlapping collision pairs */ - overlap = BLI_bvhtree_overlap(cloth_bvh, collmd->bvhtree, &result, NULL, NULL); + if (!collmd->bvhtree) { + continue; + } - // go to next object if no overlap is there - if ( result && overlap ) { - /* check if collisions really happen (costly near check) */ - cloth_bvh_objcollisions_nearcheck ( clmd, collmd, &collisions[i], - &collisions_index[i], result, overlap, dt/(float)clmd->coll_parms->loop_count); + /* Search for overlapping collision pairs. */ + overlap = BLI_bvhtree_overlap(cloth_bvh, collmd->bvhtree, &result, NULL, NULL); - // resolve nearby collisions - ret += cloth_bvh_objcollisions_resolve ( clmd, collmd, collisions[i], collisions_index[i]); - ret2 += ret; - } + /* Go to next object if no overlap is there. */ + if (result && overlap) { + /* Check if collisions really happen (costly near check). */ + cloth_bvh_objcollisions_nearcheck(clmd, collmd, &collisions[i], &collisions_index[i], + result, overlap, dt/(float)clmd->coll_parms->loop_count); - if ( overlap ) - MEM_freeN ( overlap ); - } - rounds++; + /* Resolve nearby collisions. */ + ret += cloth_bvh_objcollisions_resolve(clmd, collmd, collisions[i], collisions_index[i]); + ret2 += ret; + } - for (i = 0; i < numcollobj; i++) { - if ( collisions[i] ) MEM_freeN ( collisions[i] ); - } + MEM_SAFE_FREE(overlap); + } - MEM_freeN(collisions); - MEM_freeN(collisions_index); + for (i = 0; i < numcollobj; i++) { + MEM_SAFE_FREE(collisions[i]); + } - //////////////////////////////////////////////////////////// - // update positions - // this is needed for bvh_calc_DOP_hull_moving() [kdop.c] - //////////////////////////////////////////////////////////// + MEM_freeN(collisions); + MEM_freeN(collisions_index); - /* verts come from clmd */ - for (i = 0; i < mvert_num; i++) { - if ( clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL ) { - if ( verts [i].flags & CLOTH_VERT_FLAG_PINNED ) { - continue; + //////////////////////////////////////////////////////////// + // update positions + // this is needed for bvh_calc_DOP_hull_moving() [kdop.c] + //////////////////////////////////////////////////////////// + + /* Verts come from clmd. */ + for (i = 0; i < mvert_num; i++) { + if (clmd->sim_parms->vgroup_mass > 0) { + if (verts [i].flags & CLOTH_VERT_FLAG_PINNED) { + continue; + } } - } - VECADD ( verts[i].tx, verts[i].txold, verts[i].tv ); + VECADD(verts[i].tx, verts[i].txold, verts[i].tv); + } + //////////////////////////////////////////////////////////// } - //////////////////////////////////////////////////////////// + rounds++; //////////////////////////////////////////////////////////// // Test on *simple* selfcollisions @@ -823,7 +831,7 @@ int cloth_bvh_objcollision(Depsgraph *depsgraph, Object *ob, ClothModifierData * mindistance = clmd->coll_parms->selfepsilon* ( cloth->verts[i].avg_spring_len + cloth->verts[j].avg_spring_len ); - if ( clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL ) { + if (clmd->sim_parms->vgroup_mass > 0) { if ( ( cloth->verts [i].flags & CLOTH_VERT_FLAG_PINNED ) && ( cloth->verts [j].flags & CLOTH_VERT_FLAG_PINNED ) ) { @@ -1308,7 +1316,7 @@ int cloth_points_objcollision(Depsgraph *depsgraph, Object *ob, ClothModifierDat // verts come from clmd for (i = 0; i < mvert_num; i++) { - if ( clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL ) { + if (clmd->sim_parms->vgroup_mass > 0) { if ( verts [i].flags & CLOTH_VERT_FLAG_PINNED ) { continue; } @@ -1431,7 +1439,7 @@ void cloth_find_point_contacts(Depsgraph *depsgraph, Object *ob, ClothModifierDa // verts come from clmd for (i = 0; i < mvert_num; i++) { - if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) { + if (clmd->sim_parms->vgroup_mass > 0) { if (verts [i].flags & CLOTH_VERT_FLAG_PINNED) { continue; } diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index a5ce7893d3e..2179b035758 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -3170,8 +3170,7 @@ static void do_hair_dynamics(ParticleSimulationData *sim) if (!psys->clmd) { psys->clmd = (ClothModifierData*)modifier_new(eModifierType_Cloth); psys->clmd->sim_parms->goalspring = 0.0f; - psys->clmd->sim_parms->vel_damping = 1.0f; - psys->clmd->sim_parms->flags |= CLOTH_SIMSETTINGS_FLAG_GOAL|CLOTH_SIMSETTINGS_FLAG_RESIST_SPRING_COMPRESS; + psys->clmd->sim_parms->flags |= CLOTH_SIMSETTINGS_FLAG_RESIST_SPRING_COMPRESS; psys->clmd->coll_parms->flags &= ~CLOTH_COLLSETTINGS_FLAG_SELF; } diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index 3cf65330b3e..e763f234f2e 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -1875,9 +1875,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } } } - } - { /* Versioning code for Subsurf modifier. */ if (!DNA_struct_elem_find(fd->filesdna, "SubsurfModifier", "short", "uv_smooth")) { for (Object *object = bmain->object.first; object != NULL; object = object->id.next) { @@ -1956,5 +1954,32 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } } } + + for (Object *ob = bmain->object.first; ob; ob = ob->id.next) { + for (ModifierData *md = ob->modifiers.first; md; md = md->next) { + if (md->type == eModifierType_Cloth) { + ClothModifierData *clmd = (ClothModifierData *)md; + + if (!(clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL)) { + clmd->sim_parms->vgroup_mass = 0; + } + + if (!(clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_SCALING)) { + clmd->sim_parms->vgroup_struct = 0; + clmd->sim_parms->vgroup_shear = 0; + clmd->sim_parms->vgroup_bend = 0; + } + + if (!(clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_SEW)) { + clmd->sim_parms->shrink_min = 0.0f; + clmd->sim_parms->vgroup_shrink = 0; + } + + if (!(clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_ENABLED)) { + clmd->coll_parms->flags &= ~CLOTH_COLLSETTINGS_FLAG_SELF; + } + } + } + } } } diff --git a/source/blender/makesdna/DNA_cloth_types.h b/source/blender/makesdna/DNA_cloth_types.h index 1b7f3ab9c4a..132ce5c5d5c 100644 --- a/source/blender/makesdna/DNA_cloth_types.h +++ b/source/blender/makesdna/DNA_cloth_types.h @@ -75,7 +75,7 @@ typedef struct ClothSimSettings { float density_target; /* minimum density for hair */ float density_strength; /* influence of hair density */ float collider_friction; /* friction with colliders */ - float vel_damping; /* damp the velocity to speed up getting to the resting position */ + float vel_damping DNA_DEPRECATED; /* damp the velocity to speed up getting to the resting position */ float shrink_min; /* min amount to shrink cloth by 0.0f (no shrink) - 1.0f (shrink to nothing) */ float shrink_max; /* max amount to shrink cloth by 0.0f (no shrink) - 1.0f (shrink to nothing) */ diff --git a/source/blender/makesrna/intern/rna_cloth.c b/source/blender/makesrna/intern/rna_cloth.c index f46f6e96b62..99635f6d538 100644 --- a/source/blender/makesrna/intern/rna_cloth.c +++ b/source/blender/makesrna/intern/rna_cloth.c @@ -31,6 +31,8 @@ #include "DNA_object_types.h" #include "DNA_scene_types.h" +#include "BLI_math_base.h" + #include "RNA_define.h" #include "rna_internal.h" @@ -174,6 +176,28 @@ static void rna_ClothSettings_max_sewing_set(struct PointerRNA *ptr, float value settings->max_sewing = value; } +static void rna_ClothSettings_shrink_min_set(struct PointerRNA *ptr, float value) +{ + ClothSimSettings *settings = (ClothSimSettings *)ptr->data; + + settings->shrink_min = value; + + /* check for max clipping */ + if (value > settings->shrink_max) + settings->shrink_max = value; +} + +static void rna_ClothSettings_shrink_max_set(struct PointerRNA *ptr, float value) +{ + ClothSimSettings *settings = (ClothSimSettings *)ptr->data; + + /* check for clipping */ + if (value < settings->shrink_min) + value = settings->shrink_min; + + settings->shrink_max = value; +} + static void rna_ClothSettings_mass_vgroup_get(PointerRNA *ptr, char *value) { ClothSimSettings *sim = (ClothSimSettings *)ptr->data; @@ -510,20 +534,6 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Air Damping", "Air has normally some thickness which slows falling things down"); RNA_def_property_update(prop, 0, "rna_cloth_update"); - prop = RNA_def_property(srna, "vel_damping", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "vel_damping"); - RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_ui_text(prop, "Velocity Damping", - "Damp velocity to help cloth reach the resting position faster " - "(1.0 = no damping, 0.0 = fully dampened)"); - RNA_def_property_update(prop, 0, "rna_cloth_update"); - - prop = RNA_def_property(srna, "use_pin_cloth", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flags", CLOTH_SIMSETTINGS_FLAG_GOAL); - RNA_def_property_ui_text(prop, "Pin Cloth", "Enable pinning of cloth vertices to other objects/positions"); - RNA_def_property_update(prop, 0, "rna_cloth_pinning_changed"); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - prop = RNA_def_property(srna, "pin_stiffness", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "goalspring"); RNA_def_property_range(prop, 0.0f, 50.0); @@ -554,12 +564,14 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna) prop = RNA_def_property(srna, "shrink_min", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "shrink_min"); RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_ui_text(prop, "Shrink Factor Min", "Min amount to shrink cloth by"); + RNA_def_property_float_funcs(prop, NULL, "rna_ClothSettings_shrink_min_set", NULL); + RNA_def_property_ui_text(prop, "Shrink Factor", "Factor by which to shrink cloth"); RNA_def_property_update(prop, 0, "rna_cloth_update"); prop = RNA_def_property(srna, "shrink_max", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "shrink_max"); RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_float_funcs(prop, NULL, "rna_ClothSettings_shrink_max_set", NULL); RNA_def_property_ui_text(prop, "Shrink Factor Max", "Max amount to shrink cloth by"); RNA_def_property_update(prop, 0, "rna_cloth_update"); @@ -571,40 +583,29 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_cloth_update"); /* springs */ - - prop = RNA_def_property(srna, "use_stiffness_scale", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flags", CLOTH_SIMSETTINGS_FLAG_SCALING); - RNA_def_property_ui_text(prop, "Stiffness Scaling", - "If enabled, stiffness can be scaled along a weight painted vertex group"); - RNA_def_property_update(prop, 0, "rna_cloth_update"); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - prop = RNA_def_property(srna, "tension_damping", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "tension_damp"); RNA_def_property_range(prop, 0.0f, 50.0f); - RNA_def_property_ui_text(prop, "Tension Spring Damping", - "Damping of spring velocity (higher = more smooth, less jiggling)"); + RNA_def_property_ui_text(prop, "Tension Spring Damping", "Amount of damping in stretching behavior"); RNA_def_property_update(prop, 0, "rna_cloth_update"); prop = RNA_def_property(srna, "compression_damping", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "compression_damp"); RNA_def_property_range(prop, 0.0f, 50.0f); - RNA_def_property_ui_text(prop, "Compression Spring Damping", - "Damping of spring velocity (higher = more smooth, less jiggling)"); + RNA_def_property_ui_text(prop, "Compression Spring Damping", "Amount of damping in compression behavior"); RNA_def_property_update(prop, 0, "rna_cloth_update"); prop = RNA_def_property(srna, "shear_damping", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "shear_damp"); RNA_def_property_range(prop, 0.0f, 50.0f); - RNA_def_property_ui_text(prop, "Shear Spring Damping", - "Damping of spring velocity (higher = more smooth, less jiggling)"); + RNA_def_property_ui_text(prop, "Shear Spring Damping", "Amount of damping in shearing behavior"); RNA_def_property_update(prop, 0, "rna_cloth_update"); prop = RNA_def_property(srna, "tension_stiffness", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "tension"); RNA_def_property_range(prop, 0.0f, 10000.0f); RNA_def_property_float_funcs(prop, NULL, "rna_ClothSettings_tension_set", NULL); - RNA_def_property_ui_text(prop, "Tension Stiffness", "Tension stiffness of structure"); + RNA_def_property_ui_text(prop, "Tension Stiffness", "How much the material resists stretching"); RNA_def_property_update(prop, 0, "rna_cloth_update"); prop = RNA_def_property(srna, "tension_stiffness_max", PROP_FLOAT, PROP_NONE); @@ -618,7 +619,7 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "compression"); RNA_def_property_range(prop, 0.0f, 10000.0f); RNA_def_property_float_funcs(prop, NULL, "rna_ClothSettings_compression_set", NULL); - RNA_def_property_ui_text(prop, "Compression Stiffness", "Compression stiffness of structure"); + RNA_def_property_ui_text(prop, "Compression Stiffness", "How much the material resists compression"); RNA_def_property_update(prop, 0, "rna_cloth_update"); prop = RNA_def_property(srna, "compression_stiffness_max", PROP_FLOAT, PROP_NONE); @@ -632,7 +633,7 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "shear"); RNA_def_property_range(prop, 0.0f, 10000.0f); RNA_def_property_float_funcs(prop, NULL, "rna_ClothSettings_shear_set", NULL); - RNA_def_property_ui_text(prop, "Shear Stiffness", "Shear spring stiffness"); + RNA_def_property_ui_text(prop, "Shear Stiffness", "How much the material resists shearing"); RNA_def_property_update(prop, 0, "rna_cloth_update"); prop = RNA_def_property(srna, "shear_stiffness_max", PROP_FLOAT, PROP_NONE); @@ -669,8 +670,7 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "bending"); RNA_def_property_range(prop, 0.0f, 10000.0f); RNA_def_property_float_funcs(prop, NULL, "rna_ClothSettings_bending_set", NULL); - RNA_def_property_ui_text(prop, "Bending Stiffness", - "Wrinkle coefficient (higher = less smaller but more big wrinkles)"); + RNA_def_property_ui_text(prop, "Bending Stiffness", "How much the material resists bending"); RNA_def_property_update(prop, 0, "rna_cloth_update"); prop = RNA_def_property(srna, "bending_stiffness_max", PROP_FLOAT, PROP_NONE); @@ -683,8 +683,7 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna) prop = RNA_def_property(srna, "bending_damping", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "bending_damping"); RNA_def_property_range(prop, 0.0f, 1000.0f); - RNA_def_property_ui_text(prop, "Bending Spring Damping", - "Damping of bending motion"); + RNA_def_property_ui_text(prop, "Bending Spring Damping", "Amount of damping in bending behavior"); RNA_def_property_update(prop, 0, "rna_cloth_update"); prop = RNA_def_property(srna, "use_sewing_springs", PROP_BOOLEAN, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index a35c03eaf89..49678664ef4 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -755,7 +755,7 @@ static void rna_Particle_hair_dynamics_update(Main *bmain, Scene *scene, Pointer if (psys && !psys->clmd) { psys->clmd = (ClothModifierData *)modifier_new(eModifierType_Cloth); psys->clmd->sim_parms->goalspring = 0.0f; - psys->clmd->sim_parms->flags |= CLOTH_SIMSETTINGS_FLAG_GOAL | CLOTH_SIMSETTINGS_FLAG_RESIST_SPRING_COMPRESS; + psys->clmd->sim_parms->flags |= CLOTH_SIMSETTINGS_FLAG_RESIST_SPRING_COMPRESS; psys->clmd->coll_parms->flags &= ~CLOTH_COLLSETTINGS_FLAG_SELF; rna_Particle_redo(bmain, scene, ptr); } diff --git a/source/blender/physics/intern/BPH_mass_spring.cpp b/source/blender/physics/intern/BPH_mass_spring.cpp index 9ab688a3670..c098cfd8d95 100644 --- a/source/blender/physics/intern/BPH_mass_spring.cpp +++ b/source/blender/physics/intern/BPH_mass_spring.cpp @@ -900,8 +900,9 @@ static void cloth_collision_solve_extra( bool do_extra_solve; int i; - if (!(clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_ENABLED)) + if (!(clmd->coll_parms->flags & (CLOTH_COLLSETTINGS_FLAG_ENABLED | CLOTH_COLLSETTINGS_FLAG_SELF))) return; + if (!clmd->clothObject->bvhtree) return; @@ -939,7 +940,7 @@ static void cloth_collision_solve_extra( float newv[3]; - if ((clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) && (verts [i].flags & CLOTH_VERT_FLAG_PINNED)) + if ((clmd->sim_parms->vgroup_mass > 0) && (verts [i].flags & CLOTH_VERT_FLAG_PINNED)) continue; BPH_mass_spring_set_new_position(id, i, verts[i].tx); @@ -1035,7 +1036,7 @@ int BPH_cloth_solve(Depsgraph *depsgraph, Object *ob, float frame, ClothModifier clmd->solver_result = (ClothSolverResult *)MEM_callocN(sizeof(ClothSolverResult), "cloth solver result"); cloth_clear_result(clmd); - if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) { /* do goal stuff */ + if (clmd->sim_parms->vgroup_mass > 0) { /* Do goal stuff. */ for (i = 0; i < mvert_num; i++) { // update velocities with constrained velocities from pinned verts if (verts[i].flags & CLOTH_VERT_FLAG_PINNED) { @@ -1075,17 +1076,6 @@ int BPH_cloth_solve(Depsgraph *depsgraph, Object *ob, float frame, ClothModifier /* initialize forces to zero */ BPH_mass_spring_clear_forces(id); - // damping velocity for artistic reasons - // this is a bad way to do it, should be removed imo - lukas_t - if (clmd->sim_parms->vel_damping != 1.0f) { - for (i = 0; i < mvert_num; i++) { - float v[3]; - BPH_mass_spring_get_motion_state(id, i, NULL, v); - mul_v3_fl(v, clmd->sim_parms->vel_damping); - BPH_mass_spring_set_velocity(id, i, v); - } - } - // calculate forces cloth_calc_force(scene, clmd, frame, effectors, step); @@ -1107,7 +1097,7 @@ int BPH_cloth_solve(Depsgraph *depsgraph, Object *ob, float frame, ClothModifier /* move pinned verts to correct position */ for (i = 0; i < mvert_num; i++) { - if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) { + if (clmd->sim_parms->vgroup_mass > 0) { if (verts[i].flags & CLOTH_VERT_FLAG_PINNED) { float x[3]; /* divide by time_scale to prevent pinned vertices' delta locations from being multiplied */ |