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  */
16 
17 /** \file
18  * \ingroup RNA
19  */
20 
21 #include <limits.h>
22 #include <stdlib.h>
23 
24 #include "BLI_path_util.h"
25 #include "BLI_sys_types.h"
26 #include "BLI_utildefines.h"
27 
28 #include "RNA_define.h"
29 #include "RNA_enum_types.h"
30 
31 #include "rna_internal.h"
32 
33 #include "BKE_fluid.h"
34 #include "BKE_modifier.h"
35 #include "BKE_pointcache.h"
36 
37 #include "DNA_fluid_types.h"
38 #include "DNA_modifier_types.h"
39 #include "DNA_object_force_types.h"
40 #include "DNA_object_types.h"
41 #include "DNA_particle_types.h"
42 #include "DNA_scene_types.h"
43 
44 #include "WM_api.h"
45 #include "WM_types.h"
46 
47 #ifdef RNA_RUNTIME
48 
49 #  include "BLI_math.h"
50 #  include "BLI_threads.h"
51 
52 #  include "BKE_colorband.h"
53 #  include "BKE_context.h"
54 #  include "BKE_particle.h"
55 
56 #  include "DEG_depsgraph.h"
57 #  include "DEG_depsgraph_build.h"
58 
59 #  include "manta_fluid_API.h"
60 
rna_Fluid_update(Main * UNUSED (bmain),Scene * UNUSED (scene),PointerRNA * ptr)61 static void rna_Fluid_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
62 {
63   DEG_id_tag_update(ptr->owner_id, ID_RECALC_GEOMETRY);
64 
65   /* Needed for liquid domain objects */
66   Object *ob = (Object *)ptr->owner_id;
67   WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob);
68 }
69 
rna_Fluid_dependency_update(Main * bmain,Scene * scene,PointerRNA * ptr)70 static void rna_Fluid_dependency_update(Main *bmain, Scene *scene, PointerRNA *ptr)
71 {
72   rna_Fluid_update(bmain, scene, ptr);
73   DEG_relations_tag_update(bmain);
74 }
75 
rna_Fluid_datacache_reset(Main * UNUSED (bmain),Scene * UNUSED (scene),PointerRNA * ptr)76 static void rna_Fluid_datacache_reset(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
77 {
78 #  ifdef WITH_FLUID
79   FluidDomainSettings *settings = (FluidDomainSettings *)ptr->data;
80   if (settings->fmd && settings->fmd->domain) {
81     Object *ob = (Object *)ptr->owner_id;
82     int cache_map = (FLUID_DOMAIN_OUTDATED_DATA | FLUID_DOMAIN_OUTDATED_NOISE |
83                      FLUID_DOMAIN_OUTDATED_MESH | FLUID_DOMAIN_OUTDATED_PARTICLES);
84     BKE_fluid_cache_free(settings, ob, cache_map);
85   }
86 #  endif
87   DEG_id_tag_update(ptr->owner_id, ID_RECALC_GEOMETRY);
88 }
rna_Fluid_noisecache_reset(Main * UNUSED (bmain),Scene * UNUSED (scene),PointerRNA * ptr)89 static void rna_Fluid_noisecache_reset(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
90 {
91 #  ifdef WITH_FLUID
92   FluidDomainSettings *settings = (FluidDomainSettings *)ptr->data;
93   if (settings->fmd && settings->fmd->domain) {
94     Object *ob = (Object *)ptr->owner_id;
95     int cache_map = FLUID_DOMAIN_OUTDATED_NOISE;
96     BKE_fluid_cache_free(settings, ob, cache_map);
97   }
98 #  endif
99   DEG_id_tag_update(ptr->owner_id, ID_RECALC_GEOMETRY);
100 }
rna_Fluid_meshcache_reset(Main * UNUSED (bmain),Scene * UNUSED (scene),PointerRNA * ptr)101 static void rna_Fluid_meshcache_reset(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
102 {
103 #  ifdef WITH_FLUID
104   FluidDomainSettings *settings = (FluidDomainSettings *)ptr->data;
105   if (settings->fmd && settings->fmd->domain) {
106     Object *ob = (Object *)ptr->owner_id;
107     int cache_map = FLUID_DOMAIN_OUTDATED_MESH;
108     BKE_fluid_cache_free(settings, ob, cache_map);
109   }
110 #  endif
111   DEG_id_tag_update(ptr->owner_id, ID_RECALC_GEOMETRY);
112 }
rna_Fluid_particlescache_reset(Main * UNUSED (bmain),Scene * UNUSED (scene),PointerRNA * ptr)113 static void rna_Fluid_particlescache_reset(Main *UNUSED(bmain),
114                                            Scene *UNUSED(scene),
115                                            PointerRNA *ptr)
116 {
117 #  ifdef WITH_FLUID
118   FluidDomainSettings *settings = (FluidDomainSettings *)ptr->data;
119   if (settings->fmd && settings->fmd->domain) {
120     Object *ob = (Object *)ptr->owner_id;
121     int cache_map = FLUID_DOMAIN_OUTDATED_PARTICLES;
122     BKE_fluid_cache_free(settings, ob, cache_map);
123   }
124 #  endif
125   DEG_id_tag_update(ptr->owner_id, ID_RECALC_GEOMETRY);
126 }
rna_Fluid_guidingcache_reset(Main * UNUSED (bmain),Scene * UNUSED (scene),PointerRNA * ptr)127 static void rna_Fluid_guidingcache_reset(Main *UNUSED(bmain),
128                                          Scene *UNUSED(scene),
129                                          PointerRNA *ptr)
130 {
131 #  ifdef WITH_FLUID
132   FluidDomainSettings *settings = (FluidDomainSettings *)ptr->data;
133   if (settings->fmd && settings->fmd->domain) {
134     Object *ob = (Object *)ptr->owner_id;
135     int cache_map = (FLUID_DOMAIN_OUTDATED_DATA | FLUID_DOMAIN_OUTDATED_NOISE |
136                      FLUID_DOMAIN_OUTDATED_MESH | FLUID_DOMAIN_OUTDATED_PARTICLES |
137                      FLUID_DOMAIN_OUTDATED_GUIDE);
138     BKE_fluid_cache_free(settings, ob, cache_map);
139   }
140 #  endif
141   DEG_id_tag_update(ptr->owner_id, ID_RECALC_GEOMETRY);
142 }
143 
rna_Fluid_effector_reset(Main * bmain,Scene * scene,PointerRNA * ptr)144 static void rna_Fluid_effector_reset(Main *bmain, Scene *scene, PointerRNA *ptr)
145 {
146 #  ifdef WITH_FLUID
147   FluidEffectorSettings *settings = (FluidEffectorSettings *)ptr->data;
148   settings->flags |= FLUID_EFFECTOR_NEEDS_UPDATE;
149 #  endif
150 
151   rna_Fluid_update(bmain, scene, ptr);
152 }
153 
rna_Fluid_flow_reset(Main * bmain,Scene * scene,PointerRNA * ptr)154 static void rna_Fluid_flow_reset(Main *bmain, Scene *scene, PointerRNA *ptr)
155 {
156 #  ifdef WITH_FLUID
157   FluidFlowSettings *settings = (FluidFlowSettings *)ptr->data;
158   settings->flags |= FLUID_FLOW_NEEDS_UPDATE;
159 #  endif
160 
161   rna_Fluid_update(bmain, scene, ptr);
162 }
163 
rna_Fluid_domain_data_reset(Main * bmain,Scene * scene,PointerRNA * ptr)164 static void rna_Fluid_domain_data_reset(Main *bmain, Scene *scene, PointerRNA *ptr)
165 {
166 #  ifdef WITH_FLUID
167   FluidDomainSettings *settings = (FluidDomainSettings *)ptr->data;
168   BKE_fluid_modifier_reset(settings->fmd);
169 #  endif
170 
171   rna_Fluid_datacache_reset(bmain, scene, ptr);
172   rna_Fluid_update(bmain, scene, ptr);
173 }
174 
rna_Fluid_domain_noise_reset(Main * bmain,Scene * scene,PointerRNA * ptr)175 static void rna_Fluid_domain_noise_reset(Main *bmain, Scene *scene, PointerRNA *ptr)
176 {
177 #  ifdef WITH_FLUID
178   FluidDomainSettings *settings = (FluidDomainSettings *)ptr->data;
179   BKE_fluid_modifier_reset(settings->fmd);
180 #  endif
181 
182   rna_Fluid_noisecache_reset(bmain, scene, ptr);
183   rna_Fluid_update(bmain, scene, ptr);
184 }
185 
rna_Fluid_domain_mesh_reset(Main * bmain,Scene * scene,PointerRNA * ptr)186 static void rna_Fluid_domain_mesh_reset(Main *bmain, Scene *scene, PointerRNA *ptr)
187 {
188 #  ifdef WITH_FLUID
189   FluidDomainSettings *settings = (FluidDomainSettings *)ptr->data;
190   BKE_fluid_modifier_reset(settings->fmd);
191 #  endif
192 
193   rna_Fluid_meshcache_reset(bmain, scene, ptr);
194   rna_Fluid_update(bmain, scene, ptr);
195 }
196 
rna_Fluid_domain_particles_reset(Main * bmain,Scene * scene,PointerRNA * ptr)197 static void rna_Fluid_domain_particles_reset(Main *bmain, Scene *scene, PointerRNA *ptr)
198 {
199 #  ifdef WITH_FLUID
200   FluidDomainSettings *settings = (FluidDomainSettings *)ptr->data;
201   BKE_fluid_modifier_reset(settings->fmd);
202 #  endif
203 
204   rna_Fluid_particlescache_reset(bmain, scene, ptr);
205   rna_Fluid_update(bmain, scene, ptr);
206 }
207 
rna_Fluid_reset_dependency(Main * bmain,Scene * scene,PointerRNA * ptr)208 static void rna_Fluid_reset_dependency(Main *bmain, Scene *scene, PointerRNA *ptr)
209 {
210 #  ifdef WITH_FLUID
211   FluidDomainSettings *settings = (FluidDomainSettings *)ptr->data;
212   BKE_fluid_modifier_reset(settings->fmd);
213 #  endif
214 
215   rna_Fluid_dependency_update(bmain, scene, ptr);
216 }
217 
rna_Fluid_parts_create(Main * bmain,PointerRNA * ptr,const char * pset_name,const char * parts_name,const char * psys_name,int psys_type)218 static void rna_Fluid_parts_create(Main *bmain,
219                                    PointerRNA *ptr,
220                                    const char *pset_name,
221                                    const char *parts_name,
222                                    const char *psys_name,
223                                    int psys_type)
224 {
225 #  ifndef WITH_FLUID
226   UNUSED_VARS(bmain, ptr, pset_name, parts_name, psys_name, psys_type);
227 #  else
228   Object *ob = (Object *)ptr->owner_id;
229   BKE_fluid_particle_system_create(bmain, ob, pset_name, parts_name, psys_name, psys_type);
230 #  endif
231 }
232 
rna_Fluid_parts_delete(PointerRNA * ptr,int ptype)233 static void rna_Fluid_parts_delete(PointerRNA *ptr, int ptype)
234 {
235 #  ifndef WITH_FLUID
236   UNUSED_VARS(ptr, ptype);
237 #  else
238   Object *ob = (Object *)ptr->owner_id;
239   BKE_fluid_particle_system_destroy(ob, ptype);
240 #  endif
241 }
242 
rna_Fluid_parts_exists(PointerRNA * ptr,int ptype)243 static bool rna_Fluid_parts_exists(PointerRNA *ptr, int ptype)
244 {
245   Object *ob = (Object *)ptr->owner_id;
246   ParticleSystem *psys;
247 
248   for (psys = ob->particlesystem.first; psys; psys = psys->next) {
249     if (psys->part->type == ptype) {
250       return true;
251     }
252   }
253   return false;
254 }
255 
rna_Fluid_flip_parts_update(Main * bmain,Scene * scene,PointerRNA * ptr)256 static void rna_Fluid_flip_parts_update(Main *bmain, Scene *scene, PointerRNA *ptr)
257 {
258   Object *ob = (Object *)ptr->owner_id;
259   FluidModifierData *fmd;
260   fmd = (FluidModifierData *)BKE_modifiers_findby_type(ob, eModifierType_Fluid);
261   bool exists = rna_Fluid_parts_exists(ptr, PART_FLUID_FLIP);
262 
263   /* Only create a particle system in liquid domain mode.
264    * Remove any remaining data from a liquid sim when switching to gas. */
265   if (fmd->domain->type != FLUID_DOMAIN_TYPE_LIQUID) {
266     rna_Fluid_parts_delete(ptr, PART_FLUID_FLIP);
267     fmd->domain->particle_type &= ~FLUID_DOMAIN_PARTICLE_FLIP;
268     rna_Fluid_domain_data_reset(bmain, scene, ptr);
269     return;
270   }
271 
272   if (ob->type == OB_MESH && !exists) {
273     rna_Fluid_parts_create(
274         bmain, ptr, "LiquidParticleSettings", "Liquid", "Liquid Particle System", PART_FLUID_FLIP);
275     fmd->domain->particle_type |= FLUID_DOMAIN_PARTICLE_FLIP;
276   }
277   else {
278     rna_Fluid_parts_delete(ptr, PART_FLUID_FLIP);
279     fmd->domain->particle_type &= ~FLUID_DOMAIN_PARTICLE_FLIP;
280   }
281   rna_Fluid_update(bmain, scene, ptr);
282 }
283 
rna_Fluid_spray_parts_update(Main * bmain,Scene * UNUSED (scene),PointerRNA * ptr)284 static void rna_Fluid_spray_parts_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
285 {
286   Object *ob = (Object *)ptr->owner_id;
287   FluidModifierData *fmd;
288   fmd = (FluidModifierData *)BKE_modifiers_findby_type(ob, eModifierType_Fluid);
289   bool exists = rna_Fluid_parts_exists(ptr, PART_FLUID_SPRAY);
290 
291   if (ob->type == OB_MESH && !exists) {
292     rna_Fluid_parts_create(
293         bmain, ptr, "SprayParticleSettings", "Spray", "Spray Particle System", PART_FLUID_SPRAY);
294     fmd->domain->particle_type |= FLUID_DOMAIN_PARTICLE_SPRAY;
295   }
296   else {
297     rna_Fluid_parts_delete(ptr, PART_FLUID_SPRAY);
298     fmd->domain->particle_type &= ~FLUID_DOMAIN_PARTICLE_SPRAY;
299   }
300 }
301 
rna_Fluid_bubble_parts_update(Main * bmain,Scene * UNUSED (scene),PointerRNA * ptr)302 static void rna_Fluid_bubble_parts_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
303 {
304   Object *ob = (Object *)ptr->owner_id;
305   FluidModifierData *fmd;
306   fmd = (FluidModifierData *)BKE_modifiers_findby_type(ob, eModifierType_Fluid);
307   bool exists = rna_Fluid_parts_exists(ptr, PART_FLUID_BUBBLE);
308 
309   if (ob->type == OB_MESH && !exists) {
310     rna_Fluid_parts_create(bmain,
311                            ptr,
312                            "BubbleParticleSettings",
313                            "Bubbles",
314                            "Bubble Particle System",
315                            PART_FLUID_BUBBLE);
316     fmd->domain->particle_type |= FLUID_DOMAIN_PARTICLE_BUBBLE;
317   }
318   else {
319     rna_Fluid_parts_delete(ptr, PART_FLUID_BUBBLE);
320     fmd->domain->particle_type &= ~FLUID_DOMAIN_PARTICLE_BUBBLE;
321   }
322 }
323 
rna_Fluid_foam_parts_update(Main * bmain,Scene * UNUSED (scene),PointerRNA * ptr)324 static void rna_Fluid_foam_parts_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
325 {
326   Object *ob = (Object *)ptr->owner_id;
327   FluidModifierData *fmd;
328   fmd = (FluidModifierData *)BKE_modifiers_findby_type(ob, eModifierType_Fluid);
329   bool exists = rna_Fluid_parts_exists(ptr, PART_FLUID_FOAM);
330 
331   if (ob->type == OB_MESH && !exists) {
332     rna_Fluid_parts_create(
333         bmain, ptr, "FoamParticleSettings", "Foam", "Foam Particle System", PART_FLUID_FOAM);
334     fmd->domain->particle_type |= FLUID_DOMAIN_PARTICLE_FOAM;
335   }
336   else {
337     rna_Fluid_parts_delete(ptr, PART_FLUID_FOAM);
338     fmd->domain->particle_type &= ~FLUID_DOMAIN_PARTICLE_FOAM;
339   }
340 }
341 
rna_Fluid_tracer_parts_update(Main * bmain,Scene * UNUSED (scene),PointerRNA * ptr)342 static void rna_Fluid_tracer_parts_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
343 {
344   Object *ob = (Object *)ptr->owner_id;
345   FluidModifierData *fmd;
346   fmd = (FluidModifierData *)BKE_modifiers_findby_type(ob, eModifierType_Fluid);
347   bool exists = rna_Fluid_parts_exists(ptr, PART_FLUID_TRACER);
348 
349   if (ob->type == OB_MESH && !exists) {
350     rna_Fluid_parts_create(bmain,
351                            ptr,
352                            "TracerParticleSettings",
353                            "Tracers",
354                            "Tracer Particle System",
355                            PART_FLUID_TRACER);
356     fmd->domain->particle_type |= FLUID_DOMAIN_PARTICLE_TRACER;
357   }
358   else {
359     rna_Fluid_parts_delete(ptr, PART_FLUID_TRACER);
360     fmd->domain->particle_type &= ~FLUID_DOMAIN_PARTICLE_TRACER;
361   }
362 }
363 
rna_Fluid_combined_export_update(Main * bmain,Scene * scene,PointerRNA * ptr)364 static void rna_Fluid_combined_export_update(Main *bmain, Scene *scene, PointerRNA *ptr)
365 {
366   Object *ob = (Object *)ptr->owner_id;
367   FluidModifierData *fmd;
368   fmd = (FluidModifierData *)BKE_modifiers_findby_type(ob, eModifierType_Fluid);
369 
370   if (fmd->domain->sndparticle_combined_export == SNDPARTICLE_COMBINED_EXPORT_OFF) {
371     rna_Fluid_parts_delete(ptr, PART_FLUID_SPRAYFOAM);
372     rna_Fluid_parts_delete(ptr, PART_FLUID_SPRAYBUBBLE);
373     rna_Fluid_parts_delete(ptr, PART_FLUID_FOAMBUBBLE);
374     rna_Fluid_parts_delete(ptr, PART_FLUID_SPRAYFOAMBUBBLE);
375 
376     bool exists_spray = rna_Fluid_parts_exists(ptr, PART_FLUID_SPRAY);
377     bool exists_foam = rna_Fluid_parts_exists(ptr, PART_FLUID_FOAM);
378     bool exists_bubble = rna_Fluid_parts_exists(ptr, PART_FLUID_BUBBLE);
379 
380     /* Re-add each particle type if enabled and no particle system exists for them anymore. */
381     if ((fmd->domain->particle_type & FLUID_DOMAIN_PARTICLE_SPRAY) && !exists_spray) {
382       rna_Fluid_spray_parts_update(bmain, scene, ptr);
383     }
384     if ((fmd->domain->particle_type & FLUID_DOMAIN_PARTICLE_FOAM) && !exists_foam) {
385       rna_Fluid_foam_parts_update(bmain, scene, ptr);
386     }
387     if ((fmd->domain->particle_type & FLUID_DOMAIN_PARTICLE_BUBBLE) && !exists_bubble) {
388       rna_Fluid_bubble_parts_update(bmain, scene, ptr);
389     }
390   }
391   else if (fmd->domain->sndparticle_combined_export == SNDPARTICLE_COMBINED_EXPORT_SPRAY_FOAM) {
392     if (ob->type == OB_MESH && !rna_Fluid_parts_exists(ptr, PART_FLUID_SPRAYFOAM)) {
393 
394       rna_Fluid_parts_create(bmain,
395                              ptr,
396                              "SprayFoamParticleSettings",
397                              "Spray + Foam",
398                              "Spray + Foam Particle System",
399                              PART_FLUID_SPRAYFOAM);
400 
401       fmd->domain->particle_type |= FLUID_DOMAIN_PARTICLE_SPRAY;
402       fmd->domain->particle_type |= FLUID_DOMAIN_PARTICLE_FOAM;
403 
404       rna_Fluid_parts_delete(ptr, PART_FLUID_SPRAY);
405       rna_Fluid_parts_delete(ptr, PART_FLUID_FOAM);
406       rna_Fluid_parts_delete(ptr, PART_FLUID_SPRAYBUBBLE);
407       rna_Fluid_parts_delete(ptr, PART_FLUID_FOAMBUBBLE);
408       rna_Fluid_parts_delete(ptr, PART_FLUID_SPRAYFOAMBUBBLE);
409 
410       /* Re-add spray if enabled and no particle system exists for it anymore. */
411       bool exists_bubble = rna_Fluid_parts_exists(ptr, PART_FLUID_BUBBLE);
412       if ((fmd->domain->particle_type & FLUID_DOMAIN_PARTICLE_BUBBLE) && !exists_bubble) {
413         rna_Fluid_bubble_parts_update(bmain, scene, ptr);
414       }
415     }
416   }
417   else if (fmd->domain->sndparticle_combined_export == SNDPARTICLE_COMBINED_EXPORT_SPRAY_BUBBLE) {
418     if (ob->type == OB_MESH && !rna_Fluid_parts_exists(ptr, PART_FLUID_SPRAYBUBBLE)) {
419 
420       rna_Fluid_parts_create(bmain,
421                              ptr,
422                              "SprayBubbleParticleSettings",
423                              "Spray + Bubbles",
424                              "Spray + Bubble Particle System",
425                              PART_FLUID_SPRAYBUBBLE);
426 
427       fmd->domain->particle_type |= FLUID_DOMAIN_PARTICLE_SPRAY;
428       fmd->domain->particle_type |= FLUID_DOMAIN_PARTICLE_BUBBLE;
429 
430       rna_Fluid_parts_delete(ptr, PART_FLUID_SPRAY);
431       rna_Fluid_parts_delete(ptr, PART_FLUID_BUBBLE);
432       rna_Fluid_parts_delete(ptr, PART_FLUID_SPRAYFOAM);
433       rna_Fluid_parts_delete(ptr, PART_FLUID_FOAMBUBBLE);
434       rna_Fluid_parts_delete(ptr, PART_FLUID_SPRAYFOAMBUBBLE);
435 
436       /* Re-add foam if enabled and no particle system exists for it anymore. */
437       bool exists_foam = rna_Fluid_parts_exists(ptr, PART_FLUID_FOAM);
438       if ((fmd->domain->particle_type & FLUID_DOMAIN_PARTICLE_FOAM) && !exists_foam) {
439         rna_Fluid_foam_parts_update(bmain, scene, ptr);
440       }
441     }
442   }
443   else if (fmd->domain->sndparticle_combined_export == SNDPARTICLE_COMBINED_EXPORT_FOAM_BUBBLE) {
444     if (ob->type == OB_MESH && !rna_Fluid_parts_exists(ptr, PART_FLUID_FOAMBUBBLE)) {
445 
446       rna_Fluid_parts_create(bmain,
447                              ptr,
448                              "FoamBubbleParticleSettings",
449                              "Foam + Bubble Particles",
450                              "Foam + Bubble Particle System",
451                              PART_FLUID_FOAMBUBBLE);
452 
453       fmd->domain->particle_type |= FLUID_DOMAIN_PARTICLE_FOAM;
454       fmd->domain->particle_type |= FLUID_DOMAIN_PARTICLE_BUBBLE;
455 
456       rna_Fluid_parts_delete(ptr, PART_FLUID_FOAM);
457       rna_Fluid_parts_delete(ptr, PART_FLUID_BUBBLE);
458       rna_Fluid_parts_delete(ptr, PART_FLUID_SPRAYFOAM);
459       rna_Fluid_parts_delete(ptr, PART_FLUID_SPRAYBUBBLE);
460       rna_Fluid_parts_delete(ptr, PART_FLUID_SPRAYFOAMBUBBLE);
461 
462       /* Re-add foam if enabled and no particle system exists for it anymore. */
463       bool exists_spray = rna_Fluid_parts_exists(ptr, PART_FLUID_SPRAY);
464       if ((fmd->domain->particle_type & FLUID_DOMAIN_PARTICLE_SPRAY) && !exists_spray) {
465         rna_Fluid_spray_parts_update(bmain, scene, ptr);
466       }
467     }
468   }
469   else if (fmd->domain->sndparticle_combined_export ==
470            SNDPARTICLE_COMBINED_EXPORT_SPRAY_FOAM_BUBBLE) {
471     if (ob->type == OB_MESH && !rna_Fluid_parts_exists(ptr, PART_FLUID_SPRAYFOAMBUBBLE)) {
472 
473       rna_Fluid_parts_create(bmain,
474                              ptr,
475                              "SprayFoamBubbleParticleSettings",
476                              "Spray + Foam + Bubbles",
477                              "Spray + Foam + Bubble Particle System",
478                              PART_FLUID_SPRAYFOAMBUBBLE);
479 
480       fmd->domain->particle_type |= FLUID_DOMAIN_PARTICLE_SPRAY;
481       fmd->domain->particle_type |= FLUID_DOMAIN_PARTICLE_FOAM;
482       fmd->domain->particle_type |= FLUID_DOMAIN_PARTICLE_BUBBLE;
483 
484       rna_Fluid_parts_delete(ptr, PART_FLUID_SPRAY);
485       rna_Fluid_parts_delete(ptr, PART_FLUID_FOAM);
486       rna_Fluid_parts_delete(ptr, PART_FLUID_BUBBLE);
487       rna_Fluid_parts_delete(ptr, PART_FLUID_SPRAYFOAM);
488       rna_Fluid_parts_delete(ptr, PART_FLUID_SPRAYBUBBLE);
489       rna_Fluid_parts_delete(ptr, PART_FLUID_FOAMBUBBLE);
490     }
491   }
492   else {
493     /* sanity check, should not occur */
494     printf("ERROR: Unexpected combined export setting encountered!");
495   }
496 }
497 
rna_Fluid_cache_startframe_set(struct PointerRNA * ptr,int value)498 static void rna_Fluid_cache_startframe_set(struct PointerRNA *ptr, int value)
499 {
500   FluidDomainSettings *settings = (FluidDomainSettings *)ptr->data;
501   BKE_fluid_cache_startframe_set(settings, value);
502 }
503 
rna_Fluid_cache_endframe_set(struct PointerRNA * ptr,int value)504 static void rna_Fluid_cache_endframe_set(struct PointerRNA *ptr, int value)
505 {
506   FluidDomainSettings *settings = (FluidDomainSettings *)ptr->data;
507   BKE_fluid_cache_endframe_set(settings, value);
508 }
509 
rna_Fluid_cachetype_mesh_set(struct PointerRNA * ptr,int value)510 static void rna_Fluid_cachetype_mesh_set(struct PointerRNA *ptr, int value)
511 {
512   FluidDomainSettings *settings = (FluidDomainSettings *)ptr->data;
513   BKE_fluid_cachetype_mesh_set(settings, value);
514 }
515 
rna_Fluid_cachetype_data_set(struct PointerRNA * ptr,int value)516 static void rna_Fluid_cachetype_data_set(struct PointerRNA *ptr, int value)
517 {
518   FluidDomainSettings *settings = (FluidDomainSettings *)ptr->data;
519   BKE_fluid_cachetype_data_set(settings, value);
520 }
521 
rna_Fluid_cachetype_particle_set(struct PointerRNA * ptr,int value)522 static void rna_Fluid_cachetype_particle_set(struct PointerRNA *ptr, int value)
523 {
524   FluidDomainSettings *settings = (FluidDomainSettings *)ptr->data;
525   BKE_fluid_cachetype_particle_set(settings, value);
526 }
527 
rna_Fluid_cachetype_noise_set(struct PointerRNA * ptr,int value)528 static void rna_Fluid_cachetype_noise_set(struct PointerRNA *ptr, int value)
529 {
530   FluidDomainSettings *settings = (FluidDomainSettings *)ptr->data;
531   BKE_fluid_cachetype_noise_set(settings, value);
532 }
533 
rna_Fluid_cachetype_set(struct PointerRNA * ptr,int value)534 static void rna_Fluid_cachetype_set(struct PointerRNA *ptr, int value)
535 {
536   FluidDomainSettings *settings = (FluidDomainSettings *)ptr->data;
537 
538   if (value != settings->cache_type) {
539     settings->cache_type = value;
540     settings->cache_flag = 0;
541   }
542 }
543 
rna_Fluid_guide_parent_set(struct PointerRNA * ptr,struct PointerRNA value,struct ReportList * UNUSED (reports))544 static void rna_Fluid_guide_parent_set(struct PointerRNA *ptr,
545                                        struct PointerRNA value,
546                                        struct ReportList *UNUSED(reports))
547 {
548   FluidDomainSettings *fds = (FluidDomainSettings *)ptr->data;
549   Object *par = (Object *)value.data;
550 
551   FluidModifierData *fmd_par = NULL;
552 
553   if (par != NULL) {
554     fmd_par = (FluidModifierData *)BKE_modifiers_findby_type(par, eModifierType_Fluid);
555     if (fmd_par && fmd_par->domain) {
556       fds->guide_parent = value.data;
557       copy_v3_v3_int(fds->guide_res, fmd_par->domain->res);
558     }
559   }
560   else {
561     fds->guide_parent = NULL;
562   }
563 }
564 
rna_Fluid_cachetype_mesh_itemf(bContext * UNUSED (C),PointerRNA * UNUSED (ptr),PropertyRNA * UNUSED (prop),bool * r_free)565 static const EnumPropertyItem *rna_Fluid_cachetype_mesh_itemf(bContext *UNUSED(C),
566                                                               PointerRNA *UNUSED(ptr),
567                                                               PropertyRNA *UNUSED(prop),
568                                                               bool *r_free)
569 {
570   EnumPropertyItem *item = NULL;
571   EnumPropertyItem tmp = {0, "", 0, "", ""};
572   int totitem = 0;
573 
574   tmp.value = FLUID_DOMAIN_FILE_BIN_OBJECT;
575   tmp.identifier = "BOBJECT";
576   tmp.name = "Binary Object";
577   tmp.description = "Binary object file format (.bobj.gz)";
578   RNA_enum_item_add(&item, &totitem, &tmp);
579 
580   tmp.value = FLUID_DOMAIN_FILE_OBJECT;
581   tmp.identifier = "OBJECT";
582   tmp.name = "Object";
583   tmp.description = "Object file format (.obj)";
584   RNA_enum_item_add(&item, &totitem, &tmp);
585 
586   RNA_enum_item_end(&item, &totitem);
587   *r_free = true;
588 
589   return item;
590 }
591 
rna_Fluid_cachetype_volume_itemf(bContext * UNUSED (C),PointerRNA * ptr,PropertyRNA * UNUSED (prop),bool * r_free)592 static const EnumPropertyItem *rna_Fluid_cachetype_volume_itemf(bContext *UNUSED(C),
593                                                                 PointerRNA *ptr,
594                                                                 PropertyRNA *UNUSED(prop),
595                                                                 bool *r_free)
596 {
597   EnumPropertyItem *item = NULL;
598   EnumPropertyItem tmp = {0, "", 0, "", ""};
599   int totitem = 0;
600 
601   tmp.value = FLUID_DOMAIN_FILE_UNI;
602   tmp.identifier = "UNI";
603   tmp.name = "Uni Cache";
604   tmp.description = "Uni file format (.uni)";
605   RNA_enum_item_add(&item, &totitem, &tmp);
606 
607 #  ifdef WITH_OPENVDB
608   tmp.value = FLUID_DOMAIN_FILE_OPENVDB;
609   tmp.identifier = "OPENVDB";
610   tmp.name = "OpenVDB";
611   tmp.description = "OpenVDB file format (.vdb)";
612   RNA_enum_item_add(&item, &totitem, &tmp);
613 #  endif
614 
615   /* Support for deprecated .raw format. */
616   FluidDomainSettings *fds = (FluidDomainSettings *)ptr->data;
617   if (fds->cache_data_format == FLUID_DOMAIN_FILE_RAW ||
618       fds->cache_noise_format == FLUID_DOMAIN_FILE_RAW) {
619     tmp.value = FLUID_DOMAIN_FILE_RAW;
620     tmp.identifier = "RAW";
621     tmp.name = "Raw Cache";
622     tmp.description = "Raw file format (.raw)";
623     RNA_enum_item_add(&item, &totitem, &tmp);
624   }
625 
626   RNA_enum_item_end(&item, &totitem);
627   *r_free = true;
628 
629   return item;
630 }
631 
rna_Fluid_cachetype_particle_itemf(bContext * UNUSED (C),PointerRNA * UNUSED (ptr),PropertyRNA * UNUSED (prop),bool * r_free)632 static const EnumPropertyItem *rna_Fluid_cachetype_particle_itemf(bContext *UNUSED(C),
633                                                                   PointerRNA *UNUSED(ptr),
634                                                                   PropertyRNA *UNUSED(prop),
635                                                                   bool *r_free)
636 {
637   EnumPropertyItem *item = NULL;
638   EnumPropertyItem tmp = {0, "", 0, "", ""};
639   int totitem = 0;
640 
641   tmp.value = FLUID_DOMAIN_FILE_UNI;
642   tmp.identifier = "UNI";
643   tmp.name = "Uni Cache";
644   tmp.description = "Uni file format";
645   RNA_enum_item_add(&item, &totitem, &tmp);
646 
647   RNA_enum_item_end(&item, &totitem);
648   *r_free = true;
649 
650   return item;
651 }
652 
rna_Fluid_cache_directory_set(struct PointerRNA * ptr,const char * value)653 static void rna_Fluid_cache_directory_set(struct PointerRNA *ptr, const char *value)
654 {
655   FluidDomainSettings *settings = (FluidDomainSettings *)ptr->data;
656 
657   if (STREQ(settings->cache_directory, value)) {
658     return;
659   }
660 
661   BLI_strncpy(settings->cache_directory, value, sizeof(settings->cache_directory));
662 
663   /* TODO(sebbas): Read cache state in order to set cache bake flags and cache pause frames
664    * correctly. */
665   // settings->cache_flag = 0;
666 }
667 
rna_Fluid_cobafield_itemf(bContext * UNUSED (C),PointerRNA * ptr,PropertyRNA * UNUSED (prop),bool * r_free)668 static const EnumPropertyItem *rna_Fluid_cobafield_itemf(bContext *UNUSED(C),
669                                                          PointerRNA *ptr,
670                                                          PropertyRNA *UNUSED(prop),
671                                                          bool *r_free)
672 {
673   FluidDomainSettings *settings = (FluidDomainSettings *)ptr->data;
674 
675   EnumPropertyItem *item = NULL;
676   EnumPropertyItem tmp = {0, "", 0, "", ""};
677   int totitem = 0;
678 
679   tmp.value = FLUID_DOMAIN_FIELD_FLAGS;
680   tmp.identifier = "FLAGS";
681   tmp.icon = 0;
682   tmp.name = "Flags";
683   tmp.description = "Flag grid of the fluid domain";
684   RNA_enum_item_add(&item, &totitem, &tmp);
685 
686   tmp.value = FLUID_DOMAIN_FIELD_PRESSURE;
687   tmp.identifier = "PRESSURE";
688   tmp.icon = 0;
689   tmp.name = "Pressure";
690   tmp.description = "Pressure field of the fluid domain";
691   RNA_enum_item_add(&item, &totitem, &tmp);
692 
693   tmp.value = FLUID_DOMAIN_FIELD_VELOCITY_X;
694   tmp.identifier = "VELOCITY_X";
695   tmp.icon = 0;
696   tmp.name = "X Velocity";
697   tmp.description = "X component of the velocity field";
698   RNA_enum_item_add(&item, &totitem, &tmp);
699 
700   tmp.value = FLUID_DOMAIN_FIELD_VELOCITY_Y;
701   tmp.identifier = "VELOCITY_Y";
702   tmp.icon = 0;
703   tmp.name = "Y Velocity";
704   tmp.description = "Y component of the velocity field";
705   RNA_enum_item_add(&item, &totitem, &tmp);
706 
707   tmp.value = FLUID_DOMAIN_FIELD_VELOCITY_Z;
708   tmp.identifier = "VELOCITY_Z";
709   tmp.icon = 0;
710   tmp.name = "Z Velocity";
711   tmp.description = "Z component of the velocity field";
712   RNA_enum_item_add(&item, &totitem, &tmp);
713 
714   tmp.value = FLUID_DOMAIN_FIELD_FORCE_X;
715   tmp.identifier = "FORCE_X";
716   tmp.icon = 0;
717   tmp.name = "X Force";
718   tmp.description = "X component of the force field";
719   RNA_enum_item_add(&item, &totitem, &tmp);
720 
721   tmp.value = FLUID_DOMAIN_FIELD_FORCE_Y;
722   tmp.identifier = "FORCE_Y";
723   tmp.icon = 0;
724   tmp.name = "Y Force";
725   tmp.description = "Y component of the force field";
726   RNA_enum_item_add(&item, &totitem, &tmp);
727 
728   tmp.value = FLUID_DOMAIN_FIELD_FORCE_Z;
729   tmp.identifier = "FORCE_Z";
730   tmp.icon = 0;
731   tmp.name = "Z Force";
732   tmp.description = "Z component of the force field";
733   RNA_enum_item_add(&item, &totitem, &tmp);
734 
735   if (settings->type == FLUID_DOMAIN_TYPE_GAS) {
736     tmp.value = FLUID_DOMAIN_FIELD_COLOR_R;
737     tmp.identifier = "COLOR_R";
738     tmp.icon = 0;
739     tmp.name = "Red";
740     tmp.description = "Red component of the color field";
741     RNA_enum_item_add(&item, &totitem, &tmp);
742 
743     tmp.value = FLUID_DOMAIN_FIELD_COLOR_G;
744     tmp.identifier = "COLOR_G";
745     tmp.icon = 0;
746     tmp.name = "Green";
747     tmp.description = "Green component of the color field";
748     RNA_enum_item_add(&item, &totitem, &tmp);
749 
750     tmp.value = FLUID_DOMAIN_FIELD_COLOR_B;
751     tmp.identifier = "COLOR_B";
752     tmp.icon = 0;
753     tmp.name = "Blue";
754     tmp.description = "Blue component of the color field";
755     RNA_enum_item_add(&item, &totitem, &tmp);
756 
757     tmp.value = FLUID_DOMAIN_FIELD_DENSITY;
758     tmp.identifier = "DENSITY";
759     tmp.icon = 0;
760     tmp.name = "Density";
761     tmp.description = "Quantity of soot in the fluid";
762     RNA_enum_item_add(&item, &totitem, &tmp);
763 
764     tmp.value = FLUID_DOMAIN_FIELD_FLAME;
765     tmp.identifier = "FLAME";
766     tmp.icon = 0;
767     tmp.name = "Flame";
768     tmp.description = "Flame field";
769     RNA_enum_item_add(&item, &totitem, &tmp);
770 
771     tmp.value = FLUID_DOMAIN_FIELD_FUEL;
772     tmp.identifier = "FUEL";
773     tmp.icon = 0;
774     tmp.name = "Fuel";
775     tmp.description = "Fuel field";
776     RNA_enum_item_add(&item, &totitem, &tmp);
777 
778     tmp.value = FLUID_DOMAIN_FIELD_HEAT;
779     tmp.identifier = "HEAT";
780     tmp.icon = 0;
781     tmp.name = "Heat";
782     tmp.description = "Temperature of the fluid";
783     RNA_enum_item_add(&item, &totitem, &tmp);
784   }
785   else if (settings->type == FLUID_DOMAIN_TYPE_LIQUID) {
786     tmp.value = FLUID_DOMAIN_FIELD_PHI;
787     tmp.identifier = "PHI";
788     tmp.icon = 0;
789     tmp.name = "Fluid Levelset";
790     tmp.description = "Levelset representation of the fluid";
791     RNA_enum_item_add(&item, &totitem, &tmp);
792 
793     tmp.value = FLUID_DOMAIN_FIELD_PHI_IN;
794     tmp.identifier = "PHI_IN";
795     tmp.icon = 0;
796     tmp.name = "Inflow Levelset";
797     tmp.description = "Levelset representation of the inflow";
798     RNA_enum_item_add(&item, &totitem, &tmp);
799 
800     tmp.value = FLUID_DOMAIN_FIELD_PHI_OUT;
801     tmp.identifier = "PHI_OUT";
802     tmp.icon = 0;
803     tmp.name = "Outflow Levelset";
804     tmp.description = "Levelset representation of the outflow";
805     RNA_enum_item_add(&item, &totitem, &tmp);
806 
807     tmp.value = FLUID_DOMAIN_FIELD_PHI_OBSTACLE;
808     tmp.identifier = "PHI_OBSTACLE";
809     tmp.icon = 0;
810     tmp.name = "Obstacle Levelset";
811     tmp.description = "Levelset representation of the obstacles";
812     RNA_enum_item_add(&item, &totitem, &tmp);
813   }
814 
815   RNA_enum_item_end(&item, &totitem);
816   *r_free = true;
817 
818   return item;
819 }
820 
rna_Fluid_data_depth_itemf(bContext * UNUSED (C),PointerRNA * ptr,PropertyRNA * UNUSED (prop),bool * r_free)821 static const EnumPropertyItem *rna_Fluid_data_depth_itemf(bContext *UNUSED(C),
822                                                           PointerRNA *ptr,
823                                                           PropertyRNA *UNUSED(prop),
824                                                           bool *r_free)
825 {
826   FluidDomainSettings *settings = (FluidDomainSettings *)ptr->data;
827 
828   EnumPropertyItem *item = NULL;
829   EnumPropertyItem tmp = {0, "", 0, "", ""};
830   int totitem = 0;
831 
832   tmp.value = VDB_PRECISION_FULL_FLOAT;
833   tmp.identifier = "32";
834   tmp.icon = 0;
835   tmp.name = "Full";
836   tmp.description = "Full float (Use 32 bit for all data)";
837   RNA_enum_item_add(&item, &totitem, &tmp);
838 
839   tmp.value = VDB_PRECISION_HALF_FLOAT;
840   tmp.identifier = "16";
841   tmp.icon = 0;
842   tmp.name = "Half";
843   tmp.description = "Half float (Use 16 bit for all data)";
844   RNA_enum_item_add(&item, &totitem, &tmp);
845 
846   if (settings->type == FLUID_DOMAIN_TYPE_LIQUID) {
847     tmp.value = VDB_PRECISION_MINI_FLOAT;
848     tmp.identifier = "8";
849     tmp.icon = 0;
850     tmp.name = "Mini";
851     tmp.description = "Mini float (Use 8 bit where possible, otherwise use 16 bit)";
852     RNA_enum_item_add(&item, &totitem, &tmp);
853   }
854 
855   RNA_enum_item_end(&item, &totitem);
856   *r_free = true;
857 
858   return item;
859 }
860 
rna_Fluid_domaintype_set(struct PointerRNA * ptr,int value)861 static void rna_Fluid_domaintype_set(struct PointerRNA *ptr, int value)
862 {
863   FluidDomainSettings *settings = (FluidDomainSettings *)ptr->data;
864   Object *ob = (Object *)ptr->owner_id;
865   BKE_fluid_domain_type_set(ob, settings, value);
866   BKE_fluid_fields_sanitize(settings);
867 }
868 
rna_FluidDomainSettings_path(PointerRNA * ptr)869 static char *rna_FluidDomainSettings_path(PointerRNA *ptr)
870 {
871   FluidDomainSettings *settings = (FluidDomainSettings *)ptr->data;
872   ModifierData *md = (ModifierData *)settings->fmd;
873   char name_esc[sizeof(md->name) * 2];
874 
875   BLI_strescape(name_esc, md->name, sizeof(name_esc));
876   return BLI_sprintfN("modifiers[\"%s\"].domain_settings", name_esc);
877 }
878 
rna_FluidFlowSettings_path(PointerRNA * ptr)879 static char *rna_FluidFlowSettings_path(PointerRNA *ptr)
880 {
881   FluidFlowSettings *settings = (FluidFlowSettings *)ptr->data;
882   ModifierData *md = (ModifierData *)settings->fmd;
883   char name_esc[sizeof(md->name) * 2];
884 
885   BLI_strescape(name_esc, md->name, sizeof(name_esc));
886   return BLI_sprintfN("modifiers[\"%s\"].flow_settings", name_esc);
887 }
888 
rna_FluidEffectorSettings_path(PointerRNA * ptr)889 static char *rna_FluidEffectorSettings_path(PointerRNA *ptr)
890 {
891   FluidEffectorSettings *settings = (FluidEffectorSettings *)ptr->data;
892   ModifierData *md = (ModifierData *)settings->fmd;
893   char name_esc[sizeof(md->name) * 2];
894 
895   BLI_strescape(name_esc, md->name, sizeof(name_esc));
896   return BLI_sprintfN("modifiers[\"%s\"].effector_settings", name_esc);
897 }
898 
899 /* -------------------------------------------------------------------- */
900 /** \name Grid Accessors
901  * \{ */
902 
903 #  ifdef WITH_FLUID
904 
rna_FluidModifier_grid_get_length(PointerRNA * ptr,int length[RNA_MAX_ARRAY_DIMENSION])905 static int rna_FluidModifier_grid_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION])
906 {
907   FluidDomainSettings *fds = (FluidDomainSettings *)ptr->data;
908   float *density = NULL;
909   int size = 0;
910 
911   if (fds->flags & FLUID_DOMAIN_USE_NOISE && fds->fluid) {
912     /* high resolution smoke */
913     int res[3];
914 
915     manta_noise_get_res(fds->fluid, res);
916     size = res[0] * res[1] * res[2];
917 
918     density = manta_noise_get_density(fds->fluid);
919   }
920   else if (fds->fluid) {
921     /* regular resolution */
922     size = fds->res[0] * fds->res[1] * fds->res[2];
923     density = manta_smoke_get_density(fds->fluid);
924   }
925 
926   length[0] = (density) ? size : 0;
927   return length[0];
928 }
929 
rna_FluidModifier_color_grid_get_length(PointerRNA * ptr,int length[RNA_MAX_ARRAY_DIMENSION])930 static int rna_FluidModifier_color_grid_get_length(PointerRNA *ptr,
931                                                    int length[RNA_MAX_ARRAY_DIMENSION])
932 {
933   rna_FluidModifier_grid_get_length(ptr, length);
934 
935   length[0] *= 4;
936   return length[0];
937 }
938 
rna_FluidModifier_velocity_grid_get_length(PointerRNA * ptr,int length[RNA_MAX_ARRAY_DIMENSION])939 static int rna_FluidModifier_velocity_grid_get_length(PointerRNA *ptr,
940                                                       int length[RNA_MAX_ARRAY_DIMENSION])
941 {
942   FluidDomainSettings *fds = (FluidDomainSettings *)ptr->data;
943   float *vx = NULL;
944   float *vy = NULL;
945   float *vz = NULL;
946   int size = 0;
947 
948   /* Velocity data is always low-resolution. */
949   if (fds->fluid) {
950     size = 3 * fds->res[0] * fds->res[1] * fds->res[2];
951     vx = manta_get_velocity_x(fds->fluid);
952     vy = manta_get_velocity_y(fds->fluid);
953     vz = manta_get_velocity_z(fds->fluid);
954   }
955 
956   length[0] = (vx && vy && vz) ? size : 0;
957   return length[0];
958 }
959 
rna_FluidModifier_heat_grid_get_length(PointerRNA * ptr,int length[RNA_MAX_ARRAY_DIMENSION])960 static int rna_FluidModifier_heat_grid_get_length(PointerRNA *ptr,
961                                                   int length[RNA_MAX_ARRAY_DIMENSION])
962 {
963   FluidDomainSettings *fds = (FluidDomainSettings *)ptr->data;
964   float *heat = NULL;
965   int size = 0;
966 
967   /* Heat data is always low-resolution. */
968   if (fds->fluid) {
969     size = fds->res[0] * fds->res[1] * fds->res[2];
970     heat = manta_smoke_get_heat(fds->fluid);
971   }
972 
973   length[0] = (heat) ? size : 0;
974   return length[0];
975 }
976 
rna_FluidModifier_density_grid_get(PointerRNA * ptr,float * values)977 static void rna_FluidModifier_density_grid_get(PointerRNA *ptr, float *values)
978 {
979   FluidDomainSettings *fds = (FluidDomainSettings *)ptr->data;
980   int length[RNA_MAX_ARRAY_DIMENSION];
981   int size = rna_FluidModifier_grid_get_length(ptr, length);
982   float *density;
983 
984   BLI_rw_mutex_lock(fds->fluid_mutex, THREAD_LOCK_READ);
985 
986   if (fds->flags & FLUID_DOMAIN_USE_NOISE && fds->fluid) {
987     density = manta_noise_get_density(fds->fluid);
988   }
989   else {
990     density = manta_smoke_get_density(fds->fluid);
991   }
992 
993   memcpy(values, density, size * sizeof(float));
994 
995   BLI_rw_mutex_unlock(fds->fluid_mutex);
996 }
997 
rna_FluidModifier_velocity_grid_get(PointerRNA * ptr,float * values)998 static void rna_FluidModifier_velocity_grid_get(PointerRNA *ptr, float *values)
999 {
1000   FluidDomainSettings *fds = (FluidDomainSettings *)ptr->data;
1001   int length[RNA_MAX_ARRAY_DIMENSION];
1002   int size = rna_FluidModifier_velocity_grid_get_length(ptr, length);
1003   float *vx, *vy, *vz;
1004   int i;
1005 
1006   BLI_rw_mutex_lock(fds->fluid_mutex, THREAD_LOCK_READ);
1007 
1008   vx = manta_get_velocity_x(fds->fluid);
1009   vy = manta_get_velocity_y(fds->fluid);
1010   vz = manta_get_velocity_z(fds->fluid);
1011 
1012   for (i = 0; i < size; i += 3) {
1013     *(values++) = *(vx++);
1014     *(values++) = *(vy++);
1015     *(values++) = *(vz++);
1016   }
1017 
1018   BLI_rw_mutex_unlock(fds->fluid_mutex);
1019 }
1020 
rna_FluidModifier_color_grid_get(PointerRNA * ptr,float * values)1021 static void rna_FluidModifier_color_grid_get(PointerRNA *ptr, float *values)
1022 {
1023   FluidDomainSettings *fds = (FluidDomainSettings *)ptr->data;
1024   int length[RNA_MAX_ARRAY_DIMENSION];
1025   int size = rna_FluidModifier_grid_get_length(ptr, length);
1026 
1027   BLI_rw_mutex_lock(fds->fluid_mutex, THREAD_LOCK_READ);
1028 
1029   if (!fds->fluid) {
1030     memset(values, 0, size * sizeof(float));
1031   }
1032   else {
1033     if (fds->flags & FLUID_DOMAIN_USE_NOISE) {
1034       if (manta_noise_has_colors(fds->fluid)) {
1035         manta_noise_get_rgba(fds->fluid, values, 0);
1036       }
1037       else {
1038         manta_noise_get_rgba_fixed_color(fds->fluid, fds->active_color, values, 0);
1039       }
1040     }
1041     else {
1042       if (manta_smoke_has_colors(fds->fluid)) {
1043         manta_smoke_get_rgba(fds->fluid, values, 0);
1044       }
1045       else {
1046         manta_smoke_get_rgba_fixed_color(fds->fluid, fds->active_color, values, 0);
1047       }
1048     }
1049   }
1050 
1051   BLI_rw_mutex_unlock(fds->fluid_mutex);
1052 }
1053 
rna_FluidModifier_flame_grid_get(PointerRNA * ptr,float * values)1054 static void rna_FluidModifier_flame_grid_get(PointerRNA *ptr, float *values)
1055 {
1056   FluidDomainSettings *fds = (FluidDomainSettings *)ptr->data;
1057   int length[RNA_MAX_ARRAY_DIMENSION];
1058   int size = rna_FluidModifier_grid_get_length(ptr, length);
1059   float *flame;
1060 
1061   BLI_rw_mutex_lock(fds->fluid_mutex, THREAD_LOCK_READ);
1062 
1063   if (fds->flags & FLUID_DOMAIN_USE_NOISE && fds->fluid) {
1064     flame = manta_noise_get_flame(fds->fluid);
1065   }
1066   else {
1067     flame = manta_smoke_get_flame(fds->fluid);
1068   }
1069 
1070   if (flame) {
1071     memcpy(values, flame, size * sizeof(float));
1072   }
1073   else {
1074     memset(values, 0, size * sizeof(float));
1075   }
1076 
1077   BLI_rw_mutex_unlock(fds->fluid_mutex);
1078 }
1079 
rna_FluidModifier_heat_grid_get(PointerRNA * ptr,float * values)1080 static void rna_FluidModifier_heat_grid_get(PointerRNA *ptr, float *values)
1081 {
1082   FluidDomainSettings *fds = (FluidDomainSettings *)ptr->data;
1083   int length[RNA_MAX_ARRAY_DIMENSION];
1084   int size = rna_FluidModifier_heat_grid_get_length(ptr, length);
1085   float *heat;
1086 
1087   BLI_rw_mutex_lock(fds->fluid_mutex, THREAD_LOCK_READ);
1088 
1089   heat = manta_smoke_get_heat(fds->fluid);
1090 
1091   if (heat != NULL) {
1092     /* scale heat values from -2.0-2.0 to -1.0-1.0. */
1093     for (int i = 0; i < size; i++) {
1094       values[i] = heat[i] * 0.5f;
1095     }
1096   }
1097   else {
1098     memset(values, 0, size * sizeof(float));
1099   }
1100 
1101   BLI_rw_mutex_unlock(fds->fluid_mutex);
1102 }
1103 
rna_FluidModifier_temperature_grid_get(PointerRNA * ptr,float * values)1104 static void rna_FluidModifier_temperature_grid_get(PointerRNA *ptr, float *values)
1105 {
1106   FluidDomainSettings *fds = (FluidDomainSettings *)ptr->data;
1107   int length[RNA_MAX_ARRAY_DIMENSION];
1108   int size = rna_FluidModifier_grid_get_length(ptr, length);
1109   float *flame;
1110 
1111   BLI_rw_mutex_lock(fds->fluid_mutex, THREAD_LOCK_READ);
1112 
1113   if (fds->flags & FLUID_DOMAIN_USE_NOISE && fds->fluid) {
1114     flame = manta_noise_get_flame(fds->fluid);
1115   }
1116   else {
1117     flame = manta_smoke_get_flame(fds->fluid);
1118   }
1119 
1120   if (flame) {
1121     /* Output is such that 0..1 maps to 0..1000K */
1122     float offset = fds->flame_ignition;
1123     float scale = fds->flame_max_temp - fds->flame_ignition;
1124 
1125     for (int i = 0; i < size; i++) {
1126       values[i] = (flame[i] > 0.01f) ? offset + flame[i] * scale : 0.0f;
1127     }
1128   }
1129   else {
1130     memset(values, 0, size * sizeof(float));
1131   }
1132 
1133   BLI_rw_mutex_unlock(fds->fluid_mutex);
1134 }
1135 #  endif /* WITH_FLUID */
1136 
1137 /** \} */
1138 
rna_FluidFlow_density_vgroup_get(PointerRNA * ptr,char * value)1139 static void rna_FluidFlow_density_vgroup_get(PointerRNA *ptr, char *value)
1140 {
1141   FluidFlowSettings *flow = (FluidFlowSettings *)ptr->data;
1142   rna_object_vgroup_name_index_get(ptr, value, flow->vgroup_density);
1143 }
1144 
rna_FluidFlow_density_vgroup_length(PointerRNA * ptr)1145 static int rna_FluidFlow_density_vgroup_length(PointerRNA *ptr)
1146 {
1147   FluidFlowSettings *flow = (FluidFlowSettings *)ptr->data;
1148   return rna_object_vgroup_name_index_length(ptr, flow->vgroup_density);
1149 }
1150 
rna_FluidFlow_density_vgroup_set(struct PointerRNA * ptr,const char * value)1151 static void rna_FluidFlow_density_vgroup_set(struct PointerRNA *ptr, const char *value)
1152 {
1153   FluidFlowSettings *flow = (FluidFlowSettings *)ptr->data;
1154   rna_object_vgroup_name_index_set(ptr, value, &flow->vgroup_density);
1155 }
1156 
rna_FluidFlow_uvlayer_set(struct PointerRNA * ptr,const char * value)1157 static void rna_FluidFlow_uvlayer_set(struct PointerRNA *ptr, const char *value)
1158 {
1159   FluidFlowSettings *flow = (FluidFlowSettings *)ptr->data;
1160   rna_object_uvlayer_name_set(ptr, value, flow->uvlayer_name, sizeof(flow->uvlayer_name));
1161 }
1162 
rna_Fluid_use_color_ramp_set(struct PointerRNA * ptr,bool value)1163 static void rna_Fluid_use_color_ramp_set(struct PointerRNA *ptr, bool value)
1164 {
1165   FluidDomainSettings *fds = (FluidDomainSettings *)ptr->data;
1166 
1167   fds->use_coba = value;
1168 
1169   if (value && fds->coba == NULL) {
1170     fds->coba = BKE_colorband_add(false);
1171   }
1172 }
1173 
rna_Fluid_flowsource_set(struct PointerRNA * ptr,int value)1174 static void rna_Fluid_flowsource_set(struct PointerRNA *ptr, int value)
1175 {
1176   FluidFlowSettings *settings = (FluidFlowSettings *)ptr->data;
1177 
1178   if (value != settings->source) {
1179     settings->source = value;
1180   }
1181 }
1182 
rna_Fluid_flowsource_itemf(bContext * UNUSED (C),PointerRNA * ptr,PropertyRNA * UNUSED (prop),bool * r_free)1183 static const EnumPropertyItem *rna_Fluid_flowsource_itemf(bContext *UNUSED(C),
1184                                                           PointerRNA *ptr,
1185                                                           PropertyRNA *UNUSED(prop),
1186                                                           bool *r_free)
1187 {
1188   FluidFlowSettings *settings = (FluidFlowSettings *)ptr->data;
1189 
1190   EnumPropertyItem *item = NULL;
1191   EnumPropertyItem tmp = {0, "", 0, "", ""};
1192   int totitem = 0;
1193 
1194   tmp.value = FLUID_FLOW_SOURCE_MESH;
1195   tmp.identifier = "MESH";
1196   tmp.icon = ICON_META_CUBE;
1197   tmp.name = "Mesh";
1198   tmp.description = "Emit fluid from mesh surface or volume";
1199   RNA_enum_item_add(&item, &totitem, &tmp);
1200 
1201   if (settings->type != FLUID_FLOW_TYPE_LIQUID) {
1202     tmp.value = FLUID_FLOW_SOURCE_PARTICLES;
1203     tmp.identifier = "PARTICLES";
1204     tmp.icon = ICON_PARTICLES;
1205     tmp.name = "Particle System";
1206     tmp.description = "Emit smoke from particles";
1207     RNA_enum_item_add(&item, &totitem, &tmp);
1208   }
1209 
1210   RNA_enum_item_end(&item, &totitem);
1211   *r_free = true;
1212 
1213   return item;
1214 }
1215 
rna_Fluid_flowtype_set(struct PointerRNA * ptr,int value)1216 static void rna_Fluid_flowtype_set(struct PointerRNA *ptr, int value)
1217 {
1218   FluidFlowSettings *settings = (FluidFlowSettings *)ptr->data;
1219 
1220   if (value != settings->type) {
1221     short prev_value = settings->type;
1222     settings->type = value;
1223 
1224     /* Force flow source to mesh for liquids.
1225      * Also use different surface emission. Liquids should by default not emit around surface. */
1226     if (value == FLUID_FLOW_TYPE_LIQUID) {
1227       rna_Fluid_flowsource_set(ptr, FLUID_FLOW_SOURCE_MESH);
1228       settings->surface_distance = 0.0f;
1229     }
1230     /* Use some surface emission when switching to a gas emitter. Gases should by default emit a
1231      * bit around surface. */
1232     if (prev_value == FLUID_FLOW_TYPE_LIQUID) {
1233       settings->surface_distance = 1.5f;
1234     }
1235   }
1236 }
1237 
1238 #else
1239 
rna_def_fluid_mesh_vertices(BlenderRNA * brna)1240 static void rna_def_fluid_mesh_vertices(BlenderRNA *brna)
1241 {
1242   StructRNA *srna;
1243   PropertyRNA *prop;
1244 
1245   srna = RNA_def_struct(brna, "FluidDomainVertexVelocity", NULL);
1246   RNA_def_struct_ui_text(srna, "Fluid Mesh Velocity", "Velocity of a simulated fluid mesh");
1247   RNA_def_struct_ui_icon(srna, ICON_VERTEXSEL);
1248 
1249   prop = RNA_def_property(srna, "velocity", PROP_FLOAT, PROP_VELOCITY);
1250   RNA_def_property_array(prop, 3);
1251   RNA_def_property_float_sdna(prop, NULL, "vel");
1252   RNA_def_property_ui_text(prop, "Velocity", "");
1253   RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1254 }
1255 
rna_def_fluid_domain_settings(BlenderRNA * brna)1256 static void rna_def_fluid_domain_settings(BlenderRNA *brna)
1257 {
1258   StructRNA *srna;
1259   PropertyRNA *prop;
1260 
1261   static EnumPropertyItem domain_types[] = {
1262       {FLUID_DOMAIN_TYPE_GAS, "GAS", 0, "Gas", "Create domain for gases"},
1263       {FLUID_DOMAIN_TYPE_LIQUID, "LIQUID", 0, "Liquid", "Create domain for liquids"},
1264       {0, NULL, 0, NULL, NULL}};
1265 
1266   static const EnumPropertyItem prop_noise_type_items[] = {
1267       {FLUID_NOISE_TYPE_WAVELET, "NOISEWAVE", 0, "Wavelet", ""},
1268       {0, NULL, 0, NULL, NULL},
1269   };
1270 
1271   static const EnumPropertyItem prop_compression_items[] = {
1272       {VDB_COMPRESSION_ZIP, "ZIP", 0, "Zip", "Effective but slow compression"},
1273 #  ifdef WITH_OPENVDB_BLOSC
1274       {VDB_COMPRESSION_BLOSC,
1275        "BLOSC",
1276        0,
1277        "Blosc",
1278        "Multithreaded compression, similar in size and quality as 'Zip'"},
1279 #  endif
1280       {VDB_COMPRESSION_NONE, "NONE", 0, "None", "Do not use any compression"},
1281       {0, NULL, 0, NULL, NULL}};
1282 
1283   static const EnumPropertyItem smoke_highres_sampling_items[] = {
1284       {SM_HRES_FULLSAMPLE, "FULLSAMPLE", 0, "Full Sample", ""},
1285       {SM_HRES_LINEAR, "LINEAR", 0, "Linear", ""},
1286       {SM_HRES_NEAREST, "NEAREST", 0, "Nearest", ""},
1287       {0, NULL, 0, NULL, NULL},
1288   };
1289 
1290   static EnumPropertyItem cache_types[] = {
1291       {FLUID_DOMAIN_CACHE_REPLAY, "REPLAY", 0, "Replay", "Use the timeline to bake the scene"},
1292       {FLUID_DOMAIN_CACHE_MODULAR,
1293        "MODULAR",
1294        0,
1295        "Modular",
1296        "Bake every stage of the simulation separately"},
1297       {FLUID_DOMAIN_CACHE_ALL, "ALL", 0, "All", "Bake all simulation settings at once"},
1298       {0, NULL, 0, NULL, NULL}};
1299 
1300   /*  OpenVDB data depth - generated dynamically based on domain type */
1301   static EnumPropertyItem fluid_data_depth_items[] = {
1302       {0, "NONE", 0, "", ""},
1303       {0, NULL, 0, NULL, NULL},
1304   };
1305 
1306   static EnumPropertyItem fluid_mesh_quality_items[] = {
1307       {FLUID_DOMAIN_MESH_IMPROVED,
1308        "IMPROVED",
1309        0,
1310        "Final",
1311        "Use improved particle level set (slower but more precise and with mesh smoothening "
1312        "options)"},
1313       {FLUID_DOMAIN_MESH_UNION,
1314        "UNION",
1315        0,
1316        "Preview",
1317        "Use union particle level set (faster but lower quality)"},
1318       {0, NULL, 0, NULL, NULL},
1319   };
1320 
1321   static EnumPropertyItem fluid_guide_source_items[] = {
1322       {FLUID_DOMAIN_GUIDE_SRC_DOMAIN,
1323        "DOMAIN",
1324        0,
1325        "Domain",
1326        "Use a fluid domain for guiding (domain needs to be baked already so that velocities can "
1327        "be extracted). Guiding domain can be of any type (i.e. gas or liquid)"},
1328       {FLUID_DOMAIN_GUIDE_SRC_EFFECTOR,
1329        "EFFECTOR",
1330        0,
1331        "Effector",
1332        "Use guiding (effector) objects to create fluid guiding (guiding objects should be "
1333        "animated and baked once set up completely)"},
1334       {0, NULL, 0, NULL, NULL},
1335   };
1336 
1337   /*  Cache type - generated dynamically based on domain type */
1338   static EnumPropertyItem cache_file_type_items[] = {
1339       {0, "NONE", 0, "", ""},
1340       {0, NULL, 0, NULL, NULL},
1341   };
1342 
1343   static const EnumPropertyItem interp_method_item[] = {
1344       {FLUID_DISPLAY_INTERP_LINEAR, "LINEAR", 0, "Linear", "Good smoothness and speed"},
1345       {FLUID_DISPLAY_INTERP_CUBIC,
1346        "CUBIC",
1347        0,
1348        "Cubic",
1349        "Smoothed high quality interpolation, but slower"},
1350       {FLUID_DISPLAY_INTERP_CLOSEST, "CLOSEST", 0, "Closest", "No interpolation"},
1351       {0, NULL, 0, NULL, NULL},
1352   };
1353 
1354   static const EnumPropertyItem axis_slice_position_items[] = {
1355       {SLICE_AXIS_AUTO,
1356        "AUTO",
1357        0,
1358        "Auto",
1359        "Adjust slice direction according to the view direction"},
1360       {SLICE_AXIS_X, "X", 0, "X", "Slice along the X axis"},
1361       {SLICE_AXIS_Y, "Y", 0, "Y", "Slice along the Y axis"},
1362       {SLICE_AXIS_Z, "Z", 0, "Z", "Slice along the Z axis"},
1363       {0, NULL, 0, NULL, NULL},
1364   };
1365 
1366   static const EnumPropertyItem vector_draw_items[] = {
1367       {VECTOR_DRAW_NEEDLE, "NEEDLE", 0, "Needle", "Display vectors as needles"},
1368       {VECTOR_DRAW_STREAMLINE, "STREAMLINE", 0, "Streamlines", "Display vectors as streamlines"},
1369       {VECTOR_DRAW_MAC, "MAC", 0, "MAC Grid", "Display vector field as MAC grid"},
1370       {0, NULL, 0, NULL, NULL},
1371   };
1372 
1373   static const EnumPropertyItem vector_field_items[] = {
1374       {FLUID_DOMAIN_VECTOR_FIELD_VELOCITY,
1375        "FLUID_VELOCITY",
1376        0,
1377        "Fluid Velocity",
1378        "Velocity field of the fluid domain"},
1379       {FLUID_DOMAIN_VECTOR_FIELD_GUIDE_VELOCITY,
1380        "GUIDE_VELOCITY",
1381        0,
1382        "Guide Velocity",
1383        "Guide velocity field of the fluid domain"},
1384       {FLUID_DOMAIN_VECTOR_FIELD_FORCE, "FORCE", 0, "Force", "Force field of the fluid domain"},
1385       {0, NULL, 0, NULL, NULL},
1386   };
1387 
1388   static const EnumPropertyItem gridlines_color_field_items[] = {
1389       {0, "NONE", 0, "None", "None"},
1390       {FLUID_GRIDLINE_COLOR_TYPE_FLAGS, "FLAGS", 0, "Flags", "Flag grid of the fluid domain"},
1391       {FLUID_GRIDLINE_COLOR_TYPE_RANGE,
1392        "RANGE",
1393        0,
1394        "Highlight Range",
1395        "Highlight the voxels with values of the color mapped field within the range"},
1396       {0, NULL, 0, NULL, NULL},
1397   };
1398 
1399   static const EnumPropertyItem gridlines_cell_filter_items[] = {
1400       {FLUID_CELL_TYPE_NONE, "NONE", 0, "None", "Highlight the cells regardless of their type"},
1401       {FLUID_CELL_TYPE_FLUID, "FLUID", 0, "Fluid", "Highlight only the cells of type Fluid"},
1402       {FLUID_CELL_TYPE_OBSTACLE,
1403        "OBSTACLE",
1404        0,
1405        "Obstacle",
1406        "Highlight only the cells of type Obstacle"},
1407       {FLUID_CELL_TYPE_EMPTY, "EMPTY", 0, "Empty", "Highlight only the cells of type Empty"},
1408       {FLUID_CELL_TYPE_INFLOW, "INFLOW", 0, "Inflow", "Highlight only the cells of type Inflow"},
1409       {FLUID_CELL_TYPE_OUTFLOW,
1410        "OUTFLOW",
1411        0,
1412        "Outflow",
1413        "Highlight only the cells of type Outflow"},
1414       {0, NULL, 0, NULL, NULL},
1415   };
1416 
1417   static const EnumPropertyItem sndparticle_boundary_items[] = {
1418       {SNDPARTICLE_BOUNDARY_DELETE,
1419        "DELETE",
1420        0,
1421        "Delete",
1422        "Delete secondary particles that are inside obstacles or left the domain"},
1423       {SNDPARTICLE_BOUNDARY_PUSHOUT,
1424        "PUSHOUT",
1425        0,
1426        "Push Out",
1427        "Push secondary particles that left the domain back into the domain"},
1428       {0, NULL, 0, NULL, NULL}};
1429 
1430   static const EnumPropertyItem sndparticle_combined_export_items[] = {
1431       {SNDPARTICLE_COMBINED_EXPORT_OFF,
1432        "OFF",
1433        0,
1434        "Off",
1435        "Create a separate particle system for every secondary particle type"},
1436       {SNDPARTICLE_COMBINED_EXPORT_SPRAY_FOAM,
1437        "SPRAY_FOAM",
1438        0,
1439        "Spray + Foam",
1440        "Spray and foam particles are saved in the same particle system"},
1441       {SNDPARTICLE_COMBINED_EXPORT_SPRAY_BUBBLE,
1442        "SPRAY_BUBBLES",
1443        0,
1444        "Spray + Bubbles",
1445        "Spray and bubble particles are saved in the same particle system"},
1446       {SNDPARTICLE_COMBINED_EXPORT_FOAM_BUBBLE,
1447        "FOAM_BUBBLES",
1448        0,
1449        "Foam + Bubbles",
1450        "Foam and bubbles particles are saved in the same particle system"},
1451       {SNDPARTICLE_COMBINED_EXPORT_SPRAY_FOAM_BUBBLE,
1452        "SPRAY_FOAM_BUBBLES",
1453        0,
1454        "Spray + Foam + Bubbles",
1455        "Create one particle system that contains all three secondary particle types"},
1456       {0, NULL, 0, NULL, NULL}};
1457 
1458   static EnumPropertyItem simulation_methods[] = {
1459       {FLUID_DOMAIN_METHOD_FLIP, "FLIP", 0, "FLIP", "Use FLIP as the simulation method"},
1460       /*{FLUID_DOMAIN_METHOD_APIC, "APIC", 0, "APIC", "Use APIC as the simulation method"},*/
1461       {0, NULL, 0, NULL, NULL},
1462   };
1463 
1464   srna = RNA_def_struct(brna, "FluidDomainSettings", NULL);
1465   RNA_def_struct_ui_text(srna, "Domain Settings", "Fluid domain settings");
1466   RNA_def_struct_sdna(srna, "FluidDomainSettings");
1467   RNA_def_struct_path_func(srna, "rna_FluidDomainSettings_path");
1468 
1469   prop = RNA_def_property(srna, "effector_weights", PROP_POINTER, PROP_NONE);
1470   RNA_def_property_struct_type(prop, "EffectorWeights");
1471   RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1472   RNA_def_property_ui_text(prop, "Effector Weights", "");
1473 
1474   /* object collections */
1475 
1476   prop = RNA_def_property(srna, "effector_group", PROP_POINTER, PROP_NONE);
1477   RNA_def_property_pointer_sdna(prop, NULL, "effector_group");
1478   RNA_def_property_struct_type(prop, "Collection");
1479   RNA_def_property_flag(prop, PROP_EDITABLE);
1480   RNA_def_property_ui_text(prop, "Effector Collection", "Limit effectors to this collection");
1481   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_reset_dependency");
1482 
1483   prop = RNA_def_property(srna, "fluid_group", PROP_POINTER, PROP_NONE);
1484   RNA_def_property_pointer_sdna(prop, NULL, "fluid_group");
1485   RNA_def_property_struct_type(prop, "Collection");
1486   RNA_def_property_flag(prop, PROP_EDITABLE);
1487   RNA_def_property_ui_text(prop, "Fluid Collection", "Limit fluid objects to this collection");
1488   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_reset_dependency");
1489 
1490   prop = RNA_def_property(srna, "force_collection", PROP_POINTER, PROP_NONE);
1491   RNA_def_property_pointer_sdna(prop, NULL, "force_group");
1492   RNA_def_property_struct_type(prop, "Collection");
1493   RNA_def_property_flag(prop, PROP_EDITABLE);
1494   RNA_def_property_ui_text(prop, "Force Collection", "Limit forces to this collection");
1495   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_reset_dependency");
1496 
1497   /* grid access */
1498 
1499 #  ifdef WITH_FLUID
1500   prop = RNA_def_property(srna, "density_grid", PROP_FLOAT, PROP_NONE);
1501   RNA_def_property_array(prop, 32);
1502   RNA_def_property_flag(prop, PROP_DYNAMIC);
1503   RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1504   RNA_def_property_dynamic_array_funcs(prop, "rna_FluidModifier_grid_get_length");
1505   RNA_def_property_float_funcs(prop, "rna_FluidModifier_density_grid_get", NULL, NULL);
1506   RNA_def_property_ui_text(prop, "Density Grid", "Smoke density grid");
1507 
1508   prop = RNA_def_property(srna, "velocity_grid", PROP_FLOAT, PROP_NONE);
1509   RNA_def_property_array(prop, 32);
1510   RNA_def_property_flag(prop, PROP_DYNAMIC);
1511   RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1512   RNA_def_property_dynamic_array_funcs(prop, "rna_FluidModifier_velocity_grid_get_length");
1513   RNA_def_property_float_funcs(prop, "rna_FluidModifier_velocity_grid_get", NULL, NULL);
1514   RNA_def_property_ui_text(prop, "Velocity Grid", "Smoke velocity grid");
1515 
1516   prop = RNA_def_property(srna, "flame_grid", PROP_FLOAT, PROP_NONE);
1517   RNA_def_property_array(prop, 32);
1518   RNA_def_property_flag(prop, PROP_DYNAMIC);
1519   RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1520   RNA_def_property_dynamic_array_funcs(prop, "rna_FluidModifier_grid_get_length");
1521   RNA_def_property_float_funcs(prop, "rna_FluidModifier_flame_grid_get", NULL, NULL);
1522   RNA_def_property_ui_text(prop, "Flame Grid", "Smoke flame grid");
1523 
1524   prop = RNA_def_property(srna, "color_grid", PROP_FLOAT, PROP_NONE);
1525   RNA_def_property_array(prop, 32);
1526   RNA_def_property_flag(prop, PROP_DYNAMIC);
1527   RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1528   RNA_def_property_dynamic_array_funcs(prop, "rna_FluidModifier_color_grid_get_length");
1529   RNA_def_property_float_funcs(prop, "rna_FluidModifier_color_grid_get", NULL, NULL);
1530   RNA_def_property_ui_text(prop, "Color Grid", "Smoke color grid");
1531 
1532   prop = RNA_def_property(srna, "heat_grid", PROP_FLOAT, PROP_NONE);
1533   RNA_def_property_array(prop, 32);
1534   RNA_def_property_flag(prop, PROP_DYNAMIC);
1535   RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1536   RNA_def_property_dynamic_array_funcs(prop, "rna_FluidModifier_heat_grid_get_length");
1537   RNA_def_property_float_funcs(prop, "rna_FluidModifier_heat_grid_get", NULL, NULL);
1538   RNA_def_property_ui_text(prop, "Heat Grid", "Smoke heat grid");
1539 
1540   prop = RNA_def_property(srna, "temperature_grid", PROP_FLOAT, PROP_NONE);
1541   RNA_def_property_array(prop, 32);
1542   RNA_def_property_flag(prop, PROP_DYNAMIC);
1543   RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1544   RNA_def_property_dynamic_array_funcs(prop, "rna_FluidModifier_grid_get_length");
1545   RNA_def_property_float_funcs(prop, "rna_FluidModifier_temperature_grid_get", NULL, NULL);
1546   RNA_def_property_ui_text(
1547       prop, "Temperature Grid", "Smoke temperature grid, range 0..1 represents 0..1000K");
1548 #  endif /* WITH_FLUID */
1549 
1550   /* domain object data */
1551 
1552   prop = RNA_def_property(srna,
1553                           "start_point",
1554                           PROP_FLOAT,
1555                           PROP_XYZ); /* can change each frame when using adaptive domain */
1556   RNA_def_property_float_sdna(prop, NULL, "p0");
1557   RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1558   RNA_def_property_ui_text(prop, "p0", "Start point");
1559 
1560   prop = RNA_def_property(srna,
1561                           "cell_size",
1562                           PROP_FLOAT,
1563                           PROP_XYZ); /* can change each frame when using adaptive domain */
1564   RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1565   RNA_def_property_ui_text(prop, "cell_size", "Cell Size");
1566 
1567   prop = RNA_def_property(srna,
1568                           "domain_resolution",
1569                           PROP_INT,
1570                           PROP_XYZ); /* can change each frame when using adaptive domain */
1571   RNA_def_property_int_sdna(prop, NULL, "res");
1572   RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1573   RNA_def_property_ui_text(prop, "res", "Smoke Grid Resolution");
1574 
1575   /* adaptive domain options */
1576 
1577   prop = RNA_def_property(srna, "additional_res", PROP_INT, PROP_NONE);
1578   RNA_def_property_int_sdna(prop, NULL, "adapt_res");
1579   RNA_def_property_range(prop, 0, 512);
1580   RNA_def_property_ui_text(prop, "Additional", "Maximum number of additional cells");
1581   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
1582 
1583   prop = RNA_def_property(srna, "adapt_margin", PROP_INT, PROP_NONE);
1584   RNA_def_property_int_sdna(prop, NULL, "adapt_margin");
1585   RNA_def_property_range(prop, 2, 24);
1586   RNA_def_property_ui_text(
1587       prop, "Margin", "Margin added around fluid to minimize boundary interference");
1588   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
1589 
1590   prop = RNA_def_property(srna, "adapt_threshold", PROP_FLOAT, PROP_NONE);
1591   RNA_def_property_range(prop, 0.0, 1.0);
1592   RNA_def_property_ui_range(prop, 0.0, 1.0, 0.02, 6);
1593   RNA_def_property_ui_text(
1594       prop,
1595       "Threshold",
1596       "Minimum amount of fluid a cell can contain before it is considered empty");
1597   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
1598 
1599   prop = RNA_def_property(srna, "use_adaptive_domain", PROP_BOOLEAN, PROP_NONE);
1600   RNA_def_property_boolean_sdna(prop, NULL, "flags", FLUID_DOMAIN_USE_ADAPTIVE_DOMAIN);
1601   RNA_def_property_ui_text(
1602       prop, "Adaptive Domain", "Adapt simulation resolution and size to fluid");
1603   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
1604   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_domain_data_reset");
1605 
1606   /* fluid domain options */
1607 
1608   prop = RNA_def_property(srna, "resolution_max", PROP_INT, PROP_NONE);
1609   RNA_def_property_int_sdna(prop, NULL, "maxres");
1610   RNA_def_property_range(prop, 6, 10000);
1611   RNA_def_property_ui_range(prop, 24, 10000, 2, -1);
1612   RNA_def_property_ui_text(
1613       prop,
1614       "Maximum Resolution",
1615       "Resolution used for the fluid domain. Value corresponds to the longest domain side "
1616       "(resolution for other domain sides is calculated automatically)");
1617   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
1618   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_domain_data_reset");
1619 
1620   prop = RNA_def_property(srna, "use_collision_border_front", PROP_BOOLEAN, PROP_NONE);
1621   RNA_def_property_boolean_sdna(prop, NULL, "border_collisions", FLUID_DOMAIN_BORDER_FRONT);
1622   RNA_def_property_ui_text(prop, "Front", "Enable collisions with front domain border");
1623   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
1624 
1625   prop = RNA_def_property(srna, "use_collision_border_back", PROP_BOOLEAN, PROP_NONE);
1626   RNA_def_property_boolean_sdna(prop, NULL, "border_collisions", FLUID_DOMAIN_BORDER_BACK);
1627   RNA_def_property_ui_text(prop, "Back", "Enable collisions with back domain border");
1628   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
1629 
1630   prop = RNA_def_property(srna, "use_collision_border_right", PROP_BOOLEAN, PROP_NONE);
1631   RNA_def_property_boolean_sdna(prop, NULL, "border_collisions", FLUID_DOMAIN_BORDER_RIGHT);
1632   RNA_def_property_ui_text(prop, "Right", "Enable collisions with right domain border");
1633   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
1634 
1635   prop = RNA_def_property(srna, "use_collision_border_left", PROP_BOOLEAN, PROP_NONE);
1636   RNA_def_property_boolean_sdna(prop, NULL, "border_collisions", FLUID_DOMAIN_BORDER_LEFT);
1637   RNA_def_property_ui_text(prop, "Left", "Enable collisions with left domain border");
1638   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
1639 
1640   prop = RNA_def_property(srna, "use_collision_border_top", PROP_BOOLEAN, PROP_NONE);
1641   RNA_def_property_boolean_sdna(prop, NULL, "border_collisions", FLUID_DOMAIN_BORDER_TOP);
1642   RNA_def_property_ui_text(prop, "Top", "Enable collisions with top domain border");
1643   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
1644 
1645   prop = RNA_def_property(srna, "use_collision_border_bottom", PROP_BOOLEAN, PROP_NONE);
1646   RNA_def_property_boolean_sdna(prop, NULL, "border_collisions", FLUID_DOMAIN_BORDER_BOTTOM);
1647   RNA_def_property_ui_text(prop, "Bottom", "Enable collisions with bottom domain border");
1648   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
1649 
1650   prop = RNA_def_property(srna, "gravity", PROP_FLOAT, PROP_ACCELERATION);
1651   RNA_def_property_float_sdna(prop, NULL, "gravity");
1652   RNA_def_property_array(prop, 3);
1653   RNA_def_property_range(prop, -1000.1, 1000.1);
1654   RNA_def_property_ui_text(prop, "Gravity", "Gravity in X, Y and Z direction");
1655   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
1656 
1657   prop = RNA_def_property(srna, "domain_type", PROP_ENUM, PROP_NONE);
1658   RNA_def_property_enum_sdna(prop, NULL, "type");
1659   RNA_def_property_enum_items(prop, domain_types);
1660   RNA_def_property_enum_funcs(prop, NULL, "rna_Fluid_domaintype_set", NULL);
1661   RNA_def_property_ui_text(prop, "Domain Type", "Change domain type of the simulation");
1662   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
1663   RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Fluid_flip_parts_update");
1664 
1665   prop = RNA_def_property(srna, "delete_in_obstacle", PROP_BOOLEAN, PROP_NONE);
1666   RNA_def_property_boolean_sdna(prop, NULL, "flags", FLUID_DOMAIN_DELETE_IN_OBSTACLE);
1667   RNA_def_property_ui_text(prop, "Clear In Obstacle", "Delete fluid inside obstacles");
1668   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
1669 
1670   /* smoke domain options */
1671 
1672   prop = RNA_def_property(srna, "alpha", PROP_FLOAT, PROP_NONE);
1673   RNA_def_property_float_sdna(prop, NULL, "alpha");
1674   RNA_def_property_range(prop, -5.0, 5.0);
1675   RNA_def_property_ui_range(prop, -5.0, 5.0, 0.02, 5);
1676   RNA_def_property_ui_text(
1677       prop,
1678       "Buoyancy Density",
1679       "Buoyant force based on smoke density (higher value results in faster rising smoke)");
1680   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
1681 
1682   prop = RNA_def_property(srna, "beta", PROP_FLOAT, PROP_NONE);
1683   RNA_def_property_float_sdna(prop, NULL, "beta");
1684   RNA_def_property_range(prop, -5.0, 5.0);
1685   RNA_def_property_ui_range(prop, -5.0, 5.0, 0.02, 5);
1686   RNA_def_property_ui_text(
1687       prop,
1688       "Buoyancy Heat",
1689       "Buoyant force based on smoke heat (higher value results in faster rising smoke)");
1690   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
1691 
1692   prop = RNA_def_property(srna, "dissolve_speed", PROP_INT, PROP_NONE);
1693   RNA_def_property_int_sdna(prop, NULL, "diss_speed");
1694   RNA_def_property_range(prop, 1.0, 10000.0);
1695   RNA_def_property_ui_range(prop, 1.0, 10000.0, 1, -1);
1696   RNA_def_property_ui_text(
1697       prop,
1698       "Dissolve Speed",
1699       "Determine how quickly the smoke dissolves (lower value makes smoke disappear faster)");
1700   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
1701 
1702   prop = RNA_def_property(srna, "vorticity", PROP_FLOAT, PROP_NONE);
1703   RNA_def_property_float_sdna(prop, NULL, "vorticity");
1704   RNA_def_property_range(prop, 0.0, 4.0);
1705   RNA_def_property_ui_text(prop, "Vorticity", "Amount of turbulence and rotation in smoke");
1706   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
1707 
1708   prop = RNA_def_property(srna, "highres_sampling", PROP_ENUM, PROP_NONE);
1709   RNA_def_property_enum_items(prop, smoke_highres_sampling_items);
1710   RNA_def_property_ui_text(prop, "Emitter", "Method for sampling the high resolution flow");
1711   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
1712 
1713   prop = RNA_def_property(srna, "use_dissolve_smoke", PROP_BOOLEAN, PROP_NONE);
1714   RNA_def_property_boolean_sdna(prop, NULL, "flags", FLUID_DOMAIN_USE_DISSOLVE);
1715   RNA_def_property_ui_text(prop, "Dissolve Smoke", "Let smoke disappear over time");
1716   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
1717 
1718   prop = RNA_def_property(srna, "use_dissolve_smoke_log", PROP_BOOLEAN, PROP_NONE);
1719   RNA_def_property_boolean_sdna(prop, NULL, "flags", FLUID_DOMAIN_USE_DISSOLVE_LOG);
1720   RNA_def_property_ui_text(
1721       prop,
1722       "Logarithmic Dissolve",
1723       "Dissolve smoke in a logarithmic fashion. Dissolves quickly at first, but lingers longer");
1724   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
1725 
1726   /* flame options */
1727 
1728   prop = RNA_def_property(srna, "burning_rate", PROP_FLOAT, PROP_NONE);
1729   RNA_def_property_range(prop, 0.01, 4.0);
1730   RNA_def_property_ui_range(prop, 0.01, 2.0, 1.0, 5);
1731   RNA_def_property_ui_text(
1732       prop, "Speed", "Speed of the burning reaction (higher value results in smaller flames)");
1733   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
1734 
1735   prop = RNA_def_property(srna, "flame_smoke", PROP_FLOAT, PROP_NONE);
1736   RNA_def_property_range(prop, 0.0, 8.0);
1737   RNA_def_property_ui_range(prop, 0.0, 4.0, 1.0, 5);
1738   RNA_def_property_ui_text(prop, "Smoke", "Amount of smoke created by burning fuel");
1739   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
1740 
1741   prop = RNA_def_property(srna, "flame_vorticity", PROP_FLOAT, PROP_NONE);
1742   RNA_def_property_range(prop, 0.0, 2.0);
1743   RNA_def_property_ui_range(prop, 0.0, 1.0, 1.0, 5);
1744   RNA_def_property_ui_text(prop, "Vorticity", "Additional vorticity for the flames");
1745   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
1746 
1747   prop = RNA_def_property(srna, "flame_ignition", PROP_FLOAT, PROP_NONE);
1748   RNA_def_property_range(prop, 0.5, 5.0);
1749   RNA_def_property_ui_range(prop, 0.5, 2.5, 1.0, 5);
1750   RNA_def_property_ui_text(
1751       prop,
1752       "Minimum",
1753       "Minimum temperature of the flames (higher value results in faster rising flames)");
1754   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
1755 
1756   prop = RNA_def_property(srna, "flame_max_temp", PROP_FLOAT, PROP_NONE);
1757   RNA_def_property_range(prop, 1.0, 10.0);
1758   RNA_def_property_ui_range(prop, 1.0, 5.0, 1.0, 5);
1759   RNA_def_property_ui_text(
1760       prop,
1761       "Maximum",
1762       "Maximum temperature of the flames (higher value results in faster rising flames)");
1763   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
1764 
1765   prop = RNA_def_property(srna, "flame_smoke_color", PROP_FLOAT, PROP_COLOR_GAMMA);
1766   RNA_def_property_array(prop, 3);
1767   RNA_def_property_ui_text(prop, "Smoke Color", "Color of smoke emitted from burning fuel");
1768   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
1769 
1770   /* noise options */
1771 
1772   prop = RNA_def_property(srna, "noise_strength", PROP_FLOAT, PROP_NONE);
1773   RNA_def_property_float_sdna(prop, NULL, "noise_strength");
1774   RNA_def_property_range(prop, 0.0, 10.0);
1775   RNA_def_property_ui_range(prop, 0.0, 10.0, 1, 2);
1776   RNA_def_property_ui_text(prop, "Strength", "Strength of noise");
1777   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_noisecache_reset");
1778 
1779   prop = RNA_def_property(srna, "noise_pos_scale", PROP_FLOAT, PROP_NONE);
1780   RNA_def_property_float_sdna(prop, NULL, "noise_pos_scale");
1781   RNA_def_property_range(prop, 0.0001, 10.0);
1782   RNA_def_property_ui_text(
1783       prop, "Scale", "Scale of noise (higher value results in larger vortices)");
1784   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_noisecache_reset");
1785 
1786   prop = RNA_def_property(srna, "noise_time_anim", PROP_FLOAT, PROP_NONE);
1787   RNA_def_property_float_sdna(prop, NULL, "noise_time_anim");
1788   RNA_def_property_range(prop, 0.0001, 10.0);
1789   RNA_def_property_ui_text(prop, "Time", "Animation time of noise");
1790   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_noisecache_reset");
1791 
1792   prop = RNA_def_property(srna, "noise_scale", PROP_INT, PROP_NONE);
1793   RNA_def_property_int_sdna(prop, NULL, "noise_scale");
1794   RNA_def_property_range(prop, 1, 100);
1795   RNA_def_property_ui_range(prop, 1, 10, 1, -1);
1796   RNA_def_property_ui_text(prop,
1797                            "Noise Scale",
1798                            "The noise simulation is scaled up by this factor (compared to the "
1799                            "base resolution of the domain)");
1800   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
1801   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_domain_noise_reset");
1802 
1803   prop = RNA_def_property(srna, "noise_type", PROP_ENUM, PROP_NONE);
1804   RNA_def_property_enum_sdna(prop, NULL, "noise_type");
1805   RNA_def_property_enum_items(prop, prop_noise_type_items);
1806   RNA_def_property_ui_text(
1807       prop, "Noise Method", "Noise method which is used during the high-res simulation");
1808   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
1809   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_domain_noise_reset");
1810 
1811   prop = RNA_def_property(srna, "use_noise", PROP_BOOLEAN, PROP_NONE);
1812   RNA_def_property_boolean_sdna(prop, NULL, "flags", FLUID_DOMAIN_USE_NOISE);
1813   RNA_def_property_ui_text(prop, "Use Noise", "Enable fluid noise (using amplification)");
1814   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
1815   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_update");
1816 
1817   /* liquid domain options */
1818 
1819   prop = RNA_def_property(srna, "simulation_method", PROP_ENUM, PROP_NONE);
1820   RNA_def_property_enum_sdna(prop, NULL, "simulation_method");
1821   RNA_def_property_enum_items(prop, simulation_methods);
1822   RNA_def_property_ui_text(prop, "Simulation Method", "Change the underlying simulation method");
1823   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_domain_data_reset");
1824 
1825   prop = RNA_def_property(srna, "flip_ratio", PROP_FLOAT, PROP_NONE);
1826   RNA_def_property_range(prop, 0.0, 1.0);
1827   RNA_def_property_ui_text(
1828       prop,
1829       "FLIP Ratio",
1830       "PIC/FLIP Ratio. A value of 1.0 will result in a completely FLIP based simulation. Use a "
1831       "lower value for simulations which should produce smaller splashes");
1832   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
1833 
1834   prop = RNA_def_property(srna, "particle_randomness", PROP_FLOAT, PROP_NONE);
1835   RNA_def_property_range(prop, 0.0, 10.0);
1836   RNA_def_property_ui_text(prop, "Randomness", "Randomness factor for particle sampling");
1837   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
1838 
1839   prop = RNA_def_property(srna, "particle_number", PROP_INT, PROP_NONE);
1840   RNA_def_property_range(prop, 1, 5);
1841   RNA_def_property_ui_text(
1842       prop, "Number", "Particle number factor (higher value results in more particles)");
1843   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
1844 
1845   prop = RNA_def_property(srna, "particle_min", PROP_INT, PROP_NONE);
1846   RNA_def_property_int_sdna(prop, NULL, "particle_minimum");
1847   RNA_def_property_range(prop, 0, 1000);
1848   RNA_def_property_ui_text(prop,
1849                            "Minimum",
1850                            "Minimum number of particles per cell (ensures that each cell has at "
1851                            "least this amount of particles)");
1852   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
1853 
1854   prop = RNA_def_property(srna, "particle_max", PROP_INT, PROP_NONE);
1855   RNA_def_property_int_sdna(prop, NULL, "particle_maximum");
1856   RNA_def_property_range(prop, 0, 1000);
1857   RNA_def_property_ui_text(prop,
1858                            "Maximum",
1859                            "Maximum number of particles per cell (ensures that each cell has at "
1860                            "most this amount of particles)");
1861   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
1862 
1863   prop = RNA_def_property(srna, "particle_radius", PROP_FLOAT, PROP_NONE);
1864   RNA_def_property_range(prop, 0.0, 10.0);
1865   RNA_def_property_ui_text(prop,
1866                            "Radius",
1867                            "Particle radius factor. Increase this value if the simulation appears "
1868                            "to leak volume, decrease it if the simulation seems to gain volume");
1869   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
1870 
1871   prop = RNA_def_property(srna, "particle_band_width", PROP_FLOAT, PROP_NONE);
1872   RNA_def_property_range(prop, 0.0, 1000.0);
1873   RNA_def_property_ui_text(
1874       prop,
1875       "Width",
1876       "Particle (narrow) band width (higher value results in thicker band and more particles)");
1877   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
1878 
1879   prop = RNA_def_property(srna, "use_flip_particles", PROP_BOOLEAN, PROP_NONE);
1880   RNA_def_property_boolean_sdna(prop, NULL, "particle_type", FLUID_DOMAIN_PARTICLE_FLIP);
1881   RNA_def_property_ui_text(prop, "FLIP", "Create liquid particle system");
1882   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
1883   RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Fluid_flip_parts_update");
1884 
1885   prop = RNA_def_property(srna, "use_fractions", PROP_BOOLEAN, PROP_NONE);
1886   RNA_def_property_boolean_sdna(prop, NULL, "flags", FLUID_DOMAIN_USE_FRACTIONS);
1887   RNA_def_property_ui_text(
1888       prop,
1889       "Fractional Obstacles",
1890       "Fractional obstacles improve and smoothen the fluid-obstacle boundary");
1891   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
1892   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
1893 
1894   prop = RNA_def_property(srna, "fractions_threshold", PROP_FLOAT, PROP_NONE);
1895   RNA_def_property_range(prop, 0.001, 1.0);
1896   RNA_def_property_ui_range(prop, 0.01, 1.0, 0.05, -1);
1897   RNA_def_property_ui_text(prop,
1898                            "Obstacle Threshold",
1899                            "Determines how much fluid is allowed in an obstacle cell "
1900                            "(higher values will tag a boundary cell as an obstacle easier "
1901                            "and reduce the boundary smoothening effect)");
1902   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
1903 
1904   prop = RNA_def_property(srna, "fractions_distance", PROP_FLOAT, PROP_NONE);
1905   RNA_def_property_range(prop, -5.0, 5.0);
1906   RNA_def_property_ui_range(prop, 0.01, 5.0, 0.1, -1);
1907   RNA_def_property_ui_text(prop,
1908                            "Obstacle Distance",
1909                            "Determines how far apart fluid and obstacle are (higher values will "
1910                            "result in fluid being further away from obstacles, smaller values "
1911                            "will let fluid move towards the inside of obstacles)");
1912   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
1913 
1914   prop = RNA_def_property(srna, "sys_particle_maximum", PROP_INT, PROP_NONE);
1915   RNA_def_property_int_sdna(prop, NULL, "sys_particle_maximum");
1916   RNA_def_property_range(prop, 0, INT_MAX);
1917   RNA_def_property_ui_text(
1918       prop,
1919       "System Maximum",
1920       "Maximum number of fluid particles that are allowed in this simulation");
1921   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
1922 
1923   /*  diffusion options */
1924 
1925   prop = RNA_def_property(srna, "use_diffusion", PROP_BOOLEAN, PROP_NONE);
1926   RNA_def_property_boolean_sdna(prop, NULL, "flags", FLUID_DOMAIN_USE_DIFFUSION);
1927   RNA_def_property_ui_text(
1928       prop, "Use Diffusion", "Enable fluid diffusion settings (e.g. viscosity, surface tension)");
1929   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
1930   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
1931 
1932   prop = RNA_def_property(srna, "surface_tension", PROP_FLOAT, PROP_NONE);
1933   RNA_def_property_range(prop, 0.0, 100.0);
1934   RNA_def_property_ui_text(
1935       prop,
1936       "Tension",
1937       "Surface tension of liquid (higher value results in greater hydrophobic behaviour)");
1938   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
1939 
1940   prop = RNA_def_property(srna, "viscosity_base", PROP_FLOAT, PROP_NONE);
1941   RNA_def_property_float_sdna(prop, NULL, "viscosity_base");
1942   RNA_def_property_range(prop, 0, 10);
1943   RNA_def_property_ui_text(
1944       prop,
1945       "Viscosity Base",
1946       "Viscosity setting: value that is multiplied by 10 to the power of (exponent*-1)");
1947   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
1948 
1949   prop = RNA_def_property(srna, "viscosity_exponent", PROP_INT, PROP_NONE);
1950   RNA_def_property_int_sdna(prop, NULL, "viscosity_exponent");
1951   RNA_def_property_range(prop, 0, 10);
1952   RNA_def_property_ui_text(
1953       prop,
1954       "Viscosity Exponent",
1955       "Negative exponent for the viscosity value (to simplify entering small values "
1956       "e.g. 5*10^-6)");
1957   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
1958 
1959   /*  mesh options options */
1960 
1961   prop = RNA_def_property(srna, "mesh_concave_upper", PROP_FLOAT, PROP_NONE);
1962   RNA_def_property_range(prop, 0.0, 10.0);
1963   RNA_def_property_ui_text(
1964       prop,
1965       "Upper Concavity",
1966       "Upper mesh concavity bound (high values tend to smoothen and fill out concave regions)");
1967   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_meshcache_reset");
1968 
1969   prop = RNA_def_property(srna, "mesh_concave_lower", PROP_FLOAT, PROP_NONE);
1970   RNA_def_property_range(prop, 0.0, 10.0);
1971   RNA_def_property_ui_text(
1972       prop,
1973       "Lower Concavity",
1974       "Lower mesh concavity bound (high values tend to smoothen and fill out concave regions)");
1975   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_meshcache_reset");
1976 
1977   prop = RNA_def_property(srna, "mesh_smoothen_pos", PROP_INT, PROP_NONE);
1978   RNA_def_property_range(prop, 0, 100);
1979   RNA_def_property_ui_text(prop, "Smoothen Pos", "Positive mesh smoothening");
1980   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_meshcache_reset");
1981 
1982   prop = RNA_def_property(srna, "mesh_smoothen_neg", PROP_INT, PROP_NONE);
1983   RNA_def_property_range(prop, 0, 100);
1984   RNA_def_property_ui_text(prop, "Smoothen Neg", "Negative mesh smoothening");
1985   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_meshcache_reset");
1986 
1987   prop = RNA_def_property(srna, "mesh_scale", PROP_INT, PROP_NONE);
1988   RNA_def_property_int_sdna(prop, NULL, "mesh_scale");
1989   RNA_def_property_range(prop, 1, 100);
1990   RNA_def_property_ui_range(prop, 1, 10, 1, -1);
1991   RNA_def_property_ui_text(prop,
1992                            "Mesh scale",
1993                            "The mesh simulation is scaled up by this factor (compared to the base "
1994                            "resolution of the domain). For best meshing, it is recommended to "
1995                            "adjust the mesh particle radius alongside this value");
1996   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
1997   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_domain_mesh_reset");
1998 
1999   prop = RNA_def_property(srna, "mesh_generator", PROP_ENUM, PROP_NONE);
2000   RNA_def_property_enum_sdna(prop, NULL, "mesh_generator");
2001   RNA_def_property_enum_items(prop, fluid_mesh_quality_items);
2002   RNA_def_property_ui_text(prop, "Mesh generator", "Which particle level set generator to use");
2003   RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Fluid_update");
2004 
2005   prop = RNA_def_property(srna, "mesh_vertices", PROP_COLLECTION, PROP_NONE);
2006   RNA_def_property_collection_sdna(prop, NULL, "mesh_velocities", "totvert");
2007   RNA_def_property_struct_type(prop, "FluidDomainVertexVelocity");
2008   RNA_def_property_ui_text(
2009       prop, "Fluid Mesh Vertices", "Vertices of the fluid mesh generated by simulation");
2010 
2011   rna_def_fluid_mesh_vertices(brna);
2012 
2013   prop = RNA_def_property(srna, "use_mesh", PROP_BOOLEAN, PROP_NONE);
2014   RNA_def_property_boolean_sdna(prop, NULL, "flags", FLUID_DOMAIN_USE_MESH);
2015   RNA_def_property_ui_text(prop, "Use Mesh", "Enable fluid mesh (using amplification)");
2016   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2017   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_update");
2018 
2019   prop = RNA_def_property(srna, "use_speed_vectors", PROP_BOOLEAN, PROP_NONE);
2020   RNA_def_property_boolean_sdna(prop, NULL, "flags", FLUID_DOMAIN_USE_SPEED_VECTORS);
2021   RNA_def_property_ui_text(prop,
2022                            "Speed Vectors",
2023                            "Caches velocities of mesh vertices. These will be used "
2024                            "(automatically) when rendering with motion blur enabled");
2025   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2026   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_meshcache_reset");
2027 
2028   prop = RNA_def_property(srna, "mesh_particle_radius", PROP_FLOAT, PROP_NONE);
2029   RNA_def_property_range(prop, 0.0, 10.0);
2030   RNA_def_property_ui_text(prop,
2031                            "Radius",
2032                            "Particle radius factor (higher value results in larger (meshed) "
2033                            "particles). Needs to be adjusted after changing the mesh scale");
2034   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_meshcache_reset");
2035 
2036   /*  secondary particles options */
2037 
2038   prop = RNA_def_property(srna, "sndparticle_potential_min_wavecrest", PROP_FLOAT, PROP_NONE);
2039   RNA_def_property_float_sdna(prop, NULL, "sndparticle_tau_min_wc");
2040   RNA_def_property_range(prop, 0.0, 1000.0);
2041   RNA_def_property_ui_range(prop, 0.0, 1000.0, 100.0, 3);
2042   RNA_def_property_ui_text(prop,
2043                            "Minimum Wave Crest Potential",
2044                            "Lower clamping threshold for marking fluid cells as wave crests "
2045                            "(lower value results in more marked cells)");
2046   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_particlescache_reset");
2047 
2048   prop = RNA_def_property(srna, "sndparticle_potential_max_wavecrest", PROP_FLOAT, PROP_NONE);
2049   RNA_def_property_float_sdna(prop, NULL, "sndparticle_tau_max_wc");
2050   RNA_def_property_range(prop, 0.0, 1000.0);
2051   RNA_def_property_ui_range(prop, 0.0, 1000.0, 100.0, 3);
2052   RNA_def_property_ui_text(prop,
2053                            "Maximum Wave Crest Potential",
2054                            "Upper clamping threshold for marking fluid cells as wave crests "
2055                            "(higher value results in less marked cells)");
2056   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_particlescache_reset");
2057 
2058   prop = RNA_def_property(srna, "sndparticle_potential_min_trappedair", PROP_FLOAT, PROP_NONE);
2059   RNA_def_property_float_sdna(prop, NULL, "sndparticle_tau_min_ta");
2060   RNA_def_property_range(prop, 0.0, 1000.0);
2061   RNA_def_property_ui_range(prop, 0.0, 10000.0, 100.0, 3);
2062   RNA_def_property_ui_text(prop,
2063                            "Minimum Trapped Air Potential",
2064                            "Lower clamping threshold for marking fluid cells where air is trapped "
2065                            "(lower value results in more marked cells)");
2066   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_particlescache_reset");
2067 
2068   prop = RNA_def_property(srna, "sndparticle_potential_max_trappedair", PROP_FLOAT, PROP_NONE);
2069   RNA_def_property_float_sdna(prop, NULL, "sndparticle_tau_max_ta");
2070   RNA_def_property_range(prop, 0.0, 1000.0);
2071   RNA_def_property_ui_range(prop, 0.0, 1000.0, 100.0, 3);
2072   RNA_def_property_ui_text(prop,
2073                            "Maximum Trapped Air Potential",
2074                            "Upper clamping threshold for marking fluid cells where air is trapped "
2075                            "(higher value results in less marked cells)");
2076   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_particlescache_reset");
2077 
2078   prop = RNA_def_property(srna, "sndparticle_potential_min_energy", PROP_FLOAT, PROP_NONE);
2079   RNA_def_property_float_sdna(prop, NULL, "sndparticle_tau_min_k");
2080   RNA_def_property_range(prop, 0.0, 1000.0);
2081   RNA_def_property_ui_range(prop, 0.0, 1000.0, 100.0, 3);
2082   RNA_def_property_ui_text(
2083       prop,
2084       "Minimum Kinetic Energy Potential",
2085       "Lower clamping threshold that indicates the fluid speed where cells start to emit "
2086       "particles (lower values result in generally more particles)");
2087   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_particlescache_reset");
2088 
2089   prop = RNA_def_property(srna, "sndparticle_potential_max_energy", PROP_FLOAT, PROP_NONE);
2090   RNA_def_property_float_sdna(prop, NULL, "sndparticle_tau_max_k");
2091   RNA_def_property_range(prop, 0.0, 1000.0);
2092   RNA_def_property_ui_range(prop, 0.0, 1000.0, 100.0, 3);
2093   RNA_def_property_ui_text(
2094       prop,
2095       "Maximum Kinetic Energy Potential",
2096       "Upper clamping threshold that indicates the fluid speed where cells no longer emit more "
2097       "particles (higher value results in generally less particles)");
2098   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_particlescache_reset");
2099 
2100   prop = RNA_def_property(srna, "sndparticle_sampling_wavecrest", PROP_INT, PROP_NONE);
2101   RNA_def_property_int_sdna(prop, NULL, "sndparticle_k_wc");
2102   RNA_def_property_range(prop, 0, 10000);
2103   RNA_def_property_ui_range(prop, 0, 10000, 1.0, -1);
2104   RNA_def_property_ui_text(prop,
2105                            "Wave Crest Sampling",
2106                            "Maximum number of particles generated per wave crest cell per frame");
2107   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_particlescache_reset");
2108 
2109   prop = RNA_def_property(srna, "sndparticle_sampling_trappedair", PROP_INT, PROP_NONE);
2110   RNA_def_property_int_sdna(prop, NULL, "sndparticle_k_ta");
2111   RNA_def_property_range(prop, 0, 10000);
2112   RNA_def_property_ui_range(prop, 0, 10000, 1.0, -1);
2113   RNA_def_property_ui_text(prop,
2114                            "Trapped Air Sampling",
2115                            "Maximum number of particles generated per trapped air cell per frame");
2116   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_particlescache_reset");
2117 
2118   prop = RNA_def_property(srna, "sndparticle_bubble_buoyancy", PROP_FLOAT, PROP_NONE);
2119   RNA_def_property_float_sdna(prop, NULL, "sndparticle_k_b");
2120   RNA_def_property_range(prop, 0.0, 100.0);
2121   RNA_def_property_ui_range(prop, 0.0, 100.0, 10.0, 2);
2122   RNA_def_property_ui_text(prop,
2123                            "Bubble Buoyancy",
2124                            "Amount of buoyancy force that rises bubbles (high value results in "
2125                            "bubble movement mainly upwards)");
2126   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_particlescache_reset");
2127 
2128   prop = RNA_def_property(srna, "sndparticle_bubble_drag", PROP_FLOAT, PROP_NONE);
2129   RNA_def_property_float_sdna(prop, NULL, "sndparticle_k_d");
2130   RNA_def_property_range(prop, 0.0, 100.0);
2131   RNA_def_property_ui_range(prop, 0.0, 100.0, 10.0, 2);
2132   RNA_def_property_ui_text(prop,
2133                            "Bubble Drag",
2134                            "Amount of drag force that moves bubbles along with the fluid (high "
2135                            "value results in bubble movement mainly along with the fluid)");
2136   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_particlescache_reset");
2137 
2138   prop = RNA_def_property(srna, "sndparticle_life_min", PROP_FLOAT, PROP_NONE);
2139   RNA_def_property_float_sdna(prop, NULL, "sndparticle_l_min");
2140   RNA_def_property_range(prop, 0.0, 10000.0);
2141   RNA_def_property_ui_range(prop, 0.0, 10000.0, 100.0, 1);
2142   RNA_def_property_ui_text(prop, "Minimum Lifetime", "Lowest possible particle lifetime");
2143   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_particlescache_reset");
2144 
2145   prop = RNA_def_property(srna, "sndparticle_life_max", PROP_FLOAT, PROP_NONE);
2146   RNA_def_property_float_sdna(prop, NULL, "sndparticle_l_max");
2147   RNA_def_property_range(prop, 0.0, 10000.0);
2148   RNA_def_property_ui_range(prop, 0.0, 10000.0, 100.0, 1);
2149   RNA_def_property_ui_text(prop, "Maximum Lifetime", "Highest possible particle lifetime");
2150   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_particlescache_reset");
2151 
2152   prop = RNA_def_property(srna, "sndparticle_boundary", PROP_ENUM, PROP_NONE);
2153   RNA_def_property_enum_sdna(prop, NULL, "sndparticle_boundary");
2154   RNA_def_property_enum_items(prop, sndparticle_boundary_items);
2155   RNA_def_property_ui_text(
2156       prop, "Particles in Boundary", "How particles that left the domain are treated");
2157   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_particlescache_reset");
2158 
2159   prop = RNA_def_property(srna, "sndparticle_combined_export", PROP_ENUM, PROP_NONE);
2160   RNA_def_property_enum_sdna(prop, NULL, "sndparticle_combined_export");
2161   RNA_def_property_enum_items(prop, sndparticle_combined_export_items);
2162   RNA_def_property_ui_text(
2163       prop,
2164       "Combined Export",
2165       "Determines which particle systems are created from secondary particles");
2166   RNA_def_property_update(prop, 0, "rna_Fluid_combined_export_update");
2167 
2168   prop = RNA_def_property(srna, "sndparticle_potential_radius", PROP_INT, PROP_NONE);
2169   RNA_def_property_int_sdna(prop, NULL, "sndparticle_potential_radius");
2170   RNA_def_property_range(prop, 1, 4);
2171   RNA_def_property_ui_range(prop, 1, 4, 1, -1);
2172   RNA_def_property_ui_text(prop,
2173                            "Potential Radius",
2174                            "Radius to compute potential for each cell (higher values are slower "
2175                            "but create smoother potential grids)");
2176   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_particlescache_reset");
2177 
2178   prop = RNA_def_property(srna, "sndparticle_update_radius", PROP_INT, PROP_NONE);
2179   RNA_def_property_int_sdna(prop, NULL, "sndparticle_update_radius");
2180   RNA_def_property_range(prop, 1, 4);
2181   RNA_def_property_ui_range(prop, 1, 4, 1, -1);
2182   RNA_def_property_ui_text(prop,
2183                            "Update Radius",
2184                            "Radius to compute position update for each particle (higher values "
2185                            "are slower but particles move less chaotic)");
2186   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_particlescache_reset");
2187 
2188   prop = RNA_def_property(srna, "particle_scale", PROP_INT, PROP_NONE);
2189   RNA_def_property_int_sdna(prop, NULL, "particle_scale");
2190   RNA_def_property_range(prop, 1, 100);
2191   RNA_def_property_ui_range(prop, 1, 10, 1, -1);
2192   RNA_def_property_ui_text(prop,
2193                            "Particle scale",
2194                            "The particle simulation is scaled up by this factor (compared to the "
2195                            "base resolution of the domain)");
2196   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2197   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_domain_particles_reset");
2198 
2199   prop = RNA_def_property(srna, "use_spray_particles", PROP_BOOLEAN, PROP_NONE);
2200   RNA_def_property_boolean_sdna(prop, NULL, "particle_type", FLUID_DOMAIN_PARTICLE_SPRAY);
2201   RNA_def_property_ui_text(prop, "Spray", "Create spray particle system");
2202   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2203   RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Fluid_spray_parts_update");
2204 
2205   prop = RNA_def_property(srna, "use_bubble_particles", PROP_BOOLEAN, PROP_NONE);
2206   RNA_def_property_boolean_sdna(prop, NULL, "particle_type", FLUID_DOMAIN_PARTICLE_BUBBLE);
2207   RNA_def_property_ui_text(prop, "Bubble", "Create bubble particle system");
2208   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2209   RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Fluid_bubble_parts_update");
2210 
2211   prop = RNA_def_property(srna, "use_foam_particles", PROP_BOOLEAN, PROP_NONE);
2212   RNA_def_property_boolean_sdna(prop, NULL, "particle_type", FLUID_DOMAIN_PARTICLE_FOAM);
2213   RNA_def_property_ui_text(prop, "Foam", "Create foam particle system");
2214   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2215   RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Fluid_foam_parts_update");
2216 
2217   prop = RNA_def_property(srna, "use_tracer_particles", PROP_BOOLEAN, PROP_NONE);
2218   RNA_def_property_boolean_sdna(prop, NULL, "particle_type", FLUID_DOMAIN_PARTICLE_TRACER);
2219   RNA_def_property_ui_text(prop, "Tracer", "Create tracer particle system");
2220   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2221   RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Fluid_tracer_parts_update");
2222 
2223   /* fluid guiding options */
2224 
2225   prop = RNA_def_property(srna, "guide_alpha", PROP_FLOAT, PROP_NONE);
2226   RNA_def_property_float_sdna(prop, NULL, "guide_alpha");
2227   RNA_def_property_range(prop, 1.0, 100.0);
2228   RNA_def_property_ui_text(prop, "Weight", "Guiding weight (higher value results in greater lag)");
2229   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_guidingcache_reset");
2230 
2231   prop = RNA_def_property(srna, "guide_beta", PROP_INT, PROP_NONE);
2232   RNA_def_property_int_sdna(prop, NULL, "guide_beta");
2233   RNA_def_property_range(prop, 1, 50);
2234   RNA_def_property_ui_text(prop, "Size", "Guiding size (higher value results in larger vortices)");
2235   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_guidingcache_reset");
2236 
2237   prop = RNA_def_property(srna, "guide_vel_factor", PROP_FLOAT, PROP_NONE);
2238   RNA_def_property_float_sdna(prop, NULL, "guide_vel_factor");
2239   RNA_def_property_range(prop, 0.0, 100.0);
2240   RNA_def_property_ui_text(
2241       prop,
2242       "Velocity Factor",
2243       "Guiding velocity factor (higher value results in greater guiding velocities)");
2244   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_guidingcache_reset");
2245 
2246   prop = RNA_def_property(srna, "guide_source", PROP_ENUM, PROP_NONE);
2247   RNA_def_property_enum_sdna(prop, NULL, "guide_source");
2248   RNA_def_property_enum_items(prop, fluid_guide_source_items);
2249   RNA_def_property_ui_text(prop, "Guiding source", "Choose where to get guiding velocities from");
2250   RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Fluid_update");
2251 
2252   prop = RNA_def_property(srna, "guide_parent", PROP_POINTER, PROP_NONE);
2253   RNA_def_property_pointer_sdna(prop, NULL, "guide_parent");
2254   RNA_def_property_struct_type(prop, "Object");
2255   RNA_def_property_pointer_funcs(prop, NULL, "rna_Fluid_guide_parent_set", NULL, NULL);
2256   RNA_def_property_flag(prop, PROP_EDITABLE);
2257   RNA_def_property_ui_text(prop,
2258                            "",
2259                            "Use velocities from this object for the guiding effect (object needs "
2260                            "to have fluid modifier and be of type domain))");
2261   RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Fluid_guidingcache_reset");
2262 
2263   prop = RNA_def_property(srna, "use_guide", PROP_BOOLEAN, PROP_NONE);
2264   RNA_def_property_boolean_sdna(prop, NULL, "flags", FLUID_DOMAIN_USE_GUIDE);
2265   RNA_def_property_ui_text(prop, "Use Guiding", "Enable fluid guiding");
2266   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2267   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_guidingcache_reset");
2268 
2269   /* cache options */
2270 
2271   prop = RNA_def_property(srna, "cache_frame_start", PROP_INT, PROP_TIME);
2272   RNA_def_property_int_sdna(prop, NULL, "cache_frame_start");
2273   RNA_def_property_range(prop, -MAXFRAME, MAXFRAME);
2274   RNA_def_property_int_funcs(prop, NULL, "rna_Fluid_cache_startframe_set", NULL);
2275   RNA_def_property_ui_text(
2276       prop,
2277       "Start",
2278       "Frame on which the simulation starts. This is the first frame that will be baked");
2279   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2280 
2281   prop = RNA_def_property(srna, "cache_frame_end", PROP_INT, PROP_TIME);
2282   RNA_def_property_int_sdna(prop, NULL, "cache_frame_end");
2283   RNA_def_property_range(prop, -MAXFRAME, MAXFRAME);
2284   RNA_def_property_int_funcs(prop, NULL, "rna_Fluid_cache_endframe_set", NULL);
2285   RNA_def_property_ui_text(
2286       prop,
2287       "End",
2288       "Frame on which the simulation stops. This is the last frame that will be baked");
2289   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2290 
2291   prop = RNA_def_property(srna, "cache_frame_offset", PROP_INT, PROP_TIME);
2292   RNA_def_property_int_sdna(prop, NULL, "cache_frame_offset");
2293   RNA_def_property_range(prop, -MAXFRAME, MAXFRAME);
2294   RNA_def_property_ui_text(
2295       prop,
2296       "Offset",
2297       "Frame offset that is used when loading the simulation from the cache. It is not considered "
2298       "when baking the simulation, only when loading it");
2299   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2300 
2301   prop = RNA_def_property(srna, "cache_frame_pause_data", PROP_INT, PROP_TIME);
2302   RNA_def_property_int_sdna(prop, NULL, "cache_frame_pause_data");
2303 
2304   prop = RNA_def_property(srna, "cache_frame_pause_noise", PROP_INT, PROP_TIME);
2305   RNA_def_property_int_sdna(prop, NULL, "cache_frame_pause_noise");
2306 
2307   prop = RNA_def_property(srna, "cache_frame_pause_mesh", PROP_INT, PROP_TIME);
2308   RNA_def_property_int_sdna(prop, NULL, "cache_frame_pause_mesh");
2309 
2310   prop = RNA_def_property(srna, "cache_frame_pause_particles", PROP_INT, PROP_TIME);
2311   RNA_def_property_int_sdna(prop, NULL, "cache_frame_pause_particles");
2312 
2313   prop = RNA_def_property(srna, "cache_frame_pause_guide", PROP_INT, PROP_TIME);
2314   RNA_def_property_int_sdna(prop, NULL, "cache_frame_pause_guide");
2315 
2316   prop = RNA_def_property(srna, "cache_mesh_format", PROP_ENUM, PROP_NONE);
2317   RNA_def_property_enum_sdna(prop, NULL, "cache_mesh_format");
2318   RNA_def_property_enum_items(prop, cache_file_type_items);
2319   RNA_def_property_enum_funcs(
2320       prop, NULL, "rna_Fluid_cachetype_mesh_set", "rna_Fluid_cachetype_mesh_itemf");
2321   RNA_def_property_ui_text(
2322       prop, "File Format", "Select the file format to be used for caching surface data");
2323   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2324   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_meshcache_reset");
2325 
2326   prop = RNA_def_property(srna, "cache_data_format", PROP_ENUM, PROP_NONE);
2327   RNA_def_property_enum_sdna(prop, NULL, "cache_data_format");
2328   RNA_def_property_enum_items(prop, cache_file_type_items);
2329   RNA_def_property_enum_funcs(
2330       prop, NULL, "rna_Fluid_cachetype_data_set", "rna_Fluid_cachetype_volume_itemf");
2331   RNA_def_property_ui_text(
2332       prop, "File Format", "Select the file format to be used for caching volumetric data");
2333   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2334   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
2335 
2336   prop = RNA_def_property(srna, "cache_particle_format", PROP_ENUM, PROP_NONE);
2337   RNA_def_property_enum_sdna(prop, NULL, "cache_particle_format");
2338   RNA_def_property_enum_items(prop, cache_file_type_items);
2339   RNA_def_property_enum_funcs(
2340       prop, NULL, "rna_Fluid_cachetype_particle_set", "rna_Fluid_cachetype_particle_itemf");
2341   RNA_def_property_ui_text(
2342       prop, "File Format", "Select the file format to be used for caching particle data");
2343   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2344   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_particlescache_reset");
2345 
2346   prop = RNA_def_property(srna, "cache_noise_format", PROP_ENUM, PROP_NONE);
2347   RNA_def_property_enum_sdna(prop, NULL, "cache_noise_format");
2348   RNA_def_property_enum_items(prop, cache_file_type_items);
2349   RNA_def_property_enum_funcs(
2350       prop, NULL, "rna_Fluid_cachetype_noise_set", "rna_Fluid_cachetype_volume_itemf");
2351   RNA_def_property_ui_text(
2352       prop, "File Format", "Select the file format to be used for caching noise data");
2353   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2354   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_noisecache_reset");
2355 
2356   prop = RNA_def_property(srna, "cache_type", PROP_ENUM, PROP_NONE);
2357   RNA_def_property_enum_sdna(prop, NULL, "cache_type");
2358   RNA_def_property_enum_items(prop, cache_types);
2359   RNA_def_property_enum_funcs(prop, NULL, "rna_Fluid_cachetype_set", NULL);
2360   RNA_def_property_ui_text(prop, "Type", "Change the cache type of the simulation");
2361   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2362   RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Fluid_domain_data_reset");
2363 
2364   prop = RNA_def_property(srna, "cache_resumable", PROP_BOOLEAN, PROP_NONE);
2365   RNA_def_property_boolean_sdna(prop, NULL, "flags", FLUID_DOMAIN_USE_RESUMABLE_CACHE);
2366   RNA_def_property_ui_text(
2367       prop,
2368       "Resumable",
2369       "Additional data will be saved so that the bake jobs can be resumed after pausing. Because "
2370       "more data will be written to disk it is recommended to avoid enabling this option when "
2371       "baking at high resolutions");
2372   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2373   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
2374 
2375   prop = RNA_def_property(srna, "cache_directory", PROP_STRING, PROP_DIRPATH);
2376   RNA_def_property_string_maxlength(prop, FILE_MAX);
2377   RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Fluid_cache_directory_set");
2378   RNA_def_property_string_sdna(prop, NULL, "cache_directory");
2379   RNA_def_property_ui_text(prop, "Cache directory", "Directory that contains fluid cache files");
2380   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_update");
2381 
2382   prop = RNA_def_property(srna, "is_cache_baking_data", PROP_BOOLEAN, PROP_NONE);
2383   RNA_def_property_boolean_sdna(prop, NULL, "cache_flag", FLUID_DOMAIN_BAKING_DATA);
2384   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, NULL);
2385 
2386   prop = RNA_def_property(srna, "has_cache_baked_data", PROP_BOOLEAN, PROP_NONE);
2387   RNA_def_property_boolean_sdna(prop, NULL, "cache_flag", FLUID_DOMAIN_BAKED_DATA);
2388   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, NULL);
2389 
2390   prop = RNA_def_property(srna, "is_cache_baking_noise", PROP_BOOLEAN, PROP_NONE);
2391   RNA_def_property_boolean_sdna(prop, NULL, "cache_flag", FLUID_DOMAIN_BAKING_NOISE);
2392   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, NULL);
2393 
2394   prop = RNA_def_property(srna, "has_cache_baked_noise", PROP_BOOLEAN, PROP_NONE);
2395   RNA_def_property_boolean_sdna(prop, NULL, "cache_flag", FLUID_DOMAIN_BAKED_NOISE);
2396   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, NULL);
2397 
2398   prop = RNA_def_property(srna, "is_cache_baking_mesh", PROP_BOOLEAN, PROP_NONE);
2399   RNA_def_property_boolean_sdna(prop, NULL, "cache_flag", FLUID_DOMAIN_BAKING_MESH);
2400   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, NULL);
2401 
2402   prop = RNA_def_property(srna, "has_cache_baked_mesh", PROP_BOOLEAN, PROP_NONE);
2403   RNA_def_property_boolean_sdna(prop, NULL, "cache_flag", FLUID_DOMAIN_BAKED_MESH);
2404   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, NULL);
2405 
2406   prop = RNA_def_property(srna, "is_cache_baking_particles", PROP_BOOLEAN, PROP_NONE);
2407   RNA_def_property_boolean_sdna(prop, NULL, "cache_flag", FLUID_DOMAIN_BAKING_PARTICLES);
2408   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, NULL);
2409 
2410   prop = RNA_def_property(srna, "has_cache_baked_particles", PROP_BOOLEAN, PROP_NONE);
2411   RNA_def_property_boolean_sdna(prop, NULL, "cache_flag", FLUID_DOMAIN_BAKED_PARTICLES);
2412   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, NULL);
2413 
2414   prop = RNA_def_property(srna, "is_cache_baking_guide", PROP_BOOLEAN, PROP_NONE);
2415   RNA_def_property_boolean_sdna(prop, NULL, "cache_flag", FLUID_DOMAIN_BAKING_GUIDE);
2416   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, NULL);
2417 
2418   prop = RNA_def_property(srna, "has_cache_baked_guide", PROP_BOOLEAN, PROP_NONE);
2419   RNA_def_property_boolean_sdna(prop, NULL, "cache_flag", FLUID_DOMAIN_BAKED_GUIDE);
2420   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, NULL);
2421 
2422   /* Read only checks, avoids individually accessing flags above. */
2423   prop = RNA_def_property(srna, "is_cache_baking_any", PROP_BOOLEAN, PROP_NONE);
2424   RNA_def_property_boolean_sdna(prop, NULL, "cache_flag", FLUID_DOMAIN_BAKING_ALL);
2425   RNA_def_property_flag(prop, PROP_EDITABLE);
2426 
2427   prop = RNA_def_property(srna, "has_cache_baked_any", PROP_BOOLEAN, PROP_NONE);
2428   RNA_def_property_boolean_sdna(prop, NULL, "cache_flag", FLUID_DOMAIN_BAKED_ALL);
2429   RNA_def_property_flag(prop, PROP_EDITABLE);
2430 
2431   prop = RNA_def_property(srna, "export_manta_script", PROP_BOOLEAN, PROP_NONE);
2432   RNA_def_property_boolean_sdna(prop, NULL, "flags", FLUID_DOMAIN_EXPORT_MANTA_SCRIPT);
2433   RNA_def_property_ui_text(
2434       prop,
2435       "Export Mantaflow Script",
2436       "Generate and export Mantaflow script from current domain settings during bake. This is "
2437       "only needed if you plan to analyze the cache (e.g. view grids, velocity vectors, "
2438       "particles) in Mantaflow directly (outside of Blender) after baking the simulation");
2439   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2440   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_domain_data_reset");
2441 
2442   prop = RNA_def_property(srna, "openvdb_cache_compress_type", PROP_ENUM, PROP_NONE);
2443   RNA_def_property_enum_sdna(prop, NULL, "openvdb_compression");
2444   RNA_def_property_enum_items(prop, prop_compression_items);
2445   RNA_def_property_ui_text(prop, "Compression", "Compression method to be used");
2446   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_domain_data_reset");
2447 
2448   prop = RNA_def_property(srna, "openvdb_data_depth", PROP_ENUM, PROP_NONE);
2449   RNA_def_property_enum_sdna(prop, NULL, "openvdb_data_depth");
2450   RNA_def_property_enum_items(prop, fluid_data_depth_items);
2451   RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Fluid_data_depth_itemf");
2452   RNA_def_property_ui_text(
2453       prop,
2454       "Data Depth",
2455       "Bit depth for fluid particles and grids (lower bit values reduce file size)");
2456   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_domain_data_reset");
2457 
2458   /* time options */
2459 
2460   prop = RNA_def_property(srna, "time_scale", PROP_FLOAT, PROP_NONE);
2461   RNA_def_property_float_sdna(prop, NULL, "time_scale");
2462   RNA_def_property_range(prop, 0.0001, 10.0);
2463   RNA_def_property_ui_text(prop, "Time Scale", "Adjust simulation speed");
2464   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
2465 
2466   prop = RNA_def_property(srna, "cfl_condition", PROP_FLOAT, PROP_NONE);
2467   RNA_def_property_float_sdna(prop, NULL, "cfl_condition");
2468   RNA_def_property_range(prop, 0.0, 10.0);
2469   RNA_def_property_ui_text(
2470       prop, "CFL", "Maximal velocity per cell (higher value results in greater timesteps)");
2471   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
2472 
2473   prop = RNA_def_property(srna, "use_adaptive_timesteps", PROP_BOOLEAN, PROP_NONE);
2474   RNA_def_property_boolean_sdna(prop, NULL, "flags", FLUID_DOMAIN_USE_ADAPTIVE_TIME);
2475   RNA_def_property_ui_text(prop, "Use Adaptive Time Steps", "");
2476   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
2477 
2478   prop = RNA_def_property(srna, "timesteps_min", PROP_INT, PROP_NONE);
2479   RNA_def_property_int_sdna(prop, NULL, "timesteps_minimum");
2480   RNA_def_property_range(prop, 1, 100);
2481   RNA_def_property_ui_range(prop, 0, 100, 1, -1);
2482   RNA_def_property_ui_text(
2483       prop, "Minimum", "Minimum number of simulation steps to perform for one frame");
2484   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
2485 
2486   prop = RNA_def_property(srna, "timesteps_max", PROP_INT, PROP_NONE);
2487   RNA_def_property_int_sdna(prop, NULL, "timesteps_maximum");
2488   RNA_def_property_range(prop, 1, 100);
2489   RNA_def_property_ui_range(prop, 0, 100, 1, -1);
2490   RNA_def_property_ui_text(
2491       prop, "Maximum", "Maximum number of simulation steps to perform for one frame");
2492   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
2493 
2494   /* display settings */
2495 
2496   prop = RNA_def_property(srna, "use_slice", PROP_BOOLEAN, PROP_NONE);
2497   RNA_def_property_boolean_sdna(prop, NULL, "axis_slice_method", AXIS_SLICE_SINGLE);
2498   RNA_def_property_ui_text(prop, "Slice", "Perform a single slice of the domain object");
2499   RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2500 
2501   prop = RNA_def_property(srna, "slice_axis", PROP_ENUM, PROP_NONE);
2502   RNA_def_property_enum_sdna(prop, NULL, "slice_axis");
2503   RNA_def_property_enum_items(prop, axis_slice_position_items);
2504   RNA_def_property_ui_text(prop, "Axis", "");
2505   RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2506 
2507   prop = RNA_def_property(srna, "slice_per_voxel", PROP_FLOAT, PROP_NONE);
2508   RNA_def_property_float_sdna(prop, NULL, "slice_per_voxel");
2509   RNA_def_property_range(prop, 0.0, 100.0);
2510   RNA_def_property_ui_range(prop, 0.0, 5.0, 0.1, 1);
2511   RNA_def_property_ui_text(
2512       prop, "Slice Per Voxel", "How many slices per voxel should be generated");
2513   RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2514 
2515   prop = RNA_def_property(srna, "slice_depth", PROP_FLOAT, PROP_FACTOR);
2516   RNA_def_property_float_sdna(prop, NULL, "slice_depth");
2517   RNA_def_property_range(prop, 0.0, 1.0);
2518   RNA_def_property_ui_range(prop, 0.0, 1.0, 0.1, 3);
2519   RNA_def_property_ui_text(prop, "Position", "Position of the slice");
2520   RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2521 
2522   prop = RNA_def_property(srna, "display_thickness", PROP_FLOAT, PROP_NONE);
2523   RNA_def_property_float_sdna(prop, NULL, "display_thickness");
2524   RNA_def_property_range(prop, 0.001, 1000.0);
2525   RNA_def_property_ui_range(prop, 0.1, 100.0, 0.1, 3);
2526   RNA_def_property_ui_text(prop, "Thickness", "Thickness of smoke drawing in the viewport");
2527   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, NULL);
2528 
2529   prop = RNA_def_property(srna, "display_interpolation", PROP_ENUM, PROP_NONE);
2530   RNA_def_property_enum_sdna(prop, NULL, "interp_method");
2531   RNA_def_property_enum_items(prop, interp_method_item);
2532   RNA_def_property_ui_text(
2533       prop, "Interpolation", "Interpolation method to use for smoke/fire volumes in solid mode");
2534   RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2535 
2536   prop = RNA_def_property(srna, "show_gridlines", PROP_BOOLEAN, PROP_NONE);
2537   RNA_def_property_boolean_sdna(prop, NULL, "show_gridlines", 0);
2538   RNA_def_property_ui_text(prop, "Gridlines", "Show gridlines");
2539   RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2540 
2541   prop = RNA_def_property(srna, "show_velocity", PROP_BOOLEAN, PROP_NONE);
2542   RNA_def_property_boolean_sdna(prop, NULL, "draw_velocity", 0);
2543   RNA_def_property_ui_text(prop, "Vector Display", "Visualize vector fields");
2544   RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2545 
2546   prop = RNA_def_property(srna, "vector_display_type", PROP_ENUM, PROP_NONE);
2547   RNA_def_property_enum_sdna(prop, NULL, "vector_draw_type");
2548   RNA_def_property_enum_items(prop, vector_draw_items);
2549   RNA_def_property_ui_text(prop, "Display Type", "");
2550   RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2551 
2552   prop = RNA_def_property(srna, "vector_field", PROP_ENUM, PROP_NONE);
2553   RNA_def_property_enum_sdna(prop, NULL, "vector_field");
2554   RNA_def_property_enum_items(prop, vector_field_items);
2555   RNA_def_property_ui_text(prop, "Field", "Vector field to be represented by the display vectors");
2556   RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2557 
2558   prop = RNA_def_property(srna, "vector_scale_with_magnitude", PROP_BOOLEAN, PROP_NONE);
2559   RNA_def_property_boolean_sdna(prop, NULL, "vector_scale_with_magnitude", 0);
2560   RNA_def_property_ui_text(prop, "Magnitude", "Scale vectors with their magnitudes");
2561   RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2562 
2563   prop = RNA_def_property(srna, "vector_show_mac_x", PROP_BOOLEAN, PROP_NONE);
2564   RNA_def_property_boolean_sdna(prop, NULL, "vector_draw_mac_components", VECTOR_DRAW_MAC_X);
2565   RNA_def_property_ui_text(prop, "X", "Show X-component of MAC Grid");
2566   RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2567 
2568   prop = RNA_def_property(srna, "vector_show_mac_y", PROP_BOOLEAN, PROP_NONE);
2569   RNA_def_property_boolean_sdna(prop, NULL, "vector_draw_mac_components", VECTOR_DRAW_MAC_Y);
2570   RNA_def_property_ui_text(prop, "Y", "Show Y-component of MAC Grid");
2571   RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2572 
2573   prop = RNA_def_property(srna, "vector_show_mac_z", PROP_BOOLEAN, PROP_NONE);
2574   RNA_def_property_boolean_sdna(prop, NULL, "vector_draw_mac_components", VECTOR_DRAW_MAC_Z);
2575   RNA_def_property_ui_text(prop, "Z", "Show Z-component of MAC Grid");
2576   RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2577 
2578   prop = RNA_def_property(srna, "vector_scale", PROP_FLOAT, PROP_NONE);
2579   RNA_def_property_float_sdna(prop, NULL, "vector_scale");
2580   RNA_def_property_range(prop, 0.0, 1000.0);
2581   RNA_def_property_ui_range(prop, 0.0, 100.0, 0.1, 3);
2582   RNA_def_property_ui_text(prop, "Scale", "Multiplier for scaling the vectors");
2583   RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2584 
2585   /* --------- Color mapping. --------- */
2586 
2587   prop = RNA_def_property(srna, "use_color_ramp", PROP_BOOLEAN, PROP_NONE);
2588   RNA_def_property_boolean_sdna(prop, NULL, "use_coba", 0);
2589   RNA_def_property_boolean_funcs(prop, NULL, "rna_Fluid_use_color_ramp_set");
2590   RNA_def_property_ui_text(prop,
2591                            "Grid Display",
2592                            "Render a simulation field while mapping its voxels values to the "
2593                            "colors of a ramp or using a predefined color code");
2594   RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2595 
2596   /* Coba field items - generated dynamically based on domain type */
2597   static const EnumPropertyItem coba_field_items[] = {
2598       {0, "NONE", 0, "", ""},
2599       {0, NULL, 0, NULL, NULL},
2600   };
2601 
2602   prop = RNA_def_property(srna, "color_ramp_field", PROP_ENUM, PROP_NONE);
2603   RNA_def_property_enum_sdna(prop, NULL, "coba_field");
2604   RNA_def_property_enum_items(prop, coba_field_items);
2605   RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Fluid_cobafield_itemf");
2606   RNA_def_property_ui_text(prop, "Field", "Simulation field to color map");
2607   RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2608 
2609   prop = RNA_def_property(srna, "color_ramp_field_scale", PROP_FLOAT, PROP_NONE);
2610   RNA_def_property_float_sdna(prop, NULL, "grid_scale");
2611   RNA_def_property_range(prop, 0.001, 100000.0);
2612   RNA_def_property_ui_range(prop, 0.001, 1000.0, 0.1, 3);
2613   RNA_def_property_ui_text(
2614       prop, "Scale", "Multiplier for scaling the selected field to color map");
2615   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, NULL);
2616 
2617   prop = RNA_def_property(srna, "color_ramp", PROP_POINTER, PROP_NEVER_NULL);
2618   RNA_def_property_pointer_sdna(prop, NULL, "coba");
2619   RNA_def_property_struct_type(prop, "ColorRamp");
2620   RNA_def_property_ui_text(prop, "Color Ramp", "");
2621   RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2622 
2623   prop = RNA_def_property(srna, "clipping", PROP_FLOAT, PROP_NONE);
2624   RNA_def_property_float_sdna(prop, NULL, "clipping");
2625   RNA_def_property_range(prop, 0.0, 1.0);
2626   RNA_def_property_ui_range(prop, 0.0, 1.0, 0.1, 6);
2627   RNA_def_property_ui_text(
2628       prop,
2629       "Clipping",
2630       "Value under which voxels are considered empty space to optimize rendering");
2631   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, NULL);
2632 
2633   prop = RNA_def_property(srna, "gridlines_color_field", PROP_ENUM, PROP_NONE);
2634   RNA_def_property_enum_sdna(prop, NULL, "gridlines_color_field");
2635   RNA_def_property_enum_items(prop, gridlines_color_field_items);
2636   RNA_def_property_ui_text(
2637       prop, "Color Gridlines", "Simulation field to color map onto gridlines");
2638   RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2639 
2640   prop = RNA_def_property(srna, "gridlines_lower_bound", PROP_FLOAT, PROP_NONE);
2641   RNA_def_property_float_sdna(prop, NULL, "gridlines_lower_bound");
2642   RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
2643   RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 0.1, 6);
2644   RNA_def_property_ui_text(prop, "Lower Bound", "Lower bound of the highlighting range");
2645   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, NULL);
2646 
2647   prop = RNA_def_property(srna, "gridlines_upper_bound", PROP_FLOAT, PROP_NONE);
2648   RNA_def_property_float_sdna(prop, NULL, "gridlines_upper_bound");
2649   RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
2650   RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 0.1, 6);
2651   RNA_def_property_ui_text(prop, "Upper Bound", "Upper bound of the highlighting range");
2652   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, NULL);
2653 
2654   prop = RNA_def_property(srna, "gridlines_range_color", PROP_FLOAT, PROP_COLOR);
2655   RNA_def_property_float_sdna(prop, NULL, "gridlines_range_color");
2656   RNA_def_property_array(prop, 4);
2657   RNA_def_property_ui_text(prop, "Color", "Color used to highlight the range");
2658   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, NULL);
2659 
2660   prop = RNA_def_property(srna, "gridlines_cell_filter", PROP_ENUM, PROP_NONE);
2661   RNA_def_property_enum_sdna(prop, NULL, "gridlines_cell_filter");
2662   RNA_def_property_enum_items(prop, gridlines_cell_filter_items);
2663   RNA_def_property_ui_text(prop, "Cell Type", "Cell type to be highlighted");
2664   RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
2665 }
2666 
rna_def_fluid_flow_settings(BlenderRNA * brna)2667 static void rna_def_fluid_flow_settings(BlenderRNA *brna)
2668 {
2669   StructRNA *srna;
2670   PropertyRNA *prop;
2671 
2672   static const EnumPropertyItem flow_type_items[] = {
2673       {FLUID_FLOW_TYPE_SMOKE, "SMOKE", 0, "Smoke", "Add smoke"},
2674       {FLUID_FLOW_TYPE_SMOKEFIRE, "BOTH", 0, "Fire + Smoke", "Add fire and smoke"},
2675       {FLUID_FLOW_TYPE_FIRE, "FIRE", 0, "Fire", "Add fire"},
2676       {FLUID_FLOW_TYPE_LIQUID, "LIQUID", 0, "Liquid", "Add liquid"},
2677       {0, NULL, 0, NULL, NULL},
2678   };
2679 
2680   static EnumPropertyItem flow_behavior_items[] = {
2681       {FLUID_FLOW_BEHAVIOR_INFLOW, "INFLOW", 0, "Inflow", "Add fluid to simulation"},
2682       {FLUID_FLOW_BEHAVIOR_OUTFLOW, "OUTFLOW", 0, "Outflow", "Delete fluid from simulation"},
2683       {FLUID_FLOW_BEHAVIOR_GEOMETRY,
2684        "GEOMETRY",
2685        0,
2686        "Geometry",
2687        "Only use given geometry for fluid"},
2688       {0, NULL, 0, NULL, NULL},
2689   };
2690 
2691   /*  Flow source - generated dynamically based on flow type */
2692   static EnumPropertyItem flow_sources[] = {
2693       {0, "NONE", 0, "", ""},
2694       {0, NULL, 0, NULL, NULL},
2695   };
2696 
2697   static const EnumPropertyItem flow_texture_types[] = {
2698       {FLUID_FLOW_TEXTURE_MAP_AUTO,
2699        "AUTO",
2700        0,
2701        "Generated",
2702        "Generated coordinates centered to flow object"},
2703       {FLUID_FLOW_TEXTURE_MAP_UV, "UV", 0, "UV", "Use UV layer for texture coordinates"},
2704       {0, NULL, 0, NULL, NULL},
2705   };
2706 
2707   srna = RNA_def_struct(brna, "FluidFlowSettings", NULL);
2708   RNA_def_struct_ui_text(srna, "Flow Settings", "Fluid flow settings");
2709   RNA_def_struct_sdna(srna, "FluidFlowSettings");
2710   RNA_def_struct_path_func(srna, "rna_FluidFlowSettings_path");
2711 
2712   prop = RNA_def_property(srna, "density", PROP_FLOAT, PROP_FACTOR);
2713   RNA_def_property_float_sdna(prop, NULL, "density");
2714   RNA_def_property_range(prop, 0.0, 10);
2715   RNA_def_property_ui_range(prop, 0.0, 1.0, 1.0, 4);
2716   RNA_def_property_ui_text(prop, "Density", "");
2717   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_flow_reset");
2718 
2719   prop = RNA_def_property(srna, "smoke_color", PROP_FLOAT, PROP_COLOR_GAMMA);
2720   RNA_def_property_float_sdna(prop, NULL, "color");
2721   RNA_def_property_array(prop, 3);
2722   RNA_def_property_ui_text(prop, "Smoke Color", "Color of smoke");
2723   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_flow_reset");
2724 
2725   prop = RNA_def_property(srna, "fuel_amount", PROP_FLOAT, PROP_NONE);
2726   RNA_def_property_range(prop, 0.0, 10);
2727   RNA_def_property_ui_range(prop, 0.0, 5.0, 1.0, 4);
2728   RNA_def_property_ui_text(prop, "Flame Rate", "");
2729   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_flow_reset");
2730 
2731   prop = RNA_def_property(srna, "temperature", PROP_FLOAT, PROP_NONE);
2732   RNA_def_property_float_sdna(prop, NULL, "temperature");
2733   RNA_def_property_range(prop, -10, 10);
2734   RNA_def_property_ui_range(prop, -10, 10, 1, 1);
2735   RNA_def_property_ui_text(prop, "Temp. Diff.", "Temperature difference to ambient temperature");
2736   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_flow_reset");
2737 
2738   prop = RNA_def_property(srna, "particle_system", PROP_POINTER, PROP_NONE);
2739   RNA_def_property_pointer_sdna(prop, NULL, "psys");
2740   RNA_def_property_struct_type(prop, "ParticleSystem");
2741   RNA_def_property_flag(prop, PROP_EDITABLE);
2742   RNA_def_property_ui_text(prop, "Particle Systems", "Particle systems emitted from the object");
2743   RNA_def_property_update(prop, 0, "rna_Fluid_reset_dependency");
2744 
2745   prop = RNA_def_property(srna, "flow_type", PROP_ENUM, PROP_NONE);
2746   RNA_def_property_enum_sdna(prop, NULL, "type");
2747   RNA_def_property_enum_items(prop, flow_type_items);
2748   RNA_def_property_enum_funcs(prop, NULL, "rna_Fluid_flowtype_set", NULL);
2749   RNA_def_property_ui_text(prop, "Flow Type", "Change type of fluid in the simulation");
2750   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_flow_reset");
2751 
2752   prop = RNA_def_property(srna, "flow_behavior", PROP_ENUM, PROP_NONE);
2753   RNA_def_property_enum_sdna(prop, NULL, "behavior");
2754   RNA_def_property_enum_items(prop, flow_behavior_items);
2755   RNA_def_property_ui_text(prop, "Flow Behavior", "Change flow behavior in the simulation");
2756   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_flow_reset");
2757 
2758   prop = RNA_def_property(srna, "flow_source", PROP_ENUM, PROP_NONE);
2759   RNA_def_property_enum_sdna(prop, NULL, "source");
2760   RNA_def_property_enum_items(prop, flow_sources);
2761   RNA_def_property_enum_funcs(
2762       prop, NULL, "rna_Fluid_flowsource_set", "rna_Fluid_flowsource_itemf");
2763   RNA_def_property_ui_text(prop, "Source", "Change how fluid is emitted");
2764   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_flow_reset");
2765 
2766   prop = RNA_def_property(srna, "use_absolute", PROP_BOOLEAN, PROP_NONE);
2767   RNA_def_property_boolean_sdna(prop, NULL, "flags", FLUID_FLOW_ABSOLUTE);
2768   RNA_def_property_ui_text(prop,
2769                            "Absolute Density",
2770                            "Only allow given density value in emitter area and will not add up");
2771   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_flow_reset");
2772 
2773   prop = RNA_def_property(srna, "use_initial_velocity", PROP_BOOLEAN, PROP_NONE);
2774   RNA_def_property_boolean_sdna(prop, NULL, "flags", FLUID_FLOW_INITVELOCITY);
2775   RNA_def_property_ui_text(
2776       prop, "Initial Velocity", "Fluid has some initial velocity when it is emitted");
2777   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_flow_reset");
2778 
2779   prop = RNA_def_property(srna, "velocity_factor", PROP_FLOAT, PROP_NONE);
2780   RNA_def_property_float_sdna(prop, NULL, "vel_multi");
2781   RNA_def_property_range(prop, -100.0, 100.0);
2782   RNA_def_property_ui_range(prop, -2.0, 2.0, 0.05, 5);
2783   RNA_def_property_ui_text(prop,
2784                            "Source",
2785                            "Multiplier of source velocity passed to fluid (source velocity is "
2786                            "non-zero only if object is moving)");
2787   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_flow_reset");
2788 
2789   prop = RNA_def_property(srna, "velocity_normal", PROP_FLOAT, PROP_NONE);
2790   RNA_def_property_float_sdna(prop, NULL, "vel_normal");
2791   RNA_def_property_range(prop, -100.0, 100.0);
2792   RNA_def_property_ui_range(prop, -2.0, 2.0, 0.05, 5);
2793   RNA_def_property_ui_text(prop, "Normal", "Amount of normal directional velocity");
2794   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_flow_reset");
2795 
2796   prop = RNA_def_property(srna, "velocity_random", PROP_FLOAT, PROP_NONE);
2797   RNA_def_property_float_sdna(prop, NULL, "vel_random");
2798   RNA_def_property_range(prop, 0.0, 10.0);
2799   RNA_def_property_ui_range(prop, 0.0, 2.0, 0.05, 5);
2800   RNA_def_property_ui_text(prop, "Random", "Amount of random velocity");
2801   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_flow_reset");
2802 
2803   prop = RNA_def_property(srna, "velocity_coord", PROP_FLOAT, PROP_VELOCITY);
2804   RNA_def_property_float_sdna(prop, NULL, "vel_coord");
2805   RNA_def_property_array(prop, 3);
2806   RNA_def_property_range(prop, -1000.1, 1000.1);
2807   RNA_def_property_ui_text(
2808       prop,
2809       "Initial",
2810       "Additional initial velocity in X, Y and Z direction (added to source velocity)");
2811   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_flow_reset");
2812 
2813   prop = RNA_def_property(srna, "volume_density", PROP_FLOAT, PROP_NONE);
2814   RNA_def_property_range(prop, 0.0, 1.0);
2815   RNA_def_property_ui_range(prop, 0.0, 1.0, 0.05, 5);
2816   RNA_def_property_ui_text(prop,
2817                            "Volume Emission",
2818                            "Controls fluid emission from within the mesh (higher value results in "
2819                            "greater emissions from inside the mesh)");
2820   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_flow_reset");
2821 
2822   prop = RNA_def_property(srna, "surface_distance", PROP_FLOAT, PROP_NONE);
2823   RNA_def_property_range(prop, 0.0, 10.0);
2824   RNA_def_property_ui_range(prop, 0.0, 10.0, 0.05, 5);
2825   RNA_def_property_ui_text(prop,
2826                            "Surface Emission",
2827                            "Controls fluid emission from the mesh surface (higher value results "
2828                            "in emission further away from the mesh surface");
2829   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_flow_reset");
2830 
2831   prop = RNA_def_property(srna, "use_plane_init", PROP_BOOLEAN, PROP_NONE);
2832   RNA_def_property_boolean_sdna(prop, NULL, "flags", FLUID_FLOW_USE_PLANE_INIT);
2833   RNA_def_property_ui_text(
2834       prop,
2835       "Is Planar",
2836       "Treat this object as a planar and unclosed mesh. Fluid will only be emitted from the mesh "
2837       "surface and based on the surface emission value");
2838   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_flow_reset");
2839 
2840   prop = RNA_def_property(srna, "particle_size", PROP_FLOAT, PROP_NONE);
2841   RNA_def_property_range(prop, 0.1, FLT_MAX);
2842   RNA_def_property_ui_range(prop, 0.5, 5.0, 0.05, 5);
2843   RNA_def_property_ui_text(prop, "Size", "Particle size in simulation cells");
2844   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_flow_reset");
2845 
2846   prop = RNA_def_property(srna, "use_particle_size", PROP_BOOLEAN, PROP_NONE);
2847   RNA_def_property_boolean_sdna(prop, NULL, "flags", FLUID_FLOW_USE_PART_SIZE);
2848   RNA_def_property_ui_text(
2849       prop, "Set Size", "Set particle size in simulation cells or use nearest cell");
2850   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_flow_reset");
2851 
2852   prop = RNA_def_property(srna, "use_inflow", PROP_BOOLEAN, PROP_NONE);
2853   RNA_def_property_boolean_sdna(prop, NULL, "flags", FLUID_FLOW_USE_INFLOW);
2854   RNA_def_property_ui_text(prop, "Use Flow", "Control when to apply fluid flow");
2855   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_flow_reset");
2856 
2857   prop = RNA_def_property(srna, "subframes", PROP_INT, PROP_NONE);
2858   RNA_def_property_range(prop, 0, 200);
2859   RNA_def_property_ui_range(prop, 0, 10, 1, -1);
2860   RNA_def_property_ui_text(prop,
2861                            "Subframes",
2862                            "Number of additional samples to take between frames to improve "
2863                            "quality of fast moving flows");
2864   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_flow_reset");
2865 
2866   prop = RNA_def_property(srna, "density_vertex_group", PROP_STRING, PROP_NONE);
2867   RNA_def_property_string_funcs(prop,
2868                                 "rna_FluidFlow_density_vgroup_get",
2869                                 "rna_FluidFlow_density_vgroup_length",
2870                                 "rna_FluidFlow_density_vgroup_set");
2871   RNA_def_property_ui_text(
2872       prop, "Vertex Group", "Name of vertex group which determines surface emission rate");
2873   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_flow_reset");
2874 
2875   prop = RNA_def_property(srna, "use_texture", PROP_BOOLEAN, PROP_NONE);
2876   RNA_def_property_boolean_sdna(prop, NULL, "flags", FLUID_FLOW_TEXTUREEMIT);
2877   RNA_def_property_ui_text(prop, "Use Texture", "Use a texture to control emission strength");
2878   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_flow_reset");
2879 
2880   prop = RNA_def_property(srna, "texture_map_type", PROP_ENUM, PROP_NONE);
2881   RNA_def_property_enum_sdna(prop, NULL, "texture_type");
2882   RNA_def_property_enum_items(prop, flow_texture_types);
2883   RNA_def_property_ui_text(prop, "Mapping", "Texture mapping type");
2884   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_flow_reset");
2885 
2886   prop = RNA_def_property(srna, "uv_layer", PROP_STRING, PROP_NONE);
2887   RNA_def_property_string_sdna(prop, NULL, "uvlayer_name");
2888   RNA_def_property_ui_text(prop, "UV Map", "UV map name");
2889   RNA_def_property_string_funcs(prop, NULL, NULL, "rna_FluidFlow_uvlayer_set");
2890   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_flow_reset");
2891 
2892   prop = RNA_def_property(srna, "noise_texture", PROP_POINTER, PROP_NONE);
2893   RNA_def_property_flag(prop, PROP_EDITABLE);
2894   RNA_def_property_ui_text(prop, "Texture", "Texture that controls emission strength");
2895   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_flow_reset");
2896 
2897   prop = RNA_def_property(srna, "texture_size", PROP_FLOAT, PROP_NONE);
2898   RNA_def_property_range(prop, 0.01, 10.0);
2899   RNA_def_property_ui_range(prop, 0.1, 5.0, 0.05, 5);
2900   RNA_def_property_ui_text(prop, "Size", "Size of texture mapping");
2901   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_flow_reset");
2902 
2903   prop = RNA_def_property(srna, "texture_offset", PROP_FLOAT, PROP_NONE);
2904   RNA_def_property_range(prop, 0.0, 200.0);
2905   RNA_def_property_ui_range(prop, 0.0, 100.0, 0.05, 5);
2906   RNA_def_property_ui_text(prop, "Offset", "Z-offset of texture mapping");
2907   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_flow_reset");
2908 }
2909 
rna_def_fluid_effector_settings(BlenderRNA * brna)2910 static void rna_def_fluid_effector_settings(BlenderRNA *brna)
2911 {
2912   static EnumPropertyItem effector_type_items[] = {
2913       {FLUID_EFFECTOR_TYPE_COLLISION, "COLLISION", 0, "Collision", "Create collision object"},
2914       {FLUID_EFFECTOR_TYPE_GUIDE, "GUIDE", 0, "Guide", "Create guide object"},
2915       {0, NULL, 0, NULL, NULL},
2916   };
2917 
2918   static EnumPropertyItem fluid_guide_mode_items[] = {
2919       {FLUID_EFFECTOR_GUIDE_MAX,
2920        "MAXIMUM",
2921        0,
2922        "Maximize",
2923        "Compare velocities from previous frame with new velocities from current frame and keep "
2924        "the maximum"},
2925       {FLUID_EFFECTOR_GUIDE_MIN,
2926        "MINIMUM",
2927        0,
2928        "Minimize",
2929        "Compare velocities from previous frame with new velocities from current frame and keep "
2930        "the minimum"},
2931       {FLUID_EFFECTOR_GUIDE_OVERRIDE,
2932        "OVERRIDE",
2933        0,
2934        "Override",
2935        "Always write new guide velocities for every frame (each frame only contains current "
2936        "velocities from guiding objects)"},
2937       {FLUID_EFFECTOR_GUIDE_AVERAGED,
2938        "AVERAGED",
2939        0,
2940        "Averaged",
2941        "Take average of velocities from previous frame and new velocities from current frame"},
2942       {0, NULL, 0, NULL, NULL},
2943   };
2944 
2945   StructRNA *srna;
2946   PropertyRNA *prop;
2947 
2948   srna = RNA_def_struct(brna, "FluidEffectorSettings", NULL);
2949   RNA_def_struct_ui_text(srna, "Effector Settings", "Smoke collision settings");
2950   RNA_def_struct_sdna(srna, "FluidEffectorSettings");
2951   RNA_def_struct_path_func(srna, "rna_FluidEffectorSettings_path");
2952 
2953   prop = RNA_def_property(srna, "effector_type", PROP_ENUM, PROP_NONE);
2954   RNA_def_property_enum_sdna(prop, NULL, "type");
2955   RNA_def_property_enum_items(prop, effector_type_items);
2956   RNA_def_property_ui_text(prop, "Effector Type", "Change type of effector in the simulation");
2957   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_effector_reset");
2958 
2959   prop = RNA_def_property(srna, "surface_distance", PROP_FLOAT, PROP_NONE);
2960   RNA_def_property_range(prop, 0.0, 10.0);
2961   RNA_def_property_ui_range(prop, 0.0, 10.0, 0.05, 5);
2962   RNA_def_property_ui_text(
2963       prop, "Surface", "Additional distance around mesh surface to consider as effector");
2964   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_effector_reset");
2965 
2966   prop = RNA_def_property(srna, "use_plane_init", PROP_BOOLEAN, PROP_NONE);
2967   RNA_def_property_boolean_sdna(prop, NULL, "flags", FLUID_EFFECTOR_USE_PLANE_INIT);
2968   RNA_def_property_ui_text(prop, "Is Planar", "Treat this object as a planar, unclosed mesh");
2969   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_domain_data_reset");
2970 
2971   prop = RNA_def_property(srna, "velocity_factor", PROP_FLOAT, PROP_NONE);
2972   RNA_def_property_float_sdna(prop, NULL, "vel_multi");
2973   RNA_def_property_range(prop, -100.0, 100.0);
2974   RNA_def_property_ui_text(prop, "Source", "Multiplier of obstacle velocity");
2975   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_effector_reset");
2976 
2977   prop = RNA_def_property(srna, "guide_mode", PROP_ENUM, PROP_NONE);
2978   RNA_def_property_enum_sdna(prop, NULL, "guide_mode");
2979   RNA_def_property_enum_items(prop, fluid_guide_mode_items);
2980   RNA_def_property_ui_text(prop, "Guiding mode", "How to create guiding velocities");
2981   RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Fluid_effector_reset");
2982 
2983   prop = RNA_def_property(srna, "use_effector", PROP_BOOLEAN, PROP_NONE);
2984   RNA_def_property_boolean_sdna(prop, NULL, "flags", FLUID_EFFECTOR_USE_EFFEC);
2985   RNA_def_property_ui_text(prop, "Enabled", "Control when to apply the effector");
2986   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_effector_reset");
2987 
2988   prop = RNA_def_property(srna, "subframes", PROP_INT, PROP_NONE);
2989   RNA_def_property_range(prop, 0, 200);
2990   RNA_def_property_ui_range(prop, 0, 10, 1, -1);
2991   RNA_def_property_ui_text(prop,
2992                            "Subframes",
2993                            "Number of additional samples to take between frames to improve "
2994                            "quality of fast moving effector objects");
2995   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_effector_reset");
2996 }
2997 
RNA_def_fluid(BlenderRNA * brna)2998 void RNA_def_fluid(BlenderRNA *brna)
2999 {
3000   rna_def_fluid_domain_settings(brna);
3001   rna_def_fluid_flow_settings(brna);
3002   rna_def_fluid_effector_settings(brna);
3003 }
3004 
3005 #endif
3006