[Bf-blender-cvs] [c249d3d] soc-2014-fluid: Noise settings UI

Roman Pogribnyi noreply at git.blender.org
Tue Jun 10 23:57:03 CEST 2014


Commit: c249d3dad12e2ad8a0c94ffc571f3b9fa4a5a79a
Author: Roman Pogribnyi
Date:   Tue Jun 10 23:52:45 2014 +0200
https://developer.blender.org/rBc249d3dad12e2ad8a0c94ffc571f3b9fa4a5a79a

Noise settings UI

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

M	intern/smoke/intern/MANTA.h
M	release/scripts/startup/bl_ui/properties_physics_smoke.py
M	source/blender/makesdna/DNA_smoke_types.h
M	source/blender/makesrna/intern/rna_smoke.c

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

diff --git a/intern/smoke/intern/MANTA.h b/intern/smoke/intern/MANTA.h
index 1897a7b..fdc5307 100644
--- a/intern/smoke/intern/MANTA.h
+++ b/intern/smoke/intern/MANTA.h
@@ -92,7 +92,7 @@ static void indent_ss(stringstream& ss, int indent)
 	ss << indentation;
 }
 
-static void manta_gen_noise(stringstream& ss, char* solver, int indent, char *noise, int seed, bool load, bool clamp, int clampNeg, int clampPos, float valScale, float valOffset, float timeAnim)
+static void manta_gen_noise(stringstream& ss, char* solver, int indent, char *noise, int seed, bool load, bool clamp, float clampNeg, float clampPos, float valScale, float valOffset, float timeAnim)
 {
 	if (ss == NULL)/*should never be here*/
 	{
@@ -155,6 +155,13 @@ static void generate_manta_sim_file(Scene *scene, SmokeModifierData *smd)
 	*create python file with 2-spaces indentation*/
 	
 	bool wavelets = smd->domain->flags & MOD_SMOKE_HIGHRES;
+	bool noise_clamp = smd->domain->flags & MOD_SMOKE_NOISE_CLAMP; 
+	float noise_clamp_neg = smd->domain->noise_clamp_neg;
+	float noise_clamp_pos = smd->domain->noise_clamp_pos;
+	float noise_val_scale = smd->domain->noise_val_scale;
+	float noise_val_offset = smd->domain->noise_val_offset;
+	float noise_time_anim = smd->domain->noise_time_anim;
+	
 	FLUID_3D *fluid = smd->domain->fluid;
 	
 	ofstream manta_setup_file;
@@ -187,7 +194,7 @@ static void generate_manta_sim_file(Scene *scene, SmokeModifierData *smd)
 	ss << "s.timestep = " << smd->domain->time_scale << " \n";
 		
 /*Noise Field*/
-	manta_gen_noise(ss, "s", 0, "noise", 256, true, true, 0, 2, 1, 0.075, 0.2);
+	manta_gen_noise(ss, "s", 0, "noise", 256, true, noise_clamp, noise_clamp_neg, noise_clamp_pos, noise_val_scale, noise_val_offset, noise_time_anim);
 
 /*Inflow source - for now, using mock sphere */
 	ss << "source    = s.create(Cylinder, center=gs*vec3(0.3,0.2,0.5), radius=res*0.081, z=gs*vec3(0.081, 0, 0))\n";
@@ -209,7 +216,7 @@ static void generate_manta_sim_file(Scene *scene, SmokeModifierData *smd)
 		ss << "xl_source = xl.create(Cylinder, center=xl_gs*vec3(0.3,0.2,0.5), radius=xl_gs.x*0.081, z=xl_gs*vec3(0.081, 0, 0)) \n";
 		ss << "xl_obs    = xl.create(Sphere,   center=xl_gs*vec3(0.5,0.5,0.5), radius=xl_gs.x*0.15) \n";
 		ss << "xl_obs.applyToGrid(grid=xl_flags, value=FlagObstacle) \n";
-		manta_gen_noise(ss, "xl", 0, "xl_noise", 256, true, true, 0, 2, 1, 0.075, 0.2 * (float)upres);
+		manta_gen_noise(ss, "xl", 0, "xl_noise", 256, true, noise_clamp, noise_clamp_neg, noise_clamp_pos, noise_val_scale, noise_val_offset, noise_time_anim * (float)upres);
 	}
 /*Flow setup*/
 	ss << "flags = s.create(FlagGrid) \n";/*must always be present*/
diff --git a/release/scripts/startup/bl_ui/properties_physics_smoke.py b/release/scripts/startup/bl_ui/properties_physics_smoke.py
index 82c5435..06488d3 100644
--- a/release/scripts/startup/bl_ui/properties_physics_smoke.py
+++ b/release/scripts/startup/bl_ui/properties_physics_smoke.py
@@ -348,6 +348,16 @@ class PHYSICS_PT_smoke_manta_settings(PhysicButtonsPanel, Panel):
         col = split.column()
         col.prop(domain, "manta_solver_res", text="Solver Resolution")
         col.prop(domain, "manta_uvs", text="UVs count")
+        split = layout.split()
+        col = split.column()
+        col.label("Noise Settings")
+        col.prop(domain, "noise_clamp_neg", text="Clamp Neg")
+        col.prop(domain, "noise_clamp_pos", text="Clamp Pos")
+        col.prop(domain, "noise_time_anim", text="Time Anim")
+        col = split.column()
+        col.label("")
+        col.prop(domain, "noise_val_scale", text="Scale")
+        col.prop(domain, "noise_val_offset", text="Offset")
 
 if __name__ == "__main__":  # only for live edit.
     bpy.utils.register_module(__name__)
diff --git a/source/blender/makesdna/DNA_smoke_types.h b/source/blender/makesdna/DNA_smoke_types.h
index c8bec28..acf9982 100644
--- a/source/blender/makesdna/DNA_smoke_types.h
+++ b/source/blender/makesdna/DNA_smoke_types.h
@@ -42,6 +42,7 @@ enum {
 	MOD_SMOKE_HIGH_SMOOTH = (1 << 5),  /* -- Deprecated -- */
 	MOD_SMOKE_FILE_LOAD = (1 << 6),  /* flag for file load */
 	MOD_SMOKE_ADAPTIVE_DOMAIN = (1 << 7),
+	MOD_SMOKE_NOISE_CLAMP = (1 << 8), /*for mantaflow*/
 };
 
 #if (DNA_DEPRECATED_GCC_POISON == 1)
@@ -153,6 +154,13 @@ typedef struct SmokeDomainSettings {
 	/* mantaflow settings */
 	int manta_solver_res;	/*dimension of manta solver, 2d or 3d*/
 	int manta_uvs_num;		/*number of UVs, important for octaves count*/
+		/*noise settings*/
+	float noise_clamp_neg;
+	float noise_clamp_pos;
+	float noise_val_scale;
+	float noise_val_offset;
+	float noise_time_anim;
+	float mock_var;	/*not used*/
 } SmokeDomainSettings;
 
 
diff --git a/source/blender/makesrna/intern/rna_smoke.c b/source/blender/makesrna/intern/rna_smoke.c
index 6c1abbb..82b9926 100644
--- a/source/blender/makesrna/intern/rna_smoke.c
+++ b/source/blender/makesrna/intern/rna_smoke.c
@@ -563,6 +563,46 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna)
 	RNA_def_property_ui_range(prop, 0, 4, 1, -1);
 	RNA_def_property_ui_text(prop, "UVs number", "how many uv coordinate grind to use(Better not more than 2)");
 	RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
