[Bf-blender-cvs] [bc802ea] openvdb: A simple UI for the VDB tree visualization.

Kévin Dietrich noreply at git.blender.org
Mon Jun 15 13:35:59 CEST 2015


Commit: bc802ead9829a01038f58ff1f6a9d4481843a87b
Author: Kévin Dietrich
Date:   Sun Jun 14 03:49:43 2015 +0200
Branches: openvdb
https://developer.blender.org/rBbc802ead9829a01038f58ff1f6a9d4481843a87b

A simple UI for the VDB tree visualization.

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

M	release/scripts/startup/bl_ui/properties_physics_smoke.py
M	source/blender/blenkernel/intern/smoke.c
M	source/blender/editors/space_view3d/drawobject.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 16e2fa0..f85fb9b 100644
--- a/release/scripts/startup/bl_ui/properties_physics_smoke.py
+++ b/release/scripts/startup/bl_ui/properties_physics_smoke.py
@@ -372,6 +372,12 @@ class PHYSICS_PT_smoke_openvdb(PhysicButtonsPanel, Panel):
         layout.operator("object.smoke_vdb_export")
         layout.operator("object.smoke_vdb_transform_update")
 
+        layout.label(text="Draw OpenVDB Tree")
+        layout.prop(domain, "draw_root_node")
+        layout.prop(domain, "draw_level_1_node")
+        layout.prop(domain, "draw_level_2_node")
+        layout.prop(domain, "draw_leaf_node")
+
 
 class PHYSICS_PT_smoke_field_weights(PhysicButtonsPanel, Panel):
     bl_label = "Smoke Field Weights"
diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c
index 890c341..bd0a140 100644
--- a/source/blender/blenkernel/intern/smoke.c
+++ b/source/blender/blenkernel/intern/smoke.c
@@ -2720,15 +2720,17 @@ static void smokeModifier_process(SmokeModifierData *smd, Scene *scene, Object *
 			return;
 		}
 
+#if 0
 		/* try to read from openvdb cache */
-//		vdb_cache = BKE_openvdb_get_current_cache(sds);
-//		if (sds->use_openvdb && vdb_cache) {
-//			if (vdb_cache->flags & VDB_CACHE_SMOKE_EXPORTED) {
-//				smokeModifier_OpenVDB_import(smd, scene, ob, vdb_cache);
-//				smd->time = framenr;
-//				return;
-//			}
-//		}
+		vdb_cache = BKE_openvdb_get_current_cache(sds);
+		if (sds->use_openvdb && vdb_cache) {
+			//if (vdb_cache->flags & VDB_CACHE_SMOKE_EXPORTED) {
+				smokeModifier_OpenVDB_import(smd, scene, ob, vdb_cache);
+				smd->time = framenr;
+				return;
+			//}
+		}
+#endif
 
 		/* try to read from cache */
 		if (/*!sds->use_openvdb && */(BKE_ptcache_read(&pid, (float)framenr) == PTCACHE_READ_EXACT)) {
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index e3ed1bf..b6c75e6 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -8052,21 +8052,28 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
 				draw_box(bb.vec, false);
 
 #ifdef WITH_OPENVDB
-				glLoadMatrixf(rv3d->viewmat);
-				if (sds->density) {
-					OpenVDB_draw_primitive(sds->density, true, true, true, true);
-					OpenVDB_draw_primitive_values(sds->density);
-				}
-				if (sds->density_high) {
-					OpenVDB_draw_primitive(sds->density_high, true, true, true, true);
-					OpenVDB_draw_primitive_values(sds->density_high);
+				{
+					const bool draw_root    = (sds->draw_flags & VDB_DRAW_ROOT);
+					const bool draw_level_1 = (sds->draw_flags & VDB_DRAW_LEVEL_1);
+					const bool draw_level_2 = (sds->draw_flags & VDB_DRAW_LEVEL_2);
+					const bool draw_leaves  = (sds->draw_flags & VDB_DRAW_LEAVES);
+
+					glLoadMatrixf(rv3d->viewmat);
+					if (sds->density) {
+						OpenVDB_draw_primitive(sds->density, draw_root, draw_level_1, draw_level_2, draw_leaves);
+						OpenVDB_draw_primitive_values(sds->density);
+					}
+					if (sds->density_high) {
+						OpenVDB_draw_primitive(sds->density_high, draw_root, draw_level_1, draw_level_2, draw_leaves);
+						OpenVDB_draw_primitive_values(sds->density_high);
+					}
+					glMultMatrixf(sds->fluidmat);
 				}
-				glMultMatrixf(sds->fluidmat);
 #endif
 			}
 
 			/* don't show smoke before simulation starts, this could be made an option in the future */
-			if (smd->domain->fluid && CFRA >= smd->domain->point_cache[0]->startframe) {
+			if (!smd->domain->use_openvdb && smd->domain->fluid && CFRA >= smd->domain->point_cache[0]->startframe) {
 				float p0[3], p1[3];
 
 				glLoadMatrixf(rv3d->viewmat);
diff --git a/source/blender/makesdna/DNA_smoke_types.h b/source/blender/makesdna/DNA_smoke_types.h
index 2efa23f..6f2351d 100644
--- a/source/blender/makesdna/DNA_smoke_types.h
+++ b/source/blender/makesdna/DNA_smoke_types.h
@@ -153,7 +153,7 @@ typedef struct SmokeDomainSettings {
 	float flame_smoke_color[3];
 
 	struct ListBase vdb_caches;
-	short use_openvdb, pad[3];
+	short use_openvdb, draw_flags, pad[2];
 	struct OpenVDBPrimitive *density, *density_high;
 } SmokeDomainSettings;
 
@@ -178,6 +178,13 @@ enum {
 	VDB_COMPRESSION_NONE  = 2,
 };
 
+enum {
+    VDB_DRAW_ROOT    = (1 << 0),
+    VDB_DRAW_LEVEL_1 = (1 << 1),
+    VDB_DRAW_LEVEL_2 = (1 << 2),
+    VDB_DRAW_LEAVES  = (1 << 3),
+};
+
 /* inflow / outflow */
 
 /* type */
diff --git a/source/blender/makesrna/intern/rna_smoke.c b/source/blender/makesrna/intern/rna_smoke.c
index e3e6f5b..61fed7e 100644
--- a/source/blender/makesrna/intern/rna_smoke.c
+++ b/source/blender/makesrna/intern/rna_smoke.c
@@ -659,6 +659,26 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna)
 	                           "rna_SmokeModifier_active_openvdb_cache_index_range");
 	RNA_def_property_ui_text(prop, "Active OpenVDB cache Index", "");
 
+	prop = RNA_def_property(srna, "draw_root_node", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "draw_flags", VDB_DRAW_ROOT);
+	RNA_def_property_ui_text(prop, "Root", "Draw root node");
+	RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
+
+	prop = RNA_def_property(srna, "draw_level_1_node", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "draw_flags", VDB_DRAW_LEVEL_1);
+	RNA_def_property_ui_text(prop, "Level 1", "Draw level 1 node");
+	RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
+
+	prop = RNA_def_property(srna, "draw_level_2_node", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "draw_flags", VDB_DRAW_LEVEL_2);
+	RNA_def_property_ui_text(prop, "Level 2", "Draw level 2 node");
+	RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
+
+	prop = RNA_def_property(srna, "draw_leaf_node", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "draw_flags", VDB_DRAW_LEAVES);
+	RNA_def_property_ui_text(prop, "Leaves", "Draw leaf nodes");
+	RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
+
 	rna_def_openvdb_cache(brna);
 }




More information about the Bf-blender-cvs mailing list