Cloth: Improve UI

This reorganizes the cloth UI, and changes some of the behaviour to be
more reasonable.

Changes included here:
* Reorganized cloth panels
* Improved some tooltips
* Removed `vel_damping` option
* Removed cloth pinning checkbox
* Removed stiffness scaling checkbox
* Separated shrinking from sewing
* Separated self collisions from object collisions

Reviewed By: brecht

Differential Revision: http://developer.blender.org/D3691
This commit is contained in:
2018-09-14 15:46:55 +02:00
parent 1287965089
commit c4ef2e2f2e
11 changed files with 320 additions and 287 deletions

View File

@@ -73,91 +73,94 @@ class PHYSICS_PT_cloth(PhysicButtonsPanel, Panel):
col = flow.column() col = flow.column()
col.prop(cloth, "quality", text="Quality Steps") col.prop(cloth, "quality", text="Quality Steps")
col = flow.column()
col.prop(cloth, "time_scale", text="Speed Multiplier") col.prop(cloth, "time_scale", text="Speed Multiplier")
col.prop(cloth, "bending_model")
col.separator()
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.separator()
col = flow.column()
if cloth.bending_model == 'ANGULAR':
col.prop(cloth, "tension_stiffness", text="Stiffness Tension")
col.prop(cloth, "compression_stiffness", text="Compression")
else:
col.prop(cloth, "tension_stiffness", text="Stiffness Structural")
col.prop(cloth, "shear_stiffness", text="Shear")
col.prop(cloth, "bending_stiffness", text="Bending")
col.separator()
col = flow.column()
if cloth.bending_model == 'ANGULAR':
col.prop(cloth, "tension_damping", text="Damping Tension")
col.prop(cloth, "compression_damping", text="Compression")
else:
col.prop(cloth, "tension_damping", text="Damping Structural")
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")
class PHYSICS_PT_cloth_pinning(PhysicButtonsPanel, Panel): class PHYSICS_PT_cloth_physical_properties(PhysicButtonsPanel, Panel):
bl_label = "Pinning" bl_label = "Physical Properties"
bl_parent_id = 'PHYSICS_PT_cloth' bl_parent_id = 'PHYSICS_PT_cloth'
bl_options = {'DEFAULT_CLOSED'}
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw_header(self, context):
md = context.cloth
cloth = md.settings
self.layout.active = cloth_panel_enabled(md)
self.layout.prop(cloth, "use_pin_cloth", text="")
def draw(self, context): def draw(self, context):
layout = self.layout layout = self.layout
layout.use_property_split = True layout.use_property_split = True
md = context.cloth md = context.cloth
ob = context.object
cloth = md.settings 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.prop(cloth, "mass", text="Mass")
col = flow.column()
col.prop(cloth, "air_damping", text="Air Viscosity")
col = flow.column()
col.prop(cloth, "bending_model")
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) flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=True)
col = flow.column() col = flow.column()
col.prop_search(cloth, "vertex_group_mass", ob, "vertex_groups", text="Mass Group") if cloth.bending_model == 'ANGULAR':
col.prop(cloth, "tension_stiffness", text="Tension")
col = flow.column()
col.prop(cloth, "compression_stiffness", text="Compression")
else:
col.prop(cloth, "tension_stiffness", text="Structural")
col = flow.column() col = flow.column()
col.prop(cloth, "pin_stiffness", text="Stiffness") col.prop(cloth, "shear_stiffness", text="Shear")
col = flow.column()
col.prop(cloth, "bending_stiffness", text="Bending")
# Disabled for now.
""" class PHYSICS_PT_cloth_damping(PhysicButtonsPanel, Panel):
if cloth.vertex_group_mass: 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="Tension")
col = flow.column() col = flow.column()
col.prop(cloth, "goal_default", text="Goal Default") col.prop(cloth, "compression_damping", text="Compression")
col.prop(cloth, "goal_spring", text="Stiffness") else:
col.prop(cloth, "goal_friction", text="Friction") col.prop(cloth, "tension_damping", text="Structural")
"""
col = flow.column()
col.prop(cloth, "shear_damping", text="Shear")
col = flow.column()
col.prop(cloth, "bending_damping", text="Bending")
class PHYSICS_PT_cloth_cache(PhysicButtonsPanel, Panel): class PHYSICS_PT_cloth_cache(PhysicButtonsPanel, Panel):
@@ -171,8 +174,58 @@ class PHYSICS_PT_cloth_cache(PhysicButtonsPanel, Panel):
point_cache_ui(self, context, md.point_cache, cloth_panel_enabled(md), 'CLOTH') point_cache_ui(self, context, md.point_cache, cloth_panel_enabled(md), 'CLOTH')
class PHYSICS_PT_cloth_collision(PhysicButtonsPanel, Panel): class PHYSICS_PT_cloth_shape(PhysicButtonsPanel, Panel):
bl_label = "Collision" 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
layout.use_property_split = True
md = context.cloth
ob = context.object
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(align=True)
col.prop_search(cloth, "vertex_group_mass", ob, "vertex_groups", text="Pin Group")
sub = col.column(align=True)
sub.active = cloth.vertex_group_mass != ""
sub.prop(cloth, "pin_stiffness", text="Stiffness")
col.separator()
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")
col.separator()
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
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_parent_id = 'PHYSICS_PT_cloth'
bl_options = {'DEFAULT_CLOSED'} bl_options = {'DEFAULT_CLOSED'}
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} 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): class PHYSICS_PT_cloth_self_collision(PhysicButtonsPanel, Panel):
bl_label = "Self Collision" bl_label = "Self Collision"
bl_parent_id = 'PHYSICS_PT_cloth_collision' bl_parent_id = 'PHYSICS_PT_cloth'
bl_options = {'DEFAULT_CLOSED'} bl_options = {'DEFAULT_CLOSED'}
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
def draw_header(self, context): def draw_header(self, context):
cloth = context.cloth.collision_settings 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="") self.layout.prop(cloth, "use_self_collision", text="")
def draw(self, context): def draw(self, context):
@@ -225,7 +278,7 @@ class PHYSICS_PT_cloth_self_collision(PhysicButtonsPanel, Panel):
md = context.cloth md = context.cloth
ob = context.object 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) 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") col.prop_search(cloth, "vertex_group_self_collisions", ob, "vertex_groups", text="Vertex Group")
class PHYSICS_PT_cloth_stiffness(PhysicButtonsPanel, Panel): class PHYSICS_PT_cloth_property_weights(PhysicButtonsPanel, Panel):
bl_label = "Stiffness Scaling" bl_label = "Property Weights"
bl_parent_id = 'PHYSICS_PT_cloth' bl_parent_id = 'PHYSICS_PT_cloth'
bl_options = {'DEFAULT_CLOSED'} bl_options = {'DEFAULT_CLOSED'}
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'} 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): def draw(self, context):
layout = self.layout layout = self.layout
layout.use_property_split = True layout.use_property_split = True
@@ -257,7 +304,7 @@ class PHYSICS_PT_cloth_stiffness(PhysicButtonsPanel, Panel):
ob = context.object ob = context.object
cloth = context.cloth.settings 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) 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" text="Structural Group"
) )
col.prop(cloth, "tension_stiffness_max", text="Max Tension") 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() col.separator()
@@ -276,7 +323,7 @@ class PHYSICS_PT_cloth_stiffness(PhysicButtonsPanel, Panel):
cloth, "vertex_group_shear_stiffness", ob, "vertex_groups", cloth, "vertex_group_shear_stiffness", ob, "vertex_groups",
text="Shear Group" text="Shear Group"
) )
col.prop(cloth, "shear_stiffness_max", text="Max") col.prop(cloth, "shear_stiffness_max", text="Max Shearing")
col.separator() col.separator()
@@ -285,43 +332,16 @@ class PHYSICS_PT_cloth_stiffness(PhysicButtonsPanel, Panel):
cloth, "vertex_group_bending", ob, "vertex_groups", cloth, "vertex_group_bending", ob, "vertex_groups",
text="Bending Group" text="Bending Group"
) )
col.prop(cloth, "bending_stiffness_max", text="Max") col.prop(cloth, "bending_stiffness_max", text="Max Bending")
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.separator() col.separator()
col = col.column() col = flow.column()
col.prop_search(cloth, "vertex_group_shrink", ob, "vertex_groups", text="Shrinking Group") col.prop_search(
cloth, "vertex_group_shrink", ob, "vertex_groups",
col = flow.column(align=True) text="Shrinking Group"
col.prop(cloth, "shrink_min", text="Min") )
col.prop(cloth, "shrink_max", text="Max") col.prop(cloth, "shrink_max", text="Max Shrinking")
class PHYSICS_PT_cloth_field_weights(PhysicButtonsPanel, Panel): class PHYSICS_PT_cloth_field_weights(PhysicButtonsPanel, Panel):
@@ -338,12 +358,14 @@ class PHYSICS_PT_cloth_field_weights(PhysicButtonsPanel, Panel):
classes = ( classes = (
CLOTH_PT_presets, CLOTH_PT_presets,
PHYSICS_PT_cloth, PHYSICS_PT_cloth,
PHYSICS_PT_cloth_cache, PHYSICS_PT_cloth_physical_properties,
PHYSICS_PT_cloth_collision,
PHYSICS_PT_cloth_self_collision,
PHYSICS_PT_cloth_pinning,
PHYSICS_PT_cloth_stiffness, PHYSICS_PT_cloth_stiffness,
PHYSICS_PT_cloth_sewing, PHYSICS_PT_cloth_damping,
PHYSICS_PT_cloth_cache,
PHYSICS_PT_cloth_shape,
PHYSICS_PT_cloth_object_collision,
PHYSICS_PT_cloth_self_collision,
PHYSICS_PT_cloth_property_weights,
PHYSICS_PT_cloth_field_weights, PHYSICS_PT_cloth_field_weights,
) )

