diff options
author | Thomas Dinges <blender@dingto.org> | 2012-04-16 01:02:08 +0400 |
---|---|---|
committer | Thomas Dinges <blender@dingto.org> | 2012-04-16 01:02:08 +0400 |
commit | 5496e87eee5951345ecb2d3f503342246fd8581e (patch) | |
tree | 296cf327a299682d45dae08f5cba69506d02cd21 | |
parent | 86508076d8190a374bcd9c17785eb0802dd4c1ca (diff) |
Fluid Simulation:
* Replaced the hard coded viscosity presets with Python ones.
* Added version check, so older files load fine.
Loading new files into 2.62 also works fine.
-rw-r--r-- | release/scripts/presets/fluid/honey.py | 3 | ||||
-rw-r--r-- | release/scripts/presets/fluid/oil.py | 3 | ||||
-rw-r--r-- | release/scripts/presets/fluid/water.py | 3 | ||||
-rw-r--r-- | release/scripts/startup/bl_operators/presets.py | 17 | ||||
-rw-r--r-- | release/scripts/startup/bl_ui/properties_physics_fluid.py | 26 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_blender.h | 2 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 24 | ||||
-rw-r--r-- | source/blender/editors/physics/physics_fluid.c | 14 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_object_fluidsim.h | 3 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_fluidsim.c | 13 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_fluidsim_util.c | 1 |
11 files changed, 69 insertions, 40 deletions
diff --git a/release/scripts/presets/fluid/honey.py b/release/scripts/presets/fluid/honey.py new file mode 100644 index 00000000000..fbeb7f2b286 --- /dev/null +++ b/release/scripts/presets/fluid/honey.py @@ -0,0 +1,3 @@ +import bpy +bpy.context.fluid.settings.viscosity_base = 2.0 +bpy.context.fluid.settings.viscosity_exponent = 3 diff --git a/release/scripts/presets/fluid/oil.py b/release/scripts/presets/fluid/oil.py new file mode 100644 index 00000000000..3d73de9303a --- /dev/null +++ b/release/scripts/presets/fluid/oil.py @@ -0,0 +1,3 @@ +import bpy +bpy.context.fluid.settings.viscosity_base = 5.0 +bpy.context.fluid.settings.viscosity_exponent = 5 diff --git a/release/scripts/presets/fluid/water.py b/release/scripts/presets/fluid/water.py new file mode 100644 index 00000000000..0b68ad28c98 --- /dev/null +++ b/release/scripts/presets/fluid/water.py @@ -0,0 +1,3 @@ +import bpy +bpy.context.fluid.settings.viscosity_base = 1.0 +bpy.context.fluid.settings.viscosity_exponent = 6 diff --git a/release/scripts/startup/bl_operators/presets.py b/release/scripts/startup/bl_operators/presets.py index da6ef7483f2..2c92fccf3b4 100644 --- a/release/scripts/startup/bl_operators/presets.py +++ b/release/scripts/startup/bl_operators/presets.py @@ -294,6 +294,23 @@ class AddPresetCloth(AddPresetBase, Operator): preset_subdir = "cloth" +class AddPresetFluid(AddPresetBase, Operator): + '''Add a Fluid Preset''' + bl_idname = "fluid.preset_add" + bl_label = "Add Fluid Preset" + preset_menu = "FLUID_MT_presets" + + preset_defines = [ + "fluid = bpy.context.fluid" + ] + + preset_values = [ + "fluid.settings.viscosity_base", + "fluid.settings.viscosity_exponent", + ] + + preset_subdir = "fluid" + class AddPresetSunSky(AddPresetBase, Operator): '''Add a Sky & Atmosphere Preset''' diff --git a/release/scripts/startup/bl_ui/properties_physics_fluid.py b/release/scripts/startup/bl_ui/properties_physics_fluid.py index d334671292a..23b7a12753f 100644 --- a/release/scripts/startup/bl_ui/properties_physics_fluid.py +++ b/release/scripts/startup/bl_ui/properties_physics_fluid.py @@ -18,7 +18,13 @@ # <pep8 compliant> import bpy -from bpy.types import Panel +from bpy.types import Panel, Menu + +class FLUID_MT_presets(Menu): + bl_label = "Fluid Presets" + preset_subdir = "fluid" + preset_operator = "script.execute_preset" + draw = Menu.draw_preset class PhysicButtonsPanel(): @@ -222,16 +228,14 @@ class PHYSICS_PT_domain_gravity(PhysicButtonsPanel, Panel): col = split.column() col.label(text="Viscosity Presets:") - sub = col.column(align=True) - sub.prop(fluid, "viscosity_preset", text="") - - if fluid.viscosity_preset == 'MANUAL': - sub.prop(fluid, "viscosity_base", text="Base") - sub.prop(fluid, "viscosity_exponent", text="Exponent", slider=True) - else: - # just for padding to prevent jumping around - sub.separator() - sub.separator() + sub = col.row(align=True) + sub.menu("FLUID_MT_presets", text=bpy.types.FLUID_MT_presets.bl_label) + sub.operator("fluid.preset_add", text="", icon='ZOOMIN') + sub.operator("fluid.preset_add", text="", icon='ZOOMOUT').remove_active = True + + subsub = col.column(align=True) + subsub.prop(fluid, "viscosity_base", text="Base") + subsub.prop(fluid, "viscosity_exponent", text="Exponent", slider=True) col.label(text="Optimization:") col.prop(fluid, "grid_levels", slider=True) diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index ffabbcf32f0..296461e61c8 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -42,7 +42,7 @@ extern "C" { * and keep comment above the defines. * Use STRINGIFY() rather than defining with quotes */ #define BLENDER_VERSION 262 -#define BLENDER_SUBVERSION 3 +#define BLENDER_SUBVERSION 4 #define BLENDER_MINVERSION 250 #define BLENDER_MINSUBVERSION 0 diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 55f0ccebf95..6a40e1ebf43 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -13323,6 +13323,30 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } + if (main->versionfile < 262 || (main->versionfile == 262 && main->subversionfile < 4)) + { + /* Read Viscosity presets from older files */ + Object *ob; + + for (ob = main->object.first; ob; ob = ob->id.next) { + ModifierData *md; + for (md = ob->modifiers.first; md; md = md->next) { + if (md->type == eModifierType_Fluidsim) { + FluidsimModifierData *fmd = (FluidsimModifierData *)md; + if(fmd->fss->viscosityMode == 3) { + fmd->fss->viscosityValue = 5.0; + fmd->fss->viscosityExponent = 5; + } + else if(fmd->fss->viscosityMode == 4) { + fmd->fss->viscosityValue = 2.0; + fmd->fss->viscosityExponent = 3; + } + } + } + } + } + + { /* Default for old files is to save particle rotations to pointcache */ diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c index 6a074a542c3..20fa4c5753f 100644 --- a/source/blender/editors/physics/physics_fluid.c +++ b/source/blender/editors/physics/physics_fluid.c @@ -98,19 +98,7 @@ static float get_fluid_viscosity(FluidsimSettings *settings) { - switch (settings->viscosityMode) { - case 0: /* unused */ - return -1.0; - case 2: /* water */ - return 1.0e-6; - case 3: /* some (thick) oil */ - return 5.0e-5; - case 4: /* ca. honey */ - return 2.0e-3; - case 1: /* manual */ - default: - return (1.0f/powf(10.0f, settings->viscosityExponent)) * settings->viscosityValue; - } + return (1.0f/powf(10.0f, settings->viscosityExponent)) * settings->viscosityValue; } static float get_fluid_rate(FluidsimSettings *settings) diff --git a/source/blender/makesdna/DNA_object_fluidsim.h b/source/blender/makesdna/DNA_object_fluidsim.h index 751d420daa7..a55b7b17a22 100644 --- a/source/blender/makesdna/DNA_object_fluidsim.h +++ b/source/blender/makesdna/DNA_object_fluidsim.h @@ -35,6 +35,7 @@ #define __DNA_OBJECT_FLUIDSIM_H__ #include "DNA_ID.h" +#include "DNA_defs.h" #ifdef __cplusplus extern "C" { @@ -66,7 +67,7 @@ typedef struct FluidsimSettings { /* fluid properties */ float viscosityValue; - short viscosityMode; + short viscosityMode DNA_DEPRECATED; short viscosityExponent; /* gravity strength */ float grav[3]; diff --git a/source/blender/makesrna/intern/rna_fluidsim.c b/source/blender/makesrna/intern/rna_fluidsim.c index b5770650cb8..a4aac6f345c 100644 --- a/source/blender/makesrna/intern/rna_fluidsim.c +++ b/source/blender/makesrna/intern/rna_fluidsim.c @@ -269,13 +269,6 @@ static void rna_def_fluidsim_domain(BlenderRNA *brna) {OB_FSDOM_FINAL, "FINAL", 0, "Final", "Display final quality results"}, {0, NULL, 0, NULL, NULL}}; - static EnumPropertyItem viscosity_items[] = { - {1, "MANUAL", 0, "Manual", "Manual viscosity settings"}, - {2, "WATER", 0, "Water", "Viscosity of 1.0 * 10^-6"}, - {3, "OIL", 0, "Oil", "Viscosity of 5.0 * 10^-5"}, - {4, "HONEY", 0, "Honey", "Viscosity of 2.0 * 10^-3"}, - {0, NULL, 0, NULL, NULL}}; - srna = RNA_def_struct(brna, "DomainFluidSettings", "FluidSettings"); RNA_def_struct_sdna(srna, "FluidsimSettings"); RNA_def_struct_ui_text(srna, "Domain Fluid Simulation Settings", @@ -360,12 +353,6 @@ static void rna_def_fluidsim_domain(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "animRate"); RNA_def_property_range(prop, 0.0, 100.0); RNA_def_property_ui_text(prop, "Simulation Speed", "Fluid motion rate (0 = stationary, 1 = normal speed)"); - - prop = RNA_def_property(srna, "viscosity_preset", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "viscosityMode"); - RNA_def_property_enum_items(prop, viscosity_items); - RNA_def_property_ui_text(prop, "Viscosity Preset", - "Set viscosity of the fluid to a preset value, or use manual input"); prop = RNA_def_property(srna, "viscosity_base", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "viscosityValue"); diff --git a/source/blender/modifiers/intern/MOD_fluidsim_util.c b/source/blender/modifiers/intern/MOD_fluidsim_util.c index 9cd656c3621..fe0cb2e650f 100644 --- a/source/blender/modifiers/intern/MOD_fluidsim_util.c +++ b/source/blender/modifiers/intern/MOD_fluidsim_util.c @@ -85,7 +85,6 @@ void fluidsim_init(FluidsimModifierData *fluidmd) fss->guiDisplayMode = 2; // preview fss->renderDisplayMode = 3; // render - fss->viscosityMode = 2; // default to water fss->viscosityValue = 1.0; fss->viscosityExponent = 6; |