[Bf-blender-cvs] [2ab4225] gooseberry: Thickness setting for smoke drawing in the OpenGL viewport.

Lukas Tönne noreply at git.blender.org
Tue Apr 7 16:03:59 CEST 2015


Commit: 2ab422506b542ec68ddbbcfd2855f5ba333a145b
Author: Lukas Tönne
Date:   Tue Apr 7 16:00:20 2015 +0200
Branches: gooseberry
https://developer.blender.org/rB2ab422506b542ec68ddbbcfd2855f5ba333a145b

Thickness setting for smoke drawing in the OpenGL viewport.

This is the first actual drawing/display setting for smoke, so a new
panel "Display" has been added to give it a home in the UI.

The name "thickness" has been chosen deliberately to distinguish it from
density, since the parameter only affects OpenGL drawing but not the
actual physical density values.

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

M	release/scripts/startup/bl_ui/properties_physics_smoke.py
M	source/blender/blenloader/intern/versioning_270.c
M	source/blender/editors/space_view3d/drawvolume.c
M	source/blender/makesdna/DNA_smoke_types.h
M	source/blender/makesrna/intern/rna_smoke.c

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

diff --git a/release/scripts/startup/bl_ui/properties_physics_smoke.py b/release/scripts/startup/bl_ui/properties_physics_smoke.py
index f2dc178..624f36e 100644
--- a/release/scripts/startup/bl_ui/properties_physics_smoke.py
+++ b/release/scripts/startup/bl_ui/properties_physics_smoke.py
@@ -136,6 +136,25 @@ class PHYSICS_PT_smoke(PhysicButtonsPanel, Panel):
             col.prop(coll, "collision_type")
 
 
+class PHYSICS_PT_smoke_display(PhysicButtonsPanel, Panel):
+    bl_label = "Smoke Display"
+    bl_options = {'DEFAULT_CLOSED'}
+
+    @classmethod
+    def poll(cls, context):
+        md = context.smoke
+        return md and (md.smoke_type == 'DOMAIN')
+
+    def draw(self, context):
+        layout = self.layout
+        domain = context.smoke.domain_settings
+
+        split = layout.split()
+
+        col = split.column(align=True)
+        col.prop(domain, "display_thickness")
+
+
 class PHYSICS_PT_smoke_flow_advanced(PhysicButtonsPanel, Panel):
     bl_label = "Smoke Flow Advanced"
     bl_options = {'DEFAULT_CLOSED'}
diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c
index 301e728..aa4e53f 100644
--- a/source/blender/blenloader/intern/versioning_270.c
+++ b/source/blender/blenloader/intern/versioning_270.c
@@ -52,6 +52,7 @@
 #include "DNA_actuator_types.h"
 #include "DNA_camera_types.h"
 #include "DNA_view3d_types.h"
+#include "DNA_smoke_types.h"
 
 #include "DNA_genfile.h"
 
@@ -980,4 +981,19 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
 			}
 		}
 	}
+
+	if (!DNA_struct_elem_find(fd->filesdna, "SmokeDomainSettings", "float", "display_thickness")) {
+		Object *ob;
+		ModifierData *md;
+		for (ob = main->object.first; ob; ob = ob->id.next) {
+			for (md = ob->modifiers.first; md; md = md->next) {
+				if (md->type == eModifierType_Smoke) {
+					SmokeModifierData *smd = (SmokeModifierData *)md;
+					if (smd->domain) {
+						smd->domain->display_thickness = 1.0f;
+					}
+				}
+			}
+		}
+	}
 }
diff --git a/source/blender/editors/space_view3d/drawvolume.c b/source/blender/editors/space_view3d/drawvolume.c
index 92883f2..400fb08 100644
--- a/source/blender/editors/space_view3d/drawvolume.c
+++ b/source/blender/editors/space_view3d/drawvolume.c
@@ -106,6 +106,7 @@ void draw_smoke_volume(SmokeDomainSettings *sds, Object *ob,
 	int gl_depth = 0, gl_blend = 0;
 
 	int use_fire = (sds->active_fields & SM_ACTIVE_FIRE);
+	const float thickness = sds->display_thickness;
 
 	/* draw slices of smoke is adapted from c++ code authored
 	 * by: Johannes Schmid and Ingemar Rask, 2006, johnny at grob.org */
@@ -364,9 +365,9 @@ void draw_smoke_volume(SmokeDomainSettings *sds, Object *ob,
 		glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 0, dx, dx, dx, 1.0);
 		/* custom parameter for smoke style (higher = thicker) */
 		if (sds->active_fields & SM_ACTIVE_COLORS)
-			glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 1, 1.0, 1.0, 1.0, 10.0);
+			glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 1, 1.0, 1.0, 1.0, 10.0 * thickness);
 		else
-			glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 1, sds->active_color[0], sds->active_color[1], sds->active_color[2], 10.0);
+			glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 1, sds->active_color[0], sds->active_color[1], sds->active_color[2], 10.0 * thickness);
 	}
 	else
 		printf("Your gfx card does not support 3D View smoke drawing.\n");
diff --git a/source/blender/makesdna/DNA_smoke_types.h b/source/blender/makesdna/DNA_smoke_types.h
index cb38462..54b734f 100644
--- a/source/blender/makesdna/DNA_smoke_types.h
+++ b/source/blender/makesdna/DNA_smoke_types.h
@@ -151,6 +151,10 @@ typedef struct SmokeDomainSettings {
 	float burning_rate, flame_smoke, flame_vorticity;
 	float flame_ignition, flame_max_temp;
 	float flame_smoke_color[3];
+
+	/* display */
+	float display_thickness;
+	int pad2;
 } SmokeDomainSettings;
 
 
diff --git a/source/blender/makesrna/intern/rna_smoke.c b/source/blender/makesrna/intern/rna_smoke.c
index 5c375d3..420aede 100644
--- a/source/blender/makesrna/intern/rna_smoke.c
+++ b/source/blender/makesrna/intern/rna_smoke.c
@@ -552,6 +552,14 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna)
 	RNA_def_property_ui_text(prop, "Threshold",
 	                         "Maximum amount of fluid cell can contain before it is considered empty");
 	RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache");
+
+	/* display */
+	prop = RNA_def_property(srna, "display_thickness", PROP_FLOAT, PROP_NONE);
+	RNA_def_property_float_sdna(prop, NULL, "display_thickness");
+	RNA_def_property_range(prop, 0.001f, 1000.0f);
+	RNA_def_property_ui_range(prop, 0.1f, 10.0f, 0.1, 3);
+	RNA_def_property_ui_text(prop, "Thickness", "Thickness of smoke drawing in the viewport");
+	RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, NULL);
 }
 
 static void rna_def_smoke_flow_settings(BlenderRNA *brna)




More information about the Bf-blender-cvs mailing list