View File

@@ -28,7 +28,7 @@
* and keep comment above the defines. * and keep comment above the defines.
* Use STRINGIFY() rather than defining with quotes */ * Use STRINGIFY() rather than defining with quotes */
#define BLENDER_VERSION 280 #define BLENDER_VERSION 280
#define BLENDER_SUBVERSION 21 #define BLENDER_SUBVERSION 22
/* Several breakages with 280, e.g. collections vs layers */ /* Several breakages with 280, e.g. collections vs layers */
#define BLENDER_MINVERSION 280 #define BLENDER_MINVERSION 280
#define BLENDER_MINSUBVERSION 0 #define BLENDER_MINSUBVERSION 0

View File

@@ -169,9 +169,9 @@ ClothSpring;
/* These are the bits used in SimSettings.flags. */ /* These are the bits used in SimSettings.flags. */
typedef enum { typedef enum {
CLOTH_SIMSETTINGS_FLAG_COLLOBJ = ( 1 << 2 ),// object is only collision object, no cloth simulation is done 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_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_CCACHE_EDIT = (1 << 12), /* edit cache in editmode */
CLOTH_SIMSETTINGS_FLAG_RESIST_SPRING_COMPRESS = (1 << 13), /* don't allow spring compression */ 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 */ CLOTH_SIMSETTINGS_FLAG_SEW = (1 << 14), /* pull ends of loose edges together */

View File

@@ -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->timescale = 1.0f; /* speed factor, describes how fast cloth moves */
clmd->sim_parms->time_scale = 1.0f; /* multiplies cloth speed */ clmd->sim_parms->time_scale = 1.0f; /* multiplies cloth speed */
clmd->sim_parms->reset = 0; 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->self_friction = 5.0;
clmd->coll_parms->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 */ /* Support for dynamic vertex groups, changing from frame to frame */
cloth_apply_vgroup ( clmd, result ); 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_spring_lengths ( clmd, result );
}
cloth_update_springs( clmd ); 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) int cloth_uses_vgroup(ClothModifierData *clmd)
{ {
return (((clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_SCALING ) || return (((clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_SELF) && (clmd->coll_parms->vgroup_selfcol > 0)) ||
(clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL ) || (clmd->sim_parms->vgroup_struct > 0) ||
(clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_SEW) || (clmd->sim_parms->vgroup_bend > 0) ||
(clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_SELF)) && (clmd->sim_parms->vgroup_shrink > 0) ||
((clmd->sim_parms->vgroup_mass>0) || (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)));
} }
/** /**
@@ -717,7 +715,7 @@ static void cloth_apply_vgroup ( ClothModifierData *clmd, Mesh *mesh )
for (i = 0; i < mvert_num; i++, verts++) { for (i = 0; i < mvert_num; i++, verts++) {
/* Reset Goal values to standard */ /* 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; verts->goal= clmd->sim_parms->defgoal;
else else
verts->goal= 0.0f; 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); dvert = CustomData_get(&mesh->vdata, i, CD_MDEFORMVERT);
if ( dvert ) { if ( dvert ) {
for ( j = 0; j < dvert->totweight; j++ ) { 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; verts->goal = dvert->dw [j].weight;
/* goalfac= 1.0f; */ /* UNUSED */ /* goalfac= 1.0f; */ /* UNUSED */
@@ -745,18 +743,16 @@ static void cloth_apply_vgroup ( ClothModifierData *clmd, Mesh *mesh )
verts->flags |= CLOTH_VERT_FLAG_PINNED; 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)) {
if ( dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_struct-1)) { verts->struct_stiff = dvert->dw[j].weight;
verts->struct_stiff = dvert->dw [j].weight; }
}
if ( dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_shear-1)) { if (dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_shear - 1)) {
verts->shear_stiff = dvert->dw [j].weight; verts->shear_stiff = dvert->dw[j].weight;
} }
if ( dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_bend-1)) { if (dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_bend - 1)) {
verts->bend_stiff = dvert->dw [j].weight; verts->bend_stiff = dvert->dw[j].weight;
}
} }
if (clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_SELF ) { 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 (clmd->sim_parms->vgroup_shrink > 0) { if (dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_shrink - 1)) {
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. */
/* used for linear interpolation between min and max shrink factor based on weight */ verts->shrink_factor = dvert->dw[j].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) 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. */
/* linear interpolation between min and max shrink factor based on weight */ float base = 1.0f - clmd->sim_parms->shrink_min;
float base = 1.0f - clmd->sim_parms->shrink_min; float delta = clmd->sim_parms->shrink_min - clmd->sim_parms->shrink_max;
float delta = clmd->sim_parms->shrink_min - clmd->sim_parms->shrink_max;
float k1 = base + delta * verts[i1].shrink_factor; float k1 = base + delta * verts[i1].shrink_factor;
float k2 = base + delta * verts[i2].shrink_factor; float k2 = base + delta * verts[i2].shrink_factor;
/* Use geometrical mean to average two factors since it behaves better /* Use geometrical mean to average two factors since it behaves better
for diagonals when a rectangle transforms into a trapezoid. */ for diagonals when a rectangle transforms into a trapezoid. */
return sqrtf(k1 * k2); return sqrtf(k1 * k2);
}
else
return 1.0f;
} }
static int cloth_from_object(Object *ob, ClothModifierData *clmd, Mesh *mesh, float UNUSED(framenr), int first) 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->mass = clmd->sim_parms->mass;
verts->impulse_count = 0; 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; verts->goal= clmd->sim_parms->defgoal;
else else
verts->goal= 0.0f; verts->goal= 0.0f;

