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