+	
+	prop = RNA_def_property(srna, "manta_clamp_noise", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_SMOKE_NOISE_CLAMP);
+	RNA_def_property_ui_text(prop, "MantaFlow", "Use Mantaflow");
+	
+	prop = RNA_def_property(srna, "noise_clamp_neg", PROP_FLOAT, PROP_NONE);
+	RNA_def_property_float_sdna(prop, NULL, "noise_clamp_neg");
+	RNA_def_property_range(prop, 0.0, 2.0);
+	RNA_def_property_ui_range(prop, 0.0, 1.0, 1.0, 5);
+	RNA_def_property_ui_text(prop, "Clamp Negative Noise", "");
+	RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
+	
+	prop = RNA_def_property(srna, "noise_clamp_pos", PROP_FLOAT, PROP_NONE);
+	RNA_def_property_float_sdna(prop, NULL, "noise_clamp_pos");
+	RNA_def_property_range(prop, 0.0, 2.0);
+	RNA_def_property_ui_range(prop, 0.0, 1.0, 1.0, 5);
+	RNA_def_property_ui_text(prop, "Clamp Positive Noise", "");
+	RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
+	
+	prop = RNA_def_property(srna, "noise_val_scale", PROP_FLOAT, PROP_NONE);
+	RNA_def_property_float_sdna(prop, NULL, "noise_val_scale");
+	RNA_def_property_range(prop, 0.0, 2.0);
+	RNA_def_property_ui_range(prop, 0.0, 1.0, 1.0, 5);
+	RNA_def_property_ui_text(prop, "Noise Value Scale", "");
+	RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
+	
+	prop = RNA_def_property(srna, "noise_val_offset", PROP_FLOAT, PROP_NONE);
+	RNA_def_property_float_sdna(prop, NULL, "noise_val_offset");
+	RNA_def_property_range(prop, 0.0, 2.0);
+	RNA_def_property_ui_range(prop, 0.0, 1.0, 1.0, 5);
+	RNA_def_property_ui_text(prop, "Noise Value Offset", "");
+	RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
+	
+	prop = RNA_def_property(srna, "noise_time_anim", PROP_FLOAT, PROP_NONE);
+	RNA_def_property_float_sdna(prop, NULL, "noise_time_anim");
+	RNA_def_property_range(prop, 0.0, 2.0);
+	RNA_def_property_ui_range(prop, 0.0, 1.0, 1.0, 5);
+	RNA_def_property_ui_text(prop, "Noise animation time", "");
+	RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
+
 
 }




More information about the Bf-blender-cvs mailing list