[Bf-blender-cvs] [32e89737d7b] fluid-mantaflow: more mesh improvements
Sebastián Barschkis
noreply at git.blender.org
Tue May 1 23:43:23 CEST 2018
Commit: 32e89737d7be4ffba68127890d9cb0e0a4f366d3
Author: Sebastián Barschkis
Date: Tue May 1 23:41:22 2018 +0200
Branches: fluid-mantaflow
https://developer.blender.org/rB32e89737d7be4ffba68127890d9cb0e0a4f366d3
more mesh improvements
added more smoothening settings and a preview/final mesh switch
===================================================================
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 64908741008..6e9913a2b26 100644
--- a/intern/mantaflow/intern/FLUID.cpp
+++ b/intern/mantaflow/intern/FLUID.cpp
@@ -810,6 +810,12 @@ std::string FLUID::getRealValue(const std::string& varName, SmokeModifierData *
ss << smd->domain->mesh_smoothen_upper;
else if (varName == "MESH_SMOOTHEN_LOWER")
ss << smd->domain->mesh_smoothen_lower;
+ else if (varName == "MESH_SMOOTHEN_POS")
+ ss << smd->domain->mesh_smoothen_pos;
+ else if (varName == "MESH_SMOOTHEN_NEG")
+ ss << smd->domain->mesh_smoothen_neg;
+ else if (varName == "USING_IMPROVED_MESH")
+ ss << (smd->domain->mesh_generator == SM_MESH_IMPROVED ? "True" : "False");
else if (varName == "PARTICLE_BAND_WIDTH")
ss << smd->domain->particle_band_width;
else if (varName == "SNDPARTICLE_DROPLET_THRESH")
diff --git a/intern/mantaflow/intern/strings/liquid_script.h b/intern/mantaflow/intern/strings/liquid_script.h
index 0e906e6dc4e..5c702cfe157 100644
--- a/intern/mantaflow/intern/strings/liquid_script.h
+++ b/intern/mantaflow/intern/strings/liquid_script.h
@@ -39,14 +39,17 @@ narrowBandWidth_s$ID$ = 3\n\
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$ = $PARTICLE_MINIMUM$\n\
-maxParticles_s$ID$ = $PARTICLE_MAXIMUM$\n\
-radiusFactor_s$ID$ = $PARTICLE_RADIUS$\n\
-smoothenUpper_s$ID$ = $MESH_SMOOTHEN_UPPER$\n\
-smoothenLower_s$ID$ = $MESH_SMOOTHEN_LOWER$\n\
-randomness_s$ID$ = $PARTICLE_RANDOMNESS$\n\
-surfaceTension_s$ID$ = $LIQUID_SURFACE_TENSION$\n";
+particleNumber_s$ID$ = $PARTICLE_NUMBER$\n\
+minParticles_s$ID$ = $PARTICLE_MINIMUM$\n\
+maxParticles_s$ID$ = $PARTICLE_MAXIMUM$\n\
+radiusFactor_s$ID$ = $PARTICLE_RADIUS$\n\
+using_final_mesh_s$ID$ = $USING_IMPROVED_MESH$\n\
+smoothenUpper_s$ID$ = $MESH_SMOOTHEN_UPPER$\n\
+smoothenLower_s$ID$ = $MESH_SMOOTHEN_LOWER$\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";
const std::string liquid_variables_mesh = "\n\
mantaMsg('Liquid variables high')\n";
@@ -377,9 +380,13 @@ def liquid_save_mesh_$ID$(path, framenr, file_format):\n\
# create surface\n\
pp_xl$ID$.readParticles(pp_s$ID$)\n\
gridParticleIndex(parts=pp_xl$ID$, flags=flags_xl$ID$, indexSys=pindex_xl$ID$, index=gpi_xl$ID$)\n\
- improvedParticleLevelset(pp_xl$ID$, pindex_xl$ID$, flags_xl$ID$, gpi_xl$ID$, phiParts_xl$ID$, radiusFactor_s$ID$, 1, 1, smoothenLower_s$ID$, smoothenUpper_s$ID$)\n\
-# averagedParticleLevelset(pp_xl$ID$, pindex_xl$ID$, flags_xl$ID$, gpi_xl$ID$, phiParts_xl$ID$, radiusFactor_s$ID$, 1, 1)\n\
-# unionParticleLevelset(pp_xl$ID$, pindex_xl$ID$, flags_xl$ID$, gpi_xl$ID$, phiParts_xl$ID$, radiusFactor_s$ID$)\n\
+ \n\
+ if using_final_mesh_s$ID$:\n\
+ mantaMsg('Liquid using improved particle levelset')\n\
+ improvedParticleLevelset(pp_xl$ID$, pindex_xl$ID$, flags_xl$ID$, gpi_xl$ID$, phiParts_xl$ID$, radiusFactor_s$ID$, smoothenPos_s$ID$, smoothenNeg_s$ID$, smoothenLower_s$ID$, smoothenUpper_s$ID$)\n\
+ else:\n\
+ mantaMsg('Liquid using union particle levelset')\n\
+ unionParticleLevelset(pp_xl$ID$, pindex_xl$ID$, flags_xl$ID$, gpi_xl$ID$, phiParts_xl$ID$, radiusFactor_s$ID$)\n\
\n\
phi_xl$ID$.addConst(1.) # shrink slightly\n\
phi_xl$ID$.join(phiParts_xl$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 57d0374a5c1..12cfa874b46 100644
--- a/release/scripts/startup/bl_ui/properties_physics_smoke.py
+++ b/release/scripts/startup/bl_ui/properties_physics_smoke.py
@@ -290,7 +290,8 @@ class PHYSICS_PT_smoke_adaptive_domain(PhysicButtonsPanel, Panel):
def poll(cls, context):
md = context.smoke
# Adaptive domain only for smoke right now
- return md and (md.smoke_type == 'DOMAIN') and (md.domain_settings.smoke_domain_type in {'GAS'})
+ # TODO (sebbas): Disable for now - not working with new manta cache right now
+ return False #md and (md.smoke_type == 'DOMAIN') and (md.domain_settings.smoke_domain_type in {'GAS'})
def draw_header(self, context):
md = context.smoke.domain_settings
@@ -417,8 +418,22 @@ class PHYSICS_PT_smoke_mesh(PhysicButtonsPanel, Panel):
col.prop(domain, "particle_radius")
col = split.column(align=True)
- col.prop(domain, "mesh_smoothen_upper")
- col.prop(domain, "mesh_smoothen_lower")
+ col.label(text="Generator:")
+ col.prop(domain, "mesh_generator", text="")
+
+ if domain.mesh_generator in {'IMPROVED'}:
+ split = layout.split()
+ split.enabled = not domain.cache_baked_mesh and not baking_any
+
+ col = split.column(align=True)
+ col.label(text="Smoothening")
+ col.prop(domain, "mesh_smoothen_pos")
+ col.prop(domain, "mesh_smoothen_neg")
+
+ col = split.column(align=True)
+ col.label(text="")
+ col.prop(domain, "mesh_smoothen_upper")
+ col.prop(domain, "mesh_smoothen_lower")
# TODO (sebbas): for now just interpolate any upres grids, ie not sampling highres grids
#col = split.column()
diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c
index 4aa7e326395..1a730d0b7d9 100644
--- a/source/blender/blenkernel/intern/smoke.c
+++ b/source/blender/blenkernel/intern/smoke.c
@@ -529,6 +529,8 @@ void smokeModifier_createType(struct SmokeModifierData *smd)
smd->domain->particle_radius = 1.0f;
smd->domain->mesh_smoothen_upper = 3.5f;
smd->domain->mesh_smoothen_lower = 0.4f;
+ smd->domain->mesh_smoothen_pos = 1;
+ smd->domain->mesh_smoothen_neg = 1;
smd->domain->particle_band_width = 3.0f;
smd->domain->particle_type = 0;
@@ -690,6 +692,8 @@ void smokeModifier_copy(struct SmokeModifierData *smd, struct SmokeModifierData
tsmd->domain->particle_radius = smd->domain->particle_radius;
tsmd->domain->mesh_smoothen_upper = smd->domain->mesh_smoothen_upper;
tsmd->domain->mesh_smoothen_lower = smd->domain->mesh_smoothen_lower;
+ tsmd->domain->mesh_smoothen_pos = smd->domain->mesh_smoothen_pos;
+ tsmd->domain->mesh_smoothen_neg = smd->domain->mesh_smoothen_neg;
tsmd->domain->particle_band_width = smd->domain->particle_band_width;
tsmd->domain->particle_droplet_threshold = smd->domain->particle_droplet_threshold;
tsmd->domain->particle_droplet_amount = smd->domain->particle_droplet_amount;
diff --git a/source/blender/makesdna/DNA_smoke_types.h b/source/blender/makesdna/DNA_smoke_types.h
index b66cce72f62..0f8b7795b37 100644
--- a/source/blender/makesdna/DNA_smoke_types.h
+++ b/source/blender/makesdna/DNA_smoke_types.h
@@ -138,6 +138,10 @@ enum {
#define SM_VIEWPORT_PREVIEW 1
#define SM_VIEWPORT_FINAL 2
+/* mesh levelset generator types */
+#define SM_MESH_IMPROVED 0
+#define SM_MESH_UNION 1
+
/* effector types */
#define SM_EFFECTOR_COLLISION 0
#define SM_EFFECTOR_GUIDE 1
@@ -264,7 +268,9 @@ typedef struct SmokeDomainSettings {
/* show original meshes, preview or final sim */
short viewport_display_mode;
short render_display_mode;
-
+ short mesh_generator;
+ char pad5[6];
+
float time_scale;
float cfl_condition;
float vorticity;
@@ -285,6 +291,8 @@ typedef struct SmokeDomainSettings {
float particle_radius;
float mesh_smoothen_upper;
float mesh_smoothen_lower;
+ int mesh_smoothen_pos;
+ int mesh_smoothen_neg;
float particle_band_width;
float particle_droplet_threshold;
float particle_droplet_amount;
diff --git a/source/blender/makesrna/intern/rna_smoke.c b/source/blender/makesrna/intern/rna_smoke.c
index a88f1b065e0..ae151a6cfd4 100644
--- a/source/blender/makesrna/intern/rna_smoke.c
+++ b/source/blender/makesrna/intern/rna_smoke.c
@@ -956,6 +956,12 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna)
{0, NULL, 0, NULL, NULL}
};
+ static EnumPropertyItem fluid_mesh_quality_items[] = {
+ {SM_MESH_IMPROVED, "IMPROVED", 0, "Final", "Use improved particle levelset (slower but more precise and with mesh smoothening options)"},
+ {SM_MESH_UNION, "UNION", 0, "Preview", "Use union particle levelset (faster but lower quality)"},
+ {0, NULL, 0, NULL, NULL}
+ };
+
/* Cache type - generated dynamically based on domain type */
static EnumPropertyItem cache_file_type_items[] = {
{0, "NONE", 0, "", ""},
@@ -1178,6 +1184,12 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Render Display Mode", "How to display the mesh for rendering");
RNA_def_property_update(prop, 0, "rna_Smoke_update");
+ prop = RNA_def_property(srna, "mesh_generator", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "mesh_generator");
+ RNA_def_property_enum_items(prop, fluid_mesh_quality_items);
+ RNA_def_property_ui_text(prop, "Mesh generator", "Which particle levelset generator to use");
+ RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Smoke_update");
+
prop = RNA_def_property(srna, "effector_weights", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "EffectorWeights");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
@@ -1465,6 +1477,16 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Smoothen Lower", "Lower mesh smoothening bound (high values tend to smoothen and fill out concave regions)");
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
+ prop = RNA_def_property(srna, "mesh_smoothen_pos", PROP_INT, PROP_NONE);
+ RNA_def_property_range(prop, 0, 100);
+ RNA_def_property_ui_text(prop, "Smoothen Pos", "Positive mesh smoothening");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
+
+ prop = RNA_def_property(srna, "mesh_smoothen_neg", PROP_INT, PROP_NONE);
+ RNA_def_property_r
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list