[Bf-blender-cvs] [e6a43693f4e] fluid-mantaflow: added UI fields to control FLIP particle amount

Sebastián Barschkis noreply at git.blender.org
Sat Jul 29 00:44:23 CEST 2017


Commit: e6a43693f4e3d13881a086fa42da638776497bb3
Author: Sebastián Barschkis
Date:   Sun Jul 23 14:52:41 2017 +0200
Branches: fluid-mantaflow
https://developer.blender.org/rBe6a43693f4e3d13881a086fa42da638776497bb3

added UI fields to control FLIP particle amount

also cleaned up the UI a bit

===================================================================

M	intern/mantaflow/intern/FLUID.cpp
M	intern/mantaflow/intern/strings/liquid_script.h
M	release/scripts/startup/bl_ui/properties_physics_smoke.py
M	source/blender/blenkernel/intern/smoke.c
M	source/blender/makesdna/DNA_smoke_types.h
M	source/blender/makesrna/intern/rna_smoke.c

===================================================================

diff --git a/intern/mantaflow/intern/FLUID.cpp b/intern/mantaflow/intern/FLUID.cpp
index 0a8b8c77b76..1aff2477d54 100644
--- a/intern/mantaflow/intern/FLUID.cpp
+++ b/intern/mantaflow/intern/FLUID.cpp
@@ -653,6 +653,10 @@ std::string FLUID::getRealValue(const std::string& varName,  SmokeModifierData *
 		ss << smd->domain->particle_randomness;
 	else if (varName == "PARTICLE_NUMBER")
 		ss << smd->domain->particle_number;
+	else if (varName == "PARTICLE_SEED")
+		ss << smd->domain->particle_seed;
+	else if (varName == "PARTICLE_KILL")
+		ss << smd->domain->particle_kill;
 	else if (varName == "PARTICLE_RADIUS")
 		ss << smd->domain->particle_radius;
 	else if (varName == "PARTICLE_BAND_WIDTH")
diff --git a/intern/mantaflow/intern/strings/liquid_script.h b/intern/mantaflow/intern/strings/liquid_script.h
index 53461aac2d4..cef9361adc3 100644
--- a/intern/mantaflow/intern/strings/liquid_script.h
+++ b/intern/mantaflow/intern/strings/liquid_script.h
@@ -40,7 +40,8 @@ combineBandWidth_s$ID$        = narrowBandWidth_s$ID$ - 1\n\
 adjustedNarrowBandWidth_s$ID$ = $PARTICLE_BAND_WIDTH$ # only used in adjustNumber to control band width\n\
 \n\
 particleNumber_s$ID$ = $PARTICLE_NUMBER$\n\
-minParticles_s$ID$   = pow(particleNumber_s$ID$, dim_s$ID$)\n\
+minParticles_s$ID$   = $PARTICLE_SEED$\n\
+maxParticles_s$ID$   = $PARTICLE_KILL$\n\
 radiusFactor_s$ID$   = $PARTICLE_RADIUS$\n\
 randomness_s$ID$     = $PARTICLE_RANDOMNESS$\n\
 maxVel_s$ID$         = 1 # just declared here, do not set\n\
@@ -267,7 +268,7 @@ def liquid_step_$ID$():\n\
     \n\
     # set source grids for resampling, used in adjustNumber!\n\
     pVel_pp$ID$.setSource(vel_s$ID$, isMAC=True)\n\
-    adjustNumber(parts=pp_s$ID$, vel=vel_s$ID$, flags=flags_s$ID$, minParticles=1*minParticles_s$ID$, maxParticles=2*minParticles_s$ID$, phi=phi_s$ID$, exclude=phiObs_s$ID$, radiusFactor=radiusFactor_s$ID$, narrowBand=adjustedNarrowBandWidth_s$ID$)\n\
+    adjustNumber(parts=pp_s$ID$, vel=vel_s$ID$, flags=flags_s$ID$, minParticles=minParticles_s$ID$, maxParticles=maxParticles_s$ID$, phi=phi_s$ID$, exclude=phiObs_s$ID$, radiusFactor=radiusFactor_s$ID$, narrowBand=adjustedNarrowBandWidth_s$ID$)\n\
     flipVelocityUpdate(vel=vel_s$ID$, velOld=velOld_s$ID$, flags=flags_s$ID$, parts=pp_s$ID$, partVel=pVel_pp$ID$, flipRatio=0.97)\n";
 
 const std::string liquid_step_high = "\n\
@@ -441,6 +442,7 @@ mantaMsg('Deleting lowres liquid variables')\n\
 if 'narrowBandWidth_s$ID$'  in globals() : del narrowBandWidth_s$ID$\n\
 if 'combineBandWidth_s$ID$' in globals() : del combineBandWidth_s$ID$\n\
 if 'minParticles_s$ID$'     in globals() : del minParticles_s$ID$\n\
+if 'maxParticles_s$ID$'     in globals() : del maxParticles_s$ID$\n\
 if 'particleNumber_s$ID$'   in globals() : del particleNumber_s$ID$\n\
 if 'maxVel_s$ID$'           in globals() : del maxVel_s$ID$\n\
 if 'using_drops_s$ID$'      in globals() : del using_drops_s$ID$\n\
diff --git a/release/scripts/startup/bl_ui/properties_physics_smoke.py b/release/scripts/startup/bl_ui/properties_physics_smoke.py
index f3e730c1841..ddf6b9d8e38 100644
--- a/release/scripts/startup/bl_ui/properties_physics_smoke.py
+++ b/release/scripts/startup/bl_ui/properties_physics_smoke.py
@@ -132,11 +132,13 @@ class PHYSICS_PT_smoke(PhysicButtonsPanel, Panel):
                 col.label(text="Liquid:")
                 col.prop(domain, "particle_randomness")
                 col.prop(domain, "particle_radius")
+                col.prop(domain, "particle_seed")
 
                 col = split.column()
                 col.label()
                 col.prop(domain, "particle_number")
                 col.prop(domain, "particle_band_width")
+                col.prop(domain, "particle_kill")
 
         elif md.smoke_type == 'FLOW':
             flow = md.flow_settings
@@ -362,17 +364,27 @@ class PHYSICS_PT_smoke_particles(PhysicButtonsPanel, Panel):
         col.enabled = not domain.point_cache.is_baked
         col.prop(domain, "use_flip_particles", text="FLIP")
         col.prop(domain, "use_drop_particles", text="Drop")
-        col.prop(domain, "use_bubble_particles", text="Bubble")
+        col2 = col.column()
+        col2.active = domain.use_drop_particles
+        col2.prop(domain, "use_bubble_particles", text="Bubble")
         col.prop(domain, "use_float_particles", text="Float")
         col.prop(domain, "use_tracer_particles", text="Tracer")
 
         col = split.column()
         col.enabled = not domain.point_cache.is_baked
         sub = col.column()
-        sub.active = domain.use_drop_particles
         sub.label()
+        sub.active = domain.use_drop_particles
         sub.prop(domain, "particle_velocity_threshold", text="Threshold")
-        sub.prop(domain, "particle_bubble_rise", text="Rise")
+        sub2 = col.column()
+        sub2.active = domain.use_drop_particles and domain.use_bubble_particles
+        sub2.prop(domain, "particle_bubble_rise", text="Rise")
+        #sub3 = col.column()
+        #sub3.active = domain.use_float_particles
+        #sub3.prop(domain, "particle_float_amout", text="Amount")
+        #sub4 = col.column()
+        #sub4.active = domain.use_tracer_particles
+        #sub4.prop(domain, "particle_tracer_amout", text="Amount")
 
 class PHYSICS_PT_smoke_groups(PhysicButtonsPanel, Panel):
     bl_label = "Fluid Groups"
diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c
index f58fb029729..cb6cc79ae9b 100644
--- a/source/blender/blenkernel/intern/smoke.c
+++ b/source/blender/blenkernel/intern/smoke.c
@@ -540,6 +540,8 @@ void smokeModifier_createType(struct SmokeModifierData *smd)
 			/* liquid */
 			smd->domain->particle_randomness = 0.1f;
 			smd->domain->particle_number = 2;
+			smd->domain->particle_seed = 8;
+			smd->domain->particle_kill = 16;
 			smd->domain->particle_radius = 1.0f;
 			smd->domain->particle_band_width = 3.0f;
 			smd->domain->particle_velocity_threshold = 2.0f;
@@ -660,13 +662,14 @@ void smokeModifier_copy(struct SmokeModifierData *smd, struct SmokeModifierData
 		tsmd->domain->flame_ignition = smd->domain->flame_ignition;
 		tsmd->domain->flame_max_temp = smd->domain->flame_max_temp;
 		
-#ifdef WITH_MANTA
 		tsmd->domain->gravity[0] = smd->domain->gravity[0];
 		tsmd->domain->gravity[1] = smd->domain->gravity[1];
 		tsmd->domain->gravity[2] = smd->domain->gravity[2];
 
 		tsmd->domain->particle_randomness = smd->domain->particle_randomness;
 		tsmd->domain->particle_number = smd->domain->particle_number;
+		tsmd->domain->particle_seed = smd->domain->particle_seed;
+		tsmd->domain->particle_kill = smd->domain->particle_kill;
 		tsmd->domain->particle_radius = smd->domain->particle_radius;
 		tsmd->domain->particle_band_width = smd->domain->particle_band_width;
 		tsmd->domain->particle_velocity_threshold = smd->domain->particle_velocity_threshold;
@@ -680,7 +683,6 @@ void smokeModifier_copy(struct SmokeModifierData *smd, struct SmokeModifierData
 		tsmd->domain->render_display_mode = smd->domain->render_display_mode;
 		tsmd->domain->type = smd->domain->type;
 		tsmd->domain->preconditioner = smd->domain->preconditioner;
-#endif
 
 		copy_v3_v3(tsmd->domain->flame_smoke_color, smd->domain->flame_smoke_color);
 
diff --git a/source/blender/makesdna/DNA_smoke_types.h b/source/blender/makesdna/DNA_smoke_types.h
index 85c51db71ac..96178a7f7cf 100644
--- a/source/blender/makesdna/DNA_smoke_types.h
+++ b/source/blender/makesdna/DNA_smoke_types.h
@@ -245,6 +245,8 @@ typedef struct SmokeDomainSettings {
 	/* liquid parameters */
 	float particle_randomness;
 	int particle_number;
+	int particle_seed;
+	int particle_kill;
 	float particle_radius;
 	float particle_band_width;
 	float particle_velocity_threshold;
diff --git a/source/blender/makesrna/intern/rna_smoke.c b/source/blender/makesrna/intern/rna_smoke.c
index ac165898fe0..ad928721d32 100644
--- a/source/blender/makesrna/intern/rna_smoke.c
+++ b/source/blender/makesrna/intern/rna_smoke.c
@@ -1235,7 +1235,19 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna)
 	RNA_def_property_ui_range(prop, 1, 5, 2, -1);
 	RNA_def_property_ui_text(prop, "Number", "Particle number factor (higher value results in more particles)");
 	RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
-	
+
+	prop = RNA_def_property(srna, "particle_seed", PROP_INT, PROP_NONE);
+	RNA_def_property_range(prop, 1, 10);
+	RNA_def_property_ui_range(prop, 1, 5, 2, -1);
+	RNA_def_property_ui_text(prop, "Seed", "Amount of particles seeded per cell (higher value results in more particles)");
+	RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
+
+	prop = RNA_def_property(srna, "particle_kill", PROP_INT, PROP_NONE);
+	RNA_def_property_range(prop, 1, 10);
+	RNA_def_property_ui_range(prop, 1, 5, 2, -1);
+	RNA_def_property_ui_text(prop, "Kill", "Maximum number of particles allowed per cell (higher value results in more particles)");
+	RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
+
 	prop = RNA_def_property(srna, "particle_radius", PROP_FLOAT, PROP_NONE);
 	RNA_def_property_range(prop, 0.0, 10.0);
 	RNA_def_property_ui_range(prop, 0.0, 10.0, 0.02, 5);




More information about the Bf-blender-cvs mailing list