-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathproperties.py
408 lines (387 loc) · 14.7 KB
/
properties.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
import multiprocessing
import bpy
from . import descriptions
def update_parsys(self, context):
retina = context.preferences.addons[__package__].preferences.use_retina
obj = context.object
psys = obj.particle_systems.active.settings
max_dim = max(obj.dimensions)
psys.grid_resolution = int(max_dim / psys.mol_voxel_size)
psys.particle_size = psys.mol_voxel_size / 2
if retina:
psys.display_size = psys.particle_size / 2
else:
psys.display_size = psys.particle_size
bpy.ops.object.clear_pcache()
def define_props():
parset = bpy.types.ParticleSettings
parset.mol_active = bpy.props.BoolProperty(
name="mol_active", description=descriptions.ACTIVE, default=False
)
parset.mol_refresh = bpy.props.BoolProperty(
name="mol_refresh", description=descriptions.REFRESH, default=True
)
parset.mol_density_active = bpy.props.BoolProperty(
name="Calculate particles weight by density",
description=descriptions.DENSITY_ACTIVE,
default=False
)
matter_items = [
("-1", "custom", descriptions.MATTER_CUSTOM),
("1555", "sand", descriptions.MATTER_SAND),
("1000", "water", descriptions.MATTER_WATER),
("7800", "iron", descriptions.MATTER_IRON)
]
parset.mol_matter = bpy.props.EnumProperty(
name='Preset',
items=matter_items,
description=descriptions.MATTER
)
parset.mol_density = bpy.props.FloatProperty(
name="Kg per CubeMeter:", description=descriptions.DENSITY,
default=1000, min=0.001
)
parset.mol_selfcollision_active = bpy.props.BoolProperty(
name="Activate Self Collision",
description=descriptions.SELF_COLLISION_ACTIVE,
default=False
)
parset.mol_othercollision_active = bpy.props.BoolProperty(
name="Activate Collision with others",
description=descriptions.OTHER_COLLISION_ACTIVE,
default=False
)
parset.mol_friction = bpy.props.FloatProperty(
name='Friction:', description=descriptions.FRICTION,
default=0.005, min=0, max=1, precision=6, subtype='FACTOR'
)
parset.mol_collision_damp = bpy.props.FloatProperty(
name="Damping:", description=descriptions.COLLISION_DAMPING,
default=0.005, min=0, max=1, precision=6, subtype='FACTOR'
)
parset.mol_collision_group = bpy.props.IntProperty(
name='Collide only with:', default=1, min=1,
description=descriptions.COLLISION_GROUP
)
parset.mol_links_active = bpy.props.BoolProperty(
name="Activate Particles linking",
description=descriptions.LINKS_ACTIVE,
default=False
)
parset.mol_other_link_active = bpy.props.BoolProperty(
name="Activate Particles linking with Others",
description=descriptions.LINK_OTHER_ACTIVE, default=False
)
parset.mol_link_group = bpy.props.IntProperty(
name='Linking only with:', default=1, min=1,
description=descriptions.LINK_GROUP
)
parset.mol_link_rellength = bpy.props.BoolProperty(
name="Relative",
description=descriptions.LINK_RELATIVE_LENGTH,
default=True
)
parset.mol_link_friction = bpy.props.FloatProperty(
name="Link friction", description=descriptions.LINK_FRICTION,
min=0, max=1, default=0.005, precision=6, subtype='FACTOR'
)
parset.mol_link_length = bpy.props.FloatProperty(
name="Search Distance", description=descriptions.LINK_LENGTH,
min=0, precision=2, default=1
)
parset.mol_link_tension = bpy.props.FloatProperty(
name="Tension", description=descriptions.LINK_TENSION,
min=0, precision=6, default=1
)
parset.mol_link_tensionrand = bpy.props.FloatProperty(
name="Rand Tension",
description=descriptions.LINK_TENSION_RANDOM,
min=0, max=1, precision=6, default=0, subtype='FACTOR'
)
parset.mol_link_max = bpy.props.IntProperty(
name="Max links", description=descriptions.LINK_MAX,
min=0, default=16
)
parset.mol_link_stiff = bpy.props.FloatProperty(
name="Stiff", description=descriptions.LINK_STIFFNESS,
min=0, max=1, default=1, precision=6, subtype='FACTOR'
)
parset.mol_link_stiffrand = bpy.props.FloatProperty(
name="Rand Stiff",
description = descriptions.LINK_STIFFNESS_RANDOM,
min=0, max=1, default=0, precision=6, subtype='FACTOR'
)
parset.mol_link_stiffexp = bpy.props.IntProperty(
name="Exponent",
description=descriptions.LINK_STIFFNESS_EXPONENT,
default=1, min=1, max=10
)
parset.mol_link_damp = bpy.props.FloatProperty(
name="Damping", description=descriptions.LINK_DAMPING,
min=0, max=1, default=1, precision=6, subtype='FACTOR'
)
parset.mol_link_damprand = bpy.props.FloatProperty(
name="Rand Damping", description=descriptions.LINK_DAMPING_RANDOM,
min=0, max=1, default=0, precision=6, subtype='FACTOR'
)
parset.mol_link_broken = bpy.props.FloatProperty(
name="Broken", description=descriptions.LINK_BROKEN,
min=0, default=0.5, precision=6
)
parset.mol_link_brokenrand = bpy.props.FloatProperty(
name="Rand Broken",
description=descriptions.LINK_BROKEN_RANDOM,
min=0, max=1, default=0, precision=6, subtype='FACTOR'
)
parset.mol_link_samevalue = bpy.props.BoolProperty(
name="Same values for compression/expansion",
description=descriptions.LINK_SAME_VALUE,
default=True
)
parset.mol_link_estiff = bpy.props.FloatProperty(
name="E Stiff",
description=descriptions.LINK_EXPENSION_STIFFNESS,
min=0, max=1, default=1, precision=6, subtype='FACTOR'
)
parset.mol_link_estiffrand = bpy.props.FloatProperty(
name="Rand E Stiff",
description=descriptions.LINK_EXPENSION_STIFFNESS_RANDOM,
min=0, max=1, default=0, precision=6, subtype='FACTOR'
)
parset.mol_link_estiffexp = bpy.props.IntProperty(
name="E Exponent",
description=descriptions.LINK_EXPENSION_STIFFNESS_EXPONENT,
default=1, min=1, max=10
)
parset.mol_link_edamp = bpy.props.FloatProperty(
name="E Damping", description=descriptions.LINK_EXPENSION_DAMPING,
min=0, max=1, default=1, precision=6, subtype='FACTOR'
)
parset.mol_link_edamprand = bpy.props.FloatProperty(
name="Rand E Damping",
description=descriptions.LINK_EXPENSION_DAMPING_RANDOM,
min=0, max=1, default=0, precision=6, subtype='FACTOR'
)
parset.mol_link_ebroken = bpy.props.FloatProperty(
name="E Broken",
description=descriptions.LINK_EXPENSION_BROKEN,
min=0, default=0.5, precision=6
)
parset.mol_link_ebrokenrand = bpy.props.FloatProperty(
name="Rand E Broken",
description=descriptions.LINK_EXPENSION_BROKEN_RANDOM,
min=0, max=1, default=0, precision=6, subtype='FACTOR'
)
parset.mol_relink_group = bpy.props.IntProperty(
name='Only links with:',
default=1, min=1, description=descriptions.RELINK_GROUP
)
# item = []
# for i in range(1,12):
# item.append((str(i),"Relink Group " + str(i),"Relink only with group " + str(i) ))
# parset.mol_relink_group = bpy.props.EnumProperty(
# items = item,
# description = "Choose a group that new link are possible"
# )
parset.mol_relink_chance = bpy.props.FloatProperty(
name="% Linking",
description=descriptions.RELINK_CHANCE,
min=0, max=100, default=0, precision=1, subtype='FACTOR'
)
parset.mol_relink_chancerand = bpy.props.FloatProperty(
name="Rand % Linking",
description=descriptions.RELINK_CHANCE_RANDOM,
default=0, min=0, max=1, precision=2, subtype='FACTOR'
)
parset.mol_relink_tension = bpy.props.FloatProperty(
name="Tension",
description=descriptions.RELINK_TENSION,
min=0, precision=6, default=1
)
parset.mol_relink_tensionrand = bpy.props.FloatProperty(
name="Rand Tension",
description=descriptions.RELINK_TENSION_RANDOM,
min=0, max=1, default=0, precision=6, subtype='FACTOR'
)
parset.mol_relink_max = bpy.props.IntProperty(
name="Max links",
description=descriptions.RELINK_MAX,
min=0, default=16
)
parset.mol_relink_stiff = bpy.props.FloatProperty(
name="Stiff",
description=descriptions.RELINK_STIFFNESS,
min=0, max=1, default=1, precision=6, subtype='FACTOR'
)
parset.mol_relink_stiffrand = bpy.props.FloatProperty(
name="Rand Stiff",
description=descriptions.RELINK_STIFFNESS_RANDOM,
min=0, max=1, default=0, precision=6, subtype='FACTOR'
)
parset.mol_relink_stiffexp = bpy.props.IntProperty(
name="Exponent",
description=descriptions.RELINK_STIFFNESS_EXPONENT,
min=1, max=10, default=1
)
parset.mol_relink_damp = bpy.props.FloatProperty(
name="Damping",
description=descriptions.RELINK_DAMPING,
min=0, max=1, default=1, precision=6, subtype='FACTOR'
)
parset.mol_relink_damprand = bpy.props.FloatProperty(
name="Rand Damping",
description=descriptions.RELINK_DAMPING_RANDOM,
min=0, max=1, default=0, precision=6, subtype='FACTOR'
)
parset.mol_relink_broken = bpy.props.FloatProperty(
name="Broken",
description=descriptions.RELINK_BROKEN,
min=0, default=0.5, precision=6
)
parset.mol_relink_brokenrand = bpy.props.FloatProperty(
name="Rand Broken",
description=descriptions.RELINK_BROKEN_RANDOM,
min=0, max=1, default=0, precision=6, subtype='FACTOR'
)
parset.mol_relink_samevalue = bpy.props.BoolProperty(
name="Same values for compression/expansion",
description=descriptions.RELINK_SAME_VALUE,
default=True
)
parset.mol_relink_estiff = bpy.props.FloatProperty(
name="E Stiff",
description=descriptions.RELINK_EXPENSION_STIFFNESS,
min=0, max=1, default=1, precision=6, subtype='FACTOR'
)
parset.mol_relink_estiffrand = bpy.props.FloatProperty(
name="Rand E Stiff",
description=descriptions.RELINK_EXPENSION_STIFFNESS_RANDOM,
min=0, max=1, default=0, precision=6, subtype='FACTOR'
)
parset.mol_relink_estiffexp = bpy.props.IntProperty(
name="Exponent",
description=descriptions.RELINK_EXPENSION_STIFFNESS_EXPONENT,
min=1, max=10, default=1
)
parset.mol_relink_edamp = bpy.props.FloatProperty(
name="E Damping",
description=descriptions.RELINK_EXPENSION_DAMPING,
min=0, max=1, default=1, precision=6, subtype='FACTOR'
)
parset.mol_relink_edamprand = bpy.props.FloatProperty(
name="Rand E Damping",
description=descriptions.RELINK_EXPENSION_DAMPING_RANDOM,
min=0, max=1, default=0, precision=6, subtype='FACTOR'
)
parset.mol_relink_ebroken = bpy.props.FloatProperty(
name="E Broken",
description=descriptions.RELINK_EXPENSION_BROKEN,
min=0, default=0.5, precision=6
)
parset.mol_relink_ebrokenrand = bpy.props.FloatProperty(
name="Rand E Broken",
description=descriptions.RELINK_EXPENSION_BROKEN_RANDOM,
min=0, max=1, default=0, precision=6, subtype='FACTOR'
)
parset.mol_var1 = bpy.props.IntProperty(
name="Current numbers of particles",
description=descriptions.VAR_1,
min=1, default=1000
)
parset.mol_var2 = bpy.props.IntProperty(
name="Current substep",
description=descriptions.VAR_2,
min=1, default=4
)
parset.mol_var3=bpy.props.IntProperty(
name="Targeted numbers of particles",
description=descriptions.VAR_3,
min=1, default=1000
)
parset.mol_bakeuv = bpy.props.BoolProperty(
name="mol_bakeuv",
description=descriptions.BAKE_UV,
default=False
)
parset.mol_bakeuv_global = bpy.props.BoolProperty(
name="mol_bakeuv_global",
description="make global uv",
default=False
)
parset.mol_bake_weak_map = bpy.props.BoolProperty(
name="mol_bake_weak_map",
description="bake weak_map",
default=False
)
parset.mol_voxel_size = bpy.props.FloatProperty(
name="mol_voxel_size",
description="voxel size",
default=0.1,
step=0.1,
precision=3,
update=update_parsys
)
bpy.types.Scene.timescale = bpy.props.FloatProperty(
name="timescale",
description=descriptions.TIME_SCALE,
default=1.0
)
bpy.types.Scene.mol_substep = bpy.props.IntProperty(
name="Substeps",
description=descriptions.SUBSTEP,
min=0, max=900, default=4
)
bpy.types.Scene.mol_autosubsteps = bpy.props.BoolProperty(
name="Auto Substeps",
description="auto substeps",
default=True
)
bpy.types.Scene.mol_bake = bpy.props.BoolProperty(
name="Bake all at ending",
description=descriptions.BAKE,
default=True
)
bpy.types.Scene.mol_render = bpy.props.BoolProperty(
name="Render at ending",
description=descriptions.RENDER,
default=False
)
bpy.types.Scene.mol_cpu = bpy.props.IntProperty(
name="CPU",
description=descriptions.CPU,
default=multiprocessing.cpu_count(),
min=1, max =64
)
bpy.types.Scene.mol_parnum = bpy.props.IntProperty(
name="Particle Number",
description="Number of all particles in scene",
default=0
)
bpy.types.Scene.mol_voxel_size = bpy.props.FloatProperty(
name = "mol_voxel_size",
description = "Voxel Size for Grid",
min = 0.0001, max=1.0,precision = 4, step=0.001,
default = 0.1
)
bpy.types.Scene.mol_hexgrid = bpy.props.BoolProperty(
name = "mol_hexgrid",
description = "Create Hexagonal Grid",
default = False
)
bpy.types.Scene.mol_progress = bpy.props.StringProperty(
name = "mol_progress",
description = "ProgressBar",
default = ""
)
bpy.types.Scene.mol_exportdata = []
bpy.types.Scene.mol_minsize = bpy.props.FloatProperty()
bpy.types.Scene.mol_simrun = bpy.props.BoolProperty(default=False)
bpy.types.Scene.mol_timeremain = bpy.props.StringProperty()
bpy.types.Scene.mol_old_currentframe = bpy.props.IntProperty()
bpy.types.Scene.mol_old_startframe = bpy.props.IntProperty()
bpy.types.Scene.mol_old_endframe = bpy.props.IntProperty()
bpy.types.Scene.mol_newlink = bpy.props.IntProperty()
bpy.types.Scene.mol_deadlink = bpy.props.IntProperty()
bpy.types.Scene.mol_totallink = bpy.props.IntProperty()
bpy.types.Scene.mol_totaldeadlink = bpy.props.IntProperty()
bpy.types.Scene.mol_cancel = bpy.props.BoolProperty(default=False)