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.
This commit is contained in:
@@ -876,6 +876,7 @@ void MANTA::initializeRNAMap(FluidModifierData *fmd)
|
|||||||
mRNAMap["CACHE_DIR"] = cacheDirectory;
|
mRNAMap["CACHE_DIR"] = cacheDirectory;
|
||||||
mRNAMap["COMPRESSION_OPENVDB"] = vdbCompressionMethod;
|
mRNAMap["COMPRESSION_OPENVDB"] = vdbCompressionMethod;
|
||||||
mRNAMap["PRECISION_OPENVDB"] = vdbPrecisionHalf;
|
mRNAMap["PRECISION_OPENVDB"] = vdbPrecisionHalf;
|
||||||
|
mRNAMap["PP_PARTICLE_MAXIMUM"] = to_string(fds->sys_particle_maximum);
|
||||||
|
|
||||||
/* Fluid object names. */
|
/* Fluid object names. */
|
||||||
mRNAMap["NAME_FLAGS"] = FLUID_NAME_FLAGS;
|
mRNAMap["NAME_FLAGS"] = FLUID_NAME_FLAGS;
|
||||||
|
@@ -48,7 +48,8 @@ meshRadiusFactor_s$ID$ = $MESH_PARTICLE_RADIUS$\n\
|
|||||||
smoothenPos_s$ID$ = $MESH_SMOOTHEN_POS$\n\
|
smoothenPos_s$ID$ = $MESH_SMOOTHEN_POS$\n\
|
||||||
smoothenNeg_s$ID$ = $MESH_SMOOTHEN_NEG$\n\
|
smoothenNeg_s$ID$ = $MESH_SMOOTHEN_NEG$\n\
|
||||||
randomness_s$ID$ = $PARTICLE_RANDOMNESS$\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 =
|
const std::string liquid_variables_particles =
|
||||||
"\n\
|
"\n\
|
||||||
@@ -216,6 +217,7 @@ def liquid_adaptive_step_$ID$(framenr):\n\
|
|||||||
else:\n\
|
else:\n\
|
||||||
pVel_pp$ID$.setSource(grid=None, isMAC=False)\n\
|
pVel_pp$ID$.setSource(grid=None, isMAC=False)\n\
|
||||||
\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\
|
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\
|
flags_s$ID$.updateFromLevelset(phi_s$ID$)\n\
|
||||||
\n\
|
\n\
|
||||||
|
@@ -473,6 +473,7 @@ class PHYSICS_PT_liquid(PhysicButtonsPanel, Panel):
|
|||||||
col = flow.column()
|
col = flow.column()
|
||||||
col.prop(domain, "simulation_method", expand=False)
|
col.prop(domain, "simulation_method", expand=False)
|
||||||
col.prop(domain, "flip_ratio", text="FLIP Ratio")
|
col.prop(domain, "flip_ratio", text="FLIP Ratio")
|
||||||
|
col.prop(domain, "sys_particle_maximum", text="System Maximum")
|
||||||
col = col.column(align=True)
|
col = col.column(align=True)
|
||||||
col.prop(domain, "particle_radius", text="Particle Radius")
|
col.prop(domain, "particle_radius", text="Particle Radius")
|
||||||
col.prop(domain, "particle_number", text="Sampling")
|
col.prop(domain, "particle_number", text="Sampling")
|
||||||
|
@@ -4856,6 +4856,7 @@ void BKE_fluid_modifier_create_type_data(struct FluidModifierData *fmd)
|
|||||||
fmd->domain->particle_radius = 1.0f;
|
fmd->domain->particle_radius = 1.0f;
|
||||||
fmd->domain->particle_band_width = 3.0f;
|
fmd->domain->particle_band_width = 3.0f;
|
||||||
fmd->domain->fractions_threshold = 0.05f;
|
fmd->domain->fractions_threshold = 0.05f;
|
||||||
|
fmd->domain->sys_particle_maximum = 0;
|
||||||
|
|
||||||
/* diffusion options*/
|
/* diffusion options*/
|
||||||
fmd->domain->surface_tension = 0.0f;
|
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_radius = fds->particle_radius;
|
||||||
tfds->particle_band_width = fds->particle_band_width;
|
tfds->particle_band_width = fds->particle_band_width;
|
||||||
tfds->fractions_threshold = fds->fractions_threshold;
|
tfds->fractions_threshold = fds->fractions_threshold;
|
||||||
|
tfds->sys_particle_maximum = fds->sys_particle_maximum;
|
||||||
|
|
||||||
/* diffusion options*/
|
/* diffusion options*/
|
||||||
tfds->surface_tension = fds->surface_tension;
|
tfds->surface_tension = fds->surface_tension;
|
||||||
|
@@ -524,8 +524,9 @@ typedef struct FluidDomainSettings {
|
|||||||
float particle_band_width;
|
float particle_band_width;
|
||||||
float fractions_threshold;
|
float fractions_threshold;
|
||||||
float flip_ratio;
|
float flip_ratio;
|
||||||
|
int sys_particle_maximum;
|
||||||
short simulation_method;
|
short simulation_method;
|
||||||
char _pad4[6];
|
char _pad4[2];
|
||||||
|
|
||||||
/* Diffusion options. */
|
/* Diffusion options. */
|
||||||
float surface_tension;
|
float surface_tension;
|
||||||
|
@@ -1683,6 +1683,15 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna)
|
|||||||
"and reduce the boundary smoothening effect)");
|
"and reduce the boundary smoothening effect)");
|
||||||
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
|
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 */
|
/* diffusion options */
|
||||||
|
|
||||||
prop = RNA_def_property(srna, "use_diffusion", PROP_BOOLEAN, PROP_NONE);
|
prop = RNA_def_property(srna, "use_diffusion", PROP_BOOLEAN, PROP_NONE);
|
||||||
|
Reference in New Issue
Block a user