[Bf-blender-cvs] [04195b1e743] blender-v2.90-release: Fluid: Added new option to control the maximum number fluid particles in the simulation

Sebastián Barschkis noreply at git.blender.org
Sun Jul 26 22:04:10 CEST 2020


Commit: 04195b1e743c86550fb2d1836c882eff875dec85
Author: Sebastián Barschkis
Date:   Sun Jul 26 22:01:42 2020 +0200
Branches: blender-v2.90-release
https://developer.blender.org/rB04195b1e743c86550fb2d1836c882eff875dec85

Fluid: Added new option to control the maximum number fluid particles in the simulation

New option that lets users the define the maximum number of fluid particles that will be allowed in the simulation. This can come in handy, for example, to ensure that the particle count will not exceed the hardware capabilities, or to avoid excessive amounts of particles in a scene.

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

M	intern/mantaflow/intern/MANTA_main.cpp
M	intern/mantaflow/intern/strings/liquid_script.h
M	release/scripts/startup/bl_ui/properties_physics_fluid.py
M	source/blender/blenkernel/intern/fluid.c
M	source/blender/makesdna/DNA_fluid_types.h
M	source/blender/makesrna/intern/rna_fluid.c

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

diff --git a/intern/mantaflow/intern/MANTA_main.cpp b/intern/mantaflow/intern/MANTA_main.cpp
index 676a2fd785e..5b2cbb09979 100644
--- a/intern/mantaflow/intern/MANTA_main.cpp
+++ b/intern/mantaflow/intern/MANTA_main.cpp
@@ -876,6 +876,7 @@ void MANTA::initializeRNAMap(FluidModifierData *fmd)
   mRNAMap["CACHE_DIR"] = cacheDirectory;
   mRNAMap["COMPRESSION_OPENVDB"] = vdbCompressionMethod;
   mRNAMap["PRECISION_OPENVDB"] = vdbPrecisionHalf;
+  mRNAMap["PP_PARTICLE_MAXIMUM"] = to_string(fds->sys_particle_maximum);
 
   /* Fluid object names. */
   mRNAMap["NAME_FLAGS"] = FLUID_NAME_FLAGS;
diff --git a/intern/mantaflow/intern/strings/liquid_script.h b/intern/mantaflow/intern/strings/liquid_script.h
index f4e181873b8..08d8dcd7de3 100644
--- a/intern/mantaflow/intern/strings/liquid_script.h
+++ b/intern/mantaflow/intern/strings/liquid_script.h
@@ -48,7 +48,8 @@ meshRadiusFactor_s$ID$ = $MESH_PARTICLE_RADIUS$\n\
 smoothenPos_s$ID$      = $MESH_SMOOTHEN_POS$\n\
 smoothenNeg_s$ID$      = $MESH_SMOOTHEN_NEG$\n\
 randomness_s$ID$       = $PARTICLE_RANDOMNESS$\n\
-surfaceTension_s$ID$   = $LIQUID_SURFACE_TENSION$\n";
+surfaceTension_s$ID$   = $LIQUID_SURFACE_TENSION$\n\
+maxSysParticles_s$ID$  = $PP_PARTICLE_MAXIMUM$\n";
 
 const std::string liquid_variables_particles =
     "\n\
@@ -216,6 +217,7 @@ def liquid_adaptive_step_$ID$(framenr):\n\
     else:\n\
         pVel_pp$ID$.setSource(grid=None, isMAC=False)\n\
     \n\
+    pp_s$ID$.maxParticles = maxSysParticles_s$ID$ # remember, 0 means no particle cap\n\
     sampleLevelsetWithParticles(phi=phiIn_s$ID$, flags=flags_s$ID$, parts=pp_s$ID$, discretization=particleNumber_s$ID$, randomness=randomness_s$ID$)\n\
     flags_s$ID$.updateFromLevelset(phi_s$ID$)\n\
     \n\
diff --git a/release/scripts/startup/bl_ui/properties_physics_fluid.py b/release/scripts/startup/bl_ui/properties_physics_fluid.py
index 13073d182d1..8dd5b935922 100644
--- a/release/scripts/startup/bl_ui/properties_physics_fluid.py
+++ b/release/scripts/startup/bl_ui/properties_physics_fluid.py
@@ -473,6 +473,7 @@ class PHYSICS_PT_liquid(PhysicButtonsPanel, Panel):
         col = flow.column()
         col.prop(domain, "simulation_method", expand=False)
         col.prop(domain, "flip_ratio", text="FLIP Ratio")
+        col.prop(domain, "sys_particle_maximum", text="System Maximum")
         col = col.column(align=True)
         col.prop(domain, "particle_radius", text="Particle Radius")
         col.prop(domain, "particle_number", text="Sampling")
diff --git a/source/blender/blenkernel/intern/fluid.c b/source/blender/blenkernel/intern/fluid.c
index 286da4977e3..079b436a3ea 100644
--- a/source/blender/blenkernel/intern/fluid.c
+++ b/source/blender/blenkernel/intern/fluid.c
@@ -4856,6 +4856,7 @@ void BKE_fluid_modifier_create_type_data(struct FluidModifierData *fmd)
     fmd->domain->particle_radius = 1.0f;
     fmd->domain->particle_band_width = 3.0f;
     fmd->domain->fractions_threshold = 0.05f;
+    fmd->domain->sys_particle_maximum = 0;
 
     /* diffusion options*/
     fmd->domain->surface_tension = 0.0f;
@@ -5100,6 +5101,7 @@ void BKE_fluid_modifier_copy(const struct FluidModifierData *fmd,
     tfds->particle_radius = fds->particle_radius;
     tfds->particle_band_width = fds->particle_band_width;
     tfds->fractions_threshold = fds->fractions_threshold;
+    tfds->sys_particle_maximum = fds->sys_particle_maximum;
 
     /* diffusion options*/
     tfds->surface_tension = fds->surface_tension;
diff --git a/source/blender/makesdna/DNA_fluid_types.h b/source/blender/makesdna/DNA_fluid_types.h
index 909170523a3..90440d9af8a 100644
--- a/source/blender/makesdna/DNA_fluid_types.h
+++ b/source/blender/makesdna/DNA_fluid_types.h
@@ -524,8 +524,9 @@ typedef struct FluidDomainSettings {
   float particle_band_width;
   float fractions_threshold;
   float flip_ratio;
+  int sys_particle_maximum;
   short simulation_method;
-  char _pad4[6];
+  char _pad4[2];
 
   /* Diffusion options. */
   float surface_tension;
diff --git a/source/blender/makesrna/intern/rna_fluid.c b/source/blender/makesrna/intern/rna_fluid.c
index 71b8eee9d50..ab8f97ae3c2 100644
--- a/source/blender/makesrna/intern/rna_fluid.c
+++ b/source/blender/makesrna/intern/rna_fluid.c
@@ -1683,6 +1683,15 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna)
                            "and reduce the boundary smoothening effect)");
   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
 
+  prop = RNA_def_property(srna, "sys_particle_maximum", PROP_INT, PROP_NONE);
+  RNA_def_property_int_sdna(prop, NULL, "sys_particle_maximum");
+  RNA_def_property_range(prop, 0, INT_MAX);
+  RNA_def_property_ui_text(
+      prop,
+      "System Maximum",
+      "Maximum number of fluid particles that are allowed in this simulation");
+  RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
+
   /*  diffusion options */
 
   prop = RNA_def_property(srna, "use_diffusion", PROP_BOOLEAN, PROP_NONE);



More information about the Bf-blender-cvs mailing list