View File

@@ -708,88 +708,96 @@ int cloth_bvh_objcollision(Depsgraph *depsgraph, Object *ob, ClothModifierData *
// static collisions // static collisions
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// update cloth bvh if (clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_ENABLED) {
bvhtree_update_from_cloth ( clmd, 1 ); // 0 means STATIC, 1 means MOVING (see later in this function) bvhtree_update_from_cloth(clmd, true);
bvhselftree_update_from_cloth ( clmd, 0 ); // 0 means STATIC, 1 means MOVING (see later in this function)
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) if (!collobjs) {
return 0; return 0;
}
/* move object to position (step) in time */ /* Move object to position (step) in time. */
for (i = 0; i < numcollobj; i++) { for (i = 0; i < numcollobj; i++) {
Object *collob= collobjs[i]; Object *collob = collobjs[i];
CollisionModifierData *collmd = (CollisionModifierData *)modifiers_findByType(collob, eModifierType_Collision); CollisionModifierData *collmd = (CollisionModifierData *)modifiers_findByType(collob, eModifierType_Collision);
if (!collmd->bvhtree) if (!collmd->bvhtree) {
continue; continue;
}
/* move object to position (step) in time */ /* Move object to position (step) in time. */
collision_move_object ( collmd, step + dt, step ); collision_move_object(collmd, step + dt, step);
}
}
if (clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_SELF) {
bvhselftree_update_from_cloth(clmd, false);
} }
do { do {
CollPair **collisions, **collisions_index;
ret2 = 0; ret2 = 0;
collisions = MEM_callocN(sizeof(CollPair *) *numcollobj, "CollPair"); if (clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_ENABLED) {
collisions_index = MEM_callocN(sizeof(CollPair *) *numcollobj, "CollPair"); CollPair **collisions, **collisions_index;
// check all collision objects collisions = MEM_callocN(sizeof(CollPair *) *numcollobj, "CollPair");
for (i = 0; i < numcollobj; i++) { collisions_index = MEM_callocN(sizeof(CollPair *) *numcollobj, "CollPair");
Object *collob= collobjs[i];
CollisionModifierData *collmd = (CollisionModifierData *)modifiers_findByType(collob, eModifierType_Collision);
BVHTreeOverlap *overlap = NULL;
unsigned int result = 0;
if (!collmd->bvhtree) /* Check all collision objects. */
continue; 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 */ if (!collmd->bvhtree) {
overlap = BLI_bvhtree_overlap(cloth_bvh, collmd->bvhtree, &result, NULL, NULL);
// 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);
// resolve nearby collisions
ret += cloth_bvh_objcollisions_resolve ( clmd, collmd, collisions[i], collisions_index[i]);
ret2 += ret;
}
if ( overlap )
MEM_freeN ( overlap );
}
rounds++;
for (i = 0; i < numcollobj; i++) {
if ( collisions[i] ) MEM_freeN ( collisions[i] );
}
MEM_freeN(collisions);
MEM_freeN(collisions_index);
////////////////////////////////////////////////////////////
// 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->flags & CLOTH_SIMSETTINGS_FLAG_GOAL ) {
if ( verts [i].flags & CLOTH_VERT_FLAG_PINNED ) {
continue; continue;
} }
/* Search for overlapping collision pairs. */
overlap = BLI_bvhtree_overlap(cloth_bvh, collmd->bvhtree, &result, NULL, NULL);
/* 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);
/* Resolve nearby collisions. */
ret += cloth_bvh_objcollisions_resolve(clmd, collmd, collisions[i], collisions_index[i]);
ret2 += ret;
}
MEM_SAFE_FREE(overlap);
} }
VECADD ( verts[i].tx, verts[i].txold, verts[i].tv ); for (i = 0; i < numcollobj; i++) {
} MEM_SAFE_FREE(collisions[i]);
//////////////////////////////////////////////////////////// }
MEM_freeN(collisions);
MEM_freeN(collisions_index);
////////////////////////////////////////////////////////////
// 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);
}
////////////////////////////////////////////////////////////
}
rounds++;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Test on *simple* selfcollisions // 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 ); 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 ) && if ( ( cloth->verts [i].flags & CLOTH_VERT_FLAG_PINNED ) &&
( cloth->verts [j].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 // verts come from clmd
for (i = 0; i < mvert_num; i++) { 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 ) { if ( verts [i].flags & CLOTH_VERT_FLAG_PINNED ) {
continue; continue;
} }
@@ -1431,7 +1439,7 @@ void cloth_find_point_contacts(Depsgraph *depsgraph, Object *ob, ClothModifierDa
// verts come from clmd // verts come from clmd
for (i = 0; i < mvert_num; i++) { 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) { if (verts [i].flags & CLOTH_VERT_FLAG_PINNED) {
continue; continue;
} }

View File

@@ -3170,8 +3170,7 @@ static void do_hair_dynamics(ParticleSimulationData *sim)
if (!psys->clmd) { if (!psys->clmd) {
psys->clmd = (ClothModifierData*)modifier_new(eModifierType_Cloth); psys->clmd = (ClothModifierData*)modifier_new(eModifierType_Cloth);
psys->clmd->sim_parms->goalspring = 0.0f; psys->clmd->sim_parms->goalspring = 0.0f;
psys->clmd->sim_parms->vel_damping = 1.0f; psys->clmd->sim_parms->flags |= CLOTH_SIMSETTINGS_FLAG_RESIST_SPRING_COMPRESS;
psys->clmd->sim_parms->flags |= CLOTH_SIMSETTINGS_FLAG_GOAL|CLOTH_SIMSETTINGS_FLAG_RESIST_SPRING_COMPRESS;
psys->clmd->coll_parms->flags &= ~CLOTH_COLLSETTINGS_FLAG_SELF; psys->clmd->coll_parms->flags &= ~CLOTH_COLLSETTINGS_FLAG_SELF;
} }

View File

@@ -1875,9 +1875,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
} }
} }
} }
}
{
/* Versioning code for Subsurf modifier. */ /* Versioning code for Subsurf modifier. */
if (!DNA_struct_elem_find(fd->filesdna, "SubsurfModifier", "short", "uv_smooth")) { if (!DNA_struct_elem_find(fd->filesdna, "SubsurfModifier", "short", "uv_smooth")) {
for (Object *object = bmain->object.first; object != NULL; object = object->id.next) { 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;
}
}
}
}
} }
} }

