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