1 /*
2 * This program is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU General Public License
4 * as published by the Free Software Foundation; either version 2
5 * of the License, or (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software Foundation,
14 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15 * Adaptive time step
16 * Copyright 2011 AutoCRC
17 */
18
19 /** \file
20 * \ingroup RNA
21 */
22
23 #include <limits.h>
24 #include <stdio.h>
25 #include <stdlib.h>
26
27 #include "DNA_boid_types.h"
28 #include "DNA_cloth_types.h"
29 #include "DNA_material_types.h"
30 #include "DNA_mesh_types.h"
31 #include "DNA_meshdata_types.h"
32 #include "DNA_modifier_types.h"
33 #include "DNA_object_force_types.h"
34 #include "DNA_object_types.h"
35 #include "DNA_particle_types.h"
36 #include "DNA_scene_types.h"
37 #include "DNA_texture_types.h"
38
39 #include "RNA_define.h"
40 #include "RNA_enum_types.h"
41
42 #include "BKE_mesh.h"
43
44 #include "BLI_listbase.h"
45
46 #include "BLT_translation.h"
47
48 #include "rna_internal.h"
49
50 #include "WM_api.h"
51 #include "WM_types.h"
52
53 #ifdef RNA_RUNTIME
54 static const EnumPropertyItem part_from_items[] = {
55 {PART_FROM_VERT, "VERT", 0, "Vertices", ""},
56 {PART_FROM_FACE, "FACE", 0, "Faces", ""},
57 {PART_FROM_VOLUME, "VOLUME", 0, "Volume", ""},
58 {0, NULL, 0, NULL, NULL},
59 };
60 #endif
61
62 #ifndef RNA_RUNTIME
63 static const EnumPropertyItem part_reactor_from_items[] = {
64 {PART_FROM_VERT, "VERT", 0, "Vertices", ""},
65 {PART_FROM_FACE, "FACE", 0, "Faces", ""},
66 {PART_FROM_VOLUME, "VOLUME", 0, "Volume", ""},
67 {0, NULL, 0, NULL, NULL},
68 };
69 #endif
70
71 static const EnumPropertyItem part_dist_items[] = {
72 {PART_DISTR_JIT, "JIT", 0, "Jittered", ""},
73 {PART_DISTR_RAND, "RAND", 0, "Random", ""},
74 {PART_DISTR_GRID, "GRID", 0, "Grid", ""},
75 {0, NULL, 0, NULL, NULL},
76 };
77
78 #ifdef RNA_RUNTIME
79 static const EnumPropertyItem part_hair_dist_items[] = {
80 {PART_DISTR_JIT, "JIT", 0, "Jittered", ""},
81 {PART_DISTR_RAND, "RAND", 0, "Random", ""},
82 {0, NULL, 0, NULL, NULL},
83 };
84 #endif
85
86 static const EnumPropertyItem part_draw_as_items[] = {
87 {PART_DRAW_NOT, "NONE", 0, "None", ""},
88 {PART_DRAW_REND, "RENDER", 0, "Rendered", ""},
89 {PART_DRAW_DOT, "DOT", 0, "Point", ""},
90 {PART_DRAW_CIRC, "CIRC", 0, "Circle", ""},
91 {PART_DRAW_CROSS, "CROSS", 0, "Cross", ""},
92 {PART_DRAW_AXIS, "AXIS", 0, "Axis", ""},
93 {0, NULL, 0, NULL, NULL},
94 };
95
96 #ifdef RNA_RUNTIME
97 static const EnumPropertyItem part_hair_draw_as_items[] = {
98 {PART_DRAW_NOT, "NONE", 0, "None", ""},
99 {PART_DRAW_REND, "RENDER", 0, "Rendered", ""},
100 {PART_DRAW_PATH, "PATH", 0, "Path", ""},
101 {0, NULL, 0, NULL, NULL},
102 };
103 #endif
104
105 static const EnumPropertyItem part_ren_as_items[] = {
106 {PART_DRAW_NOT, "NONE", 0, "None", ""},
107 {PART_DRAW_HALO, "HALO", 0, "Halo", ""},
108 {PART_DRAW_LINE, "LINE", 0, "Line", ""},
109 {PART_DRAW_PATH, "PATH", 0, "Path", ""},
110 {PART_DRAW_OB, "OBJECT", 0, "Object", ""},
111 {PART_DRAW_GR, "COLLECTION", 0, "Collection", ""},
112 {0, NULL, 0, NULL, NULL},
113 };
114
115 #ifdef RNA_RUNTIME
116 static const EnumPropertyItem part_hair_ren_as_items[] = {
117 {PART_DRAW_NOT, "NONE", 0, "None", ""},
118 {PART_DRAW_PATH, "PATH", 0, "Path", ""},
119 {PART_DRAW_OB, "OBJECT", 0, "Object", ""},
120 {PART_DRAW_GR, "COLLECTION", 0, "Collection", ""},
121 {0, NULL, 0, NULL, NULL},
122 };
123 #endif
124
125 static const EnumPropertyItem part_type_items[] = {
126 {PART_EMITTER, "EMITTER", 0, "Emitter", ""},
127 /*{PART_REACTOR, "REACTOR", 0, "Reactor", ""}, */
128 {PART_HAIR, "HAIR", 0, "Hair", ""},
129 {0, NULL, 0, NULL, NULL},
130 };
131
132 #ifdef RNA_RUNTIME
133 static const EnumPropertyItem part_fluid_type_items[] = {
134 {PART_FLUID, "FLUID", 0, "Fluid", ""},
135 {PART_FLUID_FLIP, "FLIP", 0, "Liquid", ""},
136 {PART_FLUID_SPRAY, "SPRAY", 0, "Spray", ""},
137 {PART_FLUID_BUBBLE, "BUBBLE", 0, "Bubble", ""},
138 {PART_FLUID_FOAM, "FOAM", 0, "Foam", ""},
139 {PART_FLUID_TRACER, "TRACER", 0, "Tracer", ""},
140 {PART_FLUID_SPRAYFOAM, "SPRAYFOAM", 0, "Spray-Foam", ""},
141 {PART_FLUID_SPRAYBUBBLE, "SPRAYBUBBLE", 0, "Spray-Bubble", ""},
142 {PART_FLUID_FOAMBUBBLE, "FOAMBUBBLE", 0, "Foam-Bubble", ""},
143 {PART_FLUID_SPRAYFOAMBUBBLE, "SPRAYFOAMBUBBLE", 0, "Spray-Foam-Bubble", ""},
144 {0, NULL, 0, NULL, NULL},
145 };
146 #endif
147
148 #ifdef RNA_RUNTIME
149
150 # include "BLI_math.h"
151 # include "BLI_string_utils.h"
152
153 # include "BKE_boids.h"
154 # include "BKE_cloth.h"
155 # include "BKE_colortools.h"
156 # include "BKE_context.h"
157 # include "BKE_deform.h"
158 # include "BKE_effect.h"
159 # include "BKE_material.h"
160 # include "BKE_modifier.h"
161 # include "BKE_particle.h"
162 # include "BKE_pointcache.h"
163 # include "BKE_texture.h"
164
165 # include "DEG_depsgraph.h"
166 # include "DEG_depsgraph_build.h"
167
168 /* use for object space hair get/set */
rna_ParticleHairKey_location_object_info(PointerRNA * ptr,ParticleSystemModifierData ** psmd_pt,ParticleData ** pa_pt)169 static void rna_ParticleHairKey_location_object_info(PointerRNA *ptr,
170 ParticleSystemModifierData **psmd_pt,
171 ParticleData **pa_pt)
172 {
173 HairKey *hkey = (HairKey *)ptr->data;
174 Object *ob = (Object *)ptr->owner_id;
175 ModifierData *md;
176 ParticleSystemModifierData *psmd = NULL;
177 ParticleSystem *psys;
178 ParticleData *pa;
179 int i;
180
181 *psmd_pt = NULL;
182 *pa_pt = NULL;
183
184 /* given the pointer HairKey *hkey, we iterate over all particles in all
185 * particle systems in the object "ob" in order to find
186 * - the ParticleSystemData to which the HairKey (and hence the particle)
187 * belongs (will be stored in psmd_pt)
188 * - the ParticleData to which the HairKey belongs (will be stored in pa_pt)
189 *
190 * not a very efficient way of getting hair key location data,
191 * but it's the best we've got at the present
192 *
193 * IDEAS: include additional information in PointerRNA beforehand,
194 * for example a pointer to the ParticleSystemModifierData to which the
195 * hair-key belongs.
196 */
197
198 for (md = ob->modifiers.first; md; md = md->next) {
199 if (md->type == eModifierType_ParticleSystem) {
200 psmd = (ParticleSystemModifierData *)md;
201 if (psmd && psmd->mesh_final && psmd->psys) {
202 psys = psmd->psys;
203 for (i = 0, pa = psys->particles; i < psys->totpart; i++, pa++) {
204 /* Hair-keys are stored sequentially in memory, so we can
205 * find if it's the same particle by comparing pointers,
206 * without having to iterate over them all. */
207 if ((hkey >= pa->hair) && (hkey < pa->hair + pa->totkey)) {
208 *psmd_pt = psmd;
209 *pa_pt = pa;
210 return;
211 }
212 }
213 }
214 }
215 }
216 }
217
rna_ParticleHairKey_location_object_get(PointerRNA * ptr,float * values)218 static void rna_ParticleHairKey_location_object_get(PointerRNA *ptr, float *values)
219 {
220 HairKey *hkey = (HairKey *)ptr->data;
221 Object *ob = (Object *)ptr->owner_id;
222 ParticleSystemModifierData *psmd;
223 ParticleData *pa;
224
225 rna_ParticleHairKey_location_object_info(ptr, &psmd, &pa);
226
227 if (pa) {
228 Mesh *hair_mesh = (psmd->psys->flag & PSYS_HAIR_DYNAMICS) ? psmd->psys->hair_out_mesh : NULL;
229
230 if (hair_mesh) {
231 MVert *mvert = &hair_mesh->mvert[pa->hair_index + (hkey - pa->hair)];
232 copy_v3_v3(values, mvert->co);
233 }
234 else {
235 float hairmat[4][4];
236 psys_mat_hair_to_object(ob, psmd->mesh_final, psmd->psys->part->from, pa, hairmat);
237 copy_v3_v3(values, hkey->co);
238 mul_m4_v3(hairmat, values);
239 }
240 }
241 else {
242 zero_v3(values);
243 }
244 }
245
246 /* Helper function which returns index of the given hair_key in particle which owns it.
247 * Works with cases when hair_key is coming from the particle which was passed here, and from the
248 * original particle of the given one.
249 *
250 * Such trickery is needed to allow modification of hair keys in the original object using
251 * evaluated particle and object to access proper hair matrix. */
hair_key_index_get(HairKey * hair_key,ParticleSystemModifierData * modifier,ParticleData * particle)252 static int hair_key_index_get(/*const*/ HairKey *hair_key,
253 /*const*/ ParticleSystemModifierData *modifier,
254 /*const*/ ParticleData *particle)
255 {
256 if (ARRAY_HAS_ITEM(hair_key, particle->hair, particle->totkey)) {
257 return hair_key - particle->hair;
258 }
259
260 const ParticleSystem *particle_system = modifier->psys;
261 const int particle_index = particle - particle_system->particles;
262
263 const ParticleSystemModifierData *original_modifier = (ParticleSystemModifierData *)
264 BKE_modifier_get_original(&modifier->modifier);
265 const ParticleSystem *original_particle_system = original_modifier->psys;
266 const ParticleData *original_particle = &original_particle_system->particles[particle_index];
267
268 if (ARRAY_HAS_ITEM(hair_key, original_particle->hair, original_particle->totkey)) {
269 return hair_key - original_particle->hair;
270 }
271
272 return -1;
273 }
274
275 /* Set hair_key->co to the given coordinate in object space (the given coordinate will be
276 * converted to the proper space).
277 *
278 * The hair_key can be coming from both original and evaluated object. Object, modifier and
279 * particle are to be from evaluated object, so that all the data needed for hair matrix is
280 * present. */
hair_key_location_object_set(HairKey * hair_key,Object * object,ParticleSystemModifierData * modifier,ParticleData * particle,const float src_co[3])281 static void hair_key_location_object_set(HairKey *hair_key,
282 Object *object,
283 ParticleSystemModifierData *modifier,
284 ParticleData *particle,
285 const float src_co[3])
286 {
287 Mesh *hair_mesh = (modifier->psys->flag & PSYS_HAIR_DYNAMICS) ? modifier->psys->hair_out_mesh :
288 NULL;
289
290 if (hair_mesh != NULL) {
291 const int hair_key_index = hair_key_index_get(hair_key, modifier, particle);
292 if (hair_key_index == -1) {
293 return;
294 }
295
296 MVert *mvert = &hair_mesh->mvert[particle->hair_index + (hair_key_index)];
297 copy_v3_v3(mvert->co, src_co);
298 return;
299 }
300
301 float hairmat[4][4];
302 psys_mat_hair_to_object(
303 object, modifier->mesh_final, modifier->psys->part->from, particle, hairmat);
304
305 float imat[4][4];
306 invert_m4_m4(imat, hairmat);
307
308 copy_v3_v3(hair_key->co, src_co);
309 mul_m4_v3(imat, hair_key->co);
310 }
311
rna_ParticleHairKey_location_object_set(PointerRNA * ptr,const float * values)312 static void rna_ParticleHairKey_location_object_set(PointerRNA *ptr, const float *values)
313 {
314 HairKey *hkey = (HairKey *)ptr->data;
315 Object *ob = (Object *)ptr->owner_id;
316
317 ParticleSystemModifierData *psmd;
318 ParticleData *pa;
319 rna_ParticleHairKey_location_object_info(ptr, &psmd, &pa);
320
321 if (pa == NULL) {
322 zero_v3(hkey->co);
323 return;
324 }
325
326 hair_key_location_object_set(hkey, ob, psmd, pa, values);
327 }
328
rna_ParticleHairKey_co_object(HairKey * hairkey,Object * object,ParticleSystemModifierData * modifier,ParticleData * particle,float n_co[3])329 static void rna_ParticleHairKey_co_object(HairKey *hairkey,
330 Object *object,
331 ParticleSystemModifierData *modifier,
332 ParticleData *particle,
333 float n_co[3])
334 {
335
336 Mesh *hair_mesh = (modifier->psys->flag & PSYS_HAIR_DYNAMICS) ? modifier->psys->hair_out_mesh :
337 NULL;
338 if (particle) {
339 if (hair_mesh) {
340 MVert *mvert = &hair_mesh->mvert[particle->hair_index + (hairkey - particle->hair)];
341 copy_v3_v3(n_co, mvert->co);
342 }
343 else {
344 float hairmat[4][4];
345 psys_mat_hair_to_object(
346 object, modifier->mesh_final, modifier->psys->part->from, particle, hairmat);
347 copy_v3_v3(n_co, hairkey->co);
348 mul_m4_v3(hairmat, n_co);
349 }
350 }
351 else {
352 zero_v3(n_co);
353 }
354 }
355
rna_ParticleHairKey_co_object_set(ID * id,HairKey * hair_key,Object * object,ParticleSystemModifierData * modifier,ParticleData * particle,float co[3])356 static void rna_ParticleHairKey_co_object_set(ID *id,
357 HairKey *hair_key,
358 Object *object,
359 ParticleSystemModifierData *modifier,
360 ParticleData *particle,
361 float co[3])
362 {
363
364 if (particle == NULL) {
365 return;
366 }
367
368 /* Mark particle system as edited, so then particle_system_update() does not reset the hair
369 * keys from path. This behavior is similar to how particle edit mode sets flags. */
370 ParticleSystemModifierData *orig_modifier = (ParticleSystemModifierData *)
371 modifier->modifier.orig_modifier_data;
372 orig_modifier->psys->flag |= PSYS_EDITED;
373
374 hair_key_location_object_set(hair_key, object, modifier, particle, co);
375
376 /* Tag similar to brushes in particle edit mode, so the modifier stack is properly evaluated
377 * with the same particle system recalc flags as during combing. */
378 DEG_id_tag_update(id, ID_RECALC_GEOMETRY | ID_RECALC_PSYS_REDO);
379 }
380
rna_Particle_uv_on_emitter(ParticleData * particle,ReportList * reports,ParticleSystemModifierData * modifier,float r_uv[2])381 static void rna_Particle_uv_on_emitter(ParticleData *particle,
382 ReportList *reports,
383 ParticleSystemModifierData *modifier,
384 float r_uv[2])
385 {
386 # if 0
387 psys_particle_on_emitter(
388 psmd, part->from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, co, nor, 0, 0, sd.orco, 0);
389 # endif
390
391 if (modifier->mesh_final == NULL) {
392 BKE_report(reports, RPT_ERROR, "uv_on_emitter() requires a modifier from an evaluated object");
393 return;
394 }
395
396 /* get uvco & mcol */
397 int num = particle->num_dmcache;
398 int from = modifier->psys->part->from;
399
400 if (!CustomData_has_layer(&modifier->mesh_final->ldata, CD_MLOOPUV)) {
401 BKE_report(reports, RPT_ERROR, "Mesh has no UV data");
402 return;
403 }
404 BKE_mesh_tessface_ensure(modifier->mesh_final); /* BMESH - UNTIL MODIFIER IS UPDATED FOR MPoly */
405
406 if (num == DMCACHE_NOTFOUND) {
407 if (particle->num < modifier->mesh_final->totface) {
408 num = particle->num;
409 }
410 }
411
412 /* get uvco */
413 if (r_uv && ELEM(from, PART_FROM_FACE, PART_FROM_VOLUME)) {
414
415 if (num != DMCACHE_NOTFOUND) {
416 MFace *mface;
417 MTFace *mtface;
418
419 mface = modifier->mesh_final->mface;
420 mtface = modifier->mesh_final->mtface;
421
422 if (mface && mtface) {
423 mtface += num;
424 psys_interpolate_uvs(mtface, mface->v4, particle->fuv, r_uv);
425 return;
426 }
427 }
428 }
429
430 r_uv[0] = 0.0f;
431 r_uv[1] = 0.0f;
432 }
433
rna_ParticleSystem_co_hair(ParticleSystem * particlesystem,Object * object,int particle_no,int step,float n_co[3])434 static void rna_ParticleSystem_co_hair(
435 ParticleSystem *particlesystem, Object *object, int particle_no, int step, float n_co[3])
436 {
437 ParticleSettings *part = NULL;
438 ParticleData *pars = NULL;
439 ParticleCacheKey *cache = NULL;
440 int totchild = 0;
441 int totpart;
442 int max_k = 0;
443
444 if (particlesystem == NULL) {
445 return;
446 }
447
448 part = particlesystem->part;
449 pars = particlesystem->particles;
450 totpart = particlesystem->totcached;
451 totchild = particlesystem->totchildcache;
452
453 if (part == NULL || pars == NULL) {
454 return;
455 }
456
457 if (part->ren_as == PART_DRAW_OB || part->ren_as == PART_DRAW_GR ||
458 part->ren_as == PART_DRAW_NOT) {
459 return;
460 }
461
462 /* can happen for disconnected/global hair */
463 if (part->type == PART_HAIR && !particlesystem->childcache) {
464 totchild = 0;
465 }
466
467 if (particle_no < totpart && particlesystem->pathcache) {
468 cache = particlesystem->pathcache[particle_no];
469 max_k = (int)cache->segments;
470 }
471 else if (particle_no < totpart + totchild && particlesystem->childcache) {
472 cache = particlesystem->childcache[particle_no - totpart];
473
474 if (cache->segments < 0) {
475 max_k = 0;
476 }
477 else {
478 max_k = (int)cache->segments;
479 }
480 }
481 else {
482 return;
483 }
484
485 /* Strands key loop data stored in cache + step->co. */
486 if (step >= 0 && step <= max_k) {
487 copy_v3_v3(n_co, (cache + step)->co);
488 mul_m4_v3(particlesystem->imat, n_co);
489 mul_m4_v3(object->obmat, n_co);
490 }
491 }
492
rna_Particle_Material_itemf(bContext * C,PointerRNA * UNUSED (ptr),PropertyRNA * UNUSED (prop),bool * r_free)493 static const EnumPropertyItem *rna_Particle_Material_itemf(bContext *C,
494 PointerRNA *UNUSED(ptr),
495 PropertyRNA *UNUSED(prop),
496 bool *r_free)
497 {
498 Object *ob = CTX_data_pointer_get(C, "object").data;
499 Material *ma;
500 EnumPropertyItem *item = NULL;
501 EnumPropertyItem tmp = {0, "", 0, "", ""};
502 int totitem = 0;
503 int i;
504
505 if (ob && ob->totcol > 0) {
506 for (i = 1; i <= ob->totcol; i++) {
507 ma = BKE_object_material_get(ob, i);
508 tmp.value = i;
509 tmp.icon = ICON_MATERIAL_DATA;
510 if (ma) {
511 tmp.name = ma->id.name + 2;
512 tmp.identifier = tmp.name;
513 }
514 else {
515 tmp.name = "Default Material";
516 tmp.identifier = tmp.name;
517 }
518 RNA_enum_item_add(&item, &totitem, &tmp);
519 }
520 }
521 else {
522 tmp.value = 1;
523 tmp.icon = ICON_MATERIAL_DATA;
524 tmp.name = "Default Material";
525 tmp.identifier = tmp.name;
526 RNA_enum_item_add(&item, &totitem, &tmp);
527 }
528
529 RNA_enum_item_end(&item, &totitem);
530 *r_free = true;
531
532 return item;
533 }
534
535 /* return < 0 means invalid (no matching tessellated face could be found). */
rna_ParticleSystem_tessfaceidx_on_emitter(ParticleSystem * particlesystem,ParticleSystemModifierData * modifier,ParticleData * particle,int particle_no,float (** r_fuv)[4])536 static int rna_ParticleSystem_tessfaceidx_on_emitter(ParticleSystem *particlesystem,
537 ParticleSystemModifierData *modifier,
538 ParticleData *particle,
539 int particle_no,
540 float (**r_fuv)[4])
541 {
542 ParticleSettings *part = NULL;
543 int totpart;
544 int totchild = 0;
545 int totface;
546 int totvert;
547 int num = -1;
548
549 BKE_mesh_tessface_ensure(modifier->mesh_final); /* BMESH - UNTIL MODIFIER IS UPDATED FOR MPoly */
550 totface = modifier->mesh_final->totface;
551 totvert = modifier->mesh_final->totvert;
552
553 /* 1. check that everything is ok & updated */
554 if (!particlesystem || !totface) {
555 return num;
556 }
557
558 part = particlesystem->part;
559 /* Note: only hair, keyed and baked particles may have cached items... */
560 totpart = particlesystem->totcached != 0 ? particlesystem->totcached : particlesystem->totpart;
561 totchild = particlesystem->totchildcache != 0 ? particlesystem->totchildcache :
562 particlesystem->totchild;
563
564 /* can happen for disconnected/global hair */
565 if (part->type == PART_HAIR && !particlesystem->childcache) {
566 totchild = 0;
567 }
568
569 if (particle_no >= totpart + totchild) {
570 return num;
571 }
572
573 /* 2. get matching face index. */
574 if (particle_no < totpart) {
575 num = (ELEM(particle->num_dmcache, DMCACHE_ISCHILD, DMCACHE_NOTFOUND)) ? particle->num :
576 particle->num_dmcache;
577
578 if (ELEM(part->from, PART_FROM_FACE, PART_FROM_VOLUME)) {
579 if (num != DMCACHE_NOTFOUND && num < totface) {
580 *r_fuv = &particle->fuv;
581 return num;
582 }
583 }
584 else if (part->from == PART_FROM_VERT) {
585 if (num != DMCACHE_NOTFOUND && num < totvert) {
586 MFace *mface = modifier->mesh_final->mface;
587
588 *r_fuv = &particle->fuv;
589
590 /* This finds the first face to contain the emitting vertex,
591 * this is not ideal, but is mostly fine as UV seams generally
592 * map to equal-colored parts of a texture */
593 for (int i = 0; i < totface; i++, mface++) {
594 if (ELEM(num, mface->v1, mface->v2, mface->v3, mface->v4)) {
595 return i;
596 }
597 }
598 }
599 }
600 }
601 else {
602 ChildParticle *cpa = particlesystem->child + particle_no - totpart;
603 num = cpa->num;
604
605 if (part->childtype == PART_CHILD_FACES) {
606 if (ELEM(part->from, PART_FROM_FACE, PART_FROM_VOLUME, PART_FROM_VERT)) {
607 if (num != DMCACHE_NOTFOUND && num < totface) {
608 *r_fuv = &cpa->fuv;
609 return num;
610 }
611 }
612 }
613 else {
614 ParticleData *parent = particlesystem->particles + cpa->parent;
615 num = parent->num_dmcache;
616
617 if (num == DMCACHE_NOTFOUND) {
618 num = parent->num;
619 }
620
621 if (ELEM(part->from, PART_FROM_FACE, PART_FROM_VOLUME)) {
622 if (num != DMCACHE_NOTFOUND && num < totface) {
623 *r_fuv = &parent->fuv;
624 return num;
625 }
626 }
627 else if (part->from == PART_FROM_VERT) {
628 if (num != DMCACHE_NOTFOUND && num < totvert) {
629 MFace *mface = modifier->mesh_final->mface;
630
631 *r_fuv = &parent->fuv;
632
633 /* This finds the first face to contain the emitting vertex,
634 * this is not ideal, but is mostly fine as UV seams generally
635 * map to equal-colored parts of a texture */
636 for (int i = 0; i < totface; i++, mface++) {
637 if (ELEM(num, mface->v1, mface->v2, mface->v3, mface->v4)) {
638 return i;
639 }
640 }
641 }
642 }
643 }
644 }
645
646 return -1;
647 }
648
rna_ParticleSystem_uv_on_emitter(ParticleSystem * particlesystem,ReportList * reports,ParticleSystemModifierData * modifier,ParticleData * particle,int particle_no,int uv_no,float r_uv[2])649 static void rna_ParticleSystem_uv_on_emitter(ParticleSystem *particlesystem,
650 ReportList *reports,
651 ParticleSystemModifierData *modifier,
652 ParticleData *particle,
653 int particle_no,
654 int uv_no,
655 float r_uv[2])
656 {
657 if (modifier->mesh_final == NULL) {
658 BKE_report(reports, RPT_ERROR, "Object was not yet evaluated");
659 zero_v2(r_uv);
660 return;
661 }
662 if (!CustomData_has_layer(&modifier->mesh_final->ldata, CD_MLOOPUV)) {
663 BKE_report(reports, RPT_ERROR, "Mesh has no UV data");
664 zero_v2(r_uv);
665 return;
666 }
667
668 {
669 float(*fuv)[4];
670 /* Note all sanity checks are done in this helper func. */
671 const int num = rna_ParticleSystem_tessfaceidx_on_emitter(
672 particlesystem, modifier, particle, particle_no, &fuv);
673
674 if (num < 0) {
675 /* No matching face found. */
676 zero_v2(r_uv);
677 }
678 else {
679 MFace *mface = &modifier->mesh_final->mface[num];
680 MTFace *mtface = (MTFace *)CustomData_get_layer_n(
681 &modifier->mesh_final->fdata, CD_MTFACE, uv_no);
682
683 psys_interpolate_uvs(&mtface[num], mface->v4, *fuv, r_uv);
684 }
685 }
686 }
687
rna_ParticleSystem_mcol_on_emitter(ParticleSystem * particlesystem,ReportList * reports,ParticleSystemModifierData * modifier,ParticleData * particle,int particle_no,int vcol_no,float r_mcol[3])688 static void rna_ParticleSystem_mcol_on_emitter(ParticleSystem *particlesystem,
689 ReportList *reports,
690 ParticleSystemModifierData *modifier,
691 ParticleData *particle,
692 int particle_no,
693 int vcol_no,
694 float r_mcol[3])
695 {
696 if (!CustomData_has_layer(&modifier->mesh_final->ldata, CD_MLOOPCOL)) {
697 BKE_report(reports, RPT_ERROR, "Mesh has no VCol data");
698 zero_v3(r_mcol);
699 return;
700 }
701
702 {
703 float(*fuv)[4];
704 /* Note all sanity checks are done in this helper func. */
705 const int num = rna_ParticleSystem_tessfaceidx_on_emitter(
706 particlesystem, modifier, particle, particle_no, &fuv);
707
708 if (num < 0) {
709 /* No matching face found. */
710 zero_v3(r_mcol);
711 }
712 else {
713 MFace *mface = &modifier->mesh_final->mface[num];
714 MCol *mc = (MCol *)CustomData_get_layer_n(&modifier->mesh_final->fdata, CD_MCOL, vcol_no);
715 MCol mcol;
716
717 psys_interpolate_mcol(&mc[num * 4], mface->v4, *fuv, &mcol);
718 r_mcol[0] = (float)mcol.b / 255.0f;
719 r_mcol[1] = (float)mcol.g / 255.0f;
720 r_mcol[2] = (float)mcol.r / 255.0f;
721 }
722 }
723 }
724
particle_recalc(Main * UNUSED (bmain),Scene * UNUSED (scene),PointerRNA * ptr,short flag)725 static void particle_recalc(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr, short flag)
726 {
727 if (ptr->type == &RNA_ParticleSystem) {
728 Object *ob = (Object *)ptr->owner_id;
729 ParticleSystem *psys = (ParticleSystem *)ptr->data;
730
731 psys->recalc = flag;
732
733 DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
734 }
735 else {
736 DEG_id_tag_update(ptr->owner_id, ID_RECALC_GEOMETRY | flag);
737 }
738
739 WM_main_add_notifier(NC_OBJECT | ND_PARTICLE | NA_EDITED, NULL);
740 }
rna_Particle_redo(Main * bmain,Scene * scene,PointerRNA * ptr)741 static void rna_Particle_redo(Main *bmain, Scene *scene, PointerRNA *ptr)
742 {
743 particle_recalc(bmain, scene, ptr, ID_RECALC_PSYS_REDO);
744 }
745
rna_Particle_redo_dependency(Main * bmain,Scene * scene,PointerRNA * ptr)746 static void rna_Particle_redo_dependency(Main *bmain, Scene *scene, PointerRNA *ptr)
747 {
748 DEG_relations_tag_update(bmain);
749 rna_Particle_redo(bmain, scene, ptr);
750 }
751
rna_Particle_redo_count(Main * bmain,Scene * scene,PointerRNA * ptr)752 static void rna_Particle_redo_count(Main *bmain, Scene *scene, PointerRNA *ptr)
753 {
754 ParticleSettings *part = (ParticleSettings *)ptr->data;
755 DEG_relations_tag_update(bmain);
756 psys_check_group_weights(part);
757 particle_recalc(bmain, scene, ptr, ID_RECALC_PSYS_REDO);
758 }
759
rna_Particle_reset(Main * bmain,Scene * scene,PointerRNA * ptr)760 static void rna_Particle_reset(Main *bmain, Scene *scene, PointerRNA *ptr)
761 {
762 particle_recalc(bmain, scene, ptr, ID_RECALC_PSYS_RESET);
763 }
764
rna_Particle_reset_dependency(Main * bmain,Scene * scene,PointerRNA * ptr)765 static void rna_Particle_reset_dependency(Main *bmain, Scene *scene, PointerRNA *ptr)
766 {
767 DEG_relations_tag_update(bmain);
768 rna_Particle_reset(bmain, scene, ptr);
769 }
770
rna_Particle_change_type(Main * bmain,Scene * UNUSED (scene),PointerRNA * ptr)771 static void rna_Particle_change_type(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
772 {
773 ParticleSettings *part = (ParticleSettings *)ptr->owner_id;
774
775 /* Iterating over all object is slow, but no better solution exists at the moment. */
776 for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
777 LISTBASE_FOREACH (ParticleSystem *, psys, &ob->particlesystem) {
778 if (psys->part == part) {
779 psys_changed_type(ob, psys);
780 psys->recalc |= ID_RECALC_PSYS_RESET;
781 DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
782 }
783 }
784 }
785
786 WM_main_add_notifier(NC_OBJECT | ND_PARTICLE | NA_EDITED, NULL);
787 DEG_relations_tag_update(bmain);
788 }
789
rna_Particle_change_physics_type(Main * bmain,Scene * scene,PointerRNA * ptr)790 static void rna_Particle_change_physics_type(Main *bmain, Scene *scene, PointerRNA *ptr)
791 {
792 particle_recalc(bmain, scene, ptr, ID_RECALC_PSYS_RESET | ID_RECALC_PSYS_PHYS);
793
794 ParticleSettings *part = (ParticleSettings *)ptr->data;
795
796 if (part->phystype == PART_PHYS_BOIDS && part->boids == NULL) {
797 BoidState *state;
798
799 part->boids = MEM_callocN(sizeof(BoidSettings), "Boid Settings");
800 boid_default_settings(part->boids);
801
802 state = boid_new_state(part->boids);
803 BLI_addtail(&state->rules, boid_new_rule(eBoidRuleType_Separate));
804 BLI_addtail(&state->rules, boid_new_rule(eBoidRuleType_Flock));
805
806 ((BoidRule *)state->rules.first)->flag |= BOIDRULE_CURRENT;
807
808 state->flag |= BOIDSTATE_CURRENT;
809 BLI_addtail(&part->boids->states, state);
810 }
811 else if (part->phystype == PART_PHYS_FLUID && part->fluid == NULL) {
812 part->fluid = MEM_callocN(sizeof(SPHFluidSettings), "SPH Fluid Settings");
813 BKE_particlesettings_fluid_default_settings(part);
814 }
815
816 DEG_relations_tag_update(bmain);
817 }
818
rna_Particle_redo_child(Main * bmain,Scene * scene,PointerRNA * ptr)819 static void rna_Particle_redo_child(Main *bmain, Scene *scene, PointerRNA *ptr)
820 {
821 particle_recalc(bmain, scene, ptr, ID_RECALC_PSYS_CHILD);
822 }
823
rna_Particle_cloth_update(Main * UNUSED (bmain),Scene * UNUSED (scene),PointerRNA * ptr)824 static void rna_Particle_cloth_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
825 {
826 Object *ob = (Object *)ptr->owner_id;
827
828 DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
829 WM_main_add_notifier(NC_OBJECT | ND_MODIFIER, ob);
830 }
831
rna_particle_system_for_target(Object * ob,ParticleTarget * target)832 static ParticleSystem *rna_particle_system_for_target(Object *ob, ParticleTarget *target)
833 {
834 ParticleSystem *psys;
835 ParticleTarget *pt;
836
837 for (psys = ob->particlesystem.first; psys; psys = psys->next) {
838 for (pt = psys->targets.first; pt; pt = pt->next) {
839 if (pt == target) {
840 return psys;
841 }
842 }
843 }
844
845 return NULL;
846 }
847
rna_Particle_target_reset(Main * bmain,Scene * UNUSED (scene),PointerRNA * ptr)848 static void rna_Particle_target_reset(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
849 {
850 if (ptr->type == &RNA_ParticleTarget) {
851 Object *ob = (Object *)ptr->owner_id;
852 ParticleTarget *pt = (ParticleTarget *)ptr->data;
853 ParticleSystem *kpsys = NULL, *psys = rna_particle_system_for_target(ob, pt);
854
855 if (pt->ob == ob || pt->ob == NULL) {
856 kpsys = BLI_findlink(&ob->particlesystem, pt->psys - 1);
857
858 if (kpsys) {
859 pt->flag |= PTARGET_VALID;
860 }
861 else {
862 pt->flag &= ~PTARGET_VALID;
863 }
864 }
865 else {
866 if (pt->ob) {
867 kpsys = BLI_findlink(&pt->ob->particlesystem, pt->psys - 1);
868 }
869
870 if (kpsys) {
871 pt->flag |= PTARGET_VALID;
872 }
873 else {
874 pt->flag &= ~PTARGET_VALID;
875 }
876 }
877
878 psys->recalc = ID_RECALC_PSYS_RESET;
879
880 DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
881 DEG_relations_tag_update(bmain);
882 }
883
884 WM_main_add_notifier(NC_OBJECT | ND_PARTICLE | NA_EDITED, NULL);
885 }
886
rna_Particle_target_redo(Main * UNUSED (bmain),Scene * UNUSED (scene),PointerRNA * ptr)887 static void rna_Particle_target_redo(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
888 {
889 if (ptr->type == &RNA_ParticleTarget) {
890 Object *ob = (Object *)ptr->owner_id;
891 ParticleTarget *pt = (ParticleTarget *)ptr->data;
892 ParticleSystem *psys = rna_particle_system_for_target(ob, pt);
893
894 psys->recalc = ID_RECALC_PSYS_REDO;
895
896 DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
897 WM_main_add_notifier(NC_OBJECT | ND_PARTICLE | NA_EDITED, NULL);
898 }
899 }
900
rna_Particle_hair_dynamics_update(Main * bmain,Scene * scene,PointerRNA * ptr)901 static void rna_Particle_hair_dynamics_update(Main *bmain, Scene *scene, PointerRNA *ptr)
902 {
903 Object *ob = (Object *)ptr->owner_id;
904 ParticleSystem *psys = (ParticleSystem *)ptr->data;
905
906 if (psys && !psys->clmd) {
907 psys->clmd = (ClothModifierData *)BKE_modifier_new(eModifierType_Cloth);
908 psys->clmd->sim_parms->goalspring = 0.0f;
909 psys->clmd->sim_parms->flags |= CLOTH_SIMSETTINGS_FLAG_RESIST_SPRING_COMPRESS;
910 psys->clmd->coll_parms->flags &= ~CLOTH_COLLSETTINGS_FLAG_SELF;
911 rna_Particle_redo(bmain, scene, ptr);
912 }
913 else {
914 WM_main_add_notifier(NC_OBJECT | ND_PARTICLE | NA_EDITED, NULL);
915 }
916
917 DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
918 DEG_relations_tag_update(bmain);
919 }
920
rna_particle_settings_get(PointerRNA * ptr)921 static PointerRNA rna_particle_settings_get(PointerRNA *ptr)
922 {
923 ParticleSystem *psys = (ParticleSystem *)ptr->data;
924 ParticleSettings *part = psys->part;
925
926 return rna_pointer_inherit_refine(ptr, &RNA_ParticleSettings, part);
927 }
928
rna_particle_settings_set(PointerRNA * ptr,PointerRNA value,struct ReportList * UNUSED (reports))929 static void rna_particle_settings_set(PointerRNA *ptr,
930 PointerRNA value,
931 struct ReportList *UNUSED(reports))
932 {
933 Object *ob = (Object *)ptr->owner_id;
934 ParticleSystem *psys = (ParticleSystem *)ptr->data;
935 int old_type = 0;
936
937 if (psys->part) {
938 old_type = psys->part->type;
939 id_us_min(&psys->part->id);
940 }
941
942 psys->part = (ParticleSettings *)value.data;
943
944 if (psys->part) {
945 id_us_plus(&psys->part->id);
946 psys_check_boid_data(psys);
947 if (old_type != psys->part->type) {
948 psys_changed_type(ob, psys);
949 }
950 }
951 }
rna_Particle_abspathtime_update(Main * bmain,Scene * scene,PointerRNA * ptr)952 static void rna_Particle_abspathtime_update(Main *bmain, Scene *scene, PointerRNA *ptr)
953 {
954 ParticleSettings *settings = (ParticleSettings *)ptr->data;
955 float delta = settings->end + settings->lifetime - settings->sta;
956 if (settings->draw & PART_ABS_PATH_TIME) {
957 settings->path_start = settings->sta + settings->path_start * delta;
958 settings->path_end = settings->sta + settings->path_end * delta;
959 }
960 else {
961 settings->path_start = (settings->path_start - settings->sta) / delta;
962 settings->path_end = (settings->path_end - settings->sta) / delta;
963 }
964 rna_Particle_redo(bmain, scene, ptr);
965 }
rna_PartSettings_start_set(struct PointerRNA * ptr,float value)966 static void rna_PartSettings_start_set(struct PointerRNA *ptr, float value)
967 {
968 ParticleSettings *settings = (ParticleSettings *)ptr->data;
969
970 /* check for clipping */
971 if (value > settings->end) {
972 settings->end = value;
973 }
974
975 /*if (settings->type==PART_REACTOR && value < 1.0) */
976 /* value = 1.0; */
977 /*else */
978 if (value < MINAFRAMEF) {
979 value = MINAFRAMEF;
980 }
981
982 settings->sta = value;
983 }
984
rna_PartSettings_end_set(struct PointerRNA * ptr,float value)985 static void rna_PartSettings_end_set(struct PointerRNA *ptr, float value)
986 {
987 ParticleSettings *settings = (ParticleSettings *)ptr->data;
988
989 /* check for clipping */
990 if (value < settings->sta) {
991 settings->sta = value;
992 }
993
994 settings->end = value;
995 }
996
rna_PartSetings_timestep_set(struct PointerRNA * ptr,float value)997 static void rna_PartSetings_timestep_set(struct PointerRNA *ptr, float value)
998 {
999 ParticleSettings *settings = (ParticleSettings *)ptr->data;
1000
1001 settings->timetweak = value / 0.04f;
1002 }
1003
rna_PartSettings_timestep_get(struct PointerRNA * ptr)1004 static float rna_PartSettings_timestep_get(struct PointerRNA *ptr)
1005 {
1006 ParticleSettings *settings = (ParticleSettings *)ptr->data;
1007
1008 return settings->timetweak * 0.04f;
1009 }
1010
rna_PartSetting_hairlength_set(struct PointerRNA * ptr,float value)1011 static void rna_PartSetting_hairlength_set(struct PointerRNA *ptr, float value)
1012 {
1013 ParticleSettings *settings = (ParticleSettings *)ptr->data;
1014 settings->normfac = value / 4.f;
1015 }
1016
rna_PartSetting_hairlength_get(struct PointerRNA * ptr)1017 static float rna_PartSetting_hairlength_get(struct PointerRNA *ptr)
1018 {
1019 ParticleSettings *settings = (ParticleSettings *)ptr->data;
1020 return settings->normfac * 4.f;
1021 }
1022
rna_PartSetting_linelentail_set(struct PointerRNA * ptr,float value)1023 static void rna_PartSetting_linelentail_set(struct PointerRNA *ptr, float value)
1024 {
1025 ParticleSettings *settings = (ParticleSettings *)ptr->data;
1026 settings->draw_line[0] = value;
1027 }
1028
rna_PartSetting_linelentail_get(struct PointerRNA * ptr)1029 static float rna_PartSetting_linelentail_get(struct PointerRNA *ptr)
1030 {
1031 ParticleSettings *settings = (ParticleSettings *)ptr->data;
1032 return settings->draw_line[0];
1033 }
rna_PartSetting_pathstartend_range(PointerRNA * ptr,float * min,float * max,float * UNUSED (softmin),float * UNUSED (softmax))1034 static void rna_PartSetting_pathstartend_range(
1035 PointerRNA *ptr, float *min, float *max, float *UNUSED(softmin), float *UNUSED(softmax))
1036 {
1037 ParticleSettings *settings = (ParticleSettings *)ptr->data;
1038
1039 if (settings->type == PART_HAIR) {
1040 *min = 0.0f;
1041 *max = (settings->draw & PART_ABS_PATH_TIME) ? 100.0f : 1.0f;
1042 }
1043 else {
1044 *min = (settings->draw & PART_ABS_PATH_TIME) ? settings->sta : 0.0f;
1045 *max = (settings->draw & PART_ABS_PATH_TIME) ? MAXFRAMEF : 1.0f;
1046 }
1047 }
rna_PartSetting_linelenhead_set(struct PointerRNA * ptr,float value)1048 static void rna_PartSetting_linelenhead_set(struct PointerRNA *ptr, float value)
1049 {
1050 ParticleSettings *settings = (ParticleSettings *)ptr->data;
1051 settings->draw_line[1] = value;
1052 }
1053
rna_PartSetting_linelenhead_get(struct PointerRNA * ptr)1054 static float rna_PartSetting_linelenhead_get(struct PointerRNA *ptr)
1055 {
1056 ParticleSettings *settings = (ParticleSettings *)ptr->data;
1057 return settings->draw_line[1];
1058 }
1059
rna_PartSettings_is_fluid_get(PointerRNA * ptr)1060 static int rna_PartSettings_is_fluid_get(PointerRNA *ptr)
1061 {
1062 ParticleSettings *part = ptr->data;
1063 return (ELEM(part->type,
1064 PART_FLUID,
1065 PART_FLUID_FLIP,
1066 PART_FLUID_FOAM,
1067 PART_FLUID_SPRAY,
1068 PART_FLUID_BUBBLE,
1069 PART_FLUID_TRACER,
1070 PART_FLUID_SPRAYFOAM,
1071 PART_FLUID_SPRAYBUBBLE,
1072 PART_FLUID_FOAMBUBBLE,
1073 PART_FLUID_SPRAYFOAMBUBBLE));
1074 }
1075
rna_ParticleSettings_use_clump_curve_update(Main * bmain,Scene * scene,PointerRNA * ptr)1076 static void rna_ParticleSettings_use_clump_curve_update(Main *bmain, Scene *scene, PointerRNA *ptr)
1077 {
1078 ParticleSettings *part = ptr->data;
1079
1080 if (part->child_flag & PART_CHILD_USE_CLUMP_CURVE) {
1081 if (!part->clumpcurve) {
1082 BKE_particlesettings_clump_curve_init(part);
1083 }
1084 }
1085
1086 rna_Particle_redo_child(bmain, scene, ptr);
1087 }
1088
rna_ParticleSettings_use_roughness_curve_update(Main * bmain,Scene * scene,PointerRNA * ptr)1089 static void rna_ParticleSettings_use_roughness_curve_update(Main *bmain,
1090 Scene *scene,
1091 PointerRNA *ptr)
1092 {
1093 ParticleSettings *part = ptr->data;
1094
1095 if (part->child_flag & PART_CHILD_USE_ROUGH_CURVE) {
1096 if (!part->roughcurve) {
1097 BKE_particlesettings_rough_curve_init(part);
1098 }
1099 }
1100
1101 rna_Particle_redo_child(bmain, scene, ptr);
1102 }
1103
rna_ParticleSettings_use_twist_curve_update(Main * bmain,Scene * scene,PointerRNA * ptr)1104 static void rna_ParticleSettings_use_twist_curve_update(Main *bmain, Scene *scene, PointerRNA *ptr)
1105 {
1106 ParticleSettings *part = ptr->data;
1107
1108 if (part->child_flag & PART_CHILD_USE_TWIST_CURVE) {
1109 if (!part->twistcurve) {
1110 BKE_particlesettings_twist_curve_init(part);
1111 }
1112 }
1113
1114 rna_Particle_redo_child(bmain, scene, ptr);
1115 }
1116
rna_ParticleSystem_name_set(PointerRNA * ptr,const char * value)1117 static void rna_ParticleSystem_name_set(PointerRNA *ptr, const char *value)
1118 {
1119 Object *ob = (Object *)ptr->owner_id;
1120 ParticleSystem *part = (ParticleSystem *)ptr->data;
1121
1122 /* copy the new name into the name slot */
1123 BLI_strncpy_utf8(part->name, value, sizeof(part->name));
1124
1125 BLI_uniquename(&ob->particlesystem,
1126 part,
1127 DATA_("ParticleSystem"),
1128 '.',
1129 offsetof(ParticleSystem, name),
1130 sizeof(part->name));
1131 }
1132
rna_ParticleSystem_active_particle_target_get(PointerRNA * ptr)1133 static PointerRNA rna_ParticleSystem_active_particle_target_get(PointerRNA *ptr)
1134 {
1135 ParticleSystem *psys = (ParticleSystem *)ptr->data;
1136 ParticleTarget *pt = psys->targets.first;
1137
1138 for (; pt; pt = pt->next) {
1139 if (pt->flag & PTARGET_CURRENT) {
1140 return rna_pointer_inherit_refine(ptr, &RNA_ParticleTarget, pt);
1141 }
1142 }
1143 return rna_pointer_inherit_refine(ptr, &RNA_ParticleTarget, NULL);
1144 }
rna_ParticleSystem_active_particle_target_index_range(PointerRNA * ptr,int * min,int * max,int * UNUSED (softmin),int * UNUSED (softmax))1145 static void rna_ParticleSystem_active_particle_target_index_range(
1146 PointerRNA *ptr, int *min, int *max, int *UNUSED(softmin), int *UNUSED(softmax))
1147 {
1148 ParticleSystem *psys = (ParticleSystem *)ptr->data;
1149 *min = 0;
1150 *max = max_ii(0, BLI_listbase_count(&psys->targets) - 1);
1151 }
1152
rna_ParticleSystem_active_particle_target_index_get(PointerRNA * ptr)1153 static int rna_ParticleSystem_active_particle_target_index_get(PointerRNA *ptr)
1154 {
1155 ParticleSystem *psys = (ParticleSystem *)ptr->data;
1156 ParticleTarget *pt = psys->targets.first;
1157 int i = 0;
1158
1159 for (; pt; pt = pt->next, i++) {
1160 if (pt->flag & PTARGET_CURRENT) {
1161 return i;
1162 }
1163 }
1164
1165 return 0;
1166 }
1167
rna_ParticleSystem_active_particle_target_index_set(struct PointerRNA * ptr,int value)1168 static void rna_ParticleSystem_active_particle_target_index_set(struct PointerRNA *ptr, int value)
1169 {
1170 ParticleSystem *psys = (ParticleSystem *)ptr->data;
1171 ParticleTarget *pt = psys->targets.first;
1172 int i = 0;
1173
1174 for (; pt; pt = pt->next, i++) {
1175 if (i == value) {
1176 pt->flag |= PTARGET_CURRENT;
1177 }
1178 else {
1179 pt->flag &= ~PTARGET_CURRENT;
1180 }
1181 }
1182 }
1183
rna_ParticleTarget_name_get(PointerRNA * ptr,char * str)1184 static void rna_ParticleTarget_name_get(PointerRNA *ptr, char *str)
1185 {
1186 ParticleTarget *pt = ptr->data;
1187
1188 if (pt->flag & PTARGET_VALID) {
1189 ParticleSystem *psys = NULL;
1190
1191 if (pt->ob) {
1192 psys = BLI_findlink(&pt->ob->particlesystem, pt->psys - 1);
1193 }
1194 else {
1195 Object *ob = (Object *)ptr->owner_id;
1196 psys = BLI_findlink(&ob->particlesystem, pt->psys - 1);
1197 }
1198
1199 if (psys) {
1200 if (pt->ob) {
1201 sprintf(str, "%s: %s", pt->ob->id.name + 2, psys->name);
1202 }
1203 else {
1204 strcpy(str, psys->name);
1205 }
1206 }
1207 else {
1208 strcpy(str, "Invalid target!");
1209 }
1210 }
1211 else {
1212 strcpy(str, "Invalid target!");
1213 }
1214 }
1215
rna_ParticleTarget_name_length(PointerRNA * ptr)1216 static int rna_ParticleTarget_name_length(PointerRNA *ptr)
1217 {
1218 char tstr[MAX_ID_NAME + MAX_ID_NAME + 64];
1219
1220 rna_ParticleTarget_name_get(ptr, tstr);
1221
1222 return strlen(tstr);
1223 }
1224
particle_id_check(PointerRNA * ptr)1225 static int particle_id_check(PointerRNA *ptr)
1226 {
1227 ID *id = ptr->owner_id;
1228
1229 return (GS(id->name) == ID_PA);
1230 }
1231
rna_SPHFluidSettings_path(PointerRNA * ptr)1232 static char *rna_SPHFluidSettings_path(PointerRNA *ptr)
1233 {
1234 SPHFluidSettings *fluid = (SPHFluidSettings *)ptr->data;
1235
1236 if (particle_id_check(ptr)) {
1237 ParticleSettings *part = (ParticleSettings *)ptr->owner_id;
1238
1239 if (part->fluid == fluid) {
1240 return BLI_strdup("fluid");
1241 }
1242 }
1243 return NULL;
1244 }
1245
rna_ParticleSystem_multiple_caches_get(PointerRNA * ptr)1246 static bool rna_ParticleSystem_multiple_caches_get(PointerRNA *ptr)
1247 {
1248 ParticleSystem *psys = (ParticleSystem *)ptr->data;
1249
1250 return (psys->ptcaches.first != psys->ptcaches.last);
1251 }
rna_ParticleSystem_editable_get(PointerRNA * ptr)1252 static bool rna_ParticleSystem_editable_get(PointerRNA *ptr)
1253 {
1254 ParticleSystem *psys = (ParticleSystem *)ptr->data;
1255
1256 return psys_check_edited(psys);
1257 }
rna_ParticleSystem_edited_get(PointerRNA * ptr)1258 static bool rna_ParticleSystem_edited_get(PointerRNA *ptr)
1259 {
1260 ParticleSystem *psys = (ParticleSystem *)ptr->data;
1261
1262 if (psys->part && psys->part->type == PART_HAIR) {
1263 return (psys->flag & PSYS_EDITED || (psys->edit && psys->edit->edited));
1264 }
1265 else {
1266 return (psys->pointcache->edit && psys->pointcache->edit->edited);
1267 }
1268 }
rna_ParticleDupliWeight_active_get(PointerRNA * ptr)1269 static PointerRNA rna_ParticleDupliWeight_active_get(PointerRNA *ptr)
1270 {
1271 ParticleSettings *part = (ParticleSettings *)ptr->owner_id;
1272 ParticleDupliWeight *dw = part->instance_weights.first;
1273
1274 for (; dw; dw = dw->next) {
1275 if (dw->flag & PART_DUPLIW_CURRENT) {
1276 return rna_pointer_inherit_refine(ptr, &RNA_ParticleDupliWeight, dw);
1277 }
1278 }
1279 return rna_pointer_inherit_refine(ptr, &RNA_ParticleTarget, NULL);
1280 }
rna_ParticleDupliWeight_active_index_range(PointerRNA * ptr,int * min,int * max,int * UNUSED (softmin),int * UNUSED (softmax))1281 static void rna_ParticleDupliWeight_active_index_range(
1282 PointerRNA *ptr, int *min, int *max, int *UNUSED(softmin), int *UNUSED(softmax))
1283 {
1284 ParticleSettings *part = (ParticleSettings *)ptr->owner_id;
1285 *min = 0;
1286 *max = max_ii(0, BLI_listbase_count(&part->instance_weights) - 1);
1287 }
1288
rna_ParticleDupliWeight_active_index_get(PointerRNA * ptr)1289 static int rna_ParticleDupliWeight_active_index_get(PointerRNA *ptr)
1290 {
1291 ParticleSettings *part = (ParticleSettings *)ptr->owner_id;
1292 ParticleDupliWeight *dw = part->instance_weights.first;
1293 int i = 0;
1294
1295 for (; dw; dw = dw->next, i++) {
1296 if (dw->flag & PART_DUPLIW_CURRENT) {
1297 return i;
1298 }
1299 }
1300
1301 return 0;
1302 }
1303
rna_ParticleDupliWeight_active_index_set(struct PointerRNA * ptr,int value)1304 static void rna_ParticleDupliWeight_active_index_set(struct PointerRNA *ptr, int value)
1305 {
1306 ParticleSettings *part = (ParticleSettings *)ptr->owner_id;
1307 ParticleDupliWeight *dw = part->instance_weights.first;
1308 int i = 0;
1309
1310 for (; dw; dw = dw->next, i++) {
1311 if (i == value) {
1312 dw->flag |= PART_DUPLIW_CURRENT;
1313 }
1314 else {
1315 dw->flag &= ~PART_DUPLIW_CURRENT;
1316 }
1317 }
1318 }
1319
rna_ParticleDupliWeight_name_get(PointerRNA * ptr,char * str)1320 static void rna_ParticleDupliWeight_name_get(PointerRNA *ptr, char *str)
1321 {
1322 ParticleSettings *part = (ParticleSettings *)ptr->owner_id;
1323 psys_find_group_weights(part);
1324
1325 ParticleDupliWeight *dw = ptr->data;
1326
1327 if (dw->ob) {
1328 sprintf(str, "%s: %i", dw->ob->id.name + 2, dw->count);
1329 }
1330 else {
1331 strcpy(str, "No object");
1332 }
1333 }
1334
rna_ParticleDupliWeight_name_length(PointerRNA * ptr)1335 static int rna_ParticleDupliWeight_name_length(PointerRNA *ptr)
1336 {
1337 char tstr[MAX_ID_NAME + 64];
1338
1339 rna_ParticleDupliWeight_name_get(ptr, tstr);
1340
1341 return strlen(tstr);
1342 }
1343
rna_Particle_type_itemf(bContext * UNUSED (C),PointerRNA * ptr,PropertyRNA * UNUSED (prop),bool * UNUSED (r_free))1344 static const EnumPropertyItem *rna_Particle_type_itemf(bContext *UNUSED(C),
1345 PointerRNA *ptr,
1346 PropertyRNA *UNUSED(prop),
1347 bool *UNUSED(r_free))
1348 {
1349 ParticleSettings *part = (ParticleSettings *)ptr->owner_id;
1350
1351 if (part->type == PART_HAIR || part->type == PART_EMITTER) {
1352 return part_type_items;
1353 }
1354 else {
1355 return part_fluid_type_items;
1356 }
1357 }
1358
rna_Particle_from_itemf(bContext * UNUSED (C),PointerRNA * UNUSED (ptr),PropertyRNA * UNUSED (prop),bool * UNUSED (r_free))1359 static const EnumPropertyItem *rna_Particle_from_itemf(bContext *UNUSED(C),
1360 PointerRNA *UNUSED(ptr),
1361 PropertyRNA *UNUSED(prop),
1362 bool *UNUSED(r_free))
1363 {
1364 /*if (part->type==PART_REACTOR) */
1365 /* return part_reactor_from_items; */
1366 /*else */
1367 return part_from_items;
1368 }
1369
rna_Particle_dist_itemf(bContext * UNUSED (C),PointerRNA * ptr,PropertyRNA * UNUSED (prop),bool * UNUSED (r_free))1370 static const EnumPropertyItem *rna_Particle_dist_itemf(bContext *UNUSED(C),
1371 PointerRNA *ptr,
1372 PropertyRNA *UNUSED(prop),
1373 bool *UNUSED(r_free))
1374 {
1375 ParticleSettings *part = (ParticleSettings *)ptr->owner_id;
1376
1377 if (part->type == PART_HAIR) {
1378 return part_hair_dist_items;
1379 }
1380 else {
1381 return part_dist_items;
1382 }
1383 }
1384
rna_Particle_draw_as_itemf(bContext * UNUSED (C),PointerRNA * ptr,PropertyRNA * UNUSED (prop),bool * UNUSED (r_free))1385 static const EnumPropertyItem *rna_Particle_draw_as_itemf(bContext *UNUSED(C),
1386 PointerRNA *ptr,
1387 PropertyRNA *UNUSED(prop),
1388 bool *UNUSED(r_free))
1389 {
1390 ParticleSettings *part = (ParticleSettings *)ptr->owner_id;
1391
1392 if (part->type == PART_HAIR) {
1393 return part_hair_draw_as_items;
1394 }
1395 else {
1396 return part_draw_as_items;
1397 }
1398 }
1399
rna_Particle_ren_as_itemf(bContext * UNUSED (C),PointerRNA * ptr,PropertyRNA * UNUSED (prop),bool * UNUSED (r_free))1400 static const EnumPropertyItem *rna_Particle_ren_as_itemf(bContext *UNUSED(C),
1401 PointerRNA *ptr,
1402 PropertyRNA *UNUSED(prop),
1403 bool *UNUSED(r_free))
1404 {
1405 ParticleSettings *part = (ParticleSettings *)ptr->owner_id;
1406
1407 if (part->type == PART_HAIR) {
1408 return part_hair_ren_as_items;
1409 }
1410 else {
1411 return part_ren_as_items;
1412 }
1413 }
1414
rna_Particle_field1_get(PointerRNA * ptr)1415 static PointerRNA rna_Particle_field1_get(PointerRNA *ptr)
1416 {
1417 ParticleSettings *part = (ParticleSettings *)ptr->owner_id;
1418
1419 /* weak */
1420 if (!part->pd) {
1421 part->pd = BKE_partdeflect_new(0);
1422 }
1423
1424 return rna_pointer_inherit_refine(ptr, &RNA_FieldSettings, part->pd);
1425 }
1426
rna_Particle_field2_get(PointerRNA * ptr)1427 static PointerRNA rna_Particle_field2_get(PointerRNA *ptr)
1428 {
1429 ParticleSettings *part = (ParticleSettings *)ptr->owner_id;
1430
1431 /* weak */
1432 if (!part->pd2) {
1433 part->pd2 = BKE_partdeflect_new(0);
1434 }
1435
1436 return rna_pointer_inherit_refine(ptr, &RNA_FieldSettings, part->pd2);
1437 }
1438
psys_vg_name_get__internal(PointerRNA * ptr,char * value,int index)1439 static void psys_vg_name_get__internal(PointerRNA *ptr, char *value, int index)
1440 {
1441 Object *ob = (Object *)ptr->owner_id;
1442 ParticleSystem *psys = (ParticleSystem *)ptr->data;
1443
1444 if (psys->vgroup[index] > 0) {
1445 bDeformGroup *defGroup = BLI_findlink(&ob->defbase, psys->vgroup[index] - 1);
1446
1447 if (defGroup) {
1448 strcpy(value, defGroup->name);
1449 return;
1450 }
1451 }
1452
1453 value[0] = '\0';
1454 }
psys_vg_name_len__internal(PointerRNA * ptr,int index)1455 static int psys_vg_name_len__internal(PointerRNA *ptr, int index)
1456 {
1457 Object *ob = (Object *)ptr->owner_id;
1458 ParticleSystem *psys = (ParticleSystem *)ptr->data;
1459
1460 if (psys->vgroup[index] > 0) {
1461 bDeformGroup *defGroup = BLI_findlink(&ob->defbase, psys->vgroup[index] - 1);
1462
1463 if (defGroup) {
1464 return strlen(defGroup->name);
1465 }
1466 }
1467 return 0;
1468 }
psys_vg_name_set__internal(PointerRNA * ptr,const char * value,int index)1469 static void psys_vg_name_set__internal(PointerRNA *ptr, const char *value, int index)
1470 {
1471 Object *ob = (Object *)ptr->owner_id;
1472 ParticleSystem *psys = (ParticleSystem *)ptr->data;
1473
1474 if (value[0] == '\0') {
1475 psys->vgroup[index] = 0;
1476 }
1477 else {
1478 int defgrp_index = BKE_object_defgroup_name_index(ob, value);
1479
1480 if (defgrp_index == -1) {
1481 return;
1482 }
1483
1484 psys->vgroup[index] = defgrp_index + 1;
1485 }
1486 }
1487
rna_ParticleSystem_path(PointerRNA * ptr)1488 static char *rna_ParticleSystem_path(PointerRNA *ptr)
1489 {
1490 ParticleSystem *psys = (ParticleSystem *)ptr->data;
1491 char name_esc[sizeof(psys->name) * 2];
1492
1493 BLI_strescape(name_esc, psys->name, sizeof(name_esc));
1494 return BLI_sprintfN("particle_systems[\"%s\"]", name_esc);
1495 }
1496
rna_ParticleSettings_mtex_begin(CollectionPropertyIterator * iter,PointerRNA * ptr)1497 static void rna_ParticleSettings_mtex_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
1498 {
1499 ParticleSettings *part = (ParticleSettings *)ptr->data;
1500 rna_iterator_array_begin(iter, (void *)part->mtex, sizeof(MTex *), MAX_MTEX, 0, NULL);
1501 }
1502
rna_ParticleSettings_active_texture_get(PointerRNA * ptr)1503 static PointerRNA rna_ParticleSettings_active_texture_get(PointerRNA *ptr)
1504 {
1505 ParticleSettings *part = (ParticleSettings *)ptr->data;
1506 Tex *tex;
1507
1508 tex = give_current_particle_texture(part);
1509 return rna_pointer_inherit_refine(ptr, &RNA_Texture, tex);
1510 }
1511
rna_ParticleSettings_active_texture_set(PointerRNA * ptr,PointerRNA value,struct ReportList * UNUSED (reports))1512 static void rna_ParticleSettings_active_texture_set(PointerRNA *ptr,
1513 PointerRNA value,
1514 struct ReportList *UNUSED(reports))
1515 {
1516 ParticleSettings *part = (ParticleSettings *)ptr->data;
1517
1518 set_current_particle_texture(part, value.data);
1519 }
1520
1521 /* irritating string functions for each index :/ */
rna_ParticleVGroup_name_get_0(PointerRNA * ptr,char * value)1522 static void rna_ParticleVGroup_name_get_0(PointerRNA *ptr, char *value)
1523 {
1524 psys_vg_name_get__internal(ptr, value, 0);
1525 }
rna_ParticleVGroup_name_get_1(PointerRNA * ptr,char * value)1526 static void rna_ParticleVGroup_name_get_1(PointerRNA *ptr, char *value)
1527 {
1528 psys_vg_name_get__internal(ptr, value, 1);
1529 }
rna_ParticleVGroup_name_get_2(PointerRNA * ptr,char * value)1530 static void rna_ParticleVGroup_name_get_2(PointerRNA *ptr, char *value)
1531 {
1532 psys_vg_name_get__internal(ptr, value, 2);
1533 }
rna_ParticleVGroup_name_get_3(PointerRNA * ptr,char * value)1534 static void rna_ParticleVGroup_name_get_3(PointerRNA *ptr, char *value)
1535 {
1536 psys_vg_name_get__internal(ptr, value, 3);
1537 }
rna_ParticleVGroup_name_get_4(PointerRNA * ptr,char * value)1538 static void rna_ParticleVGroup_name_get_4(PointerRNA *ptr, char *value)
1539 {
1540 psys_vg_name_get__internal(ptr, value, 4);
1541 }
rna_ParticleVGroup_name_get_5(PointerRNA * ptr,char * value)1542 static void rna_ParticleVGroup_name_get_5(PointerRNA *ptr, char *value)
1543 {
1544 psys_vg_name_get__internal(ptr, value, 5);
1545 }
rna_ParticleVGroup_name_get_6(PointerRNA * ptr,char * value)1546 static void rna_ParticleVGroup_name_get_6(PointerRNA *ptr, char *value)
1547 {
1548 psys_vg_name_get__internal(ptr, value, 6);
1549 }
rna_ParticleVGroup_name_get_7(PointerRNA * ptr,char * value)1550 static void rna_ParticleVGroup_name_get_7(PointerRNA *ptr, char *value)
1551 {
1552 psys_vg_name_get__internal(ptr, value, 7);
1553 }
rna_ParticleVGroup_name_get_8(PointerRNA * ptr,char * value)1554 static void rna_ParticleVGroup_name_get_8(PointerRNA *ptr, char *value)
1555 {
1556 psys_vg_name_get__internal(ptr, value, 8);
1557 }
rna_ParticleVGroup_name_get_9(PointerRNA * ptr,char * value)1558 static void rna_ParticleVGroup_name_get_9(PointerRNA *ptr, char *value)
1559 {
1560 psys_vg_name_get__internal(ptr, value, 9);
1561 }
rna_ParticleVGroup_name_get_10(PointerRNA * ptr,char * value)1562 static void rna_ParticleVGroup_name_get_10(PointerRNA *ptr, char *value)
1563 {
1564 psys_vg_name_get__internal(ptr, value, 10);
1565 }
rna_ParticleVGroup_name_get_11(PointerRNA * ptr,char * value)1566 static void rna_ParticleVGroup_name_get_11(PointerRNA *ptr, char *value)
1567 {
1568 psys_vg_name_get__internal(ptr, value, 11);
1569 }
rna_ParticleVGroup_name_get_12(PointerRNA * ptr,char * value)1570 static void rna_ParticleVGroup_name_get_12(PointerRNA *ptr, char *value)
1571 {
1572 psys_vg_name_get__internal(ptr, value, 12);
1573 }
1574
rna_ParticleVGroup_name_len_0(PointerRNA * ptr)1575 static int rna_ParticleVGroup_name_len_0(PointerRNA *ptr)
1576 {
1577 return psys_vg_name_len__internal(ptr, 0);
1578 }
rna_ParticleVGroup_name_len_1(PointerRNA * ptr)1579 static int rna_ParticleVGroup_name_len_1(PointerRNA *ptr)
1580 {
1581 return psys_vg_name_len__internal(ptr, 1);
1582 }
rna_ParticleVGroup_name_len_2(PointerRNA * ptr)1583 static int rna_ParticleVGroup_name_len_2(PointerRNA *ptr)
1584 {
1585 return psys_vg_name_len__internal(ptr, 2);
1586 }
rna_ParticleVGroup_name_len_3(PointerRNA * ptr)1587 static int rna_ParticleVGroup_name_len_3(PointerRNA *ptr)
1588 {
1589 return psys_vg_name_len__internal(ptr, 3);
1590 }
rna_ParticleVGroup_name_len_4(PointerRNA * ptr)1591 static int rna_ParticleVGroup_name_len_4(PointerRNA *ptr)
1592 {
1593 return psys_vg_name_len__internal(ptr, 4);
1594 }
rna_ParticleVGroup_name_len_5(PointerRNA * ptr)1595 static int rna_ParticleVGroup_name_len_5(PointerRNA *ptr)
1596 {
1597 return psys_vg_name_len__internal(ptr, 5);
1598 }
rna_ParticleVGroup_name_len_6(PointerRNA * ptr)1599 static int rna_ParticleVGroup_name_len_6(PointerRNA *ptr)
1600 {
1601 return psys_vg_name_len__internal(ptr, 6);
1602 }
rna_ParticleVGroup_name_len_7(PointerRNA * ptr)1603 static int rna_ParticleVGroup_name_len_7(PointerRNA *ptr)
1604 {
1605 return psys_vg_name_len__internal(ptr, 7);
1606 }
rna_ParticleVGroup_name_len_8(PointerRNA * ptr)1607 static int rna_ParticleVGroup_name_len_8(PointerRNA *ptr)
1608 {
1609 return psys_vg_name_len__internal(ptr, 8);
1610 }
rna_ParticleVGroup_name_len_9(PointerRNA * ptr)1611 static int rna_ParticleVGroup_name_len_9(PointerRNA *ptr)
1612 {
1613 return psys_vg_name_len__internal(ptr, 9);
1614 }
rna_ParticleVGroup_name_len_10(PointerRNA * ptr)1615 static int rna_ParticleVGroup_name_len_10(PointerRNA *ptr)
1616 {
1617 return psys_vg_name_len__internal(ptr, 10);
1618 }
rna_ParticleVGroup_name_len_11(PointerRNA * ptr)1619 static int rna_ParticleVGroup_name_len_11(PointerRNA *ptr)
1620 {
1621 return psys_vg_name_len__internal(ptr, 11);
1622 }
rna_ParticleVGroup_name_len_12(PointerRNA * ptr)1623 static int rna_ParticleVGroup_name_len_12(PointerRNA *ptr)
1624 {
1625 return psys_vg_name_len__internal(ptr, 12);
1626 }
1627
rna_ParticleVGroup_name_set_0(PointerRNA * ptr,const char * value)1628 static void rna_ParticleVGroup_name_set_0(PointerRNA *ptr, const char *value)
1629 {
1630 psys_vg_name_set__internal(ptr, value, 0);
1631 }
rna_ParticleVGroup_name_set_1(PointerRNA * ptr,const char * value)1632 static void rna_ParticleVGroup_name_set_1(PointerRNA *ptr, const char *value)
1633 {
1634 psys_vg_name_set__internal(ptr, value, 1);
1635 }
rna_ParticleVGroup_name_set_2(PointerRNA * ptr,const char * value)1636 static void rna_ParticleVGroup_name_set_2(PointerRNA *ptr, const char *value)
1637 {
1638 psys_vg_name_set__internal(ptr, value, 2);
1639 }
rna_ParticleVGroup_name_set_3(PointerRNA * ptr,const char * value)1640 static void rna_ParticleVGroup_name_set_3(PointerRNA *ptr, const char *value)
1641 {
1642 psys_vg_name_set__internal(ptr, value, 3);
1643 }
rna_ParticleVGroup_name_set_4(PointerRNA * ptr,const char * value)1644 static void rna_ParticleVGroup_name_set_4(PointerRNA *ptr, const char *value)
1645 {
1646 psys_vg_name_set__internal(ptr, value, 4);
1647 }
rna_ParticleVGroup_name_set_5(PointerRNA * ptr,const char * value)1648 static void rna_ParticleVGroup_name_set_5(PointerRNA *ptr, const char *value)
1649 {
1650 psys_vg_name_set__internal(ptr, value, 5);
1651 }
rna_ParticleVGroup_name_set_6(PointerRNA * ptr,const char * value)1652 static void rna_ParticleVGroup_name_set_6(PointerRNA *ptr, const char *value)
1653 {
1654 psys_vg_name_set__internal(ptr, value, 6);
1655 }
rna_ParticleVGroup_name_set_7(PointerRNA * ptr,const char * value)1656 static void rna_ParticleVGroup_name_set_7(PointerRNA *ptr, const char *value)
1657 {
1658 psys_vg_name_set__internal(ptr, value, 7);
1659 }
rna_ParticleVGroup_name_set_8(PointerRNA * ptr,const char * value)1660 static void rna_ParticleVGroup_name_set_8(PointerRNA *ptr, const char *value)
1661 {
1662 psys_vg_name_set__internal(ptr, value, 8);
1663 }
rna_ParticleVGroup_name_set_9(PointerRNA * ptr,const char * value)1664 static void rna_ParticleVGroup_name_set_9(PointerRNA *ptr, const char *value)
1665 {
1666 psys_vg_name_set__internal(ptr, value, 9);
1667 }
rna_ParticleVGroup_name_set_10(PointerRNA * ptr,const char * value)1668 static void rna_ParticleVGroup_name_set_10(PointerRNA *ptr, const char *value)
1669 {
1670 psys_vg_name_set__internal(ptr, value, 10);
1671 }
rna_ParticleVGroup_name_set_11(PointerRNA * ptr,const char * value)1672 static void rna_ParticleVGroup_name_set_11(PointerRNA *ptr, const char *value)
1673 {
1674 psys_vg_name_set__internal(ptr, value, 11);
1675 }
rna_ParticleVGroup_name_set_12(PointerRNA * ptr,const char * value)1676 static void rna_ParticleVGroup_name_set_12(PointerRNA *ptr, const char *value)
1677 {
1678 psys_vg_name_set__internal(ptr, value, 12);
1679 }
1680
1681 #else
1682
rna_def_particle_hair_key(BlenderRNA * brna)1683 static void rna_def_particle_hair_key(BlenderRNA *brna)
1684 {
1685 StructRNA *srna;
1686 PropertyRNA *prop;
1687
1688 FunctionRNA *func;
1689 PropertyRNA *parm;
1690
1691 srna = RNA_def_struct(brna, "ParticleHairKey", NULL);
1692 RNA_def_struct_sdna(srna, "HairKey");
1693 RNA_def_struct_ui_text(srna, "Particle Hair Key", "Particle key for hair particle system");
1694
1695 prop = RNA_def_property(srna, "time", PROP_FLOAT, PROP_UNSIGNED);
1696 RNA_def_property_ui_text(prop, "Time", "Relative time of key over hair length");
1697
1698 prop = RNA_def_property(srna, "weight", PROP_FLOAT, PROP_UNSIGNED);
1699 RNA_def_property_range(prop, 0.0, 1.0);
1700 RNA_def_property_ui_text(prop, "Weight", "Weight for cloth simulation");
1701
1702 prop = RNA_def_property(srna, "co", PROP_FLOAT, PROP_TRANSLATION);
1703 RNA_def_property_array(prop, 3);
1704 RNA_def_property_ui_text(
1705 prop, "Location (Object Space)", "Location of the hair key in object space");
1706 RNA_def_property_float_funcs(prop,
1707 "rna_ParticleHairKey_location_object_get",
1708 "rna_ParticleHairKey_location_object_set",
1709 NULL);
1710
1711 prop = RNA_def_property(srna, "co_local", PROP_FLOAT, PROP_TRANSLATION);
1712 RNA_def_property_float_sdna(prop, NULL, "co");
1713 RNA_def_property_ui_text(prop,
1714 "Location",
1715 "Location of the hair key in its local coordinate system, "
1716 "relative to the emitting face");
1717
1718 /* Aided co func */
1719 func = RNA_def_function(srna, "co_object", "rna_ParticleHairKey_co_object");
1720 RNA_def_function_ui_description(func, "Obtain hairkey location with particle and modifier data");
1721 parm = RNA_def_pointer(func, "object", "Object", "", "Object");
1722 RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
1723 parm = RNA_def_pointer(func, "modifier", "ParticleSystemModifier", "", "Particle modifier");
1724 RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
1725 parm = RNA_def_pointer(func, "particle", "Particle", "", "hair particle");
1726 RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
1727 parm = RNA_def_float_vector(
1728 func, "co", 3, NULL, -FLT_MAX, FLT_MAX, "Co", "Exported hairkey location", -1e4, 1e4);
1729 RNA_def_parameter_flags(parm, PROP_THICK_WRAP, 0);
1730 RNA_def_function_output(func, parm);
1731
1732 func = RNA_def_function(srna, "co_object_set", "rna_ParticleHairKey_co_object_set");
1733 RNA_def_function_flag(func, FUNC_USE_SELF_ID);
1734 RNA_def_function_ui_description(func, "Set hairkey location with particle and modifier data");
1735 parm = RNA_def_pointer(func, "object", "Object", "", "Object");
1736 RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
1737 parm = RNA_def_pointer(func, "modifier", "ParticleSystemModifier", "", "Particle modifier");
1738 RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
1739 parm = RNA_def_pointer(func, "particle", "Particle", "", "hair particle");
1740 RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
1741 parm = RNA_def_float_vector(
1742 func, "co", 3, NULL, -FLT_MAX, FLT_MAX, "Co", "Specified hairkey location", -1e4, 1e4);
1743 RNA_def_parameter_flags(parm, PROP_THICK_WRAP, PARM_REQUIRED);
1744 }
1745
rna_def_particle_key(BlenderRNA * brna)1746 static void rna_def_particle_key(BlenderRNA *brna)
1747 {
1748 StructRNA *srna;
1749 PropertyRNA *prop;
1750
1751 srna = RNA_def_struct(brna, "ParticleKey", NULL);
1752 RNA_def_struct_ui_text(srna, "Particle Key", "Key location for a particle over time");
1753
1754 prop = RNA_def_property(srna, "location", PROP_FLOAT, PROP_TRANSLATION);
1755 RNA_def_property_float_sdna(prop, NULL, "co");
1756 RNA_def_property_ui_text(prop, "Location", "Key location");
1757
1758 prop = RNA_def_property(srna, "velocity", PROP_FLOAT, PROP_VELOCITY);
1759 RNA_def_property_float_sdna(prop, NULL, "vel");
1760 RNA_def_property_ui_text(prop, "Velocity", "Key velocity");
1761
1762 prop = RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_QUATERNION);
1763 RNA_def_property_float_sdna(prop, NULL, "rot");
1764 RNA_def_property_ui_text(prop, "Rotation", "Key rotation quaternion");
1765
1766 prop = RNA_def_property(srna, "angular_velocity", PROP_FLOAT, PROP_VELOCITY);
1767 RNA_def_property_float_sdna(prop, NULL, "ave");
1768 RNA_def_property_ui_text(prop, "Angular Velocity", "Key angular velocity");
1769
1770 prop = RNA_def_property(srna, "time", PROP_FLOAT, PROP_UNSIGNED);
1771 RNA_def_property_ui_text(prop, "Time", "Time of key over the simulation");
1772 }
1773
rna_def_child_particle(BlenderRNA * brna)1774 static void rna_def_child_particle(BlenderRNA *brna)
1775 {
1776 StructRNA *srna;
1777 /*PropertyRNA *prop; */
1778
1779 srna = RNA_def_struct(brna, "ChildParticle", NULL);
1780 RNA_def_struct_ui_text(
1781 srna, "Child Particle", "Child particle interpolated from simulated or edited particles");
1782
1783 /* int num, parent; */ /* num is face index on the final derived mesh */
1784
1785 /* int pa[4]; */ /* nearest particles to the child, used for the interpolation */
1786 /* float w[4]; */ /* interpolation weights for the above particles */
1787 /* float fuv[4], foffset; */ /* face vertex weights and offset */
1788 /* float rand[3]; */
1789 }
1790
rna_def_particle(BlenderRNA * brna)1791 static void rna_def_particle(BlenderRNA *brna)
1792 {
1793 StructRNA *srna;
1794 PropertyRNA *prop;
1795
1796 FunctionRNA *func;
1797 PropertyRNA *parm;
1798
1799 static const EnumPropertyItem alive_items[] = {
1800 /*{PARS_KILLED, "KILLED", 0, "Killed", ""}, */
1801 {PARS_DEAD, "DEAD", 0, "Dead", ""},
1802 {PARS_UNBORN, "UNBORN", 0, "Unborn", ""},
1803 {PARS_ALIVE, "ALIVE", 0, "Alive", ""},
1804 {PARS_DYING, "DYING", 0, "Dying", ""},
1805 {0, NULL, 0, NULL, NULL},
1806 };
1807
1808 srna = RNA_def_struct(brna, "Particle", NULL);
1809 RNA_def_struct_sdna(srna, "ParticleData");
1810 RNA_def_struct_ui_text(srna, "Particle", "Particle in a particle system");
1811
1812 /* Particle State & Previous State */
1813 prop = RNA_def_property(srna, "location", PROP_FLOAT, PROP_TRANSLATION);
1814 RNA_def_property_float_sdna(prop, NULL, "state.co");
1815 RNA_def_property_ui_text(prop, "Particle Location", "");
1816
1817 prop = RNA_def_property(srna, "velocity", PROP_FLOAT, PROP_VELOCITY);
1818 RNA_def_property_float_sdna(prop, NULL, "state.vel");
1819 RNA_def_property_ui_text(prop, "Particle Velocity", "");
1820
1821 prop = RNA_def_property(srna, "angular_velocity", PROP_FLOAT, PROP_VELOCITY);
1822 RNA_def_property_float_sdna(prop, NULL, "state.ave");
1823 RNA_def_property_ui_text(prop, "Angular Velocity", "");
1824
1825 prop = RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_QUATERNION);
1826 RNA_def_property_float_sdna(prop, NULL, "state.rot");
1827 RNA_def_property_ui_text(prop, "Rotation", "");
1828
1829 prop = RNA_def_property(srna, "prev_location", PROP_FLOAT, PROP_TRANSLATION);
1830 RNA_def_property_float_sdna(prop, NULL, "prev_state.co");
1831 RNA_def_property_ui_text(prop, "Previous Particle Location", "");
1832
1833 prop = RNA_def_property(srna, "prev_velocity", PROP_FLOAT, PROP_VELOCITY);
1834 RNA_def_property_float_sdna(prop, NULL, "prev_state.vel");
1835 RNA_def_property_ui_text(prop, "Previous Particle Velocity", "");
1836
1837 prop = RNA_def_property(srna, "prev_angular_velocity", PROP_FLOAT, PROP_VELOCITY);
1838 RNA_def_property_float_sdna(prop, NULL, "prev_state.ave");
1839 RNA_def_property_ui_text(prop, "Previous Angular Velocity", "");
1840
1841 prop = RNA_def_property(srna, "prev_rotation", PROP_FLOAT, PROP_QUATERNION);
1842 RNA_def_property_float_sdna(prop, NULL, "prev_state.rot");
1843 RNA_def_property_ui_text(prop, "Previous Rotation", "");
1844
1845 /* Hair & Keyed Keys */
1846
1847 prop = RNA_def_property(srna, "hair_keys", PROP_COLLECTION, PROP_NONE);
1848 RNA_def_property_collection_sdna(prop, NULL, "hair", "totkey");
1849 RNA_def_property_struct_type(prop, "ParticleHairKey");
1850 RNA_def_property_ui_text(prop, "Hair", "");
1851
1852 prop = RNA_def_property(srna, "particle_keys", PROP_COLLECTION, PROP_NONE);
1853 RNA_def_property_collection_sdna(prop, NULL, "keys", "totkey");
1854 RNA_def_property_struct_type(prop, "ParticleKey");
1855 RNA_def_property_ui_text(prop, "Keyed States", "");
1856 /* */
1857 /* float fuv[4], foffset; */ /* coordinates on face/edge number "num" and depth along*/
1858 /* */ /* face normal for volume emission */
1859
1860 prop = RNA_def_property(srna, "birth_time", PROP_FLOAT, PROP_TIME);
1861 RNA_def_property_float_sdna(prop, NULL, "time");
1862 /* RNA_def_property_range(prop, lowerLimitf, upperLimitf); */
1863 RNA_def_property_ui_text(prop, "Birth Time", "");
1864
1865 prop = RNA_def_property(srna, "lifetime", PROP_FLOAT, PROP_TIME);
1866 /* RNA_def_property_range(prop, lowerLimitf, upperLimitf); */
1867 RNA_def_property_ui_text(prop, "Lifetime", "");
1868
1869 prop = RNA_def_property(srna, "die_time", PROP_FLOAT, PROP_TIME);
1870 RNA_def_property_float_sdna(prop, NULL, "dietime");
1871 /* RNA_def_property_range(prop, lowerLimitf, upperLimitf); */
1872 RNA_def_property_ui_text(prop, "Die Time", "");
1873
1874 prop = RNA_def_property(srna, "size", PROP_FLOAT, PROP_NONE);
1875 /* RNA_def_property_range(prop, lowerLimitf, upperLimitf); */
1876 RNA_def_property_ui_text(prop, "Size", "");
1877
1878 /* */
1879 /* int num; */ /* index to vert/edge/face */
1880 /* int num_dmcache; */ /* index to derived mesh data (face) to avoid slow lookups */
1881 /* int pad; */
1882 /* */
1883 /* int totkey; */
1884
1885 /* flag */
1886 prop = RNA_def_property(srna, "is_exist", PROP_BOOLEAN, PROP_NONE);
1887 RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", PARS_UNEXIST);
1888 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1889 RNA_def_property_ui_text(prop, "Exists", "");
1890
1891 prop = RNA_def_property(srna, "is_visible", PROP_BOOLEAN, PROP_NONE);
1892 RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", PARS_NO_DISP);
1893 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1894 RNA_def_property_ui_text(prop, "Visible", "");
1895
1896 prop = RNA_def_property(srna, "alive_state", PROP_ENUM, PROP_NONE);
1897 RNA_def_property_enum_sdna(prop, NULL, "alive");
1898 RNA_def_property_enum_items(prop, alive_items);
1899 RNA_def_property_ui_text(prop, "Alive State", "");
1900
1901 /* short rt2; */
1902
1903 /* UVs */
1904 func = RNA_def_function(srna, "uv_on_emitter", "rna_Particle_uv_on_emitter");
1905 RNA_def_function_ui_description(func,
1906 "Obtain UV coordinates for a particle on an evaluated mesh.");
1907 RNA_def_function_flag(func, FUNC_USE_REPORTS);
1908 parm = RNA_def_pointer(func,
1909 "modifier",
1910 "ParticleSystemModifier",
1911 "",
1912 "Particle modifier from an evaluated object");
1913 RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
1914 parm = RNA_def_property(func, "uv", PROP_FLOAT, PROP_COORDS);
1915 RNA_def_property_array(parm, 2);
1916 RNA_def_parameter_flags(parm, PROP_THICK_WRAP, 0);
1917 RNA_def_function_output(func, parm);
1918 }
1919
rna_def_particle_dupliweight(BlenderRNA * brna)1920 static void rna_def_particle_dupliweight(BlenderRNA *brna)
1921 {
1922 StructRNA *srna;
1923 PropertyRNA *prop;
1924
1925 srna = RNA_def_struct(brna, "ParticleDupliWeight", NULL);
1926 RNA_def_struct_ui_text(
1927 srna, "Particle Dupliobject Weight", "Weight of a particle dupliobject in a collection");
1928 RNA_def_struct_sdna(srna, "ParticleDupliWeight");
1929
1930 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1931 RNA_def_property_string_funcs(
1932 prop, "rna_ParticleDupliWeight_name_get", "rna_ParticleDupliWeight_name_length", NULL);
1933 RNA_def_property_ui_text(prop, "Name", "Particle dupliobject name");
1934 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1935 RNA_def_struct_name_property(srna, prop);
1936
1937 prop = RNA_def_property(srna, "count", PROP_INT, PROP_UNSIGNED);
1938 RNA_def_property_range(prop, 0, SHRT_MAX);
1939 RNA_def_property_ui_text(
1940 prop, "Count", "The number of times this object is repeated with respect to other objects");
1941 RNA_def_property_update(prop, 0, "rna_Particle_redo");
1942 }
1943
rna_def_fluid_settings(BlenderRNA * brna)1944 static void rna_def_fluid_settings(BlenderRNA *brna)
1945 {
1946 StructRNA *srna;
1947 PropertyRNA *prop;
1948
1949 static const EnumPropertyItem sph_solver_items[] = {
1950 {SPH_SOLVER_DDR,
1951 "DDR",
1952 0,
1953 "Double-Density",
1954 "An artistic solver with strong surface tension effects (original)"},
1955 {SPH_SOLVER_CLASSICAL, "CLASSICAL", 0, "Classical", "A more physically-accurate solver"},
1956 {0, NULL, 0, NULL, NULL},
1957 };
1958
1959 srna = RNA_def_struct(brna, "SPHFluidSettings", NULL);
1960 RNA_def_struct_path_func(srna, "rna_SPHFluidSettings_path");
1961 RNA_def_struct_ui_text(srna, "SPH Fluid Settings", "Settings for particle fluids physics");
1962
1963 /* Fluid settings */
1964 prop = RNA_def_property(srna, "solver", PROP_ENUM, PROP_NONE);
1965 RNA_def_property_enum_sdna(prop, NULL, "solver");
1966 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
1967 RNA_def_property_enum_items(prop, sph_solver_items);
1968 RNA_def_property_ui_text(
1969 prop, "SPH Solver", "The code used to calculate internal forces on particles");
1970 RNA_def_property_update(prop, 0, "rna_Particle_reset");
1971
1972 prop = RNA_def_property(srna, "spring_force", PROP_FLOAT, PROP_NONE);
1973 RNA_def_property_float_sdna(prop, NULL, "spring_k");
1974 RNA_def_property_range(prop, 0.0f, 100.0f);
1975 RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1, 3);
1976 RNA_def_property_ui_text(prop, "Spring Force", "Spring force");
1977 RNA_def_property_update(prop, 0, "rna_Particle_reset");
1978
1979 prop = RNA_def_property(srna, "fluid_radius", PROP_FLOAT, PROP_NONE);
1980 RNA_def_property_float_sdna(prop, NULL, "radius");
1981 RNA_def_property_range(prop, 0.0f, 20.0f);
1982 RNA_def_property_ui_range(prop, 0.0f, 2.0f, 1, 3);
1983 RNA_def_property_ui_text(prop, "Interaction Radius", "Fluid interaction radius");
1984 RNA_def_property_update(prop, 0, "rna_Particle_reset");
1985
1986 prop = RNA_def_property(srna, "rest_length", PROP_FLOAT, PROP_NONE);
1987 RNA_def_property_range(prop, 0.0f, 2.0f);
1988 RNA_def_property_ui_text(prop, "Rest Length", "Spring rest length (factor of particle radius)");
1989 RNA_def_property_update(prop, 0, "rna_Particle_reset");
1990
1991 prop = RNA_def_property(srna, "use_viscoelastic_springs", PROP_BOOLEAN, PROP_NONE);
1992 RNA_def_property_boolean_sdna(prop, NULL, "flag", SPH_VISCOELASTIC_SPRINGS);
1993 RNA_def_property_ui_text(
1994 prop, "Viscoelastic Springs", "Use viscoelastic springs instead of Hooke's springs");
1995 RNA_def_property_update(prop, 0, "rna_Particle_reset");
1996
1997 prop = RNA_def_property(srna, "use_initial_rest_length", PROP_BOOLEAN, PROP_NONE);
1998 RNA_def_property_boolean_sdna(prop, NULL, "flag", SPH_CURRENT_REST_LENGTH);
1999 RNA_def_property_ui_text(
2000 prop,
2001 "Initial Rest Length",
2002 "Use the initial length as spring rest length instead of 2 * particle size");
2003 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2004
2005 prop = RNA_def_property(srna, "plasticity", PROP_FLOAT, PROP_NONE);
2006 RNA_def_property_float_sdna(prop, NULL, "plasticity_constant");
2007 RNA_def_property_range(prop, 0.0f, 100.0f);
2008 RNA_def_property_ui_text(
2009 prop,
2010 "Plasticity",
2011 "How much the spring rest length can change after the elastic limit is crossed");
2012 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2013
2014 prop = RNA_def_property(srna, "yield_ratio", PROP_FLOAT, PROP_FACTOR);
2015 RNA_def_property_float_sdna(prop, NULL, "yield_ratio");
2016 RNA_def_property_range(prop, 0.0f, 1.0f);
2017 RNA_def_property_ui_text(
2018 prop,
2019 "Elastic Limit",
2020 "How much the spring has to be stretched/compressed in order to change its rest length");
2021 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2022
2023 prop = RNA_def_property(srna, "spring_frames", PROP_INT, PROP_NONE);
2024 RNA_def_property_range(prop, 0.0f, 100.0f);
2025 RNA_def_property_ui_text(
2026 prop,
2027 "Spring Frames",
2028 "Create springs for this number of frames since particles birth (0 is always)");
2029 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2030
2031 /* Viscosity */
2032 prop = RNA_def_property(srna, "linear_viscosity", PROP_FLOAT, PROP_NONE);
2033 RNA_def_property_float_sdna(prop, NULL, "viscosity_omega");
2034 RNA_def_property_range(prop, 0.0f, 100.0f);
2035 RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1, 3);
2036 RNA_def_property_ui_text(prop, "Viscosity", "Linear viscosity");
2037 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2038
2039 prop = RNA_def_property(srna, "stiff_viscosity", PROP_FLOAT, PROP_NONE);
2040 RNA_def_property_float_sdna(prop, NULL, "viscosity_beta");
2041 RNA_def_property_range(prop, 0.0f, 100.0f);
2042 RNA_def_property_ui_range(prop, 0.0f, 2.0f, 1, 3);
2043 RNA_def_property_ui_text(prop, "Stiff Viscosity", "Creates viscosity for expanding fluid");
2044 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2045
2046 /* Double density relaxation */
2047 prop = RNA_def_property(srna, "stiffness", PROP_FLOAT, PROP_NONE);
2048 RNA_def_property_float_sdna(prop, NULL, "stiffness_k");
2049 RNA_def_property_range(prop, 0.0f, 1000.0f);
2050 RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1, 3);
2051 RNA_def_property_ui_text(prop, "Stiffness", "How incompressible the fluid is (speed of sound)");
2052 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2053
2054 prop = RNA_def_property(srna, "repulsion", PROP_FLOAT, PROP_NONE);
2055 RNA_def_property_float_sdna(prop, NULL, "stiffness_knear");
2056 RNA_def_property_range(prop, 0.0f, 100.0f);
2057 RNA_def_property_ui_range(prop, 0.0f, 2.0f, 1, 3);
2058 RNA_def_property_ui_text(
2059 prop,
2060 "Repulsion Factor",
2061 "How strongly the fluid tries to keep from clustering (factor of stiffness)");
2062 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2063
2064 prop = RNA_def_property(srna, "rest_density", PROP_FLOAT, PROP_NONE);
2065 RNA_def_property_float_sdna(prop, NULL, "rest_density");
2066 RNA_def_property_range(prop, 0.0f, 10000.0f);
2067 RNA_def_property_ui_range(prop, 0.0f, 2.0f, 1, 3);
2068 RNA_def_property_ui_text(prop, "Rest Density", "Fluid rest density");
2069 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2070
2071 /* Buoyancy */
2072 prop = RNA_def_property(srna, "buoyancy", PROP_FLOAT, PROP_NONE);
2073 RNA_def_property_float_sdna(prop, NULL, "buoyancy");
2074 RNA_def_property_range(prop, 0.0f, 10.0f);
2075 RNA_def_property_ui_range(prop, 0.0f, 1.0f, 1, 3);
2076 RNA_def_property_ui_text(
2077 prop,
2078 "Buoyancy",
2079 "Artificial buoyancy force in negative gravity direction based on pressure "
2080 "differences inside the fluid");
2081 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2082
2083 /* Factor flags */
2084
2085 prop = RNA_def_property(srna, "use_factor_repulsion", PROP_BOOLEAN, PROP_NONE);
2086 RNA_def_property_boolean_sdna(prop, NULL, "flag", SPH_FAC_REPULSION);
2087 RNA_def_property_ui_text(prop, "Factor Repulsion", "Repulsion is a factor of stiffness");
2088 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2089
2090 prop = RNA_def_property(srna, "use_factor_density", PROP_BOOLEAN, PROP_NONE);
2091 RNA_def_property_boolean_sdna(prop, NULL, "flag", SPH_FAC_DENSITY);
2092 RNA_def_property_ui_text(
2093 prop,
2094 "Factor Density",
2095 "Density is calculated as a factor of default density (depends on particle size)");
2096 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2097
2098 prop = RNA_def_property(srna, "use_factor_radius", PROP_BOOLEAN, PROP_NONE);
2099 RNA_def_property_boolean_sdna(prop, NULL, "flag", SPH_FAC_RADIUS);
2100 RNA_def_property_ui_text(
2101 prop, "Factor Radius", "Interaction radius is a factor of 4 * particle size");
2102 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2103
2104 prop = RNA_def_property(srna, "use_factor_stiff_viscosity", PROP_BOOLEAN, PROP_NONE);
2105 RNA_def_property_boolean_sdna(prop, NULL, "flag", SPH_FAC_VISCOSITY);
2106 RNA_def_property_ui_text(
2107 prop, "Factor Stiff Viscosity", "Stiff viscosity is a factor of normal viscosity");
2108 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2109
2110 prop = RNA_def_property(srna, "use_factor_rest_length", PROP_BOOLEAN, PROP_NONE);
2111 RNA_def_property_boolean_sdna(prop, NULL, "flag", SPH_FAC_REST_LENGTH);
2112 RNA_def_property_ui_text(
2113 prop, "Factor Rest Length", "Spring rest length is a factor of 2 * particle size");
2114 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2115 }
2116
rna_def_particle_settings_mtex(BlenderRNA * brna)2117 static void rna_def_particle_settings_mtex(BlenderRNA *brna)
2118 {
2119 StructRNA *srna;
2120 PropertyRNA *prop;
2121
2122 static const EnumPropertyItem texco_items[] = {
2123 {TEXCO_GLOB, "GLOBAL", 0, "Global", "Use global coordinates for the texture coordinates"},
2124 {TEXCO_OBJECT,
2125 "OBJECT",
2126 0,
2127 "Object",
2128 "Use linked object's coordinates for texture coordinates"},
2129 {TEXCO_UV, "UV", 0, "UV", "Use UV coordinates for texture coordinates"},
2130 {TEXCO_ORCO,
2131 "ORCO",
2132 0,
2133 "Generated",
2134 "Use the original undeformed coordinates of the object"},
2135 {TEXCO_STRAND,
2136 "STRAND",
2137 0,
2138 "Strand / Particle",
2139 "Use normalized strand texture coordinate (1D) or particle age (X) and trail position (Y)"},
2140 {0, NULL, 0, NULL, NULL},
2141 };
2142
2143 static const EnumPropertyItem prop_mapping_items[] = {
2144 {MTEX_FLAT, "FLAT", 0, "Flat", "Map X and Y coordinates directly"},
2145 {MTEX_CUBE, "CUBE", 0, "Cube", "Map using the normal vector"},
2146 {MTEX_TUBE, "TUBE", 0, "Tube", "Map with Z as central axis"},
2147 {MTEX_SPHERE, "SPHERE", 0, "Sphere", "Map with Z as central axis"},
2148 {0, NULL, 0, NULL, NULL},
2149 };
2150
2151 static const EnumPropertyItem prop_x_mapping_items[] = {
2152 {0, "NONE", 0, "None", ""},
2153 {1, "X", 0, "X", ""},
2154 {2, "Y", 0, "Y", ""},
2155 {3, "Z", 0, "Z", ""},
2156 {0, NULL, 0, NULL, NULL},
2157 };
2158
2159 static const EnumPropertyItem prop_y_mapping_items[] = {
2160 {0, "NONE", 0, "None", ""},
2161 {1, "X", 0, "X", ""},
2162 {2, "Y", 0, "Y", ""},
2163 {3, "Z", 0, "Z", ""},
2164 {0, NULL, 0, NULL, NULL},
2165 };
2166
2167 static const EnumPropertyItem prop_z_mapping_items[] = {
2168 {0, "NONE", 0, "None", ""},
2169 {1, "X", 0, "X", ""},
2170 {2, "Y", 0, "Y", ""},
2171 {3, "Z", 0, "Z", ""},
2172 {0, NULL, 0, NULL, NULL},
2173 };
2174
2175 srna = RNA_def_struct(brna, "ParticleSettingsTextureSlot", "TextureSlot");
2176 RNA_def_struct_sdna(srna, "MTex");
2177 RNA_def_struct_ui_text(srna,
2178 "Particle Settings Texture Slot",
2179 "Texture slot for textures in a Particle Settings data-block");
2180
2181 prop = RNA_def_property(srna, "texture_coords", PROP_ENUM, PROP_NONE);
2182 RNA_def_property_enum_sdna(prop, NULL, "texco");
2183 RNA_def_property_enum_items(prop, texco_items);
2184 RNA_def_property_ui_text(prop,
2185 "Texture Coordinates",
2186 "Texture coordinates used to map the texture onto the background");
2187 RNA_def_property_update(prop, 0, "rna_Particle_reset_dependency");
2188
2189 prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
2190 RNA_def_property_pointer_sdna(prop, NULL, "object");
2191 RNA_def_property_struct_type(prop, "Object");
2192 RNA_def_property_flag(prop, PROP_EDITABLE);
2193 RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
2194 RNA_def_property_ui_text(
2195 prop, "Object", "Object to use for mapping with Object texture coordinates");
2196 RNA_def_property_update(prop, 0, "rna_Particle_reset_dependency");
2197
2198 prop = RNA_def_property(srna, "uv_layer", PROP_STRING, PROP_NONE);
2199 RNA_def_property_string_sdna(prop, NULL, "uvname");
2200 RNA_def_property_ui_text(
2201 prop, "UV Map", "UV map to use for mapping with UV texture coordinates");
2202 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2203
2204 prop = RNA_def_property(srna, "mapping_x", PROP_ENUM, PROP_NONE);
2205 RNA_def_property_enum_sdna(prop, NULL, "projx");
2206 RNA_def_property_enum_items(prop, prop_x_mapping_items);
2207 RNA_def_property_ui_text(prop, "X Mapping", "");
2208 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2209
2210 prop = RNA_def_property(srna, "mapping_y", PROP_ENUM, PROP_NONE);
2211 RNA_def_property_enum_sdna(prop, NULL, "projy");
2212 RNA_def_property_enum_items(prop, prop_y_mapping_items);
2213 RNA_def_property_ui_text(prop, "Y Mapping", "");
2214 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2215
2216 prop = RNA_def_property(srna, "mapping_z", PROP_ENUM, PROP_NONE);
2217 RNA_def_property_enum_sdna(prop, NULL, "projz");
2218 RNA_def_property_enum_items(prop, prop_z_mapping_items);
2219 RNA_def_property_ui_text(prop, "Z Mapping", "");
2220 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2221
2222 prop = RNA_def_property(srna, "mapping", PROP_ENUM, PROP_NONE);
2223 RNA_def_property_enum_items(prop, prop_mapping_items);
2224 RNA_def_property_ui_text(prop, "Mapping", "");
2225 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2226
2227 /* map to */
2228 prop = RNA_def_property(srna, "use_map_time", PROP_BOOLEAN, PROP_NONE);
2229 RNA_def_property_boolean_sdna(prop, NULL, "mapto", PAMAP_TIME);
2230 RNA_def_property_ui_text(prop, "Emission Time", "Affect the emission time of the particles");
2231 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2232
2233 prop = RNA_def_property(srna, "use_map_life", PROP_BOOLEAN, PROP_NONE);
2234 RNA_def_property_boolean_sdna(prop, NULL, "mapto", PAMAP_LIFE);
2235 RNA_def_property_ui_text(prop, "Life Time", "Affect the life time of the particles");
2236 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2237
2238 prop = RNA_def_property(srna, "use_map_density", PROP_BOOLEAN, PROP_NONE);
2239 RNA_def_property_boolean_sdna(prop, NULL, "mapto", PAMAP_DENS);
2240 RNA_def_property_ui_text(prop, "Density", "Affect the density of the particles");
2241 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2242
2243 prop = RNA_def_property(srna, "use_map_size", PROP_BOOLEAN, PROP_NONE);
2244 RNA_def_property_boolean_sdna(prop, NULL, "mapto", PAMAP_SIZE);
2245 RNA_def_property_ui_text(prop, "Size", "Affect the particle size");
2246 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2247
2248 prop = RNA_def_property(srna, "use_map_velocity", PROP_BOOLEAN, PROP_NONE);
2249 RNA_def_property_boolean_sdna(prop, NULL, "mapto", PAMAP_IVEL);
2250 RNA_def_property_ui_text(prop, "Initial Velocity", "Affect the particle initial velocity");
2251 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2252
2253 prop = RNA_def_property(srna, "use_map_field", PROP_BOOLEAN, PROP_NONE);
2254 RNA_def_property_boolean_sdna(prop, NULL, "mapto", PAMAP_FIELD);
2255 RNA_def_property_ui_text(prop, "Force Field", "Affect the particle force fields");
2256 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2257
2258 prop = RNA_def_property(srna, "use_map_gravity", PROP_BOOLEAN, PROP_NONE);
2259 RNA_def_property_boolean_sdna(prop, NULL, "mapto", PAMAP_GRAVITY);
2260 RNA_def_property_ui_text(prop, "Gravity", "Affect the particle gravity");
2261 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2262
2263 prop = RNA_def_property(srna, "use_map_damp", PROP_BOOLEAN, PROP_NONE);
2264 RNA_def_property_boolean_sdna(prop, NULL, "mapto", PAMAP_DAMP);
2265 RNA_def_property_ui_text(prop, "Damp", "Affect the particle velocity damping");
2266 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
2267
2268 prop = RNA_def_property(srna, "use_map_clump", PROP_BOOLEAN, PROP_NONE);
2269 RNA_def_property_boolean_sdna(prop, NULL, "mapto", PAMAP_CLUMP);
2270 RNA_def_property_ui_text(prop, "Clump", "Affect the child clumping");
2271 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2272
2273 prop = RNA_def_property(srna, "use_map_kink_amp", PROP_BOOLEAN, PROP_NONE);
2274 RNA_def_property_boolean_sdna(prop, NULL, "mapto", PAMAP_KINK_AMP);
2275 RNA_def_property_ui_text(prop, "Kink Amplitude", "Affect the child kink amplitude");
2276 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
2277
2278 prop = RNA_def_property(srna, "use_map_kink_freq", PROP_BOOLEAN, PROP_NONE);
2279 RNA_def_property_boolean_sdna(prop, NULL, "mapto", PAMAP_KINK_FREQ);
2280 RNA_def_property_ui_text(prop, "Kink Frequency", "Affect the child kink frequency");
2281 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
2282
2283 prop = RNA_def_property(srna, "use_map_rough", PROP_BOOLEAN, PROP_NONE);
2284 RNA_def_property_boolean_sdna(prop, NULL, "mapto", PAMAP_ROUGH);
2285 RNA_def_property_ui_text(prop, "Rough", "Affect the child rough");
2286 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
2287
2288 prop = RNA_def_property(srna, "use_map_length", PROP_BOOLEAN, PROP_NONE);
2289 RNA_def_property_boolean_sdna(prop, NULL, "mapto", PAMAP_LENGTH);
2290 RNA_def_property_ui_text(prop, "Length", "Affect the child hair length");
2291 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
2292
2293 prop = RNA_def_property(srna, "use_map_twist", PROP_BOOLEAN, PROP_NONE);
2294 RNA_def_property_boolean_sdna(prop, NULL, "mapto", PAMAP_TWIST);
2295 RNA_def_property_ui_text(prop, "Twist", "Affect the child twist");
2296 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
2297
2298 /* influence factors */
2299 prop = RNA_def_property(srna, "time_factor", PROP_FLOAT, PROP_NONE);
2300 RNA_def_property_float_sdna(prop, NULL, "timefac");
2301 RNA_def_property_ui_range(prop, 0, 1, 10, 3);
2302 RNA_def_property_ui_text(
2303 prop, "Emission Time Factor", "Amount texture affects particle emission time");
2304 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2305
2306 prop = RNA_def_property(srna, "life_factor", PROP_FLOAT, PROP_NONE);
2307 RNA_def_property_float_sdna(prop, NULL, "lifefac");
2308 RNA_def_property_ui_range(prop, 0, 1, 10, 3);
2309 RNA_def_property_ui_text(prop, "Life Time Factor", "Amount texture affects particle life time");
2310 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2311
2312 prop = RNA_def_property(srna, "density_factor", PROP_FLOAT, PROP_NONE);
2313 RNA_def_property_float_sdna(prop, NULL, "padensfac");
2314 RNA_def_property_ui_range(prop, 0, 1, 10, 3);
2315 RNA_def_property_ui_text(prop, "Density Factor", "Amount texture affects particle density");
2316 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2317
2318 prop = RNA_def_property(srna, "size_factor", PROP_FLOAT, PROP_NONE);
2319 RNA_def_property_float_sdna(prop, NULL, "sizefac");
2320 RNA_def_property_ui_range(prop, 0, 1, 10, 3);
2321 RNA_def_property_ui_text(prop, "Size Factor", "Amount texture affects physical particle size");
2322 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2323
2324 prop = RNA_def_property(srna, "velocity_factor", PROP_FLOAT, PROP_NONE);
2325 RNA_def_property_float_sdna(prop, NULL, "ivelfac");
2326 RNA_def_property_ui_range(prop, 0, 1, 10, 3);
2327 RNA_def_property_ui_text(
2328 prop, "Velocity Factor", "Amount texture affects particle initial velocity");
2329 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2330
2331 prop = RNA_def_property(srna, "field_factor", PROP_FLOAT, PROP_NONE);
2332 RNA_def_property_float_sdna(prop, NULL, "fieldfac");
2333 RNA_def_property_ui_range(prop, 0, 1, 10, 3);
2334 RNA_def_property_ui_text(prop, "Field Factor", "Amount texture affects particle force fields");
2335 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2336
2337 prop = RNA_def_property(srna, "gravity_factor", PROP_FLOAT, PROP_NONE);
2338 RNA_def_property_float_sdna(prop, NULL, "gravityfac");
2339 RNA_def_property_ui_range(prop, 0, 1, 10, 3);
2340 RNA_def_property_ui_text(prop, "Gravity Factor", "Amount texture affects particle gravity");
2341 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2342
2343 prop = RNA_def_property(srna, "damp_factor", PROP_FLOAT, PROP_NONE);
2344 RNA_def_property_float_sdna(prop, NULL, "dampfac");
2345 RNA_def_property_ui_range(prop, 0, 1, 10, 3);
2346 RNA_def_property_ui_text(prop, "Damp Factor", "Amount texture affects particle damping");
2347 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2348
2349 prop = RNA_def_property(srna, "length_factor", PROP_FLOAT, PROP_NONE);
2350 RNA_def_property_float_sdna(prop, NULL, "lengthfac");
2351 RNA_def_property_ui_range(prop, 0, 1, 10, 3);
2352 RNA_def_property_ui_text(prop, "Length Factor", "Amount texture affects child hair length");
2353 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
2354
2355 prop = RNA_def_property(srna, "clump_factor", PROP_FLOAT, PROP_NONE);
2356 RNA_def_property_float_sdna(prop, NULL, "clumpfac");
2357 RNA_def_property_ui_range(prop, 0, 1, 10, 3);
2358 RNA_def_property_ui_text(prop, "Clump Factor", "Amount texture affects child clump");
2359 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
2360
2361 prop = RNA_def_property(srna, "kink_amp_factor", PROP_FLOAT, PROP_NONE);
2362 RNA_def_property_float_sdna(prop, NULL, "kinkampfac");
2363 RNA_def_property_ui_range(prop, 0, 1, 10, 3);
2364 RNA_def_property_ui_text(
2365 prop, "Kink Amplitude Factor", "Amount texture affects child kink amplitude");
2366 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
2367
2368 prop = RNA_def_property(srna, "kink_freq_factor", PROP_FLOAT, PROP_NONE);
2369 RNA_def_property_float_sdna(prop, NULL, "kinkfac");
2370 RNA_def_property_ui_range(prop, 0, 1, 10, 3);
2371 RNA_def_property_ui_text(
2372 prop, "Kink Frequency Factor", "Amount texture affects child kink frequency");
2373 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
2374
2375 prop = RNA_def_property(srna, "rough_factor", PROP_FLOAT, PROP_NONE);
2376 RNA_def_property_float_sdna(prop, NULL, "roughfac");
2377 RNA_def_property_ui_range(prop, 0, 1, 10, 3);
2378 RNA_def_property_ui_text(prop, "Rough Factor", "Amount texture affects child roughness");
2379 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
2380
2381 prop = RNA_def_property(srna, "twist_factor", PROP_FLOAT, PROP_NONE);
2382 RNA_def_property_float_sdna(prop, NULL, "twistfac");
2383 RNA_def_property_ui_range(prop, 0, 1, 10, 3);
2384 RNA_def_property_ui_text(prop, "Twist Factor", "Amount texture affects child twist");
2385 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
2386 }
2387
rna_def_particle_settings(BlenderRNA * brna)2388 static void rna_def_particle_settings(BlenderRNA *brna)
2389 {
2390 StructRNA *srna;
2391 PropertyRNA *prop;
2392
2393 static const EnumPropertyItem phys_type_items[] = {
2394 {PART_PHYS_NO, "NO", 0, "None", ""},
2395 {PART_PHYS_NEWTON, "NEWTON", 0, "Newtonian", ""},
2396 {PART_PHYS_KEYED, "KEYED", 0, "Keyed", ""},
2397 {PART_PHYS_BOIDS, "BOIDS", 0, "Boids", ""},
2398 {PART_PHYS_FLUID, "FLUID", 0, "Fluid", ""},
2399 {0, NULL, 0, NULL, NULL},
2400 };
2401
2402 static const EnumPropertyItem rot_mode_items[] = {
2403 {0, "NONE", 0, "None", ""},
2404 {PART_ROT_NOR, "NOR", 0, "Normal", ""},
2405 {PART_ROT_NOR_TAN, "NOR_TAN", 0, "Normal-Tangent", ""},
2406 {PART_ROT_VEL, "VEL", 0, "Velocity / Hair", ""},
2407 {PART_ROT_GLOB_X, "GLOB_X", 0, "Global X", ""},
2408 {PART_ROT_GLOB_Y, "GLOB_Y", 0, "Global Y", ""},
2409 {PART_ROT_GLOB_Z, "GLOB_Z", 0, "Global Z", ""},
2410 {PART_ROT_OB_X, "OB_X", 0, "Object X", ""},
2411 {PART_ROT_OB_Y, "OB_Y", 0, "Object Y", ""},
2412 {PART_ROT_OB_Z, "OB_Z", 0, "Object Z", ""},
2413 {0, NULL, 0, NULL, NULL},
2414 };
2415
2416 static const EnumPropertyItem ave_mode_items[] = {
2417 {0, "NONE", 0, "None", ""},
2418 {PART_AVE_VELOCITY, "VELOCITY", 0, "Velocity", ""},
2419 {PART_AVE_HORIZONTAL, "HORIZONTAL", 0, "Horizontal", ""},
2420 {PART_AVE_VERTICAL, "VERTICAL", 0, "Vertical", ""},
2421 {PART_AVE_GLOBAL_X, "GLOBAL_X", 0, "Global X", ""},
2422 {PART_AVE_GLOBAL_Y, "GLOBAL_Y", 0, "Global Y", ""},
2423 {PART_AVE_GLOBAL_Z, "GLOBAL_Z", 0, "Global Z", ""},
2424 {PART_AVE_RAND, "RAND", 0, "Random", ""},
2425 {0, NULL, 0, NULL, NULL},
2426 };
2427
2428 static const EnumPropertyItem react_event_items[] = {
2429 {PART_EVENT_DEATH, "DEATH", 0, "Death", ""},
2430 {PART_EVENT_COLLIDE, "COLLIDE", 0, "Collision", ""},
2431 {PART_EVENT_NEAR, "NEAR", 0, "Near", ""},
2432 {0, NULL, 0, NULL, NULL},
2433 };
2434
2435 static const EnumPropertyItem child_type_items[] = {
2436 {0, "NONE", 0, "None", ""},
2437 {PART_CHILD_PARTICLES, "SIMPLE", 0, "Simple", ""},
2438 {PART_CHILD_FACES, "INTERPOLATED", 0, "Interpolated", ""},
2439 {0, NULL, 0, NULL, NULL},
2440 };
2441
2442 /*TODO: names, tooltips */
2443 static const EnumPropertyItem integrator_type_items[] = {
2444 {PART_INT_EULER, "EULER", 0, "Euler", ""},
2445 {PART_INT_VERLET, "VERLET", 0, "Verlet", ""},
2446 {PART_INT_MIDPOINT, "MIDPOINT", 0, "Midpoint", ""},
2447 {PART_INT_RK4, "RK4", 0, "RK4", ""},
2448 {0, NULL, 0, NULL, NULL},
2449 };
2450
2451 static const EnumPropertyItem kink_type_items[] = {
2452 {PART_KINK_NO, "NO", 0, "Nothing", ""},
2453 {PART_KINK_CURL, "CURL", 0, "Curl", ""},
2454 {PART_KINK_RADIAL, "RADIAL", 0, "Radial", ""},
2455 {PART_KINK_WAVE, "WAVE", 0, "Wave", ""},
2456 {PART_KINK_BRAID, "BRAID", 0, "Braid", ""},
2457 {PART_KINK_SPIRAL, "SPIRAL", 0, "Spiral", ""},
2458 {0, NULL, 0, NULL, NULL},
2459 };
2460
2461 static const EnumPropertyItem draw_col_items[] = {
2462 {PART_DRAW_COL_NONE, "NONE", 0, "None", ""},
2463 {PART_DRAW_COL_MAT, "MATERIAL", 0, "Material", ""},
2464 {PART_DRAW_COL_VEL, "VELOCITY", 0, "Velocity", ""},
2465 {PART_DRAW_COL_ACC, "ACCELERATION", 0, "Acceleration", ""},
2466 {0, NULL, 0, NULL, NULL},
2467 };
2468
2469 static const EnumPropertyItem part_mat_items[] = {
2470 {0, "DUMMY", 0, "Dummy", ""},
2471 {0, NULL, 0, NULL, NULL},
2472 };
2473
2474 srna = RNA_def_struct(brna, "ParticleSettings", "ID");
2475 RNA_def_struct_ui_text(
2476 srna, "Particle Settings", "Particle settings, reusable by multiple particle systems");
2477 RNA_def_struct_ui_icon(srna, ICON_PARTICLE_DATA);
2478
2479 rna_def_mtex_common(brna,
2480 srna,
2481 "rna_ParticleSettings_mtex_begin",
2482 "rna_ParticleSettings_active_texture_get",
2483 "rna_ParticleSettings_active_texture_set",
2484 NULL,
2485 "ParticleSettingsTextureSlot",
2486 "ParticleSettingsTextureSlots",
2487 "rna_Particle_reset",
2488 NULL);
2489
2490 /* Fluid particle type can't be checked from the type value in RNA
2491 * as it's not shown in the menu. */
2492 prop = RNA_def_property(srna, "is_fluid", PROP_BOOLEAN, PROP_NONE);
2493 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2494 RNA_def_property_boolean_funcs(prop, "rna_PartSettings_is_fluid_get", NULL);
2495 RNA_def_property_ui_text(prop, "Fluid", "Particles were created by a fluid simulation");
2496
2497 /* flag */
2498 prop = RNA_def_property(srna, "use_react_start_end", PROP_BOOLEAN, PROP_NONE);
2499 RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_REACT_STA_END);
2500 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2501 RNA_def_property_ui_text(prop, "Start/End", "Give birth to unreacted particles eventually");
2502 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2503
2504 prop = RNA_def_property(srna, "use_react_multiple", PROP_BOOLEAN, PROP_NONE);
2505 RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_REACT_MULTIPLE);
2506 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2507 RNA_def_property_ui_text(prop, "Multi React", "React multiple times");
2508 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2509
2510 prop = RNA_def_property(srna, "use_regrow_hair", PROP_BOOLEAN, PROP_NONE);
2511 RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_HAIR_REGROW);
2512 RNA_def_property_ui_text(prop, "Regrow", "Regrow hair for each frame");
2513 RNA_def_property_update(prop, 0, "rna_Particle_redo");
2514
2515 prop = RNA_def_property(srna, "show_unborn", PROP_BOOLEAN, PROP_NONE);
2516 RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_UNBORN);
2517 RNA_def_property_ui_text(prop, "Unborn", "Show particles before they are emitted");
2518 RNA_def_property_update(prop, 0, "rna_Particle_redo");
2519
2520 prop = RNA_def_property(srna, "use_dead", PROP_BOOLEAN, PROP_NONE);
2521 RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_DIED);
2522 RNA_def_property_ui_text(prop, "Died", "Show particles after they have died");
2523 RNA_def_property_update(prop, 0, "rna_Particle_redo");
2524
2525 prop = RNA_def_property(srna, "use_emit_random", PROP_BOOLEAN, PROP_NONE);
2526 RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_TRAND);
2527 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2528 RNA_def_property_ui_text(prop, "Random", "Emit in random order of elements");
2529 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2530
2531 prop = RNA_def_property(srna, "use_even_distribution", PROP_BOOLEAN, PROP_NONE);
2532 RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_EDISTR);
2533 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2534 RNA_def_property_ui_text(prop,
2535 "Even Distribution",
2536 "Use even distribution from faces based on face areas or edge lengths");
2537 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2538
2539 prop = RNA_def_property(srna, "use_die_on_collision", PROP_BOOLEAN, PROP_NONE);
2540 RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_DIE_ON_COL);
2541 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2542 RNA_def_property_ui_text(
2543 prop, "Die on Hit", "Particles die when they collide with a deflector object");
2544 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2545
2546 prop = RNA_def_property(srna, "use_size_deflect", PROP_BOOLEAN, PROP_NONE);
2547 RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_SIZE_DEFL);
2548 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2549 RNA_def_property_ui_text(prop, "Size Deflect", "Use particle's size in deflection");
2550 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2551
2552 prop = RNA_def_property(srna, "use_rotations", PROP_BOOLEAN, PROP_NONE);
2553 RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_ROTATIONS);
2554 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2555 RNA_def_property_ui_text(prop, "Rotations", "Calculate particle rotations");
2556 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2557
2558 prop = RNA_def_property(srna, "use_dynamic_rotation", PROP_BOOLEAN, PROP_NONE);
2559 RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_ROT_DYN);
2560 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2561 RNA_def_property_ui_text(
2562 prop, "Dynamic", "Particle rotations are affected by collisions and effectors");
2563 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2564
2565 prop = RNA_def_property(srna, "use_multiply_size_mass", PROP_BOOLEAN, PROP_NONE);
2566 RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_SIZEMASS);
2567 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2568 RNA_def_property_ui_text(prop, "Mass from Size", "Multiply mass by particle size");
2569 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2570
2571 prop = RNA_def_property(srna, "use_advanced_hair", PROP_BOOLEAN, PROP_NONE);
2572 RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", PART_HIDE_ADVANCED_HAIR);
2573 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2574 RNA_def_property_ui_text(prop, "Advanced", "Use full physics calculations for growing hair");
2575 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2576
2577 prop = RNA_def_property(srna, "lock_boids_to_surface", PROP_BOOLEAN, PROP_NONE);
2578 RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_BOIDS_2D);
2579 RNA_def_property_ui_text(prop, "Boids 2D", "Constrain boids to a surface");
2580 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2581
2582 prop = RNA_def_property(srna, "use_hair_bspline", PROP_BOOLEAN, PROP_NONE);
2583 RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_HAIR_BSPLINE);
2584 RNA_def_property_ui_text(prop, "B-Spline", "Interpolate hair using B-Splines");
2585 RNA_def_property_update(prop, 0, "rna_Particle_redo");
2586
2587 prop = RNA_def_property(srna, "invert_grid", PROP_BOOLEAN, PROP_NONE);
2588 RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_GRID_INVERT);
2589 RNA_def_property_ui_text(
2590 prop, "Invert Grid", "Invert what is considered object and what is not");
2591 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2592
2593 prop = RNA_def_property(srna, "hexagonal_grid", PROP_BOOLEAN, PROP_NONE);
2594 RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_GRID_HEXAGONAL);
2595 RNA_def_property_ui_text(prop, "Hexagonal Grid", "Create the grid in a hexagonal pattern");
2596 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2597
2598 prop = RNA_def_property(srna, "apply_effector_to_children", PROP_BOOLEAN, PROP_NONE);
2599 RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_CHILD_EFFECT);
2600 RNA_def_property_ui_text(prop, "Effect Children", "Apply effectors to children");
2601 RNA_def_property_update(prop, 0, "rna_Particle_redo");
2602
2603 prop = RNA_def_property(srna, "create_long_hair_children", PROP_BOOLEAN, PROP_NONE);
2604 RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_CHILD_LONG_HAIR);
2605 RNA_def_property_ui_text(prop, "Long Hair", "Calculate children that suit long hair well");
2606 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
2607
2608 prop = RNA_def_property(srna, "apply_guide_to_children", PROP_BOOLEAN, PROP_NONE);
2609 RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_CHILD_GUIDE);
2610 RNA_def_property_ui_text(prop, "apply_guide_to_children", "");
2611 RNA_def_property_update(prop, 0, "rna_Particle_redo");
2612
2613 prop = RNA_def_property(srna, "use_self_effect", PROP_BOOLEAN, PROP_NONE);
2614 RNA_def_property_boolean_sdna(prop, NULL, "flag", PART_SELF_EFFECT);
2615 RNA_def_property_ui_text(prop, "Self Effect", "Particle effectors affect themselves");
2616 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2617
2618 prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
2619 RNA_def_property_enum_items(prop, part_type_items);
2620 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2621 RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Particle_type_itemf");
2622 RNA_def_property_ui_text(prop, "Type", "Particle Type");
2623 RNA_def_property_update(prop, 0, "rna_Particle_change_type");
2624
2625 prop = RNA_def_property(srna, "emit_from", PROP_ENUM, PROP_NONE);
2626 RNA_def_property_enum_sdna(prop, NULL, "from");
2627 RNA_def_property_enum_items(prop, part_reactor_from_items);
2628 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2629 RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Particle_from_itemf");
2630 RNA_def_property_ui_text(prop, "Emit From", "Where to emit particles from");
2631 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2632
2633 prop = RNA_def_property(srna, "distribution", PROP_ENUM, PROP_NONE);
2634 RNA_def_property_enum_sdna(prop, NULL, "distr");
2635 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2636 RNA_def_property_enum_items(prop, part_dist_items);
2637 RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Particle_dist_itemf");
2638 RNA_def_property_ui_text(
2639 prop, "Distribution", "How to distribute particles on selected element");
2640 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2641
2642 /* physics modes */
2643 prop = RNA_def_property(srna, "physics_type", PROP_ENUM, PROP_NONE);
2644 RNA_def_property_enum_sdna(prop, NULL, "phystype");
2645 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2646 RNA_def_property_enum_items(prop, phys_type_items);
2647 RNA_def_property_ui_text(prop, "Physics Type", "Particle physics type");
2648 RNA_def_property_update(prop, 0, "rna_Particle_change_physics_type");
2649
2650 prop = RNA_def_property(srna, "rotation_mode", PROP_ENUM, PROP_NONE);
2651 RNA_def_property_enum_sdna(prop, NULL, "rotmode");
2652 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2653 RNA_def_property_enum_items(prop, rot_mode_items);
2654 RNA_def_property_ui_text(
2655 prop,
2656 "Orientation Axis",
2657 "Particle orientation axis (does not affect Explode modifier's results)");
2658 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2659
2660 prop = RNA_def_property(srna, "angular_velocity_mode", PROP_ENUM, PROP_NONE);
2661 RNA_def_property_enum_sdna(prop, NULL, "avemode");
2662 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2663 RNA_def_property_enum_items(prop, ave_mode_items);
2664 RNA_def_property_ui_text(
2665 prop, "Angular Velocity Axis", "What axis is used to change particle rotation with time");
2666 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2667
2668 prop = RNA_def_property(srna, "react_event", PROP_ENUM, PROP_NONE);
2669 RNA_def_property_enum_sdna(prop, NULL, "reactevent");
2670 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2671 RNA_def_property_enum_items(prop, react_event_items);
2672 RNA_def_property_ui_text(prop, "React On", "The event of target particles to react on");
2673 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2674
2675 /*draw flag*/
2676 prop = RNA_def_property(srna, "show_guide_hairs", PROP_BOOLEAN, PROP_NONE);
2677 RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_GUIDE_HAIRS);
2678 RNA_def_property_ui_text(prop, "Guide Hairs", "Show guide hairs");
2679 RNA_def_property_update(prop, 0, "rna_Particle_redo");
2680
2681 prop = RNA_def_property(srna, "show_hair_grid", PROP_BOOLEAN, PROP_NONE);
2682 RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_HAIR_GRID);
2683 RNA_def_property_ui_text(prop, "Guide Hairs", "Show hair simulation grid");
2684 RNA_def_property_update(prop, 0, "rna_Particle_redo");
2685
2686 prop = RNA_def_property(srna, "show_velocity", PROP_BOOLEAN, PROP_NONE);
2687 RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_VEL);
2688 RNA_def_property_ui_text(prop, "Velocity", "Show particle velocity");
2689 RNA_def_property_update(prop, 0, "rna_Particle_redo");
2690
2691 prop = RNA_def_property(srna, "show_size", PROP_BOOLEAN, PROP_NONE);
2692 RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_SIZE);
2693 RNA_def_property_ui_text(prop, "Size", "Show particle size");
2694 RNA_def_property_update(prop, 0, "rna_Particle_redo");
2695
2696 prop = RNA_def_property(srna, "show_health", PROP_BOOLEAN, PROP_NONE);
2697 RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_HEALTH);
2698 RNA_def_property_ui_text(prop, "Health", "Draw boid health");
2699 RNA_def_property_update(prop, 0, "rna_Particle_redo");
2700
2701 prop = RNA_def_property(srna, "use_absolute_path_time", PROP_BOOLEAN, PROP_NONE);
2702 RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_ABS_PATH_TIME);
2703 RNA_def_property_ui_text(prop, "Absolute Path Time", "Path timing is in absolute frames");
2704 RNA_def_property_update(prop, 0, "rna_Particle_abspathtime_update");
2705
2706 prop = RNA_def_property(srna, "use_parent_particles", PROP_BOOLEAN, PROP_NONE);
2707 RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_PARENT);
2708 RNA_def_property_ui_text(prop, "Parents", "Render parent particles");
2709 RNA_def_property_update(prop, 0, "rna_Particle_redo");
2710
2711 prop = RNA_def_property(srna, "show_number", PROP_BOOLEAN, PROP_NONE);
2712 RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_NUM);
2713 RNA_def_property_ui_text(prop, "Number", "Show particle number");
2714 RNA_def_property_update(prop, 0, "rna_Particle_redo");
2715
2716 prop = RNA_def_property(srna, "use_collection_pick_random", PROP_BOOLEAN, PROP_NONE);
2717 RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_RAND_GR);
2718 RNA_def_property_ui_text(prop, "Pick Random", "Pick objects from collection randomly");
2719 RNA_def_property_update(prop, 0, "rna_Particle_redo");
2720
2721 prop = RNA_def_property(srna, "use_collection_count", PROP_BOOLEAN, PROP_NONE);
2722 RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_COUNT_GR);
2723 RNA_def_property_ui_text(prop, "Use Count", "Use object multiple times in the same collection");
2724 RNA_def_property_update(prop, 0, "rna_Particle_redo_count");
2725
2726 prop = RNA_def_property(srna, "use_global_instance", PROP_BOOLEAN, PROP_NONE);
2727 RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_GLOBAL_OB);
2728 RNA_def_property_ui_text(prop, "Global", "Use object's global coordinates for duplication");
2729 RNA_def_property_update(prop, 0, "rna_Particle_redo");
2730
2731 prop = RNA_def_property(srna, "use_rotation_instance", PROP_BOOLEAN, PROP_NONE);
2732 RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_ROTATE_OB);
2733 RNA_def_property_ui_text(prop,
2734 "Rotation",
2735 "Use object's rotation for duplication (global x-axis is aligned "
2736 "particle rotation axis)");
2737 RNA_def_property_update(prop, 0, "rna_Particle_redo");
2738
2739 prop = RNA_def_property(srna, "use_scale_instance", PROP_BOOLEAN, PROP_NONE);
2740 RNA_def_property_boolean_negative_sdna(prop, NULL, "draw", PART_DRAW_NO_SCALE_OB);
2741 RNA_def_property_ui_text(prop, "Scale", "Use object's scale for duplication");
2742 RNA_def_property_update(prop, 0, "rna_Particle_redo");
2743
2744 prop = RNA_def_property(srna, "use_render_adaptive", PROP_BOOLEAN, PROP_NONE);
2745 RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_REN_ADAPT);
2746 RNA_def_property_ui_text(prop, "Adaptive Render", "Draw steps of the particle path");
2747 RNA_def_property_update(prop, 0, "rna_Particle_redo");
2748
2749 prop = RNA_def_property(srna, "use_velocity_length", PROP_BOOLEAN, PROP_NONE);
2750 RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_VEL_LENGTH);
2751 RNA_def_property_ui_text(prop, "Speed", "Multiply line length by particle speed");
2752 RNA_def_property_update(prop, 0, "rna_Particle_redo");
2753
2754 prop = RNA_def_property(srna, "use_whole_collection", PROP_BOOLEAN, PROP_NONE);
2755 RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_WHOLE_GR);
2756 RNA_def_property_ui_text(prop, "Whole Collection", "Use whole collection at once");
2757 RNA_def_property_update(prop, 0, "rna_Particle_redo");
2758
2759 prop = RNA_def_property(srna, "use_strand_primitive", PROP_BOOLEAN, PROP_NONE);
2760 RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_REN_STRAND);
2761 RNA_def_property_ui_text(prop, "Strand Render", "Use the strand primitive for rendering");
2762 RNA_def_property_update(prop, 0, "rna_Particle_redo");
2763
2764 prop = RNA_def_property(srna, "display_method", PROP_ENUM, PROP_NONE);
2765 RNA_def_property_enum_sdna(prop, NULL, "draw_as");
2766 RNA_def_property_enum_items(prop, part_draw_as_items);
2767 RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Particle_draw_as_itemf");
2768 RNA_def_property_ui_text(prop, "Particle Drawing", "How particles are drawn in viewport");
2769 RNA_def_property_update(prop, 0, "rna_Particle_redo");
2770
2771 prop = RNA_def_property(srna, "render_type", PROP_ENUM, PROP_NONE);
2772 RNA_def_property_enum_sdna(prop, NULL, "ren_as");
2773 RNA_def_property_enum_items(prop, part_ren_as_items);
2774 RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Particle_ren_as_itemf");
2775 RNA_def_property_ui_text(prop, "Particle Rendering", "How particles are rendered");
2776 RNA_def_property_update(prop, 0, "rna_Particle_redo");
2777
2778 prop = RNA_def_property(srna, "display_color", PROP_ENUM, PROP_NONE);
2779 RNA_def_property_enum_sdna(prop, NULL, "draw_col");
2780 RNA_def_property_enum_items(prop, draw_col_items);
2781 RNA_def_property_ui_text(prop, "Draw Color", "Draw additional particle data as a color");
2782 RNA_def_property_update(prop, 0, "rna_Particle_redo");
2783
2784 prop = RNA_def_property(srna, "display_size", PROP_FLOAT, PROP_DISTANCE);
2785 RNA_def_property_float_sdna(prop, NULL, "draw_size");
2786 RNA_def_property_range(prop, 0, 1000);
2787 RNA_def_property_ui_range(prop, 0, 100, 1, -1);
2788 RNA_def_property_ui_text(prop, "Draw Size", "Size of particles on viewport in BU");
2789 RNA_def_property_update(prop, 0, "rna_Particle_redo");
2790
2791 prop = RNA_def_property(srna, "child_type", PROP_ENUM, PROP_NONE);
2792 RNA_def_property_enum_sdna(prop, NULL, "childtype");
2793 RNA_def_property_enum_items(prop, child_type_items);
2794 RNA_def_property_ui_text(prop, "Children From", "Create child particles");
2795 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
2796
2797 prop = RNA_def_property(srna, "display_step", PROP_INT, PROP_NONE);
2798 RNA_def_property_int_sdna(prop, NULL, "draw_step");
2799 RNA_def_property_range(prop, 0, 10);
2800 RNA_def_property_ui_range(prop, 0, 7, 1, -1);
2801 RNA_def_property_ui_text(prop, "Steps", "How many steps paths are drawn with (power of 2)");
2802 RNA_def_property_update(prop, 0, "rna_Particle_redo");
2803
2804 prop = RNA_def_property(srna, "render_step", PROP_INT, PROP_NONE);
2805 RNA_def_property_int_sdna(prop, NULL, "ren_step");
2806 RNA_def_property_range(prop, 0, 20);
2807 RNA_def_property_ui_range(prop, 0, 9, 1, -1);
2808 RNA_def_property_ui_text(prop, "Render", "How many steps paths are rendered with (power of 2)");
2809
2810 prop = RNA_def_property(srna, "hair_step", PROP_INT, PROP_NONE);
2811 RNA_def_property_range(prop, 2, SHRT_MAX);
2812 RNA_def_property_ui_range(prop, 2, 50, 1, 1);
2813 RNA_def_property_ui_text(prop, "Segments", "Number of hair segments");
2814 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2815
2816 prop = RNA_def_property(srna, "bending_random", PROP_FLOAT, PROP_FACTOR);
2817 RNA_def_property_float_sdna(prop, NULL, "bending_random");
2818 RNA_def_property_range(prop, 0.0f, 1.0f);
2819 RNA_def_property_ui_text(prop, "Random Bending Stiffness", "Random stiffness of hairs");
2820 RNA_def_property_update(prop, 0, "rna_Particle_cloth_update");
2821
2822 /*TODO: not found in UI, readonly? */
2823 prop = RNA_def_property(srna, "keys_step", PROP_INT, PROP_NONE);
2824 RNA_def_property_range(prop, 0, SHRT_MAX); /*TODO:min,max */
2825 RNA_def_property_ui_text(prop, "Keys Step", "");
2826
2827 /* adaptive path rendering */
2828 prop = RNA_def_property(srna, "adaptive_angle", PROP_INT, PROP_NONE);
2829 RNA_def_property_int_sdna(prop, NULL, "adapt_angle");
2830 RNA_def_property_range(prop, 0, 45);
2831 RNA_def_property_ui_text(
2832 prop, "Degrees", "How many degrees path has to curve to make another render segment");
2833
2834 prop = RNA_def_property(srna, "adaptive_pixel", PROP_INT, PROP_NONE);
2835 RNA_def_property_int_sdna(prop, NULL, "adapt_pix");
2836 RNA_def_property_range(prop, 0, 50);
2837 RNA_def_property_ui_text(
2838 prop, "Pixel", "How many pixels path has to cover to make another render segment");
2839
2840 prop = RNA_def_property(srna, "display_percentage", PROP_INT, PROP_PERCENTAGE);
2841 RNA_def_property_int_sdna(prop, NULL, "disp");
2842 RNA_def_property_range(prop, 0, 100);
2843 RNA_def_property_ui_text(prop, "Display", "Percentage of particles to display in 3D view");
2844 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2845
2846 prop = RNA_def_property(srna, "material", PROP_INT, PROP_NONE);
2847 RNA_def_property_int_sdna(prop, NULL, "omat");
2848 RNA_def_property_range(prop, 1, 32767);
2849 RNA_def_property_ui_text(
2850 prop, "Material Index", "Index of material slot used for rendering particles");
2851 RNA_def_property_update(prop, 0, "rna_Particle_redo");
2852
2853 prop = RNA_def_property(srna, "material_slot", PROP_ENUM, PROP_NONE);
2854 RNA_def_property_enum_sdna(prop, NULL, "omat");
2855 RNA_def_property_enum_items(prop, part_mat_items);
2856 RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Particle_Material_itemf");
2857 RNA_def_property_ui_text(prop, "Material Slot", "Material slot used for rendering particles");
2858 RNA_def_property_update(prop, 0, "rna_Particle_redo");
2859
2860 prop = RNA_def_property(srna, "integrator", PROP_ENUM, PROP_NONE);
2861 RNA_def_property_enum_items(prop, integrator_type_items);
2862 RNA_def_property_ui_text(prop,
2863 "Integration",
2864 "Algorithm used to calculate physics, from the fastest to the "
2865 "most stable/accurate: Midpoint, Euler, Verlet, RK4 (Old)");
2866 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2867
2868 prop = RNA_def_property(srna, "kink", PROP_ENUM, PROP_NONE);
2869 RNA_def_property_enum_items(prop, kink_type_items);
2870 RNA_def_property_ui_text(prop, "Kink", "Type of periodic offset on the path");
2871 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
2872
2873 prop = RNA_def_property(srna, "kink_axis", PROP_ENUM, PROP_NONE);
2874 RNA_def_property_enum_items(prop, rna_enum_axis_xyz_items);
2875 RNA_def_property_ui_text(prop, "Axis", "Which axis to use for offset");
2876 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
2877
2878 prop = RNA_def_property(srna, "color_maximum", PROP_FLOAT, PROP_NONE);
2879 RNA_def_property_float_sdna(prop, NULL, "color_vec_max");
2880 RNA_def_property_range(prop, 0.01f, 100.0f);
2881 RNA_def_property_ui_text(prop, "Color Maximum", "Maximum length of the particle color vector");
2882 RNA_def_property_update(prop, 0, "rna_Particle_redo");
2883
2884 /* general values */
2885 prop = RNA_def_property(srna, "frame_start", PROP_FLOAT, PROP_TIME);
2886 RNA_def_property_float_sdna(prop, NULL, "sta"); /*optional if prop names are the same */
2887 RNA_def_property_range(prop, MINAFRAMEF, MAXFRAMEF);
2888 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2889 RNA_def_property_float_funcs(prop, NULL, "rna_PartSettings_start_set", NULL);
2890 RNA_def_property_ui_text(prop, "Start", "Frame number to start emitting particles");
2891 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2892
2893 prop = RNA_def_property(srna, "frame_end", PROP_FLOAT, PROP_TIME);
2894 RNA_def_property_float_sdna(prop, NULL, "end");
2895 RNA_def_property_range(prop, MINAFRAMEF, MAXFRAMEF);
2896
2897 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2898 RNA_def_property_float_funcs(prop, NULL, "rna_PartSettings_end_set", NULL);
2899 RNA_def_property_ui_text(prop, "End", "Frame number to stop emitting particles");
2900 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2901
2902 prop = RNA_def_property(srna, "lifetime", PROP_FLOAT, PROP_TIME);
2903 RNA_def_property_range(prop, 1.0f, MAXFRAMEF);
2904 RNA_def_property_ui_text(prop, "Lifetime", "Life span of the particles");
2905 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2906
2907 prop = RNA_def_property(srna, "lifetime_random", PROP_FLOAT, PROP_FACTOR);
2908 RNA_def_property_float_sdna(prop, NULL, "randlife");
2909 RNA_def_property_range(prop, 0.0f, 1.0f);
2910 RNA_def_property_ui_text(prop, "Random", "Give the particle life a random variation");
2911 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2912
2913 prop = RNA_def_property(srna, "time_tweak", PROP_FLOAT, PROP_NONE);
2914 RNA_def_property_float_sdna(prop, NULL, "timetweak");
2915 RNA_def_property_range(prop, 0.0f, 100.0f);
2916 RNA_def_property_ui_range(prop, 0, 10, 1, 3);
2917 RNA_def_property_ui_text(
2918 prop, "Tweak", "A multiplier for physics timestep (1.0 means one frame = 1/25 seconds)");
2919 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2920
2921 prop = RNA_def_property(srna, "timestep", PROP_FLOAT, PROP_NONE);
2922 RNA_def_property_float_funcs(
2923 prop, "rna_PartSettings_timestep_get", "rna_PartSetings_timestep_set", NULL);
2924 RNA_def_property_range(prop, 0.0001, 100.0);
2925 RNA_def_property_ui_range(prop, 0.01, 10, 1, 3);
2926 RNA_def_property_ui_text(
2927 prop, "Timestep", "The simulation timestep per frame (seconds per frame)");
2928 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2929
2930 prop = RNA_def_property(srna, "use_adaptive_subframes", PROP_BOOLEAN, PROP_NONE);
2931 RNA_def_property_boolean_sdna(prop, NULL, "time_flag", PART_TIME_AUTOSF);
2932 RNA_def_property_ui_text(
2933 prop, "Automatic Subframes", "Automatically set the number of subframes");
2934 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2935
2936 prop = RNA_def_property(srna, "subframes", PROP_INT, PROP_NONE);
2937 RNA_def_property_range(prop, 0, 1000);
2938 RNA_def_property_ui_text(
2939 prop,
2940 "Subframes",
2941 "Subframes to simulate for improved stability and finer granularity simulations "
2942 "(dt = timestep / (subframes + 1))");
2943 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2944
2945 prop = RNA_def_property(srna, "courant_target", PROP_FLOAT, PROP_NONE);
2946 RNA_def_property_range(prop, 0.0001, 10);
2947 RNA_def_property_ui_text(
2948 prop,
2949 "Adaptive Subframe Threshold",
2950 "The relative distance a particle can move before requiring more subframes "
2951 "(target Courant number); 0.01-0.3 is the recommended range");
2952 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2953
2954 prop = RNA_def_property(srna, "jitter_factor", PROP_FLOAT, PROP_NONE);
2955 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2956 RNA_def_property_float_sdna(prop, NULL, "jitfac");
2957 RNA_def_property_range(prop, 0.0f, 2.0f);
2958 RNA_def_property_ui_text(prop, "Amount", "Amount of jitter applied to the sampling");
2959 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2960
2961 prop = RNA_def_property(srna, "effect_hair", PROP_FLOAT, PROP_FACTOR);
2962 RNA_def_property_float_sdna(prop, NULL, "eff_hair");
2963 RNA_def_property_range(prop, 0.0f, 1.0f);
2964 RNA_def_property_ui_text(prop, "Stiffness", "Hair stiffness for effectors");
2965 RNA_def_property_update(prop, 0, "rna_Particle_redo");
2966
2967 prop = RNA_def_property(srna, "count", PROP_INT, PROP_UNSIGNED);
2968 RNA_def_property_int_sdna(prop, NULL, "totpart");
2969 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2970 RNA_def_property_ui_range(prop, 0, 1000000, 1, -1);
2971 RNA_def_property_ui_text(prop, "Number", "Total number of particles");
2972 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2973
2974 prop = RNA_def_property(
2975 srna, "userjit", PROP_INT, PROP_UNSIGNED); /*TODO: can we get a better name for userjit? */
2976 RNA_def_property_int_sdna(prop, NULL, "userjit");
2977 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2978 RNA_def_property_range(prop, 0, 1000);
2979 RNA_def_property_ui_text(prop, "Particles/Face", "Emission locations per face (0 = automatic)");
2980 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2981
2982 prop = RNA_def_property(srna, "grid_resolution", PROP_INT, PROP_UNSIGNED);
2983 RNA_def_property_int_sdna(prop, NULL, "grid_res");
2984 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2985 RNA_def_property_range(
2986 prop, 1, 250); /* ~15M particles in a cube (ouch!), but could be very usable in a plane */
2987 RNA_def_property_ui_range(prop, 1, 50, 1, -1); /* ~100k particles in a cube */
2988 RNA_def_property_ui_text(prop, "Resolution", "The resolution of the particle grid");
2989 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2990
2991 prop = RNA_def_property(srna, "grid_random", PROP_FLOAT, PROP_FACTOR);
2992 RNA_def_property_float_sdna(prop, NULL, "grid_rand");
2993 RNA_def_property_range(prop, 0.0f, 1.0f);
2994 RNA_def_property_ui_text(prop, "Grid Randomness", "Add random offset to the grid locations");
2995 RNA_def_property_update(prop, 0, "rna_Particle_reset");
2996
2997 prop = RNA_def_property(srna, "effector_amount", PROP_INT, PROP_UNSIGNED);
2998 /* In theory PROP_ANIMATABLE perhaps should be cleared,
2999 * but animating this can give some interesting results! */
3000 RNA_def_property_range(prop, 0, 10000); /* 10000 effectors will bel SLOW, but who knows */
3001 RNA_def_property_ui_range(prop, 0, 100, 1, -1);
3002 RNA_def_property_ui_text(
3003 prop, "Effector Number", "How many particles are effectors (0 is all particles)");
3004 RNA_def_property_update(prop, 0, "rna_Particle_reset");
3005
3006 /* initial velocity factors */
3007 prop = RNA_def_property(srna, "normal_factor", PROP_FLOAT, PROP_VELOCITY);
3008 RNA_def_property_float_sdna(prop, NULL, "normfac"); /*optional if prop names are the same */
3009 RNA_def_property_range(prop, -1000.0f, 1000.0f);
3010 RNA_def_property_ui_range(prop, 0, 100, 1, 3);
3011 RNA_def_property_ui_text(
3012 prop, "Normal", "Let the surface normal give the particle a starting velocity");
3013 RNA_def_property_update(prop, 0, "rna_Particle_reset");
3014
3015 prop = RNA_def_property(srna, "object_factor", PROP_FLOAT, PROP_NONE);
3016 RNA_def_property_float_sdna(prop, NULL, "obfac");
3017 RNA_def_property_range(prop, -200.0f, 200.0f);
3018 RNA_def_property_ui_range(prop, -1.0f, 1.0f, 0.1, 3);
3019 RNA_def_property_ui_text(
3020 prop, "Object Velocity", "Let the object give the particle a starting velocity");
3021 RNA_def_property_update(prop, 0, "rna_Particle_reset");
3022
3023 prop = RNA_def_property(srna, "factor_random", PROP_FLOAT, PROP_NONE);
3024 RNA_def_property_float_sdna(prop, NULL, "randfac"); /*optional if prop names are the same */
3025 RNA_def_property_range(prop, 0.0f, 200.0f);
3026 RNA_def_property_ui_range(prop, 0, 100, 1, 3);
3027 RNA_def_property_ui_text(prop, "Random", "Give the starting velocity a random variation");
3028 RNA_def_property_update(prop, 0, "rna_Particle_reset");
3029
3030 prop = RNA_def_property(srna, "particle_factor", PROP_FLOAT, PROP_NONE);
3031 RNA_def_property_float_sdna(prop, NULL, "partfac");
3032 RNA_def_property_range(prop, -200.0f, 200.0f);
3033 RNA_def_property_ui_range(prop, -1.0f, 1.0f, 0.1, 3);
3034 RNA_def_property_ui_text(
3035 prop, "Particle", "Let the target particle give the particle a starting velocity");
3036 RNA_def_property_update(prop, 0, "rna_Particle_reset");
3037
3038 prop = RNA_def_property(srna, "tangent_factor", PROP_FLOAT, PROP_VELOCITY);
3039 RNA_def_property_float_sdna(prop, NULL, "tanfac");
3040 RNA_def_property_range(prop, -1000.0f, 1000.0f);
3041 RNA_def_property_ui_range(prop, -100, 100, 1, 2);
3042 RNA_def_property_ui_text(
3043 prop, "Tangent", "Let the surface tangent give the particle a starting velocity");
3044 RNA_def_property_update(prop, 0, "rna_Particle_reset");
3045
3046 prop = RNA_def_property(srna, "tangent_phase", PROP_FLOAT, PROP_NONE);
3047 RNA_def_property_float_sdna(prop, NULL, "tanphase");
3048 RNA_def_property_range(prop, -1.0f, 1.0f);
3049 RNA_def_property_ui_text(prop, "Rotation", "Rotate the surface tangent");
3050 RNA_def_property_update(prop, 0, "rna_Particle_reset");
3051
3052 prop = RNA_def_property(srna, "reactor_factor", PROP_FLOAT, PROP_NONE);
3053 RNA_def_property_float_sdna(prop, NULL, "reactfac");
3054 RNA_def_property_range(prop, -10.0f, 10.0f);
3055 RNA_def_property_ui_text(
3056 prop,
3057 "Reactor",
3058 "Let the vector away from the target particle's location give the particle "
3059 "a starting velocity");
3060 RNA_def_property_update(prop, 0, "rna_Particle_reset");
3061
3062 prop = RNA_def_property(srna, "object_align_factor", PROP_FLOAT, PROP_VELOCITY);
3063 RNA_def_property_float_sdna(prop, NULL, "ob_vel");
3064 RNA_def_property_array(prop, 3);
3065 RNA_def_property_range(prop, -200.0f, 200.0f);
3066 RNA_def_property_ui_range(prop, -100, 100, 1, 3);
3067 RNA_def_property_ui_text(
3068 prop,
3069 "Object Aligned",
3070 "Let the emitter object orientation give the particle a starting velocity");
3071 RNA_def_property_update(prop, 0, "rna_Particle_reset");
3072
3073 prop = RNA_def_property(srna, "angular_velocity_factor", PROP_FLOAT, PROP_NONE);
3074 RNA_def_property_float_sdna(prop, NULL, "avefac");
3075 RNA_def_property_range(prop, -200.0f, 200.0f);
3076 RNA_def_property_ui_range(prop, -100, 100, 10, 3);
3077 RNA_def_property_ui_text(
3078 prop, "Angular Velocity", "Angular velocity amount (in radians per second)");
3079 RNA_def_property_update(prop, 0, "rna_Particle_reset");
3080
3081 prop = RNA_def_property(srna, "phase_factor", PROP_FLOAT, PROP_NONE);
3082 RNA_def_property_float_sdna(prop, NULL, "phasefac");
3083 RNA_def_property_range(prop, -1.0f, 1.0f);
3084 RNA_def_property_ui_text(prop, "Phase", "Rotation around the chosen orientation axis");
3085 RNA_def_property_update(prop, 0, "rna_Particle_reset");
3086
3087 prop = RNA_def_property(srna, "rotation_factor_random", PROP_FLOAT, PROP_FACTOR);
3088 RNA_def_property_float_sdna(prop, NULL, "randrotfac");
3089 RNA_def_property_range(prop, 0.0f, 1.0f);
3090 RNA_def_property_ui_text(prop, "Random Orientation", "Randomize particle orientation");
3091 RNA_def_property_update(prop, 0, "rna_Particle_reset");
3092
3093 prop = RNA_def_property(srna, "phase_factor_random", PROP_FLOAT, PROP_FACTOR);
3094 RNA_def_property_float_sdna(prop, NULL, "randphasefac");
3095 RNA_def_property_range(prop, 0.0f, 2.0f);
3096 RNA_def_property_ui_text(
3097 prop, "Random Phase", "Randomize rotation around the chosen orientation axis");
3098 RNA_def_property_update(prop, 0, "rna_Particle_reset");
3099
3100 prop = RNA_def_property(srna, "hair_length", PROP_FLOAT, PROP_DISTANCE);
3101 RNA_def_property_float_funcs(
3102 prop, "rna_PartSetting_hairlength_get", "rna_PartSetting_hairlength_set", NULL);
3103 RNA_def_property_range(prop, 0.0f, 1000.0f);
3104 RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1, 3);
3105 RNA_def_property_ui_text(prop, "Hair Length", "Length of the hair");
3106 RNA_def_property_update(prop, 0, "rna_Particle_reset");
3107
3108 /* physical properties */
3109 prop = RNA_def_property(srna, "mass", PROP_FLOAT, PROP_UNIT_MASS);
3110 RNA_def_property_range(prop, 0.00000001f, 100000.0f);
3111 RNA_def_property_ui_range(prop, 0.01, 100, 1, 4);
3112 RNA_def_property_ui_text(prop, "Mass", "Mass of the particles");
3113 RNA_def_property_update(prop, 0, "rna_Particle_reset");
3114
3115 prop = RNA_def_property(srna, "particle_size", PROP_FLOAT, PROP_NONE);
3116 RNA_def_property_float_sdna(prop, NULL, "size");
3117 RNA_def_property_range(prop, 0.001f, 100000.0f);
3118 RNA_def_property_ui_range(prop, 0.01, 100, 1, 3);
3119 RNA_def_property_ui_text(prop, "Size", "The size of the particles");
3120 RNA_def_property_update(prop, 0, "rna_Particle_reset");
3121
3122 prop = RNA_def_property(srna, "size_random", PROP_FLOAT, PROP_FACTOR);
3123 RNA_def_property_float_sdna(prop, NULL, "randsize");
3124 RNA_def_property_range(prop, 0.0f, 1.0f);
3125 RNA_def_property_ui_text(prop, "Random Size", "Give the particle size a random variation");
3126 RNA_def_property_update(prop, 0, "rna_Particle_reset");
3127
3128 prop = RNA_def_property(srna, "collision_collection", PROP_POINTER, PROP_NONE);
3129 RNA_def_property_struct_type(prop, "Collection");
3130 RNA_def_property_pointer_sdna(prop, NULL, "collision_group");
3131 RNA_def_property_flag(prop, PROP_EDITABLE);
3132 RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
3133 RNA_def_property_ui_text(prop, "Collision Collection", "Limit colliders to this collection");
3134 RNA_def_property_update(prop, 0, "rna_Particle_reset_dependency");
3135
3136 /* global physical properties */
3137 prop = RNA_def_property(srna, "drag_factor", PROP_FLOAT, PROP_FACTOR);
3138 RNA_def_property_float_sdna(prop, NULL, "dragfac");
3139 RNA_def_property_range(prop, 0.0f, 1.0f);
3140 RNA_def_property_ui_text(prop, "Drag", "Amount of air-drag");
3141 RNA_def_property_update(prop, 0, "rna_Particle_reset");
3142
3143 prop = RNA_def_property(srna, "brownian_factor", PROP_FLOAT, PROP_NONE);
3144 RNA_def_property_float_sdna(prop, NULL, "brownfac");
3145 RNA_def_property_range(prop, 0.0f, 200.0f);
3146 RNA_def_property_ui_range(prop, 0, 20, 1, 3);
3147 RNA_def_property_ui_text(prop, "Brownian", "Amount of random, erratic particle movement");
3148 RNA_def_property_update(prop, 0, "rna_Particle_reset");
3149
3150 prop = RNA_def_property(srna, "damping", PROP_FLOAT, PROP_FACTOR);
3151 RNA_def_property_float_sdna(prop, NULL, "dampfac");
3152 RNA_def_property_range(prop, 0.0f, 1.0f);
3153 RNA_def_property_ui_text(prop, "Damp", "Amount of damping");
3154 RNA_def_property_update(prop, 0, "rna_Particle_reset");
3155
3156 /* random length */
3157 prop = RNA_def_property(srna, "length_random", PROP_FLOAT, PROP_FACTOR);
3158 RNA_def_property_float_sdna(prop, NULL, "randlength");
3159 RNA_def_property_range(prop, 0.0f, 1.0f);
3160 RNA_def_property_ui_text(prop, "Random Length", "Give path length a random variation");
3161 RNA_def_property_update(prop, 0, "rna_Particle_redo");
3162
3163 /* children */
3164 prop = RNA_def_property(srna, "child_nbr", PROP_INT, PROP_NONE);
3165 RNA_def_property_int_sdna(prop, NULL, "child_nbr"); /*optional if prop names are the same */
3166 RNA_def_property_range(prop, 0, 100000);
3167 RNA_def_property_ui_range(prop, 0, 1000, 1, -1);
3168 RNA_def_property_ui_text(prop, "Children Per Parent", "Number of children/parent");
3169 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
3170
3171 prop = RNA_def_property(srna, "rendered_child_count", PROP_INT, PROP_NONE);
3172 RNA_def_property_int_sdna(prop, NULL, "ren_child_nbr");
3173 RNA_def_property_range(prop, 0, 100000);
3174 RNA_def_property_ui_range(prop, 0, 10000, 1, -1);
3175 RNA_def_property_ui_text(prop, "Rendered Children", "Number of children/parent for rendering");
3176
3177 prop = RNA_def_property(srna, "virtual_parents", PROP_FLOAT, PROP_FACTOR);
3178 RNA_def_property_float_sdna(prop, NULL, "parents");
3179 RNA_def_property_range(prop, 0.0f, 1.0f);
3180 RNA_def_property_ui_text(prop, "Virtual Parents", "Relative amount of virtual parents");
3181 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
3182
3183 prop = RNA_def_property(srna, "child_size", PROP_FLOAT, PROP_NONE);
3184 RNA_def_property_float_sdna(prop, NULL, "childsize");
3185 RNA_def_property_range(prop, 0.001f, 100000.0f);
3186 RNA_def_property_ui_range(prop, 0.01f, 100.0f, 0.1, 3);
3187 RNA_def_property_ui_text(prop, "Child Size", "A multiplier for the child particle size");
3188 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
3189
3190 prop = RNA_def_property(srna, "child_size_random", PROP_FLOAT, PROP_FACTOR);
3191 RNA_def_property_float_sdna(prop, NULL, "childrandsize");
3192 RNA_def_property_range(prop, 0.0f, 1.0f);
3193 RNA_def_property_ui_text(
3194 prop, "Random Child Size", "Random variation to the size of the child particles");
3195 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
3196
3197 prop = RNA_def_property(srna, "child_radius", PROP_FLOAT, PROP_DISTANCE);
3198 RNA_def_property_float_sdna(prop, NULL, "childrad");
3199 RNA_def_property_range(prop, 0.0f, 100000.0f);
3200 RNA_def_property_ui_range(prop, 0.0f, 10.0f, 0.1, 3);
3201 RNA_def_property_ui_text(prop, "Child Radius", "Radius of children around parent");
3202 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
3203
3204 prop = RNA_def_property(srna, "child_roundness", PROP_FLOAT, PROP_FACTOR);
3205 RNA_def_property_float_sdna(prop, NULL, "childflat");
3206 RNA_def_property_range(prop, 0.0f, 1.0f);
3207 RNA_def_property_ui_text(prop, "Child Roundness", "Roundness of children around parent");
3208 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
3209
3210 /* clumping */
3211 prop = RNA_def_property(srna, "clump_factor", PROP_FLOAT, PROP_NONE);
3212 RNA_def_property_float_sdna(prop, NULL, "clumpfac");
3213 RNA_def_property_range(prop, -1.0f, 1.0f);
3214 RNA_def_property_ui_text(prop, "Clump", "Amount of clumping");
3215 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
3216
3217 prop = RNA_def_property(srna, "clump_shape", PROP_FLOAT, PROP_NONE);
3218 RNA_def_property_float_sdna(prop, NULL, "clumppow");
3219 RNA_def_property_range(prop, -0.999f, 0.999f);
3220 RNA_def_property_ui_text(prop, "Shape", "Shape of clumping");
3221 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
3222
3223 prop = RNA_def_property(srna, "use_clump_curve", PROP_BOOLEAN, PROP_NONE);
3224 RNA_def_property_boolean_sdna(prop, NULL, "child_flag", PART_CHILD_USE_CLUMP_CURVE);
3225 RNA_def_property_ui_text(prop, "Use Clump Curve", "Use a curve to define clump tapering");
3226 RNA_def_property_update(prop, 0, "rna_ParticleSettings_use_clump_curve_update");
3227
3228 prop = RNA_def_property(srna, "clump_curve", PROP_POINTER, PROP_NONE);
3229 RNA_def_property_pointer_sdna(prop, NULL, "clumpcurve");
3230 RNA_def_property_struct_type(prop, "CurveMapping");
3231 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
3232 RNA_def_property_ui_text(prop, "Clump Curve", "Curve defining clump tapering");
3233 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
3234
3235 prop = RNA_def_property(srna, "use_clump_noise", PROP_BOOLEAN, PROP_NONE);
3236 RNA_def_property_boolean_sdna(prop, NULL, "child_flag", PART_CHILD_USE_CLUMP_NOISE);
3237 RNA_def_property_ui_text(prop, "Use Clump Noise", "Create random clumps around the parent");
3238 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
3239
3240 prop = RNA_def_property(srna, "clump_noise_size", PROP_FLOAT, PROP_NONE);
3241 RNA_def_property_float_sdna(prop, NULL, "clump_noise_size");
3242 RNA_def_property_range(prop, 0.00001f, 100000.0f);
3243 RNA_def_property_ui_range(prop, 0.01f, 10.0f, 0.1f, 3);
3244 RNA_def_property_ui_text(prop, "Clump Noise Size", "Size of clump noise");
3245 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
3246
3247 /* kink */
3248 prop = RNA_def_property(srna, "kink_amplitude", PROP_FLOAT, PROP_DISTANCE);
3249 RNA_def_property_float_sdna(prop, NULL, "kink_amp");
3250 RNA_def_property_range(prop, -100000.0f, 100000.0f);
3251 RNA_def_property_ui_range(prop, -10.0f, 10.0f, 0.1, 3);
3252 RNA_def_property_ui_text(prop, "Amplitude", "The amplitude of the offset");
3253 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
3254
3255 prop = RNA_def_property(srna, "kink_amplitude_clump", PROP_FLOAT, PROP_FACTOR);
3256 RNA_def_property_float_sdna(prop, NULL, "kink_amp_clump");
3257 RNA_def_property_range(prop, 0.0f, 1.0f);
3258 RNA_def_property_ui_text(prop, "Amplitude Clump", "How much clump affects kink amplitude");
3259 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
3260
3261 prop = RNA_def_property(srna, "kink_amplitude_random", PROP_FLOAT, PROP_FACTOR);
3262 RNA_def_property_float_sdna(prop, NULL, "kink_amp_random");
3263 RNA_def_property_range(prop, 0.0f, 1.0f);
3264 RNA_def_property_ui_text(prop, "Amplitude Random", "Random variation of the amplitude");
3265 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
3266
3267 prop = RNA_def_property(srna, "kink_frequency", PROP_FLOAT, PROP_NONE);
3268 RNA_def_property_float_sdna(prop, NULL, "kink_freq");
3269 RNA_def_property_range(prop, -100000.0f, 100000.0f);
3270 RNA_def_property_ui_range(prop, -10.0f, 10.0f, 0.1, 3);
3271 RNA_def_property_ui_text(prop, "Frequency", "The frequency of the offset (1/total length)");
3272 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
3273
3274 prop = RNA_def_property(srna, "kink_shape", PROP_FLOAT, PROP_NONE);
3275 RNA_def_property_range(prop, -0.999f, 0.999f);
3276 RNA_def_property_ui_text(prop, "Shape", "Adjust the offset to the beginning/end");
3277 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
3278
3279 prop = RNA_def_property(srna, "kink_flat", PROP_FLOAT, PROP_FACTOR);
3280 RNA_def_property_range(prop, 0.0f, 1.0f);
3281 RNA_def_property_ui_text(prop, "Flatness", "How flat the hairs are");
3282 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
3283
3284 prop = RNA_def_property(srna, "kink_extra_steps", PROP_INT, PROP_NONE);
3285 RNA_def_property_range(prop, 1, INT_MAX);
3286 RNA_def_property_ui_range(prop, 1, 100, 1, -1);
3287 RNA_def_property_ui_text(
3288 prop, "Extra Steps", "Extra steps for resolution of special kink features");
3289 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
3290
3291 prop = RNA_def_property(srna, "kink_axis_random", PROP_FLOAT, PROP_FACTOR);
3292 RNA_def_property_range(prop, 0.0f, 1.0f);
3293 RNA_def_property_ui_text(prop, "Axis Random", "Random variation of the orientation");
3294 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
3295
3296 /* rough */
3297 prop = RNA_def_property(srna, "roughness_1", PROP_FLOAT, PROP_NONE);
3298 RNA_def_property_float_sdna(prop, NULL, "rough1");
3299 RNA_def_property_range(prop, 0.0f, 100000.0f);
3300 RNA_def_property_ui_range(prop, 0.0f, 10.0f, 0.1, 3);
3301 RNA_def_property_ui_text(prop, "Rough1", "Amount of location dependent rough");
3302 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
3303
3304 prop = RNA_def_property(srna, "roughness_1_size", PROP_FLOAT, PROP_NONE);
3305 RNA_def_property_float_sdna(prop, NULL, "rough1_size");
3306 RNA_def_property_range(prop, 0.01f, 100000.0f);
3307 RNA_def_property_ui_range(prop, 0.01f, 10.0f, 0.1, 3);
3308 RNA_def_property_ui_text(prop, "Size1", "Size of location dependent rough");
3309 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
3310
3311 prop = RNA_def_property(srna, "roughness_2", PROP_FLOAT, PROP_NONE);
3312 RNA_def_property_float_sdna(prop, NULL, "rough2");
3313 RNA_def_property_range(prop, 0.0f, 100000.0f);
3314 RNA_def_property_ui_range(prop, 0.0f, 10.0f, 0.1, 3);
3315 RNA_def_property_ui_text(prop, "Rough2", "Amount of random rough");
3316 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
3317
3318 prop = RNA_def_property(srna, "roughness_2_size", PROP_FLOAT, PROP_NONE);
3319 RNA_def_property_float_sdna(prop, NULL, "rough2_size");
3320 RNA_def_property_range(prop, 0.01f, 100000.0f);
3321 RNA_def_property_ui_range(prop, 0.01f, 10.0f, 0.1, 3);
3322 RNA_def_property_ui_text(prop, "Size2", "Size of random rough");
3323 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
3324
3325 prop = RNA_def_property(srna, "roughness_2_threshold", PROP_FLOAT, PROP_FACTOR);
3326 RNA_def_property_float_sdna(prop, NULL, "rough2_thres");
3327 RNA_def_property_range(prop, 0.0f, 1.0f);
3328 RNA_def_property_ui_text(
3329 prop, "Threshold", "Amount of particles left untouched by random rough");
3330 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
3331
3332 prop = RNA_def_property(srna, "roughness_endpoint", PROP_FLOAT, PROP_NONE);
3333 RNA_def_property_float_sdna(prop, NULL, "rough_end");
3334 RNA_def_property_range(prop, 0.0f, 100000.0f);
3335 RNA_def_property_ui_range(prop, 0.0f, 10.0f, 0.1, 3);
3336 RNA_def_property_ui_text(prop, "Rough Endpoint", "Amount of end point rough");
3337 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
3338
3339 prop = RNA_def_property(srna, "roughness_end_shape", PROP_FLOAT, PROP_NONE);
3340 RNA_def_property_float_sdna(prop, NULL, "rough_end_shape");
3341 RNA_def_property_range(prop, 0.0f, 10.0f);
3342 RNA_def_property_ui_text(prop, "Shape", "Shape of end point rough");
3343 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
3344
3345 prop = RNA_def_property(srna, "use_roughness_curve", PROP_BOOLEAN, PROP_NONE);
3346 RNA_def_property_boolean_sdna(prop, NULL, "child_flag", PART_CHILD_USE_ROUGH_CURVE);
3347 RNA_def_property_ui_text(prop, "Use Roughness Curve", "Use a curve to define roughness");
3348 RNA_def_property_update(prop, 0, "rna_ParticleSettings_use_roughness_curve_update");
3349
3350 prop = RNA_def_property(srna, "roughness_curve", PROP_POINTER, PROP_NONE);
3351 RNA_def_property_pointer_sdna(prop, NULL, "roughcurve");
3352 RNA_def_property_struct_type(prop, "CurveMapping");
3353 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
3354 RNA_def_property_ui_text(prop, "Roughness Curve", "Curve defining roughness");
3355 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
3356
3357 prop = RNA_def_property(srna, "child_length", PROP_FLOAT, PROP_FACTOR);
3358 RNA_def_property_float_sdna(prop, NULL, "clength");
3359 RNA_def_property_range(prop, 0.0f, 1.0f);
3360 RNA_def_property_ui_text(prop, "Length", "Length of child paths");
3361 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
3362
3363 prop = RNA_def_property(srna, "child_length_threshold", PROP_FLOAT, PROP_FACTOR);
3364 RNA_def_property_float_sdna(prop, NULL, "clength_thres");
3365 RNA_def_property_range(prop, 0.0f, 1.0f);
3366 RNA_def_property_ui_text(
3367 prop, "Threshold", "Amount of particles left untouched by child path length");
3368 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
3369
3370 /* parting */
3371 prop = RNA_def_property(srna, "child_parting_factor", PROP_FLOAT, PROP_FACTOR);
3372 RNA_def_property_float_sdna(prop, NULL, "parting_fac");
3373 RNA_def_property_range(prop, 0.0f, 1.0f);
3374 RNA_def_property_ui_text(
3375 prop, "Parting Factor", "Create parting in the children based on parent strands");
3376 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
3377
3378 prop = RNA_def_property(srna, "child_parting_min", PROP_FLOAT, PROP_NONE);
3379 RNA_def_property_float_sdna(prop, NULL, "parting_min");
3380 RNA_def_property_range(prop, 0.0f, 180.0f);
3381 RNA_def_property_ui_text(prop,
3382 "Parting Minimum",
3383 "Minimum root to tip angle (tip distance/root distance for long hair)");
3384 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
3385
3386 prop = RNA_def_property(srna, "child_parting_max", PROP_FLOAT, PROP_NONE);
3387 RNA_def_property_float_sdna(prop, NULL, "parting_max");
3388 RNA_def_property_range(prop, 0.0f, 180.0f);
3389 RNA_def_property_ui_text(prop,
3390 "Parting Maximum",
3391 "Maximum root to tip angle (tip distance/root distance for long hair)");
3392 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
3393
3394 /* branching */
3395 prop = RNA_def_property(srna, "branch_threshold", PROP_FLOAT, PROP_FACTOR);
3396 RNA_def_property_float_sdna(prop, NULL, "branch_thres");
3397 RNA_def_property_range(prop, 0.0f, 1.0f);
3398 RNA_def_property_ui_text(prop, "Threshold", "Threshold of branching");
3399 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
3400
3401 /* drawing stuff */
3402 prop = RNA_def_property(srna, "line_length_tail", PROP_FLOAT, PROP_NONE);
3403 RNA_def_property_float_funcs(
3404 prop, "rna_PartSetting_linelentail_get", "rna_PartSetting_linelentail_set", NULL);
3405 RNA_def_property_range(prop, 0.0f, 100000.0f);
3406 RNA_def_property_ui_range(prop, 0.0f, 10.0f, 0.1, 3);
3407 RNA_def_property_ui_text(prop, "Tail", "Length of the line's tail");
3408 RNA_def_property_update(prop, 0, "rna_Particle_redo");
3409
3410 prop = RNA_def_property(srna, "line_length_head", PROP_FLOAT, PROP_NONE);
3411 RNA_def_property_float_funcs(
3412 prop, "rna_PartSetting_linelenhead_get", "rna_PartSetting_linelenhead_set", NULL);
3413 RNA_def_property_range(prop, 0.0f, 100000.0f);
3414 RNA_def_property_ui_range(prop, 0.0f, 10.0f, 0.1, 3);
3415 RNA_def_property_ui_text(prop, "Head", "Length of the line's head");
3416 RNA_def_property_update(prop, 0, "rna_Particle_redo");
3417
3418 prop = RNA_def_property(srna, "path_start", PROP_FLOAT, PROP_NONE);
3419 RNA_def_property_float_sdna(prop, NULL, "path_start");
3420 RNA_def_property_float_funcs(prop, NULL, NULL, "rna_PartSetting_pathstartend_range");
3421 RNA_def_property_ui_text(prop, "Path Start", "Starting time of drawn path");
3422 RNA_def_property_update(prop, 0, "rna_Particle_redo");
3423
3424 prop = RNA_def_property(srna, "path_end", PROP_FLOAT, PROP_NONE);
3425 RNA_def_property_float_sdna(prop, NULL, "path_end");
3426 RNA_def_property_float_funcs(prop, NULL, NULL, "rna_PartSetting_pathstartend_range");
3427 RNA_def_property_ui_text(prop, "Path End", "End time of drawn path");
3428 RNA_def_property_update(prop, 0, "rna_Particle_redo");
3429
3430 prop = RNA_def_property(srna, "trail_count", PROP_INT, PROP_NONE);
3431 RNA_def_property_int_sdna(prop, NULL, "trail_count");
3432 RNA_def_property_range(prop, 1, 100000);
3433 RNA_def_property_ui_range(prop, 1, 100, 1, -1);
3434 RNA_def_property_ui_text(prop, "Trail Count", "Number of trail particles");
3435 RNA_def_property_update(prop, 0, "rna_Particle_redo");
3436
3437 /* keyed particles */
3438 prop = RNA_def_property(srna, "keyed_loops", PROP_INT, PROP_NONE);
3439 RNA_def_property_int_sdna(prop, NULL, "keyed_loops");
3440 RNA_def_property_range(prop, 1.0f, 10000.0f);
3441 RNA_def_property_ui_range(prop, 1.0f, 100.0f, 1, 3);
3442 RNA_def_property_ui_text(prop, "Loop Count", "Number of times the keys are looped");
3443 RNA_def_property_update(prop, 0, "rna_Particle_redo");
3444
3445 /* modified dm support */
3446 prop = RNA_def_property(srna, "use_modifier_stack", PROP_BOOLEAN, PROP_NONE);
3447 RNA_def_property_boolean_sdna(prop, NULL, "use_modifier_stack", 0);
3448 RNA_def_property_ui_text(
3449 prop,
3450 "Use Modifier Stack",
3451 "Emit particles from mesh with modifiers applied "
3452 "(must use same subdivision surface level for viewport and render for correct results)");
3453 RNA_def_property_update(prop, 0, "rna_Particle_change_type");
3454
3455 /* draw objects & collections */
3456 prop = RNA_def_property(srna, "instance_collection", PROP_POINTER, PROP_NONE);
3457 RNA_def_property_pointer_sdna(prop, NULL, "instance_collection");
3458 RNA_def_property_struct_type(prop, "Collection");
3459 RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT);
3460 RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
3461 RNA_def_property_ui_text(
3462 prop, "Dupli Collection", "Show Objects in this collection in place of particles");
3463 RNA_def_property_update(prop, 0, "rna_Particle_redo_count");
3464
3465 prop = RNA_def_property(srna, "instance_weights", PROP_COLLECTION, PROP_NONE);
3466 RNA_def_property_collection_sdna(prop, NULL, "instance_weights", NULL);
3467 RNA_def_property_struct_type(prop, "ParticleDupliWeight");
3468 RNA_def_property_ui_text(
3469 prop, "Dupli Collection Weights", "Weights for all of the objects in the dupli collection");
3470
3471 prop = RNA_def_property(srna, "active_instanceweight", PROP_POINTER, PROP_NONE);
3472 RNA_def_property_struct_type(prop, "ParticleDupliWeight");
3473 RNA_def_property_pointer_funcs(prop, "rna_ParticleDupliWeight_active_get", NULL, NULL, NULL);
3474 RNA_def_property_ui_text(prop, "Active Dupli Object", "");
3475
3476 prop = RNA_def_property(srna, "active_instanceweight_index", PROP_INT, PROP_UNSIGNED);
3477 RNA_def_property_int_funcs(prop,
3478 "rna_ParticleDupliWeight_active_index_get",
3479 "rna_ParticleDupliWeight_active_index_set",
3480 "rna_ParticleDupliWeight_active_index_range");
3481 RNA_def_property_ui_text(prop, "Active Dupli Object Index", "");
3482
3483 prop = RNA_def_property(srna, "instance_object", PROP_POINTER, PROP_NONE);
3484 RNA_def_property_struct_type(prop, "Object");
3485 RNA_def_property_flag(prop, PROP_EDITABLE);
3486 RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
3487 RNA_def_property_ui_text(prop, "Instance Object", "Show this Object in place of particles");
3488 RNA_def_property_update(prop, 0, "rna_Particle_redo_dependency");
3489
3490 /* boids */
3491 prop = RNA_def_property(srna, "boids", PROP_POINTER, PROP_NONE);
3492 RNA_def_property_struct_type(prop, "BoidSettings");
3493 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
3494 RNA_def_property_ui_text(prop, "Boid Settings", "");
3495
3496 /* Fluid particles */
3497 prop = RNA_def_property(srna, "fluid", PROP_POINTER, PROP_NONE);
3498 RNA_def_property_struct_type(prop, "SPHFluidSettings");
3499 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
3500 RNA_def_property_ui_text(prop, "SPH Fluid Settings", "");
3501
3502 /* Effector weights */
3503 prop = RNA_def_property(srna, "effector_weights", PROP_POINTER, PROP_NONE);
3504 RNA_def_property_struct_type(prop, "EffectorWeights");
3505 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
3506 RNA_def_property_ui_text(prop, "Effector Weights", "");
3507
3508 /* animation here? */
3509 rna_def_animdata_common(srna);
3510
3511 prop = RNA_def_property(srna, "force_field_1", PROP_POINTER, PROP_NONE);
3512 RNA_def_property_pointer_sdna(prop, NULL, "pd");
3513 RNA_def_property_struct_type(prop, "FieldSettings");
3514 RNA_def_property_pointer_funcs(prop, "rna_Particle_field1_get", NULL, NULL, NULL);
3515 RNA_def_property_ui_text(prop, "Force Field 1", "");
3516
3517 prop = RNA_def_property(srna, "force_field_2", PROP_POINTER, PROP_NONE);
3518 RNA_def_property_pointer_sdna(prop, NULL, "pd2");
3519 RNA_def_property_struct_type(prop, "FieldSettings");
3520 RNA_def_property_pointer_funcs(prop, "rna_Particle_field2_get", NULL, NULL, NULL);
3521 RNA_def_property_ui_text(prop, "Force Field 2", "");
3522
3523 /* twist */
3524 prop = RNA_def_property(srna, "twist", PROP_FLOAT, PROP_NONE);
3525 RNA_def_property_range(prop, -100000.0f, 100000.0f);
3526 RNA_def_property_ui_range(prop, -10.0f, 10.0f, 0.1, 3);
3527 RNA_def_property_ui_text(prop, "Twist", "Number of turns around parent along the strand");
3528 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
3529
3530 prop = RNA_def_property(srna, "use_twist_curve", PROP_BOOLEAN, PROP_NONE);
3531 RNA_def_property_boolean_sdna(prop, NULL, "child_flag", PART_CHILD_USE_TWIST_CURVE);
3532 RNA_def_property_ui_text(prop, "Use Twist Curve", "Use a curve to define twist");
3533 RNA_def_property_update(prop, 0, "rna_ParticleSettings_use_twist_curve_update");
3534
3535 prop = RNA_def_property(srna, "twist_curve", PROP_POINTER, PROP_NONE);
3536 RNA_def_property_pointer_sdna(prop, NULL, "twistcurve");
3537 RNA_def_property_struct_type(prop, "CurveMapping");
3538 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
3539 RNA_def_property_ui_text(prop, "Twist Curve", "Curve defining twist");
3540 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
3541
3542 /* hair shape */
3543 prop = RNA_def_property(srna, "use_close_tip", PROP_BOOLEAN, PROP_NONE);
3544 RNA_def_property_boolean_sdna(prop, NULL, "shape_flag", PART_SHAPE_CLOSE_TIP);
3545 RNA_def_property_ui_text(prop, "Close Tip", "Set tip radius to zero");
3546 RNA_def_property_update(
3547 prop, 0, "rna_Particle_redo"); /* TODO: Only need to tell the render engine to update. */
3548
3549 prop = RNA_def_property(srna, "shape", PROP_FLOAT, PROP_FACTOR);
3550 RNA_def_property_range(prop, -1.0f, 1.0f);
3551 RNA_def_property_ui_text(prop, "Shape", "Strand shape parameter");
3552 RNA_def_property_update(
3553 prop, 0, "rna_Particle_redo"); /* TODO: Only need to tell the render engine to update. */
3554
3555 prop = RNA_def_property(srna, "root_radius", PROP_FLOAT, PROP_DISTANCE);
3556 RNA_def_property_float_sdna(prop, NULL, "rad_root");
3557 RNA_def_property_range(prop, 0.0f, FLT_MAX);
3558 RNA_def_property_ui_range(prop, 0.0f, 10.0f, 0.1, 2);
3559 RNA_def_property_ui_text(prop, "Root Diameter", "Strand diameter width at the root");
3560 RNA_def_property_update(
3561 prop, 0, "rna_Particle_redo"); /* TODO: Only need to tell the render engine to update. */
3562
3563 prop = RNA_def_property(srna, "tip_radius", PROP_FLOAT, PROP_DISTANCE);
3564 RNA_def_property_float_sdna(prop, NULL, "rad_tip");
3565 RNA_def_property_range(prop, 0.0f, FLT_MAX);
3566 RNA_def_property_ui_range(prop, 0.0f, 10.0f, 0.1, 2);
3567 RNA_def_property_ui_text(prop, "Tip Diameter", "Strand diameter width at the tip");
3568 RNA_def_property_update(
3569 prop, 0, "rna_Particle_redo"); /* TODO: Only need to tell the render engine to update. */
3570
3571 prop = RNA_def_property(srna, "radius_scale", PROP_FLOAT, PROP_NONE);
3572 RNA_def_property_float_sdna(prop, NULL, "rad_scale");
3573 RNA_def_property_range(prop, 0.0f, FLT_MAX);
3574 RNA_def_property_ui_range(prop, 0.0f, 10.0f, 0.1, 2);
3575 RNA_def_property_ui_text(prop, "Diameter Scale", "Multiplier of diameter properties");
3576 RNA_def_property_update(
3577 prop, 0, "rna_Particle_redo"); /* TODO: Only need to tell the render engine to update. */
3578 }
3579
rna_def_particle_target(BlenderRNA * brna)3580 static void rna_def_particle_target(BlenderRNA *brna)
3581 {
3582 StructRNA *srna;
3583 PropertyRNA *prop;
3584
3585 static const EnumPropertyItem mode_items[] = {
3586 {PTARGET_MODE_FRIEND, "FRIEND", 0, "Friend", ""},
3587 {PTARGET_MODE_NEUTRAL, "NEUTRAL", 0, "Neutral", ""},
3588 {PTARGET_MODE_ENEMY, "ENEMY", 0, "Enemy", ""},
3589 {0, NULL, 0, NULL, NULL},
3590 };
3591
3592 srna = RNA_def_struct(brna, "ParticleTarget", NULL);
3593 RNA_def_struct_ui_text(srna, "Particle Target", "Target particle system");
3594
3595 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
3596 RNA_def_property_string_funcs(
3597 prop, "rna_ParticleTarget_name_get", "rna_ParticleTarget_name_length", NULL);
3598 RNA_def_property_ui_text(prop, "Name", "Particle target name");
3599 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
3600 RNA_def_struct_name_property(srna, prop);
3601
3602 prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
3603 RNA_def_property_pointer_sdna(prop, NULL, "ob");
3604 RNA_def_property_flag(prop, PROP_EDITABLE);
3605 RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
3606 RNA_def_property_ui_text(
3607 prop,
3608 "Target Object",
3609 "The object that has the target particle system (empty if same object)");
3610 RNA_def_property_update(prop, 0, "rna_Particle_target_reset");
3611
3612 prop = RNA_def_property(srna, "system", PROP_INT, PROP_UNSIGNED);
3613 RNA_def_property_int_sdna(prop, NULL, "psys");
3614 RNA_def_property_range(prop, 1, INT_MAX);
3615 RNA_def_property_ui_text(
3616 prop, "Target Particle System", "The index of particle system on the target object");
3617 RNA_def_property_update(prop, 0, "rna_Particle_target_reset");
3618
3619 prop = RNA_def_property(srna, "time", PROP_FLOAT, PROP_TIME);
3620 RNA_def_property_float_sdna(prop, NULL, "time");
3621 RNA_def_property_range(prop, 0.0, MAXFRAMEF);
3622 RNA_def_property_ui_text(prop, "Time", "");
3623 RNA_def_property_update(prop, 0, "rna_Particle_target_redo");
3624
3625 prop = RNA_def_property(srna, "duration", PROP_FLOAT, PROP_NONE);
3626 RNA_def_property_float_sdna(prop, NULL, "duration");
3627 RNA_def_property_range(prop, 0.0, MAXFRAMEF);
3628 RNA_def_property_ui_text(prop, "Duration", "");
3629 RNA_def_property_update(prop, 0, "rna_Particle_target_redo");
3630
3631 prop = RNA_def_property(srna, "is_valid", PROP_BOOLEAN, PROP_NONE);
3632 RNA_def_property_boolean_sdna(prop, NULL, "flag", PTARGET_VALID);
3633 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
3634 RNA_def_property_ui_text(prop, "Valid", "Keyed particles target is valid");
3635
3636 prop = RNA_def_property(srna, "alliance", PROP_ENUM, PROP_NONE);
3637 RNA_def_property_enum_sdna(prop, NULL, "mode");
3638 RNA_def_property_enum_items(prop, mode_items);
3639 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
3640 RNA_def_property_ui_text(prop, "Mode", "");
3641 RNA_def_property_update(prop, 0, "rna_Particle_target_reset");
3642 }
rna_def_particle_system(BlenderRNA * brna)3643 static void rna_def_particle_system(BlenderRNA *brna)
3644 {
3645 StructRNA *srna;
3646 PropertyRNA *prop;
3647
3648 FunctionRNA *func;
3649 PropertyRNA *parm;
3650
3651 srna = RNA_def_struct(brna, "ParticleSystem", NULL);
3652 RNA_def_struct_ui_text(srna, "Particle System", "Particle system in an object");
3653 RNA_def_struct_ui_icon(srna, ICON_PARTICLE_DATA);
3654
3655 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
3656 RNA_def_property_ui_text(prop, "Name", "Particle system name");
3657 RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER | NA_RENAME, NULL);
3658 RNA_def_property_string_funcs(prop, NULL, NULL, "rna_ParticleSystem_name_set");
3659 RNA_def_struct_name_property(srna, prop);
3660
3661 /* access to particle settings is redirected through functions */
3662 /* to allow proper id-buttons functionality */
3663 prop = RNA_def_property(srna, "settings", PROP_POINTER, PROP_NONE);
3664 /*RNA_def_property_pointer_sdna(prop, NULL, "part"); */
3665 RNA_def_property_struct_type(prop, "ParticleSettings");
3666 RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_NULL);
3667 RNA_def_property_pointer_funcs(
3668 prop, "rna_particle_settings_get", "rna_particle_settings_set", NULL, NULL);
3669 RNA_def_property_ui_text(prop, "Settings", "Particle system settings");
3670 RNA_def_property_update(prop, 0, "rna_Particle_reset_dependency");
3671
3672 prop = RNA_def_property(srna, "particles", PROP_COLLECTION, PROP_NONE);
3673 RNA_def_property_collection_sdna(prop, NULL, "particles", "totpart");
3674 RNA_def_property_struct_type(prop, "Particle");
3675 RNA_def_property_override_flag(prop, PROPOVERRIDE_NO_COMPARISON);
3676 RNA_def_property_ui_text(prop, "Particles", "Particles generated by the particle system");
3677
3678 prop = RNA_def_property(srna, "child_particles", PROP_COLLECTION, PROP_NONE);
3679 RNA_def_property_collection_sdna(prop, NULL, "child", "totchild");
3680 RNA_def_property_struct_type(prop, "ChildParticle");
3681 RNA_def_property_override_flag(prop, PROPOVERRIDE_NO_COMPARISON);
3682 RNA_def_property_ui_text(
3683 prop, "Child Particles", "Child particles generated by the particle system");
3684
3685 prop = RNA_def_property(srna, "seed", PROP_INT, PROP_UNSIGNED);
3686 RNA_def_property_ui_text(
3687 prop, "Seed", "Offset in the random number table, to get a different randomized result");
3688 RNA_def_property_update(prop, 0, "rna_Particle_reset");
3689
3690 prop = RNA_def_property(srna, "child_seed", PROP_INT, PROP_UNSIGNED);
3691 RNA_def_property_ui_text(
3692 prop,
3693 "Child Seed",
3694 "Offset in the random number table for child particles, to get a different "
3695 "randomized result");
3696 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
3697
3698 /* hair */
3699 prop = RNA_def_property(srna, "is_global_hair", PROP_BOOLEAN, PROP_NONE);
3700 RNA_def_property_boolean_sdna(prop, NULL, "flag", PSYS_GLOBAL_HAIR);
3701 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
3702 RNA_def_property_ui_text(prop, "Global Hair", "Hair keys are in global coordinate space");
3703
3704 prop = RNA_def_property(srna, "use_hair_dynamics", PROP_BOOLEAN, PROP_NONE);
3705 RNA_def_property_boolean_sdna(prop, NULL, "flag", PSYS_HAIR_DYNAMICS);
3706 RNA_def_property_ui_text(prop, "Hair Dynamics", "Enable hair dynamics using cloth simulation");
3707 RNA_def_property_update(prop, 0, "rna_Particle_hair_dynamics_update");
3708
3709 prop = RNA_def_property(srna, "cloth", PROP_POINTER, PROP_NONE);
3710 RNA_def_property_pointer_sdna(prop, NULL, "clmd");
3711 RNA_def_property_struct_type(prop, "ClothModifier");
3712 RNA_def_property_flag(prop, PROP_NEVER_NULL);
3713 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
3714 RNA_def_property_ui_text(prop, "Cloth", "Cloth dynamics for hair");
3715
3716 /* reactor */
3717 prop = RNA_def_property(srna, "reactor_target_object", PROP_POINTER, PROP_NONE);
3718 RNA_def_property_pointer_sdna(prop, NULL, "target_ob");
3719 RNA_def_property_flag(prop, PROP_EDITABLE);
3720 RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
3721 RNA_def_property_ui_text(prop,
3722 "Reactor Target Object",
3723 "For reactor systems, the object that has the target particle system "
3724 "(empty if same object)");
3725 RNA_def_property_update(prop, 0, "rna_Particle_reset");
3726
3727 prop = RNA_def_property(srna, "reactor_target_particle_system", PROP_INT, PROP_UNSIGNED);
3728 RNA_def_property_int_sdna(prop, NULL, "target_psys");
3729 RNA_def_property_range(prop, 1, SHRT_MAX);
3730 RNA_def_property_ui_text(prop,
3731 "Reactor Target Particle System",
3732 "For reactor systems, index of particle system on the target object");
3733 RNA_def_property_update(prop, 0, "rna_Particle_reset");
3734
3735 /* keyed */
3736 prop = RNA_def_property(srna, "use_keyed_timing", PROP_BOOLEAN, PROP_NONE);
3737 RNA_def_property_boolean_sdna(prop, NULL, "flag", PSYS_KEYED_TIMING);
3738 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
3739 RNA_def_property_ui_text(prop, "Keyed Timing", "Use key times");
3740 RNA_def_property_update(prop, 0, "rna_Particle_redo");
3741
3742 prop = RNA_def_property(srna, "targets", PROP_COLLECTION, PROP_NONE);
3743 RNA_def_property_struct_type(prop, "ParticleTarget");
3744 RNA_def_property_ui_text(prop, "Targets", "Target particle systems");
3745
3746 prop = RNA_def_property(srna, "active_particle_target", PROP_POINTER, PROP_NONE);
3747 RNA_def_property_struct_type(prop, "ParticleTarget");
3748 RNA_def_property_pointer_funcs(
3749 prop, "rna_ParticleSystem_active_particle_target_get", NULL, NULL, NULL);
3750 RNA_def_property_ui_text(prop, "Active Particle Target", "");
3751
3752 prop = RNA_def_property(srna, "active_particle_target_index", PROP_INT, PROP_UNSIGNED);
3753 RNA_def_property_int_funcs(prop,
3754 "rna_ParticleSystem_active_particle_target_index_get",
3755 "rna_ParticleSystem_active_particle_target_index_set",
3756 "rna_ParticleSystem_active_particle_target_index_range");
3757 RNA_def_property_ui_text(prop, "Active Particle Target Index", "");
3758
3759 /* vertex groups */
3760
3761 /* note, internally store as ints, access as strings */
3762 # if 0 /* int access. works ok but isn't useful for the UI */
3763 prop = RNA_def_property(srna, "vertex_group_density", PROP_INT, PROP_NONE);
3764 RNA_def_property_int_sdna(prop, NULL, "vgroup[0]");
3765 RNA_def_property_ui_text(prop, "Vertex Group Density", "Vertex group to control density");
3766 RNA_def_property_update(prop, 0, "rna_Particle_reset");
3767 # endif
3768
3769 prop = RNA_def_property(srna, "vertex_group_density", PROP_STRING, PROP_NONE);
3770 RNA_def_property_string_funcs(prop,
3771 "rna_ParticleVGroup_name_get_0",
3772 "rna_ParticleVGroup_name_len_0",
3773 "rna_ParticleVGroup_name_set_0");
3774 RNA_def_property_ui_text(prop, "Vertex Group Density", "Vertex group to control density");
3775 RNA_def_property_update(prop, 0, "rna_Particle_reset");
3776
3777 prop = RNA_def_property(srna, "invert_vertex_group_density", PROP_BOOLEAN, PROP_NONE);
3778 RNA_def_property_boolean_sdna(prop, NULL, "vg_neg", (1 << PSYS_VG_DENSITY));
3779 RNA_def_property_ui_text(
3780 prop, "Vertex Group Density Negate", "Negate the effect of the density vertex group");
3781 RNA_def_property_update(prop, 0, "rna_Particle_reset");
3782
3783 prop = RNA_def_property(srna, "vertex_group_velocity", PROP_STRING, PROP_NONE);
3784 RNA_def_property_string_funcs(prop,
3785 "rna_ParticleVGroup_name_get_1",
3786 "rna_ParticleVGroup_name_len_1",
3787 "rna_ParticleVGroup_name_set_1");
3788 RNA_def_property_ui_text(prop, "Vertex Group Velocity", "Vertex group to control velocity");
3789 RNA_def_property_update(prop, 0, "rna_Particle_reset");
3790
3791 prop = RNA_def_property(srna, "invert_vertex_group_velocity", PROP_BOOLEAN, PROP_NONE);
3792 RNA_def_property_boolean_sdna(prop, NULL, "vg_neg", (1 << PSYS_VG_VEL));
3793 RNA_def_property_ui_text(
3794 prop, "Vertex Group Velocity Negate", "Negate the effect of the velocity vertex group");
3795 RNA_def_property_update(prop, 0, "rna_Particle_reset");
3796
3797 prop = RNA_def_property(srna, "vertex_group_length", PROP_STRING, PROP_NONE);
3798 RNA_def_property_string_funcs(prop,
3799 "rna_ParticleVGroup_name_get_2",
3800 "rna_ParticleVGroup_name_len_2",
3801 "rna_ParticleVGroup_name_set_2");
3802 RNA_def_property_ui_text(prop, "Vertex Group Length", "Vertex group to control length");
3803 RNA_def_property_update(prop, 0, "rna_Particle_redo");
3804
3805 prop = RNA_def_property(srna, "invert_vertex_group_length", PROP_BOOLEAN, PROP_NONE);
3806 RNA_def_property_boolean_sdna(prop, NULL, "vg_neg", (1 << PSYS_VG_LENGTH));
3807 RNA_def_property_ui_text(
3808 prop, "Vertex Group Length Negate", "Negate the effect of the length vertex group");
3809 RNA_def_property_update(prop, 0, "rna_Particle_redo");
3810
3811 prop = RNA_def_property(srna, "vertex_group_clump", PROP_STRING, PROP_NONE);
3812 RNA_def_property_string_funcs(prop,
3813 "rna_ParticleVGroup_name_get_3",
3814 "rna_ParticleVGroup_name_len_3",
3815 "rna_ParticleVGroup_name_set_3");
3816 RNA_def_property_ui_text(prop, "Vertex Group Clump", "Vertex group to control clump");
3817 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
3818
3819 prop = RNA_def_property(srna, "invert_vertex_group_clump", PROP_BOOLEAN, PROP_NONE);
3820 RNA_def_property_boolean_sdna(prop, NULL, "vg_neg", (1 << PSYS_VG_CLUMP));
3821 RNA_def_property_ui_text(
3822 prop, "Vertex Group Clump Negate", "Negate the effect of the clump vertex group");
3823 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
3824
3825 prop = RNA_def_property(srna, "vertex_group_kink", PROP_STRING, PROP_NONE);
3826 RNA_def_property_string_funcs(prop,
3827 "rna_ParticleVGroup_name_get_4",
3828 "rna_ParticleVGroup_name_len_4",
3829 "rna_ParticleVGroup_name_set_4");
3830 RNA_def_property_ui_text(prop, "Vertex Group Kink", "Vertex group to control kink");
3831 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
3832
3833 prop = RNA_def_property(srna, "invert_vertex_group_kink", PROP_BOOLEAN, PROP_NONE);
3834 RNA_def_property_boolean_sdna(prop, NULL, "vg_neg", (1 << PSYS_VG_KINK));
3835 RNA_def_property_ui_text(
3836 prop, "Vertex Group Kink Negate", "Negate the effect of the kink vertex group");
3837 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
3838
3839 prop = RNA_def_property(srna, "vertex_group_roughness_1", PROP_STRING, PROP_NONE);
3840 RNA_def_property_string_funcs(prop,
3841 "rna_ParticleVGroup_name_get_5",
3842 "rna_ParticleVGroup_name_len_5",
3843 "rna_ParticleVGroup_name_set_5");
3844 RNA_def_property_ui_text(
3845 prop, "Vertex Group Roughness 1", "Vertex group to control roughness 1");
3846 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
3847
3848 prop = RNA_def_property(srna, "invert_vertex_group_roughness_1", PROP_BOOLEAN, PROP_NONE);
3849 RNA_def_property_boolean_sdna(prop, NULL, "vg_neg", (1 << PSYS_VG_ROUGH1));
3850 RNA_def_property_ui_text(prop,
3851 "Vertex Group Roughness 1 Negate",
3852 "Negate the effect of the roughness 1 vertex group");
3853 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
3854
3855 prop = RNA_def_property(srna, "vertex_group_roughness_2", PROP_STRING, PROP_NONE);
3856 RNA_def_property_string_funcs(prop,
3857 "rna_ParticleVGroup_name_get_6",
3858 "rna_ParticleVGroup_name_len_6",
3859 "rna_ParticleVGroup_name_set_6");
3860 RNA_def_property_ui_text(
3861 prop, "Vertex Group Roughness 2", "Vertex group to control roughness 2");
3862 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
3863
3864 prop = RNA_def_property(srna, "invert_vertex_group_roughness_2", PROP_BOOLEAN, PROP_NONE);
3865 RNA_def_property_boolean_sdna(prop, NULL, "vg_neg", (1 << PSYS_VG_ROUGH2));
3866 RNA_def_property_ui_text(prop,
3867 "Vertex Group Roughness 2 Negate",
3868 "Negate the effect of the roughness 2 vertex group");
3869 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
3870
3871 prop = RNA_def_property(srna, "vertex_group_roughness_end", PROP_STRING, PROP_NONE);
3872 RNA_def_property_string_funcs(prop,
3873 "rna_ParticleVGroup_name_get_7",
3874 "rna_ParticleVGroup_name_len_7",
3875 "rna_ParticleVGroup_name_set_7");
3876 RNA_def_property_ui_text(
3877 prop, "Vertex Group Roughness End", "Vertex group to control roughness end");
3878 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
3879
3880 prop = RNA_def_property(srna, "invert_vertex_group_roughness_end", PROP_BOOLEAN, PROP_NONE);
3881 RNA_def_property_boolean_sdna(prop, NULL, "vg_neg", (1 << PSYS_VG_ROUGHE));
3882 RNA_def_property_ui_text(prop,
3883 "Vertex Group Roughness End Negate",
3884 "Negate the effect of the roughness end vertex group");
3885 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
3886
3887 prop = RNA_def_property(srna, "vertex_group_size", PROP_STRING, PROP_NONE);
3888 RNA_def_property_string_funcs(prop,
3889 "rna_ParticleVGroup_name_get_8",
3890 "rna_ParticleVGroup_name_len_8",
3891 "rna_ParticleVGroup_name_set_8");
3892 RNA_def_property_ui_text(prop, "Vertex Group Size", "Vertex group to control size");
3893 RNA_def_property_update(prop, 0, "rna_Particle_reset");
3894
3895 prop = RNA_def_property(srna, "invert_vertex_group_size", PROP_BOOLEAN, PROP_NONE);
3896 RNA_def_property_boolean_sdna(prop, NULL, "vg_neg", (1 << PSYS_VG_SIZE));
3897 RNA_def_property_ui_text(
3898 prop, "Vertex Group Size Negate", "Negate the effect of the size vertex group");
3899 RNA_def_property_update(prop, 0, "rna_Particle_reset");
3900
3901 prop = RNA_def_property(srna, "vertex_group_tangent", PROP_STRING, PROP_NONE);
3902 RNA_def_property_string_funcs(prop,
3903 "rna_ParticleVGroup_name_get_9",
3904 "rna_ParticleVGroup_name_len_9",
3905 "rna_ParticleVGroup_name_set_9");
3906 RNA_def_property_ui_text(prop, "Vertex Group Tangent", "Vertex group to control tangent");
3907 RNA_def_property_update(prop, 0, "rna_Particle_reset");
3908
3909 prop = RNA_def_property(srna, "invert_vertex_group_tangent", PROP_BOOLEAN, PROP_NONE);
3910 RNA_def_property_boolean_sdna(prop, NULL, "vg_neg", (1 << PSYS_VG_TAN));
3911 RNA_def_property_ui_text(
3912 prop, "Vertex Group Tangent Negate", "Negate the effect of the tangent vertex group");
3913 RNA_def_property_update(prop, 0, "rna_Particle_reset");
3914
3915 prop = RNA_def_property(srna, "vertex_group_rotation", PROP_STRING, PROP_NONE);
3916 RNA_def_property_string_funcs(prop,
3917 "rna_ParticleVGroup_name_get_10",
3918 "rna_ParticleVGroup_name_len_10",
3919 "rna_ParticleVGroup_name_set_10");
3920 RNA_def_property_ui_text(prop, "Vertex Group Rotation", "Vertex group to control rotation");
3921 RNA_def_property_update(prop, 0, "rna_Particle_reset");
3922
3923 prop = RNA_def_property(srna, "invert_vertex_group_rotation", PROP_BOOLEAN, PROP_NONE);
3924 RNA_def_property_boolean_sdna(prop, NULL, "vg_neg", (1 << PSYS_VG_ROT));
3925 RNA_def_property_ui_text(
3926 prop, "Vertex Group Rotation Negate", "Negate the effect of the rotation vertex group");
3927 RNA_def_property_update(prop, 0, "rna_Particle_reset");
3928
3929 prop = RNA_def_property(srna, "vertex_group_field", PROP_STRING, PROP_NONE);
3930 RNA_def_property_string_funcs(prop,
3931 "rna_ParticleVGroup_name_get_11",
3932 "rna_ParticleVGroup_name_len_11",
3933 "rna_ParticleVGroup_name_set_11");
3934 RNA_def_property_ui_text(prop, "Vertex Group Field", "Vertex group to control field");
3935 RNA_def_property_update(prop, 0, "rna_Particle_reset");
3936
3937 prop = RNA_def_property(srna, "invert_vertex_group_field", PROP_BOOLEAN, PROP_NONE);
3938 RNA_def_property_boolean_sdna(prop, NULL, "vg_neg", (1 << PSYS_VG_EFFECTOR));
3939 RNA_def_property_ui_text(
3940 prop, "Vertex Group Field Negate", "Negate the effect of the field vertex group");
3941 RNA_def_property_update(prop, 0, "rna_Particle_reset");
3942
3943 prop = RNA_def_property(srna, "vertex_group_twist", PROP_STRING, PROP_NONE);
3944 RNA_def_property_string_funcs(prop,
3945 "rna_ParticleVGroup_name_get_12",
3946 "rna_ParticleVGroup_name_len_12",
3947 "rna_ParticleVGroup_name_set_12");
3948 RNA_def_property_ui_text(prop, "Vertex Group Twist", "Vertex group to control twist");
3949 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
3950
3951 prop = RNA_def_property(srna, "invert_vertex_group_twist", PROP_BOOLEAN, PROP_NONE);
3952 RNA_def_property_boolean_sdna(prop, NULL, "vg_neg", (1 << PSYS_VG_TWIST));
3953 RNA_def_property_ui_text(
3954 prop, "Vertex Group Twist Negate", "Negate the effect of the twist vertex group");
3955 RNA_def_property_update(prop, 0, "rna_Particle_redo_child");
3956
3957 /* pointcache */
3958 prop = RNA_def_property(srna, "point_cache", PROP_POINTER, PROP_NONE);
3959 RNA_def_property_flag(prop, PROP_NEVER_NULL);
3960 RNA_def_property_pointer_sdna(prop, NULL, "pointcache");
3961 RNA_def_property_struct_type(prop, "PointCache");
3962 RNA_def_property_ui_text(prop, "Point Cache", "");
3963
3964 prop = RNA_def_property(srna, "has_multiple_caches", PROP_BOOLEAN, PROP_NONE);
3965 RNA_def_property_boolean_funcs(prop, "rna_ParticleSystem_multiple_caches_get", NULL);
3966 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
3967 RNA_def_property_ui_text(prop, "Multiple Caches", "Particle system has multiple point caches");
3968
3969 /* offset ob */
3970 prop = RNA_def_property(srna, "parent", PROP_POINTER, PROP_NONE);
3971 RNA_def_property_pointer_sdna(prop, NULL, "parent");
3972 RNA_def_property_flag(prop, PROP_EDITABLE);
3973 RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
3974 RNA_def_property_ui_text(
3975 prop, "Parent", "Use this object's coordinate system instead of global coordinate system");
3976 RNA_def_property_update(prop, 0, "rna_Particle_redo");
3977
3978 /* hair or cache editing */
3979 prop = RNA_def_property(srna, "is_editable", PROP_BOOLEAN, PROP_NONE);
3980 RNA_def_property_boolean_funcs(prop, "rna_ParticleSystem_editable_get", NULL);
3981 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
3982 RNA_def_property_ui_text(prop, "Editable", "Particle system can be edited in particle mode");
3983
3984 prop = RNA_def_property(srna, "is_edited", PROP_BOOLEAN, PROP_NONE);
3985 RNA_def_property_boolean_funcs(prop, "rna_ParticleSystem_edited_get", NULL);
3986 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
3987 RNA_def_property_ui_text(prop, "Edited", "Particle system has been edited in particle mode");
3988
3989 /* Read-only: this is calculated internally. Changing it would only affect
3990 * the next time-step. The user should change ParticlSettings.subframes or
3991 * ParticleSettings.courant_target instead. */
3992 prop = RNA_def_property(srna, "dt_frac", PROP_FLOAT, PROP_NONE);
3993 RNA_def_property_range(prop, 1.0f / 101.0f, 1.0f);
3994 RNA_def_property_ui_text(
3995 prop, "Timestep", "The current simulation time step size, as a fraction of a frame");
3996 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
3997
3998 RNA_def_struct_path_func(srna, "rna_ParticleSystem_path");
3999
4000 /* extract cached hair location data */
4001 func = RNA_def_function(srna, "co_hair", "rna_ParticleSystem_co_hair");
4002 RNA_def_function_ui_description(func, "Obtain cache hair data");
4003 parm = RNA_def_pointer(func, "object", "Object", "", "Object");
4004 RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
4005 RNA_def_int(func, "particle_no", 0, INT_MIN, INT_MAX, "Particle no", "", INT_MIN, INT_MAX);
4006 RNA_def_int(func, "step", 0, INT_MIN, INT_MAX, "step no", "", INT_MIN, INT_MAX);
4007 parm = RNA_def_float_vector(
4008 func, "co", 3, NULL, -FLT_MAX, FLT_MAX, "Co", "Exported hairkey location", -1e4, 1e4);
4009 RNA_def_parameter_flags(parm, PROP_THICK_WRAP, 0);
4010 RNA_def_function_output(func, parm);
4011
4012 /* extract hair UVs */
4013 func = RNA_def_function(srna, "uv_on_emitter", "rna_ParticleSystem_uv_on_emitter");
4014 RNA_def_function_ui_description(func, "Obtain uv for all particles");
4015 RNA_def_function_flag(func, FUNC_USE_REPORTS);
4016 parm = RNA_def_pointer(func, "modifier", "ParticleSystemModifier", "", "Particle modifier");
4017 RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
4018 prop = RNA_def_pointer(func, "particle", "Particle", "", "Particle");
4019 RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
4020 RNA_def_int(func, "particle_no", 0, INT_MIN, INT_MAX, "Particle no", "", INT_MIN, INT_MAX);
4021 RNA_def_int(func, "uv_no", 0, INT_MIN, INT_MAX, "UV no", "", INT_MIN, INT_MAX);
4022 parm = RNA_def_property(func, "uv", PROP_FLOAT, PROP_COORDS);
4023 RNA_def_property_array(parm, 2);
4024 RNA_def_parameter_flags(parm, PROP_THICK_WRAP, 0);
4025 RNA_def_function_output(func, parm);
4026
4027 /* extract hair mcols */
4028 func = RNA_def_function(srna, "mcol_on_emitter", "rna_ParticleSystem_mcol_on_emitter");
4029 RNA_def_function_flag(func, FUNC_USE_REPORTS);
4030 RNA_def_function_ui_description(func, "Obtain mcol for all particles");
4031 parm = RNA_def_pointer(func, "modifier", "ParticleSystemModifier", "", "Particle modifier");
4032 RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
4033 parm = RNA_def_pointer(func, "particle", "Particle", "", "Particle");
4034 RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
4035 RNA_def_int(func, "particle_no", 0, INT_MIN, INT_MAX, "Particle no", "", INT_MIN, INT_MAX);
4036 RNA_def_int(func, "vcol_no", 0, INT_MIN, INT_MAX, "vcol no", "", INT_MIN, INT_MAX);
4037 parm = RNA_def_property(func, "mcol", PROP_FLOAT, PROP_COLOR);
4038 RNA_def_property_array(parm, 3);
4039 RNA_def_parameter_flags(parm, PROP_THICK_WRAP, 0);
4040 RNA_def_function_output(func, parm);
4041 }
4042
RNA_def_particle(BlenderRNA * brna)4043 void RNA_def_particle(BlenderRNA *brna)
4044 {
4045 rna_def_particle_target(brna);
4046 rna_def_fluid_settings(brna);
4047 rna_def_particle_hair_key(brna);
4048 rna_def_particle_key(brna);
4049
4050 rna_def_child_particle(brna);
4051 rna_def_particle(brna);
4052 rna_def_particle_dupliweight(brna);
4053 rna_def_particle_system(brna);
4054 rna_def_particle_settings_mtex(brna);
4055 rna_def_particle_settings(brna);
4056 }
4057
4058 #endif
4059