View File

@@ -75,7 +75,7 @@ typedef struct ClothSimSettings {
float density_target; /* minimum density for hair */ float density_target; /* minimum density for hair */
float density_strength; /* influence of hair density */ float density_strength; /* influence of hair density */
float collider_friction; /* friction with colliders */ 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_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) */ float shrink_max; /* max amount to shrink cloth by 0.0f (no shrink) - 1.0f (shrink to nothing) */

View File

@@ -31,6 +31,8 @@
#include "DNA_object_types.h" #include "DNA_object_types.h"
#include "DNA_scene_types.h" #include "DNA_scene_types.h"
#include "BLI_math_base.h"
#include "RNA_define.h" #include "RNA_define.h"
#include "rna_internal.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; 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) static void rna_ClothSettings_mass_vgroup_get(PointerRNA *ptr, char *value)
{ {
ClothSimSettings *sim = (ClothSimSettings *)ptr->data; 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_ui_text(prop, "Air Damping", "Air has normally some thickness which slows falling things down");
RNA_def_property_update(prop, 0, "rna_cloth_update"); 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); prop = RNA_def_property(srna, "pin_stiffness", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "goalspring"); RNA_def_property_float_sdna(prop, NULL, "goalspring");
RNA_def_property_range(prop, 0.0f, 50.0); 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); prop = RNA_def_property(srna, "shrink_min", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "shrink_min"); RNA_def_property_float_sdna(prop, NULL, "shrink_min");
RNA_def_property_range(prop, 0.0f, 1.0f); 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"); RNA_def_property_update(prop, 0, "rna_cloth_update");
prop = RNA_def_property(srna, "shrink_max", PROP_FLOAT, PROP_NONE); prop = RNA_def_property(srna, "shrink_max", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "shrink_max"); RNA_def_property_float_sdna(prop, NULL, "shrink_max");
RNA_def_property_range(prop, 0.0f, 1.0f); 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_ui_text(prop, "Shrink Factor Max", "Max amount to shrink cloth by");
RNA_def_property_update(prop, 0, "rna_cloth_update"); 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"); RNA_def_property_update(prop, 0, "rna_cloth_update");
/* springs */ /* 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); prop = RNA_def_property(srna, "tension_damping", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "tension_damp"); RNA_def_property_float_sdna(prop, NULL, "tension_damp");
RNA_def_property_range(prop, 0.0f, 50.0f); RNA_def_property_range(prop, 0.0f, 50.0f);
RNA_def_property_ui_text(prop, "Tension Spring Damping", RNA_def_property_ui_text(prop, "Tension Spring Damping", "Amount of damping in stretching behavior");
"Damping of spring velocity (higher = more smooth, less jiggling)");
RNA_def_property_update(prop, 0, "rna_cloth_update"); RNA_def_property_update(prop, 0, "rna_cloth_update");
prop = RNA_def_property(srna, "compression_damping", PROP_FLOAT, PROP_NONE); prop = RNA_def_property(srna, "compression_damping", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "compression_damp"); RNA_def_property_float_sdna(prop, NULL, "compression_damp");
RNA_def_property_range(prop, 0.0f, 50.0f); RNA_def_property_range(prop, 0.0f, 50.0f);
RNA_def_property_ui_text(prop, "Compression Spring Damping", RNA_def_property_ui_text(prop, "Compression Spring Damping", "Amount of damping in compression behavior");
"Damping of spring velocity (higher = more smooth, less jiggling)");
RNA_def_property_update(prop, 0, "rna_cloth_update"); RNA_def_property_update(prop, 0, "rna_cloth_update");
prop = RNA_def_property(srna, "shear_damping", PROP_FLOAT, PROP_NONE); prop = RNA_def_property(srna, "shear_damping", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "shear_damp"); RNA_def_property_float_sdna(prop, NULL, "shear_damp");
RNA_def_property_range(prop, 0.0f, 50.0f); RNA_def_property_range(prop, 0.0f, 50.0f);
RNA_def_property_ui_text(prop, "Shear Spring Damping", RNA_def_property_ui_text(prop, "Shear Spring Damping", "Amount of damping in shearing behavior");
"Damping of spring velocity (higher = more smooth, less jiggling)");
RNA_def_property_update(prop, 0, "rna_cloth_update"); RNA_def_property_update(prop, 0, "rna_cloth_update");
prop = RNA_def_property(srna, "tension_stiffness", PROP_FLOAT, PROP_NONE); prop = RNA_def_property(srna, "tension_stiffness", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "tension"); RNA_def_property_float_sdna(prop, NULL, "tension");
RNA_def_property_range(prop, 0.0f, 10000.0f); RNA_def_property_range(prop, 0.0f, 10000.0f);
RNA_def_property_float_funcs(prop, NULL, "rna_ClothSettings_tension_set", NULL); 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"); RNA_def_property_update(prop, 0, "rna_cloth_update");
prop = RNA_def_property(srna, "tension_stiffness_max", PROP_FLOAT, PROP_NONE); 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_float_sdna(prop, NULL, "compression");
RNA_def_property_range(prop, 0.0f, 10000.0f); RNA_def_property_range(prop, 0.0f, 10000.0f);
RNA_def_property_float_funcs(prop, NULL, "rna_ClothSettings_compression_set", NULL); 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"); RNA_def_property_update(prop, 0, "rna_cloth_update");
prop = RNA_def_property(srna, "compression_stiffness_max", PROP_FLOAT, PROP_NONE); 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_float_sdna(prop, NULL, "shear");
RNA_def_property_range(prop, 0.0f, 10000.0f); RNA_def_property_range(prop, 0.0f, 10000.0f);
RNA_def_property_float_funcs(prop, NULL, "rna_ClothSettings_shear_set", NULL); 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"); RNA_def_property_update(prop, 0, "rna_cloth_update");
prop = RNA_def_property(srna, "shear_stiffness_max", PROP_FLOAT, PROP_NONE); 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_float_sdna(prop, NULL, "bending");
RNA_def_property_range(prop, 0.0f, 10000.0f); RNA_def_property_range(prop, 0.0f, 10000.0f);
RNA_def_property_float_funcs(prop, NULL, "rna_ClothSettings_bending_set", NULL); RNA_def_property_float_funcs(prop, NULL, "rna_ClothSettings_bending_set", NULL);
RNA_def_property_ui_text(prop, "Bending Stiffness", RNA_def_property_ui_text(prop, "Bending Stiffness", "How much the material resists bending");
"Wrinkle coefficient (higher = less smaller but more big wrinkles)");
RNA_def_property_update(prop, 0, "rna_cloth_update"); RNA_def_property_update(prop, 0, "rna_cloth_update");
prop = RNA_def_property(srna, "bending_stiffness_max", PROP_FLOAT, PROP_NONE); 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); prop = RNA_def_property(srna, "bending_damping", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "bending_damping"); RNA_def_property_float_sdna(prop, NULL, "bending_damping");
RNA_def_property_range(prop, 0.0f, 1000.0f); RNA_def_property_range(prop, 0.0f, 1000.0f);
RNA_def_property_ui_text(prop, "Bending Spring Damping", RNA_def_property_ui_text(prop, "Bending Spring Damping", "Amount of damping in bending behavior");
"Damping of bending motion");
RNA_def_property_update(prop, 0, "rna_cloth_update"); RNA_def_property_update(prop, 0, "rna_cloth_update");
prop = RNA_def_property(srna, "use_sewing_springs", PROP_BOOLEAN, PROP_NONE); prop = RNA_def_property(srna, "use_sewing_springs", PROP_BOOLEAN, PROP_NONE);

View File

@@ -755,7 +755,7 @@ static void rna_Particle_hair_dynamics_update(Main *bmain, Scene *scene, Pointer
if (psys && !psys->clmd) { if (psys && !psys->clmd) {
psys->clmd = (ClothModifierData *)modifier_new(eModifierType_Cloth); psys->clmd = (ClothModifierData *)modifier_new(eModifierType_Cloth);
psys->clmd->sim_parms->goalspring = 0.0f; 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; psys->clmd->coll_parms->flags &= ~CLOTH_COLLSETTINGS_FLAG_SELF;
rna_Particle_redo(bmain, scene, ptr); rna_Particle_redo(bmain, scene, ptr);
} }

View File

@@ -900,8 +900,9 @@ static void cloth_collision_solve_extra(
bool do_extra_solve; bool do_extra_solve;
int i; 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; return;
if (!clmd->clothObject->bvhtree) if (!clmd->clothObject->bvhtree)
return; return;
@@ -939,7 +940,7 @@ static void cloth_collision_solve_extra(
float newv[3]; 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; continue;
BPH_mass_spring_set_new_position(id, i, verts[i].tx); 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"); clmd->solver_result = (ClothSolverResult *)MEM_callocN(sizeof(ClothSolverResult), "cloth solver result");
cloth_clear_result(clmd); 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++) { for (i = 0; i < mvert_num; i++) {
// update velocities with constrained velocities from pinned verts // update velocities with constrained velocities from pinned verts
if (verts[i].flags & CLOTH_VERT_FLAG_PINNED) { 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 */ /* initialize forces to zero */
BPH_mass_spring_clear_forces(id); 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 // calculate forces
cloth_calc_force(scene, clmd, frame, effectors, step); 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 */ /* move pinned verts to correct position */
for (i = 0; i < mvert_num; i++) { 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) { if (verts[i].flags & CLOTH_VERT_FLAG_PINNED) {
float x[3]; float x[3];
/* divide by time_scale to prevent pinned vertices' delta locations from being multiplied */ /* divide by time_scale to prevent pinned vertices' delta locations from being multiplied */