Skip to content

Commit 73057c9

Browse files
Update ModelingCloth.py
1 parent f5d1267 commit 73057c9

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

ModelingCloth.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -482,15 +482,18 @@ def add_virtual_springs(remove=False):
482482
return
483483

484484
existing = np.append(cloth.eidx, cloth.virtual_springs, axis=0)
485+
flip = existing[:, ::-1]
486+
existing = np.append(existing, flip, axis=0)
485487
ls = existing[:,0]
488+
486489
springs = []
487490
for i in idxer[sel]:
488491

489492
# to avoid duplicates:
490493
# where this vert occurs on the left side of the existing spring list
491494
v_in = existing[i == ls]
492495
v_in_r = v_in[:,1]
493-
not_in = selected[-np.in1d(selected, v_in_r)]
496+
not_in = selected[~np.in1d(selected, v_in_r)]
494497
idx_set = not_in[not_in != i]
495498
for sv in idx_set:
496499
springs.append([i, sv])
@@ -755,15 +758,13 @@ def create_instance(new=True):
755758
cloth.waiting = False
756759
cloth.clicked = False # for the grab tool
757760

758-
#print(cloth.eidx_tiler.shape, 'this is my tiler')
759-
760761
uni = np.unique(cloth.eidx_tiler, return_inverse=True, return_counts=True)
761762

762763
#cloth.mix = (1/uni[2][uni[1]])[:, nax].astype(np.float32) # force gets divided by number of springs
763764

764765
# this helps with extra springs behaving as if they had more mass---->>>
765766
cloth.mix = mixology[unpinned][:, nax]
766-
cloth.mix = (cloth.mix ** .87) * 0.35
767+
#cloth.mix = (cloth.mix ** .87) * 0.35
767768
# -------------->>>
768769

769770
# new self collisions:
@@ -839,6 +840,9 @@ def run_handler(cloth):
839840
co[cloth.pindexer] += cloth.noise[cloth.pindexer]
840841
cloth.noise *= cloth.ob.modeling_cloth_noise_decay
841842

843+
# mix in vel before collisions and sewing
844+
co[cloth.pindexer] += cloth.vel[cloth.pindexer]
845+
842846
cloth.vel_start[:] = co
843847
force = cloth.ob.modeling_cloth_spring_force
844848
mix = cloth.mix * force
@@ -883,7 +887,7 @@ def run_handler(cloth):
883887
# grab inside spring iterations
884888
if cloth.clicked: # for the grab tool
885889
cloth.co[extra_data['vidx']] = np.array(extra_data['stored_vidx']) + np.array(+ extra_data['move'])
886-
890+
887891
spring_dif = cloth.co - cloth.vel_start
888892
grav = cloth.ob.modeling_cloth_gravity * (.01 / cloth.ob.modeling_cloth_iterations)
889893
cloth.vel += revert_rotation(cloth.ob, np.array([0, 0, grav]))
@@ -922,9 +926,6 @@ def run_handler(cloth):
922926
squared_move_dist += 1
923927
cloth.vel *= (1 / (squared_move_dist / cloth.ob.modeling_cloth_velocity))[:, nax]
924928

925-
# mix in vel before collisions and sewing
926-
co[cloth.pindexer] += cloth.vel[cloth.pindexer]
927-
928929
# old self collisions
929930
self_col = cloth.ob.modeling_cloth_self_collision
930931

@@ -2024,20 +2025,20 @@ def create_properties():
20242025
# spring forces ------------>>>
20252026
bpy.types.Object.modeling_cloth_spring_force = bpy.props.FloatProperty(name="Modeling Cloth Spring Force",
20262027
description="Set the spring force",
2027-
default=3, precision=4, min=0, max=10)#, update=refresh_noise)
2028+
default=1, precision=4, min=0, max=1.5)#, update=refresh_noise)
20282029

20292030
bpy.types.Object.modeling_cloth_push_springs = bpy.props.FloatProperty(name="Modeling Cloth Spring Force",
20302031
description="Set the spring force",
2031-
default=0.2, precision=4, min=0, max=2)#, update=refresh_noise)
2032+
default=0.2, precision=4, min=0, max=1.5)#, update=refresh_noise)
20322033
# -------------------------->>>
20332034

20342035
bpy.types.Object.modeling_cloth_gravity = bpy.props.FloatProperty(name="Modeling Cloth Gravity",
20352036
description="Modeling cloth gravity",
2036-
default=0.0, precision=4, min= -1, max=1)#, update=refresh_noise_decay)
2037+
default=0.0, precision=4, min= -10, max=10)#, update=refresh_noise_decay)
20372038

20382039
bpy.types.Object.modeling_cloth_iterations = bpy.props.IntProperty(name="Stiffness",
20392040
description="How stiff the cloth is",
2040-
default=4, min=1, max=500)#, update=refresh_noise_decay)
2041+
default=2, min=1, max=500)#, update=refresh_noise_decay)
20412042

20422043
bpy.types.Object.modeling_cloth_velocity = bpy.props.FloatProperty(name="Velocity",
20432044
description="Cloth keeps moving",

0 commit comments

Comments
 (0)