diff options
Diffstat (limited to 'source/blender/makesrna/intern/rna_smoke.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_smoke.c | 137 |
1 files changed, 137 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_smoke.c b/source/blender/makesrna/intern/rna_smoke.c index 539f3c192be..d1786dab8ca 100644 --- a/source/blender/makesrna/intern/rna_smoke.c +++ b/source/blender/makesrna/intern/rna_smoke.c @@ -53,6 +53,8 @@ #include "BKE_depsgraph.h" #include "BKE_particle.h" +#include "BLI_math.h" + #include "smoke_API.h" @@ -316,8 +318,99 @@ static void rna_SmokeFlow_uvlayer_set(PointerRNA *ptr, const char *value) rna_object_uvlayer_name_set(ptr, value, flow->uvlayer_name, sizeof(flow->uvlayer_name)); } +static PointerRNA rna_SmokeModifier_active_openvdb_cache_get(PointerRNA *ptr) +{ + SmokeDomainSettings *sds = (SmokeDomainSettings *)ptr->data; + OpenVDBCache *cache = NULL; + + cache = BKE_openvdb_get_current_cache(sds); + return rna_pointer_inherit_refine(ptr, &RNA_OpenVDBCache, cache); +} + +static void rna_SmokeModifier_active_openvdb_cache_index_range(PointerRNA *ptr, int *min, int *max, + int *UNUSED(softmin), int *UNUSED(softmax)) +{ + SmokeDomainSettings *sds = (SmokeDomainSettings *)ptr->data; + *min = 0; + *max = max_ii(0, BLI_listbase_count(&sds->vdb_caches) - 1); +} + +static int rna_SmokeModifier_active_openvdb_cache_index_get(PointerRNA *ptr) +{ + SmokeDomainSettings *sds = (SmokeDomainSettings *)ptr->data; + OpenVDBCache *cache = (OpenVDBCache *)sds->vdb_caches.first; + int i = 0; + + for (; cache; cache = cache->next, i++) { + if (cache->flags & VDB_CACHE_CURRENT) + return i; + } + return 0; +} + +static void rna_SmokeModifier_active_openvdb_cache_index_set(struct PointerRNA *ptr, int value) +{ + SmokeDomainSettings *sds = (SmokeDomainSettings *)ptr->data; + OpenVDBCache *cache = (OpenVDBCache *)sds->vdb_caches.first; + int i = 0; + + for (; cache; cache = cache->next, i++) { + if (i == value) + cache->flags |= VDB_CACHE_CURRENT; + else + cache->flags &= ~VDB_CACHE_CURRENT; + } +} + + #else +static void rna_def_openvdb_cache(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + static EnumPropertyItem prop_compression_items[] = { + { VDB_COMPRESSION_ZIP, "ZIP", 0, "Zip", "Slow and effective compression" }, +#ifdef WITH_OPENVDB_BLOSC + { VDB_COMPRESSION_BLOSC, "BLOSC", 0, "Blosc", "Multithreaded compression, almost similar in size and quality as 'Zip'" }, +#endif + { VDB_COMPRESSION_NONE, "NONE", 0, "None", "Do not use any compression" }, + { 0, NULL, 0, NULL, NULL } + }; + + srna = RNA_def_struct(brna, "OpenVDBCache", NULL); + RNA_def_struct_ui_text(srna, "OpenVDB cache", "OpenVDB cache"); + + prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_TIME); + RNA_def_property_int_sdna(prop, NULL, "startframe"); + RNA_def_property_range(prop, -MAXFRAME, MAXFRAME); + RNA_def_property_ui_range(prop, 1, MAXFRAME, 1, 1); + RNA_def_property_ui_text(prop, "Start", "Frame on which the simulation starts"); + + prop = RNA_def_property(srna, "frame_end", PROP_INT, PROP_TIME); + RNA_def_property_int_sdna(prop, NULL, "endframe"); + RNA_def_property_range(prop, 1, MAXFRAME); + RNA_def_property_ui_text(prop, "End", "Frame on which the simulation stops"); + + prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_DIRPATH); + RNA_def_property_string_sdna(prop, NULL, "path"); + RNA_def_property_ui_text(prop, "File Path", "Cache file path"); +// RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_idname_change"); + + prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "name"); + RNA_def_property_ui_text(prop, "Name", "Cache name"); + RNA_def_struct_name_property(srna, prop); + + prop = RNA_def_property(srna, "compression", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "compression"); + RNA_def_property_enum_items(prop, prop_compression_items); + RNA_def_property_ui_text(prop, "File Compression", + "Select what type of compression to use when writing the files"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset"); +} + static void rna_def_smoke_domain_settings(BlenderRNA *brna) { StructRNA *srna; @@ -463,6 +556,14 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna) RNA_def_property_enum_items(prop, smoke_cache_comp_items); RNA_def_property_ui_text(prop, "Cache Compression", "Compression method to be used"); + prop = RNA_def_property(srna, "point_cache_offset", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "point_cache_offset"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_range(prop, -10000, 10000); + RNA_def_property_ui_range(prop, -10000, 10000, 1, -1); + RNA_def_property_ui_text(prop, "Point Cache Offset", "Offset to add to cached frames"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_update"); + prop = RNA_def_property(srna, "collision_extents", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "border_collisions"); RNA_def_property_enum_items(prop, smoke_domain_colli_items); @@ -601,6 +702,37 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Threshold", "Maximum amount of fluid cell can contain before it is considered empty"); RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache"); + + /* display */ + prop = RNA_def_property(srna, "display_thickness", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "display_thickness"); + RNA_def_property_range(prop, 0.001f, 1000.0f); + RNA_def_property_ui_range(prop, 0.1f, 10.0f, 0.1, 3); + RNA_def_property_ui_text(prop, "Thickness", "Thickness of smoke drawing in the viewport"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, NULL); + + prop = RNA_def_property(srna, "use_openvdb", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "use_openvdb", 1); + RNA_def_property_ui_text(prop, "Use OpenVDB", "Use OpenVDB to cache the simulation"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, NULL); + + prop = RNA_def_property(srna, "cache", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_sdna(prop, NULL, "vdb_caches", NULL); + RNA_def_property_struct_type(prop, "OpenVDBCache"); + + prop = RNA_def_property(srna, "active_openvdb_cache", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "OpenVDBCache"); + RNA_def_property_pointer_funcs(prop, "rna_SmokeModifier_active_openvdb_cache_get", NULL, NULL, NULL); + RNA_def_property_ui_text(prop, "Active OpenVDB cache", ""); + + prop = RNA_def_property(srna, "active_openvdb_cache_index", PROP_INT, PROP_UNSIGNED); + RNA_def_property_int_funcs(prop, "rna_SmokeModifier_active_openvdb_cache_index_get", + "rna_SmokeModifier_active_openvdb_cache_index_set", + "rna_SmokeModifier_active_openvdb_cache_index_range"); + RNA_def_property_ui_text(prop, "Active OpenVDB cache Index", ""); + + rna_def_openvdb_cache(brna); } static void rna_def_smoke_flow_settings(BlenderRNA *brna) @@ -732,6 +864,11 @@ static void rna_def_smoke_flow_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Set Size", "Set particle size in simulation cells or use nearest cell"); RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset"); + prop = RNA_def_property(srna, "use_particle_texture_color", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_SMOKE_FLOW_USE_PART_TEXCOLOR); + RNA_def_property_ui_text(prop, "Set Texture Color", "Set particle texture color in simulation cells"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset"); + prop = RNA_def_property(srna, "subframes", PROP_INT, PROP_NONE); RNA_def_property_range(prop, 0, 50); RNA_def_property_ui_range(prop, 0, 10, 1, -1); |