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.
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.
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.
17 /** \file \ingroup RNA
24 #include "BLI_sys_types.h"
26 #include "RNA_define.h"
27 #include "RNA_enum_types.h"
29 #include "rna_internal.h"
31 #include "BKE_modifier.h"
32 #include "BKE_smoke.h"
33 #include "BKE_pointcache.h"
35 #include "DNA_modifier_types.h"
36 #include "DNA_object_force_types.h"
37 #include "DNA_object_types.h"
38 #include "DNA_scene_types.h"
39 #include "DNA_smoke_types.h"
46 #include "BLI_threads.h"
48 #include "BKE_colorband.h"
49 #include "BKE_context.h"
50 #include "BKE_particle.h"
52 #include "DEG_depsgraph.h"
53 #include "DEG_depsgraph_build.h"
55 #include "smoke_API.h"
58 static void rna_Smoke_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
60 DEG_id_tag_update(ptr->id.data, ID_RECALC_GEOMETRY);
63 static void rna_Smoke_dependency_update(Main *bmain, Scene *scene, PointerRNA *ptr)
65 rna_Smoke_update(bmain, scene, ptr);
66 DEG_relations_tag_update(bmain);
69 static void rna_Smoke_resetCache(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
71 SmokeDomainSettings *settings = (SmokeDomainSettings *)ptr->data;
72 if (settings->smd && settings->smd->domain)
73 settings->point_cache[0]->flag |= PTCACHE_OUTDATED;
74 DEG_id_tag_update(ptr->id.data, ID_RECALC_GEOMETRY);
77 static void rna_Smoke_cachetype_set(struct PointerRNA *ptr, int value)
79 SmokeDomainSettings *settings = (SmokeDomainSettings *)ptr->data;
80 Object *ob = (Object *)ptr->id.data;
82 if (value != settings->cache_file_format) {
83 /* Clear old caches. */
85 BKE_ptcache_id_from_smoke(&id, ob, settings->smd);
86 BKE_ptcache_id_clear(&id, PTCACHE_CLEAR_ALL, 0);
88 settings->cache_file_format = value;
92 static void rna_Smoke_reset(Main *bmain, Scene *scene, PointerRNA *ptr)
94 SmokeDomainSettings *settings = (SmokeDomainSettings *)ptr->data;
96 smokeModifier_reset(settings->smd);
97 rna_Smoke_resetCache(bmain, scene, ptr);
99 rna_Smoke_update(bmain, scene, ptr);
102 static void rna_Smoke_reset_dependency(Main *bmain, Scene *scene, PointerRNA *ptr)
104 SmokeDomainSettings *settings = (SmokeDomainSettings *)ptr->data;
106 smokeModifier_reset(settings->smd);
108 if (settings->smd && settings->smd->domain)
109 settings->smd->domain->point_cache[0]->flag |= PTCACHE_OUTDATED;
111 rna_Smoke_dependency_update(bmain, scene, ptr);
114 static char *rna_SmokeDomainSettings_path(PointerRNA *ptr)
116 SmokeDomainSettings *settings = (SmokeDomainSettings *)ptr->data;
117 ModifierData *md = (ModifierData *)settings->smd;
118 char name_esc[sizeof(md->name) * 2];
120 BLI_strescape(name_esc, md->name, sizeof(name_esc));
121 return BLI_sprintfN("modifiers[\"%s\"].domain_settings", name_esc);
124 static char *rna_SmokeFlowSettings_path(PointerRNA *ptr)
126 SmokeFlowSettings *settings = (SmokeFlowSettings *)ptr->data;
127 ModifierData *md = (ModifierData *)settings->smd;
128 char name_esc[sizeof(md->name) * 2];
130 BLI_strescape(name_esc, md->name, sizeof(name_esc));
131 return BLI_sprintfN("modifiers[\"%s\"].flow_settings", name_esc);
134 static char *rna_SmokeCollSettings_path(PointerRNA *ptr)
136 SmokeCollSettings *settings = (SmokeCollSettings *)ptr->data;
137 ModifierData *md = (ModifierData *)settings->smd;
138 char name_esc[sizeof(md->name) * 2];
140 BLI_strescape(name_esc, md->name, sizeof(name_esc));
141 return BLI_sprintfN("modifiers[\"%s\"].coll_settings", name_esc);
144 static int rna_SmokeModifier_grid_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION])
147 SmokeDomainSettings *sds = (SmokeDomainSettings *)ptr->data;
148 float *density = NULL;
151 if (sds->flags & MOD_SMOKE_HIGHRES && sds->wt) {
152 /* high resolution smoke */
155 smoke_turbulence_get_res(sds->wt, res);
156 size = res[0] * res[1] * res[2];
158 density = smoke_turbulence_get_density(sds->wt);
160 else if (sds->fluid) {
161 /* regular resolution */
162 size = sds->res[0] * sds->res[1] * sds->res[2];
163 density = smoke_get_density(sds->fluid);
166 length[0] = (density) ? size : 0;
174 static int rna_SmokeModifier_color_grid_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION])
176 rna_SmokeModifier_grid_get_length(ptr, length);
182 static int rna_SmokeModifier_velocity_grid_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION])
185 SmokeDomainSettings *sds = (SmokeDomainSettings *)ptr->data;
191 /* Velocity data is always low-resolution. */
193 size = 3 * sds->res[0] * sds->res[1] * sds->res[2];
194 vx = smoke_get_velocity_x(sds->fluid);
195 vy = smoke_get_velocity_y(sds->fluid);
196 vz = smoke_get_velocity_z(sds->fluid);
199 length[0] = (vx && vy && vz) ? size : 0;
207 static int rna_SmokeModifier_heat_grid_get_length(
209 int length[RNA_MAX_ARRAY_DIMENSION])
212 SmokeDomainSettings *sds = (SmokeDomainSettings *)ptr->data;
216 /* Heat data is always low-resolution. */
218 size = sds->res[0] * sds->res[1] * sds->res[2];
219 heat = smoke_get_heat(sds->fluid);
222 length[0] = (heat) ? size : 0;
230 static void rna_SmokeModifier_density_grid_get(PointerRNA *ptr, float *values)
233 SmokeDomainSettings *sds = (SmokeDomainSettings *)ptr->data;
234 int length[RNA_MAX_ARRAY_DIMENSION];
235 int size = rna_SmokeModifier_grid_get_length(ptr, length);
238 BLI_rw_mutex_lock(sds->fluid_mutex, THREAD_LOCK_READ);
240 if (sds->flags & MOD_SMOKE_HIGHRES && sds->wt)
241 density = smoke_turbulence_get_density(sds->wt);
243 density = smoke_get_density(sds->fluid);
245 memcpy(values, density, size * sizeof(float));
247 BLI_rw_mutex_unlock(sds->fluid_mutex);
249 UNUSED_VARS(ptr, values);
253 static void rna_SmokeModifier_velocity_grid_get(PointerRNA *ptr, float *values)
256 SmokeDomainSettings *sds = (SmokeDomainSettings *)ptr->data;
257 int length[RNA_MAX_ARRAY_DIMENSION];
258 int size = rna_SmokeModifier_velocity_grid_get_length(ptr, length);
262 BLI_rw_mutex_lock(sds->fluid_mutex, THREAD_LOCK_READ);
264 vx = smoke_get_velocity_x(sds->fluid);
265 vy = smoke_get_velocity_y(sds->fluid);
266 vz = smoke_get_velocity_z(sds->fluid);
268 for (i = 0; i < size; i += 3) {
269 *(values++) = *(vx++);
270 *(values++) = *(vy++);
271 *(values++) = *(vz++);
274 BLI_rw_mutex_unlock(sds->fluid_mutex);
276 UNUSED_VARS(ptr, values);
280 static void rna_SmokeModifier_color_grid_get(PointerRNA *ptr, float *values)
283 SmokeDomainSettings *sds = (SmokeDomainSettings *)ptr->data;
284 int length[RNA_MAX_ARRAY_DIMENSION];
285 int size = rna_SmokeModifier_grid_get_length(ptr, length);
287 BLI_rw_mutex_lock(sds->fluid_mutex, THREAD_LOCK_READ);
290 memset(values, 0, size * sizeof(float));
293 if (sds->flags & MOD_SMOKE_HIGHRES) {
294 if (smoke_turbulence_has_colors(sds->wt))
295 smoke_turbulence_get_rgba(sds->wt, values, 0);
297 smoke_turbulence_get_rgba_from_density(sds->wt, sds->active_color, values, 0);
300 if (smoke_has_colors(sds->fluid))
301 smoke_get_rgba(sds->fluid, values, 0);
303 smoke_get_rgba_from_density(sds->fluid, sds->active_color, values, 0);
307 BLI_rw_mutex_unlock(sds->fluid_mutex);
309 UNUSED_VARS(ptr, values);
313 static void rna_SmokeModifier_flame_grid_get(PointerRNA *ptr, float *values)
316 SmokeDomainSettings *sds = (SmokeDomainSettings *)ptr->data;
317 int length[RNA_MAX_ARRAY_DIMENSION];
318 int size = rna_SmokeModifier_grid_get_length(ptr, length);
321 BLI_rw_mutex_lock(sds->fluid_mutex, THREAD_LOCK_READ);
323 if (sds->flags & MOD_SMOKE_HIGHRES && sds->wt)
324 flame = smoke_turbulence_get_flame(sds->wt);
326 flame = smoke_get_flame(sds->fluid);
329 memcpy(values, flame, size * sizeof(float));
331 memset(values, 0, size * sizeof(float));
333 BLI_rw_mutex_unlock(sds->fluid_mutex);
335 UNUSED_VARS(ptr, values);
339 static void rna_SmokeModifier_heat_grid_get(PointerRNA *ptr, float *values)
342 SmokeDomainSettings *sds = (SmokeDomainSettings *)ptr->data;
343 int length[RNA_MAX_ARRAY_DIMENSION];
344 int size = rna_SmokeModifier_heat_grid_get_length(ptr, length);
347 BLI_rw_mutex_lock(sds->fluid_mutex, THREAD_LOCK_READ);
349 heat = smoke_get_heat(sds->fluid);
352 /* scale heat values from -2.0-2.0 to -1.0-1.0. */
353 for (int i = 0; i < size; i++) {
354 values[i] = heat[i] * 0.5f;
358 memset(values, 0, size * sizeof(float));
361 BLI_rw_mutex_unlock(sds->fluid_mutex);
363 UNUSED_VARS(ptr, values);
367 static void rna_SmokeModifier_temperature_grid_get(PointerRNA *ptr, float *values)
370 SmokeDomainSettings *sds = (SmokeDomainSettings *)ptr->data;
371 int length[RNA_MAX_ARRAY_DIMENSION];
372 int size = rna_SmokeModifier_grid_get_length(ptr, length);
375 BLI_rw_mutex_lock(sds->fluid_mutex, THREAD_LOCK_READ);
377 if (sds->flags & MOD_SMOKE_HIGHRES && sds->wt) {
378 flame = smoke_turbulence_get_flame(sds->wt);
381 flame = smoke_get_flame(sds->fluid);
385 /* Output is such that 0..1 maps to 0..1000K */
386 float offset = sds->flame_ignition;
387 float scale = sds->flame_max_temp - sds->flame_ignition;
389 for (int i = 0; i < size; i++) {
390 values[i] = (flame[i] > 0.01f) ? offset + flame[i] * scale : 0.0f;
394 memset(values, 0, size * sizeof(float));
397 BLI_rw_mutex_unlock(sds->fluid_mutex);
399 UNUSED_VARS(ptr, values);
403 static void rna_SmokeFlow_density_vgroup_get(PointerRNA *ptr, char *value)
405 SmokeFlowSettings *flow = (SmokeFlowSettings *)ptr->data;
406 rna_object_vgroup_name_index_get(ptr, value, flow->vgroup_density);
409 static int rna_SmokeFlow_density_vgroup_length(PointerRNA *ptr)
411 SmokeFlowSettings *flow = (SmokeFlowSettings *)ptr->data;
412 return rna_object_vgroup_name_index_length(ptr, flow->vgroup_density);
415 static void rna_SmokeFlow_density_vgroup_set(PointerRNA *ptr, const char *value)
417 SmokeFlowSettings *flow = (SmokeFlowSettings *)ptr->data;
418 rna_object_vgroup_name_index_set(ptr, value, &flow->vgroup_density);
421 static void rna_SmokeFlow_uvlayer_set(PointerRNA *ptr, const char *value)
423 SmokeFlowSettings *flow = (SmokeFlowSettings *)ptr->data;
424 rna_object_uvlayer_name_set(ptr, value, flow->uvlayer_name, sizeof(flow->uvlayer_name));
427 static void rna_Smoke_use_color_ramp_set(PointerRNA *ptr, bool value)
429 SmokeDomainSettings *sds = (SmokeDomainSettings *)ptr->data;
431 sds->use_coba = value;
433 if (value && sds->coba == NULL) {
434 sds->coba = BKE_colorband_add(false);
440 static void rna_def_smoke_domain_settings(BlenderRNA *brna)
445 static const EnumPropertyItem prop_noise_type_items[] = {
446 {MOD_SMOKE_NOISEWAVE, "NOISEWAVE", 0, "Wavelet", ""},
448 {MOD_SMOKE_NOISEFFT, "NOISEFFT", 0, "FFT", ""},
450 /* {MOD_SMOKE_NOISECURL, "NOISECURL", 0, "Curl", ""}, */
451 {0, NULL, 0, NULL, NULL},
454 static const EnumPropertyItem prop_compression_items[] = {
455 { VDB_COMPRESSION_ZIP, "ZIP", 0, "Zip", "Effective but slow compression" },
456 #ifdef WITH_OPENVDB_BLOSC
457 { VDB_COMPRESSION_BLOSC, "BLOSC", 0, "Blosc", "Multithreaded compression, similar in size and quality as 'Zip'" },
459 { VDB_COMPRESSION_NONE, "NONE", 0, "None", "Do not use any compression" },
460 { 0, NULL, 0, NULL, NULL }
463 static const EnumPropertyItem smoke_cache_comp_items[] = {
464 {SM_CACHE_LIGHT, "CACHELIGHT", 0, "Light", "Fast but not so effective compression"},
465 {SM_CACHE_HEAVY, "CACHEHEAVY", 0, "Heavy", "Effective but slow compression"},
466 {0, NULL, 0, NULL, NULL},
469 static const EnumPropertyItem smoke_highres_sampling_items[] = {
470 {SM_HRES_FULLSAMPLE, "FULLSAMPLE", 0, "Full Sample", ""},
471 {SM_HRES_LINEAR, "LINEAR", 0, "Linear", ""},
472 {SM_HRES_NEAREST, "NEAREST", 0, "Nearest", ""},
473 {0, NULL, 0, NULL, NULL},
476 static const EnumPropertyItem smoke_data_depth_items[] = {
477 {16, "16", 0, "Float (Half)", "Half float (16 bit data)"},
478 {0, "32", 0, "Float (Full)", "Full float (32 bit data)"}, /* default */
479 {0, NULL, 0, NULL, NULL},
482 static const EnumPropertyItem smoke_domain_colli_items[] = {
483 {SM_BORDER_OPEN, "BORDEROPEN", 0, "Open", "Smoke doesn't collide with any border"},
484 {SM_BORDER_VERTICAL, "BORDERVERTICAL", 0, "Vertically Open",
485 "Smoke doesn't collide with top and bottom sides"},
486 {SM_BORDER_CLOSED, "BORDERCLOSED", 0, "Collide All", "Smoke collides with every side"},
487 {0, NULL, 0, NULL, NULL},
490 static const EnumPropertyItem cache_file_type_items[] = {
491 {PTCACHE_FILE_PTCACHE, "POINTCACHE", 0, "Point Cache", "Blender specific point cache file format"},
493 {PTCACHE_FILE_OPENVDB, "OPENVDB", 0, "OpenVDB", "OpenVDB file format"},
495 {0, NULL, 0, NULL, NULL},
498 static const EnumPropertyItem smoke_view_items[] = {
499 {MOD_SMOKE_SLICE_VIEW_ALIGNED, "VIEW_ALIGNED", 0, "View", "Slice volume parallel to the view plane"},
500 {MOD_SMOKE_SLICE_AXIS_ALIGNED, "AXIS_ALIGNED", 0, "Axis", "Slice volume parallel to the major axis"},
501 {0, NULL, 0, NULL, NULL},
504 static const EnumPropertyItem axis_slice_method_items[] = {
505 {AXIS_SLICE_FULL, "FULL", 0, "Full", "Slice the whole domain object"},
506 {AXIS_SLICE_SINGLE, "SINGLE", 0, "Single", "Perform a single slice of the domain object"},
507 {0, NULL, 0, NULL, NULL},
510 static const EnumPropertyItem interp_method_item[] = {
511 {VOLUME_INTERP_LINEAR, "LINEAR", 0, "Linear", "Good smoothness and speed"},
512 {VOLUME_INTERP_CUBIC, "CUBIC", 0, "Cubic", "Smoothed high quality interpolation, but slower"},
513 {0, NULL, 0, NULL, NULL},
516 static const EnumPropertyItem axis_slice_position_items[] = {
517 {SLICE_AXIS_AUTO, "AUTO", 0, "Auto", "Adjust slice direction according to the view direction"},
518 {SLICE_AXIS_X, "X", 0, "X", "Slice along the X axis"},
519 {SLICE_AXIS_Y, "Y", 0, "Y", "Slice along the Y axis"},
520 {SLICE_AXIS_Z, "Z", 0, "Z", "Slice along the Z axis"},
521 {0, NULL, 0, NULL, NULL},
524 static const EnumPropertyItem vector_draw_items[] = {
525 {VECTOR_DRAW_NEEDLE, "NEEDLE", 0, "Needle", "Display vectors as needles"},
526 {VECTOR_DRAW_STREAMLINE, "STREAMLINE", 0, "Streamlines", "Display vectors as streamlines"},
527 {0, NULL, 0, NULL, NULL},
530 srna = RNA_def_struct(brna, "SmokeDomainSettings", NULL);
531 RNA_def_struct_ui_text(srna, "Domain Settings", "Smoke domain settings");
532 RNA_def_struct_sdna(srna, "SmokeDomainSettings");
533 RNA_def_struct_path_func(srna, "rna_SmokeDomainSettings_path");
535 prop = RNA_def_property(srna, "resolution_max", PROP_INT, PROP_NONE);
536 RNA_def_property_int_sdna(prop, NULL, "maxres");
537 RNA_def_property_range(prop, 6, 512);
538 RNA_def_property_ui_range(prop, 24, 512, 2, -1);
539 RNA_def_property_ui_text(prop, "Max Res", "Maximal resolution used in the fluid domain");
540 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
541 RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
543 prop = RNA_def_property(srna, "amplify", PROP_INT, PROP_NONE);
544 RNA_def_property_int_sdna(prop, NULL, "amplify");
545 RNA_def_property_range(prop, 1, 10);
546 RNA_def_property_ui_range(prop, 1, 10, 1, -1);
547 RNA_def_property_ui_text(prop, "Amplification", "Enhance the resolution of smoke by this factor using noise");
548 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
549 RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
551 prop = RNA_def_property(srna, "use_high_resolution", PROP_BOOLEAN, PROP_NONE);
552 RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_SMOKE_HIGHRES);
553 RNA_def_property_ui_text(prop, "High res", "Enable high resolution (using amplification)");
554 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
555 RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
557 prop = RNA_def_property(srna, "show_high_resolution", PROP_BOOLEAN, PROP_NONE);
558 RNA_def_property_boolean_sdna(prop, NULL, "viewsettings", MOD_SMOKE_VIEW_SHOWBIG);
559 RNA_def_property_ui_text(prop, "Show High Resolution", "Show high resolution (using amplification)");
560 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
562 prop = RNA_def_property(srna, "noise_type", PROP_ENUM, PROP_NONE);
563 RNA_def_property_enum_sdna(prop, NULL, "noise");
564 RNA_def_property_enum_items(prop, prop_noise_type_items);
565 RNA_def_property_ui_text(prop, "Noise Method", "Noise method which is used for creating the high resolution");
566 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
567 RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
569 prop = RNA_def_property(srna, "alpha", PROP_FLOAT, PROP_NONE);
570 RNA_def_property_float_sdna(prop, NULL, "alpha");
571 RNA_def_property_range(prop, -5.0, 5.0);
572 RNA_def_property_ui_range(prop, -5.0, 5.0, 0.02, 5);
573 RNA_def_property_ui_text(prop, "Density",
574 "How much density affects smoke motion (higher value results in faster rising smoke)");
575 RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
577 prop = RNA_def_property(srna, "beta", PROP_FLOAT, PROP_NONE);
578 RNA_def_property_float_sdna(prop, NULL, "beta");
579 RNA_def_property_range(prop, -5.0, 5.0);
580 RNA_def_property_ui_range(prop, -5.0, 5.0, 0.02, 5);
581 RNA_def_property_ui_text(prop, "Heat",
582 "How much heat affects smoke motion (higher value results in faster rising smoke)");
583 RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
585 prop = RNA_def_property(srna, "collision_collection", PROP_POINTER, PROP_NONE);
586 RNA_def_property_pointer_sdna(prop, NULL, "coll_group");
587 RNA_def_property_struct_type(prop, "Collection");
588 RNA_def_property_flag(prop, PROP_EDITABLE);
589 RNA_def_property_ui_text(prop, "Collision Collection", "Limit collisions to this collection");
590 RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset_dependency");
592 prop = RNA_def_property(srna, "fluid_collection", PROP_POINTER, PROP_NONE);
593 RNA_def_property_pointer_sdna(prop, NULL, "fluid_group");
594 RNA_def_property_struct_type(prop, "Collection");
595 RNA_def_property_flag(prop, PROP_EDITABLE);
596 RNA_def_property_ui_text(prop, "Fluid Collection", "Limit fluid objects to this collection");
597 RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset_dependency");
599 prop = RNA_def_property(srna, "effector_collection", PROP_POINTER, PROP_NONE);
600 RNA_def_property_pointer_sdna(prop, NULL, "eff_group");
601 RNA_def_property_struct_type(prop, "Collection");
602 RNA_def_property_flag(prop, PROP_EDITABLE);
603 RNA_def_property_ui_text(prop, "Effector Collection", "Limit effectors to this collection");
604 RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset_dependency");
606 prop = RNA_def_property(srna, "strength", PROP_FLOAT, PROP_NONE);
607 RNA_def_property_float_sdna(prop, NULL, "strength");
608 RNA_def_property_range(prop, 0.0, 10.0);
609 RNA_def_property_ui_range(prop, 0.0, 10.0, 1, 2);
610 RNA_def_property_ui_text(prop, "Strength", "Strength of noise");
611 RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
613 prop = RNA_def_property(srna, "dissolve_speed", PROP_INT, PROP_NONE);
614 RNA_def_property_int_sdna(prop, NULL, "diss_speed");
615 RNA_def_property_range(prop, 1.0, 10000.0);
616 RNA_def_property_ui_range(prop, 1.0, 10000.0, 1, -1);
617 RNA_def_property_ui_text(prop, "Dissolve Speed", "Dissolve Speed");
618 RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
620 prop = RNA_def_property(srna, "use_dissolve_smoke", PROP_BOOLEAN, PROP_NONE);
621 RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_SMOKE_DISSOLVE);
622 RNA_def_property_ui_text(prop, "Dissolve Smoke", "Enable smoke to disappear over time");
623 RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
625 prop = RNA_def_property(srna, "use_dissolve_smoke_log", PROP_BOOLEAN, PROP_NONE);
626 RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_SMOKE_DISSOLVE_LOG);
627 RNA_def_property_ui_text(prop, "Logarithmic dissolve", "Using 1/x ");
628 RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
630 prop = RNA_def_property(srna, "point_cache", PROP_POINTER, PROP_NONE);
631 RNA_def_property_flag(prop, PROP_NEVER_NULL);
632 RNA_def_property_pointer_sdna(prop, NULL, "point_cache[0]");
633 RNA_def_property_struct_type(prop, "PointCache");
634 RNA_def_property_ui_text(prop, "Point Cache", "");
636 prop = RNA_def_property(srna, "point_cache_compress_type", PROP_ENUM, PROP_NONE);
637 RNA_def_property_enum_sdna(prop, NULL, "cache_comp");
638 RNA_def_property_enum_items(prop, smoke_cache_comp_items);
639 RNA_def_property_ui_text(prop, "Cache Compression", "Compression method to be used");
641 prop = RNA_def_property(srna, "openvdb_cache_compress_type", PROP_ENUM, PROP_NONE);
642 RNA_def_property_enum_sdna(prop, NULL, "openvdb_comp");
643 RNA_def_property_enum_items(prop, prop_compression_items);
644 RNA_def_property_ui_text(prop, "Compression", "Compression method to be used");
646 prop = RNA_def_property(srna, "data_depth", PROP_ENUM, PROP_NONE);
647 RNA_def_property_enum_bitflag_sdna(prop, NULL, "data_depth");
648 RNA_def_property_enum_items(prop, smoke_data_depth_items);
649 RNA_def_property_ui_text(prop, "Data Depth",
650 "Bit depth for writing all scalar (including vector) "
651 "lower values reduce file size");
652 RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, NULL);
654 prop = RNA_def_property(srna, "collision_extents", PROP_ENUM, PROP_NONE);
655 RNA_def_property_enum_sdna(prop, NULL, "border_collisions");
656 RNA_def_property_enum_items(prop, smoke_domain_colli_items);
657 RNA_def_property_ui_text(prop, "Border Collisions",
658 "Select which domain border will be treated as collision object");
659 RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
661 prop = RNA_def_property(srna, "effector_weights", PROP_POINTER, PROP_NONE);
662 RNA_def_property_struct_type(prop, "EffectorWeights");
663 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
664 RNA_def_property_ui_text(prop, "Effector Weights", "");
666 prop = RNA_def_property(srna, "highres_sampling", PROP_ENUM, PROP_NONE);
667 RNA_def_property_enum_items(prop, smoke_highres_sampling_items);
668 RNA_def_property_ui_text(prop, "Emitter", "Method for sampling the high resolution flow");
669 RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
671 prop = RNA_def_property(srna, "time_scale", PROP_FLOAT, PROP_NONE);
672 RNA_def_property_float_sdna(prop, NULL, "time_scale");
673 RNA_def_property_range(prop, 0.2, 1.5);
674 RNA_def_property_ui_range(prop, 0.2, 1.5, 0.02, 5);
675 RNA_def_property_ui_text(prop, "Time Scale", "Adjust simulation speed");
676 RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
678 prop = RNA_def_property(srna, "vorticity", PROP_FLOAT, PROP_NONE);
679 RNA_def_property_float_sdna(prop, NULL, "vorticity");
680 RNA_def_property_range(prop, 0.01, 4.0);
681 RNA_def_property_ui_range(prop, 0.01, 4.0, 0.02, 5);
682 RNA_def_property_ui_text(prop, "Vorticity", "Amount of turbulence/rotation in fluid");
683 RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
685 prop = RNA_def_property(srna, "density_grid", PROP_FLOAT, PROP_NONE);
686 RNA_def_property_array(prop, 32);
687 RNA_def_property_flag(prop, PROP_DYNAMIC);
688 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
689 RNA_def_property_dynamic_array_funcs(prop, "rna_SmokeModifier_grid_get_length");
690 RNA_def_property_float_funcs(prop, "rna_SmokeModifier_density_grid_get", NULL, NULL);
691 RNA_def_property_ui_text(prop, "Density Grid", "Smoke density grid");
693 prop = RNA_def_property(srna, "velocity_grid", PROP_FLOAT, PROP_NONE);
694 RNA_def_property_array(prop, 32);
695 RNA_def_property_flag(prop, PROP_DYNAMIC);
696 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
697 RNA_def_property_dynamic_array_funcs(prop, "rna_SmokeModifier_velocity_grid_get_length");
698 RNA_def_property_float_funcs(prop, "rna_SmokeModifier_velocity_grid_get", NULL, NULL);
699 RNA_def_property_ui_text(prop, "Velocity Grid", "Smoke velocity grid");
701 prop = RNA_def_property(srna, "flame_grid", PROP_FLOAT, PROP_NONE);
702 RNA_def_property_array(prop, 32);
703 RNA_def_property_flag(prop, PROP_DYNAMIC);
704 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
705 RNA_def_property_dynamic_array_funcs(prop, "rna_SmokeModifier_grid_get_length");
706 RNA_def_property_float_funcs(prop, "rna_SmokeModifier_flame_grid_get", NULL, NULL);
707 RNA_def_property_ui_text(prop, "Flame Grid", "Smoke flame grid");
709 prop = RNA_def_property(srna, "color_grid", PROP_FLOAT, PROP_NONE);
710 RNA_def_property_array(prop, 32);
711 RNA_def_property_flag(prop, PROP_DYNAMIC);
712 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
713 RNA_def_property_dynamic_array_funcs(prop, "rna_SmokeModifier_color_grid_get_length");
714 RNA_def_property_float_funcs(prop, "rna_SmokeModifier_color_grid_get", NULL, NULL);
715 RNA_def_property_ui_text(prop, "Color Grid", "Smoke color grid");
717 prop = RNA_def_property(srna, "heat_grid", PROP_FLOAT, PROP_NONE);
718 RNA_def_property_array(prop, 32);
719 RNA_def_property_flag(prop, PROP_DYNAMIC);
720 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
721 RNA_def_property_dynamic_array_funcs(prop, "rna_SmokeModifier_heat_grid_get_length");
722 RNA_def_property_float_funcs(prop, "rna_SmokeModifier_heat_grid_get", NULL, NULL);
723 RNA_def_property_ui_text(prop, "Heat Grid", "Smoke heat grid");
725 prop = RNA_def_property(srna, "temperature_grid", PROP_FLOAT, PROP_NONE);
726 RNA_def_property_array(prop, 32);
727 RNA_def_property_flag(prop, PROP_DYNAMIC);
728 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
729 RNA_def_property_dynamic_array_funcs(prop, "rna_SmokeModifier_grid_get_length");
730 RNA_def_property_float_funcs(prop, "rna_SmokeModifier_temperature_grid_get", NULL, NULL);
731 RNA_def_property_ui_text(prop, "Temperature Grid", "Smoke temperature grid, range 0..1 represents 0..1000K");
733 prop = RNA_def_property(srna, "cell_size", PROP_FLOAT, PROP_XYZ); /* can change each frame when using adaptive domain */
734 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
735 RNA_def_property_ui_text(prop, "cell_size", "Cell Size");
737 prop = RNA_def_property(srna, "start_point", PROP_FLOAT, PROP_XYZ); /* can change each frame when using adaptive domain */
738 RNA_def_property_float_sdna(prop, NULL, "p0");
739 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
740 RNA_def_property_ui_text(prop, "p0", "Start point");
742 prop = RNA_def_property(srna, "domain_resolution", PROP_INT, PROP_XYZ); /* can change each frame when using adaptive domain */
743 RNA_def_property_int_sdna(prop, NULL, "res");
744 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
745 RNA_def_property_ui_text(prop, "res", "Smoke Grid Resolution");
747 prop = RNA_def_property(srna, "burning_rate", PROP_FLOAT, PROP_NONE);
748 RNA_def_property_range(prop, 0.01, 4.0);
749 RNA_def_property_ui_range(prop, 0.01, 2.0, 1.0, 5);
750 RNA_def_property_ui_text(prop, "Speed", "Speed of the burning reaction (use larger values for smaller flame)");
751 RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
753 prop = RNA_def_property(srna, "flame_smoke", PROP_FLOAT, PROP_NONE);
754 RNA_def_property_range(prop, 0.0, 8.0);
755 RNA_def_property_ui_range(prop, 0.0, 4.0, 1.0, 5);
756 RNA_def_property_ui_text(prop, "Smoke", "Amount of smoke created by burning fuel");
757 RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
759 prop = RNA_def_property(srna, "flame_vorticity", PROP_FLOAT, PROP_NONE);
760 RNA_def_property_range(prop, 0.0, 2.0);
761 RNA_def_property_ui_range(prop, 0.0, 1.0, 1.0, 5);
762 RNA_def_property_ui_text(prop, "Vorticity", "Additional vorticity for the flames");
763 RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
765 prop = RNA_def_property(srna, "flame_ignition", PROP_FLOAT, PROP_NONE);
766 RNA_def_property_range(prop, 0.5, 5.0);
767 RNA_def_property_ui_range(prop, 0.5, 2.5, 1.0, 5);
768 RNA_def_property_ui_text(prop, "Ignition", "Minimum temperature of flames");
769 RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
771 prop = RNA_def_property(srna, "flame_max_temp", PROP_FLOAT, PROP_NONE);
772 RNA_def_property_range(prop, 1.0, 10.0);
773 RNA_def_property_ui_range(prop, 1.0, 5.0, 1.0, 5);
774 RNA_def_property_ui_text(prop, "Maximum", "Maximum temperature of flames");
775 RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
777 prop = RNA_def_property(srna, "flame_smoke_color", PROP_FLOAT, PROP_COLOR_GAMMA);
778 RNA_def_property_array(prop, 3);
779 RNA_def_property_ui_text(prop, "Smoke Color", "Color of smoke emitted from burning fuel");
780 RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
782 prop = RNA_def_property(srna, "use_adaptive_domain", PROP_BOOLEAN, PROP_NONE);
783 RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_SMOKE_ADAPTIVE_DOMAIN);
784 RNA_def_property_ui_text(prop, "Adaptive Domain", "Adapt simulation resolution and size to fluid");
785 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
786 RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
788 prop = RNA_def_property(srna, "additional_res", PROP_INT, PROP_NONE);
789 RNA_def_property_int_sdna(prop, NULL, "adapt_res");
790 RNA_def_property_range(prop, 0, 512);
791 RNA_def_property_ui_range(prop, 0, 512, 2, -1);
792 RNA_def_property_ui_text(prop, "Additional", "Maximum number of additional cells");
793 RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
795 prop = RNA_def_property(srna, "adapt_margin", PROP_INT, PROP_NONE);
796 RNA_def_property_int_sdna(prop, NULL, "adapt_margin");
797 RNA_def_property_range(prop, 2, 24);
798 RNA_def_property_ui_range(prop, 2, 24, 2, -1);
799 RNA_def_property_ui_text(prop, "Margin", "Margin added around fluid to minimize boundary interference");
800 RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
802 prop = RNA_def_property(srna, "adapt_threshold", PROP_FLOAT, PROP_NONE);
803 RNA_def_property_range(prop, 0.01, 0.5);
804 RNA_def_property_ui_range(prop, 0.01, 0.5, 1.0, 5);
805 RNA_def_property_ui_text(prop, "Threshold",
806 "Maximum amount of fluid cell can contain before it is considered empty");
807 RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
809 prop = RNA_def_property(srna, "cache_file_format", PROP_ENUM, PROP_NONE);
810 RNA_def_property_enum_sdna(prop, NULL, "cache_file_format");
811 RNA_def_property_enum_items(prop, cache_file_type_items);
812 RNA_def_property_enum_funcs(prop, NULL, "rna_Smoke_cachetype_set", NULL);
813 RNA_def_property_ui_text(prop, "File Format", "Select the file format to be used for caching");
814 RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
816 /* display settings */
818 prop = RNA_def_property(srna, "slice_method", PROP_ENUM, PROP_NONE);
819 RNA_def_property_enum_sdna(prop, NULL, "slice_method");
820 RNA_def_property_enum_items(prop, smoke_view_items);
821 RNA_def_property_ui_text(prop, "View Method", "How to slice the volume for viewport rendering");
822 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
824 prop = RNA_def_property(srna, "axis_slice_method", PROP_ENUM, PROP_NONE);
825 RNA_def_property_enum_sdna(prop, NULL, "axis_slice_method");
826 RNA_def_property_enum_items(prop, axis_slice_method_items);
827 RNA_def_property_ui_text(prop, "Method", "");
828 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
830 prop = RNA_def_property(srna, "slice_axis", PROP_ENUM, PROP_NONE);
831 RNA_def_property_enum_sdna(prop, NULL, "slice_axis");
832 RNA_def_property_enum_items(prop, axis_slice_position_items);
833 RNA_def_property_ui_text(prop, "Axis", "");
834 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
836 prop = RNA_def_property(srna, "slice_per_voxel", PROP_FLOAT, PROP_NONE);
837 RNA_def_property_float_sdna(prop, NULL, "slice_per_voxel");
838 RNA_def_property_range(prop, 0.0, 100.0);
839 RNA_def_property_ui_range(prop, 0.0, 5.0, 0.1, 1);
840 RNA_def_property_ui_text(prop, "Slice Per Voxel",
841 "How many slices per voxel should be generated");
842 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
844 prop = RNA_def_property(srna, "slice_depth", PROP_FLOAT, PROP_NONE);
845 RNA_def_property_float_sdna(prop, NULL, "slice_depth");
846 RNA_def_property_range(prop, 0.0, 1.0);
847 RNA_def_property_ui_range(prop, 0.0, 1.0, 0.1, 3);
848 RNA_def_property_ui_text(prop, "Position", "Position of the slice");
849 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
851 prop = RNA_def_property(srna, "display_thickness", PROP_FLOAT, PROP_NONE);
852 RNA_def_property_float_sdna(prop, NULL, "display_thickness");
853 RNA_def_property_range(prop, 0.001, 1000.0);
854 RNA_def_property_ui_range(prop, 0.1, 100.0, 0.1, 3);
855 RNA_def_property_ui_text(prop, "Thickness", "Thickness of smoke drawing in the viewport");
856 RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, NULL);
858 prop = RNA_def_property(srna, "display_interpolation", PROP_ENUM, PROP_NONE);
859 RNA_def_property_enum_sdna(prop, NULL, "interp_method");
860 RNA_def_property_enum_items(prop, interp_method_item);
861 RNA_def_property_ui_text(prop, "Interpolation", "Interpolation method to use for smoke/fire volumes in solid mode");
862 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
864 prop = RNA_def_property(srna, "display_velocity", PROP_BOOLEAN, PROP_NONE);
865 RNA_def_property_boolean_sdna(prop, NULL, "draw_velocity", 0);
866 RNA_def_property_ui_text(prop, "Display Velocity", "Toggle visualization of the velocity field as needles");
867 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
869 prop = RNA_def_property(srna, "vector_display_type", PROP_ENUM, PROP_NONE);
870 RNA_def_property_enum_sdna(prop, NULL, "vector_draw_type");
871 RNA_def_property_enum_items(prop, vector_draw_items);
872 RNA_def_property_ui_text(prop, "Display Type", "");
873 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
875 prop = RNA_def_property(srna, "vector_scale", PROP_FLOAT, PROP_NONE);
876 RNA_def_property_float_sdna(prop, NULL, "vector_scale");
877 RNA_def_property_range(prop, 0.0, 1000.0);
878 RNA_def_property_ui_range(prop, 0.0, 100.0, 0.1, 3);
879 RNA_def_property_ui_text(prop, "Scale", "Multiplier for scaling the vectors");
880 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
882 /* --------- Color mapping. --------- */
884 prop = RNA_def_property(srna, "use_color_ramp", PROP_BOOLEAN, PROP_NONE);
885 RNA_def_property_boolean_sdna(prop, NULL, "use_coba", 0);
886 RNA_def_property_boolean_funcs(prop, NULL, "rna_Smoke_use_color_ramp_set");
887 RNA_def_property_ui_text(prop, "Use Color Ramp",
888 "Render a simulation field while mapping its voxels values to the colors of a ramp");
889 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
891 static const EnumPropertyItem coba_field_items[] = {
892 {FLUID_FIELD_COLOR_R, "COLOR_R", 0, "Red", "Red component of the color field"},
893 {FLUID_FIELD_COLOR_G, "COLOR_G", 0, "Green", "Green component of the color field"},
894 {FLUID_FIELD_COLOR_B, "COLOR_B", 0, "Blue", "Blue component of the color field"},
895 {FLUID_FIELD_DENSITY, "DENSITY", 0, "Density", "Quantity of soot in the fluid"},
896 {FLUID_FIELD_FLAME, "FLAME", 0, "Flame", "Flame field"},
897 {FLUID_FIELD_FUEL, "FUEL", 0, "Fuel", "Fuel field"},
898 {FLUID_FIELD_HEAT, "HEAT", 0, "Heat", "Temperature of the fluid"},
899 {FLUID_FIELD_VELOCITY_X, "VELOCITY_X", 0, "X Velocity", "X component of the velocity field"},
900 {FLUID_FIELD_VELOCITY_Y, "VELOCITY_Y", 0, "Y Velocity", "Y component of the velocity field"},
901 {FLUID_FIELD_VELOCITY_Z, "VELOCITY_Z", 0, "Z Velocity", "Z component of the velocity field"},
902 {0, NULL, 0, NULL, NULL},
905 prop = RNA_def_property(srna, "coba_field", PROP_ENUM, PROP_NONE);
906 RNA_def_property_enum_sdna(prop, NULL, "coba_field");
907 RNA_def_property_enum_items(prop, coba_field_items);
908 RNA_def_property_ui_text(prop, "Field", "Simulation field to color map");
909 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
911 prop = RNA_def_property(srna, "color_ramp", PROP_POINTER, PROP_NEVER_NULL);
912 RNA_def_property_pointer_sdna(prop, NULL, "coba");
913 RNA_def_property_struct_type(prop, "ColorRamp");
914 RNA_def_property_ui_text(prop, "Color Ramp", "");
915 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
917 prop = RNA_def_property(srna, "clipping", PROP_FLOAT, PROP_NONE);
918 RNA_def_property_float_sdna(prop, NULL, "clipping");
919 RNA_def_property_range(prop, 0.0, 1.0);
920 RNA_def_property_ui_range(prop, 0.0, 1.0, 0.1, 3);
921 RNA_def_property_ui_text(prop, "Clipping",
922 "Value under which voxels are considered empty space to optimize caching and rendering");
923 RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, NULL);
926 static void rna_def_smoke_flow_settings(BlenderRNA *brna)
931 static const EnumPropertyItem smoke_flow_types[] = {
932 {MOD_SMOKE_FLOW_TYPE_OUTFLOW, "OUTFLOW", 0, "Outflow", "Delete smoke from simulation"},
933 {MOD_SMOKE_FLOW_TYPE_SMOKE, "SMOKE", 0, "Smoke", "Add smoke"},
934 {MOD_SMOKE_FLOW_TYPE_SMOKEFIRE, "BOTH", 0, "Fire + Smoke", "Add fire and smoke"},
935 {MOD_SMOKE_FLOW_TYPE_FIRE, "FIRE", 0, "Fire", "Add fire"},
936 {0, NULL, 0, NULL, NULL},
939 static const EnumPropertyItem smoke_flow_sources[] = {
940 {MOD_SMOKE_FLOW_SOURCE_PARTICLES, "PARTICLES", ICON_PARTICLES, "Particle System", "Emit smoke from particles"},
941 {MOD_SMOKE_FLOW_SOURCE_MESH, "MESH", ICON_META_CUBE, "Mesh", "Emit smoke from mesh surface or volume"},
942 {0, NULL, 0, NULL, NULL},
945 static const EnumPropertyItem smoke_flow_texture_types[] = {
946 {MOD_SMOKE_FLOW_TEXTURE_MAP_AUTO, "AUTO", 0, "Generated", "Generated coordinates centered to flow object"},
947 {MOD_SMOKE_FLOW_TEXTURE_MAP_UV, "UV", 0, "UV", "Use UV layer for texture coordinates"},
948 {0, NULL, 0, NULL, NULL},
951 srna = RNA_def_struct(brna, "SmokeFlowSettings", NULL);
952 RNA_def_struct_ui_text(srna, "Flow Settings", "Smoke flow settings");
953 RNA_def_struct_sdna(srna, "SmokeFlowSettings");
954 RNA_def_struct_path_func(srna, "rna_SmokeFlowSettings_path");
956 prop = RNA_def_property(srna, "density", PROP_FLOAT, PROP_NONE);
957 RNA_def_property_float_sdna(prop, NULL, "density");
958 RNA_def_property_range(prop, 0.0, 1);
959 RNA_def_property_ui_range(prop, 0.0, 1.0, 1.0, 4);
960 RNA_def_property_ui_text(prop, "Density", "");
961 RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
963 prop = RNA_def_property(srna, "smoke_color", PROP_FLOAT, PROP_COLOR_GAMMA);
964 RNA_def_property_float_sdna(prop, NULL, "color");
965 RNA_def_property_array(prop, 3);
966 RNA_def_property_ui_text(prop, "Smoke Color", "Color of smoke");
967 RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
969 prop = RNA_def_property(srna, "fuel_amount", PROP_FLOAT, PROP_NONE);
970 RNA_def_property_range(prop, 0.0, 10);
971 RNA_def_property_ui_range(prop, 0.0, 5.0, 1.0, 4);
972 RNA_def_property_ui_text(prop, "Flame Rate", "");
973 RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
975 prop = RNA_def_property(srna, "temperature", PROP_FLOAT, PROP_NONE);
976 RNA_def_property_float_sdna(prop, NULL, "temp");
977 RNA_def_property_range(prop, -10, 10);
978 RNA_def_property_ui_range(prop, -10, 10, 1, 1);
979 RNA_def_property_ui_text(prop, "Temp. Diff.", "Temperature difference to ambient temperature");
980 RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
982 prop = RNA_def_property(srna, "particle_system", PROP_POINTER, PROP_NONE);
983 RNA_def_property_pointer_sdna(prop, NULL, "psys");
984 RNA_def_property_struct_type(prop, "ParticleSystem");
985 RNA_def_property_flag(prop, PROP_EDITABLE);
986 RNA_def_property_ui_text(prop, "Particle Systems", "Particle systems emitted from the object");
987 RNA_def_property_update(prop, 0, "rna_Smoke_reset_dependency");
989 prop = RNA_def_property(srna, "smoke_flow_type", PROP_ENUM, PROP_NONE);
990 RNA_def_property_enum_sdna(prop, NULL, "type");
991 RNA_def_property_enum_items(prop, smoke_flow_types);
992 RNA_def_property_ui_text(prop, "Flow Type", "Change how flow affects the simulation");
993 RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
995 prop = RNA_def_property(srna, "smoke_flow_source", PROP_ENUM, PROP_NONE);
996 RNA_def_property_enum_sdna(prop, NULL, "source");
997 RNA_def_property_enum_items(prop, smoke_flow_sources);
998 RNA_def_property_ui_text(prop, "Source", "Change how smoke is emitted");
999 RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
1001 prop = RNA_def_property(srna, "use_absolute", PROP_BOOLEAN, PROP_NONE);
1002 RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_SMOKE_FLOW_ABSOLUTE);
1003 RNA_def_property_ui_text(prop, "Absolute Density", "Only allow given density value in emitter area");
1004 RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
1006 prop = RNA_def_property(srna, "use_initial_velocity", PROP_BOOLEAN, PROP_NONE);
1007 RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_SMOKE_FLOW_INITVELOCITY);
1008 RNA_def_property_ui_text(prop, "Initial Velocity", "Smoke has some initial velocity when it is emitted");
1009 RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
1011 prop = RNA_def_property(srna, "velocity_factor", PROP_FLOAT, PROP_NONE);
1012 RNA_def_property_float_sdna(prop, NULL, "vel_multi");
1013 RNA_def_property_range(prop, -100.0, 100.0);
1014 RNA_def_property_ui_range(prop, -2.0, 2.0, 0.05, 5);
1015 RNA_def_property_ui_text(prop, "Source", "Multiplier of source velocity passed to smoke");
1016 RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
1018 prop = RNA_def_property(srna, "velocity_normal", PROP_FLOAT, PROP_NONE);
1019 RNA_def_property_float_sdna(prop, NULL, "vel_normal");
1020 RNA_def_property_range(prop, -100.0, 100.0);
1021 RNA_def_property_ui_range(prop, -2.0, 2.0, 0.05, 5);
1022 RNA_def_property_ui_text(prop, "Normal", "Amount of normal directional velocity");
1023 RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
1025 prop = RNA_def_property(srna, "velocity_random", PROP_FLOAT, PROP_NONE);
1026 RNA_def_property_float_sdna(prop, NULL, "vel_random");
1027 RNA_def_property_range(prop, 0.0, 10.0);
1028 RNA_def_property_ui_range(prop, 0.0, 2.0, 0.05, 5);
1029 RNA_def_property_ui_text(prop, "Random", "Amount of random velocity");
1030 RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
1032 prop = RNA_def_property(srna, "volume_density", PROP_FLOAT, PROP_NONE);
1033 RNA_def_property_range(prop, 0.0, 1.0);
1034 RNA_def_property_ui_range(prop, 0.0, 1.0, 0.05, 5);
1035 RNA_def_property_ui_text(prop, "Volume", "Factor for smoke emitted from inside the mesh volume");
1036 RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
1038 prop = RNA_def_property(srna, "surface_distance", PROP_FLOAT, PROP_NONE);
1039 RNA_def_property_range(prop, 0.0, 10.0);
1040 RNA_def_property_ui_range(prop, 0.5, 5.0, 0.05, 5);
1041 RNA_def_property_ui_text(prop, "Surface", "Maximum distance from mesh surface to emit smoke");
1042 RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
1044 prop = RNA_def_property(srna, "particle_size", PROP_FLOAT, PROP_NONE);
1045 RNA_def_property_range(prop, 0.1, 20.0);
1046 RNA_def_property_ui_range(prop, 0.5, 5.0, 0.05, 5);
1047 RNA_def_property_ui_text(prop, "Size", "Particle size in simulation cells");
1048 RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
1050 prop = RNA_def_property(srna, "use_particle_size", PROP_BOOLEAN, PROP_NONE);
1051 RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_SMOKE_FLOW_USE_PART_SIZE);
1052 RNA_def_property_ui_text(prop, "Set Size", "Set particle size in simulation cells or use nearest cell");
1053 RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
1055 prop = RNA_def_property(srna, "subframes", PROP_INT, PROP_NONE);
1056 RNA_def_property_range(prop, 0, 50);
1057 RNA_def_property_ui_range(prop, 0, 10, 1, -1);
1058 RNA_def_property_ui_text(prop, "Subframes", "Number of additional samples to take between frames to improve quality of fast moving flows");
1059 RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
1061 prop = RNA_def_property(srna, "density_vertex_group", PROP_STRING, PROP_NONE);
1062 RNA_def_property_string_funcs(prop, "rna_SmokeFlow_density_vgroup_get",
1063 "rna_SmokeFlow_density_vgroup_length",
1064 "rna_SmokeFlow_density_vgroup_set");
1065 RNA_def_property_ui_text(prop, "Vertex Group",
1066 "Name of vertex group which determines surface emission rate");
1067 RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
1069 prop = RNA_def_property(srna, "use_texture", PROP_BOOLEAN, PROP_NONE);
1070 RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_SMOKE_FLOW_TEXTUREEMIT);
1071 RNA_def_property_ui_text(prop, "Use Texture", "Use a texture to control emission strength");
1072 RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
1074 prop = RNA_def_property(srna, "texture_map_type", PROP_ENUM, PROP_NONE);
1075 RNA_def_property_enum_sdna(prop, NULL, "texture_type");
1076 RNA_def_property_enum_items(prop, smoke_flow_texture_types);
1077 RNA_def_property_ui_text(prop, "Mapping", "Texture mapping type");
1078 RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
1080 prop = RNA_def_property(srna, "uv_layer", PROP_STRING, PROP_NONE);
1081 RNA_def_property_string_sdna(prop, NULL, "uvlayer_name");
1082 RNA_def_property_ui_text(prop, "UV Map", "UV map name");
1083 RNA_def_property_string_funcs(prop, NULL, NULL, "rna_SmokeFlow_uvlayer_set");
1084 RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
1086 prop = RNA_def_property(srna, "noise_texture", PROP_POINTER, PROP_NONE);
1087 RNA_def_property_flag(prop, PROP_EDITABLE);
1088 RNA_def_property_ui_text(prop, "Texture", "Texture that controls emission strength");
1089 RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
1091 prop = RNA_def_property(srna, "texture_size", PROP_FLOAT, PROP_NONE);
1092 RNA_def_property_range(prop, 0.01, 10.0);
1093 RNA_def_property_ui_range(prop, 0.1, 5.0, 0.05, 5);
1094 RNA_def_property_ui_text(prop, "Size", "Size of texture mapping");
1095 RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
1097 prop = RNA_def_property(srna, "texture_offset", PROP_FLOAT, PROP_NONE);
1098 RNA_def_property_range(prop, 0.0, 200.0);
1099 RNA_def_property_ui_range(prop, 0.0, 100.0, 0.05, 5);
1100 RNA_def_property_ui_text(prop, "Offset", "Z-offset of texture mapping");
1101 RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
1104 static void rna_def_smoke_coll_settings(BlenderRNA *brna)
1106 static const EnumPropertyItem smoke_coll_type_items[] = {
1107 {SM_COLL_STATIC, "COLLSTATIC", 0, "Static", "Non moving obstacle"},
1108 {SM_COLL_RIGID, "COLLRIGID", 0, "Rigid", "Rigid obstacle"},
1109 {SM_COLL_ANIMATED, "COLLANIMATED", 0, "Animated", "Animated obstacle"},
1110 {0, NULL, 0, NULL, NULL},
1116 srna = RNA_def_struct(brna, "SmokeCollSettings", NULL);
1117 RNA_def_struct_ui_text(srna, "Collision Settings", "Smoke collision settings");
1118 RNA_def_struct_sdna(srna, "SmokeCollSettings");
1119 RNA_def_struct_path_func(srna, "rna_SmokeCollSettings_path");
1121 prop = RNA_def_property(srna, "collision_type", PROP_ENUM, PROP_NONE);
1122 RNA_def_property_enum_sdna(prop, NULL, "type");
1123 RNA_def_property_enum_items(prop, smoke_coll_type_items);
1124 RNA_def_property_ui_text(prop, "Collision type", "Collision type");
1125 RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
1128 void RNA_def_smoke(BlenderRNA *brna)
1130 rna_def_smoke_domain_settings(brna);
1131 rna_def_smoke_flow_settings(brna);
1132 rna_def_smoke_coll_settings(brna);