[Bf-blender-cvs] [f2e1284] openvdb: Move draw settings to its own struct and add some more options.
Kévin Dietrich
noreply at git.blender.org
Thu Jun 18 07:01:04 CEST 2015
Commit: f2e1284f056d097990c40c26896dd5afcfd9e2e3
Author: Kévin Dietrich
Date: Wed Jun 17 15:56:55 2015 +0200
Branches: openvdb
https://developer.blender.org/rBf2e1284f056d097990c40c26896dd5afcfd9e2e3
Move draw settings to its own struct and add some more options.
For now the options control the tolerance for drawing voxels and their
size in the viewport.
===================================================================
M intern/openvdb/intern/openvdb_render.cpp
M intern/openvdb/intern/openvdb_render.h
M intern/openvdb/openvdb_capi.cpp
M intern/openvdb/openvdb_capi.h
M release/scripts/startup/bl_ui/properties_physics_smoke.py
M source/blender/blenkernel/intern/smoke.c
M source/blender/blenloader/intern/readfile.c
M source/blender/blenloader/intern/writefile.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/intern/openvdb/intern/openvdb_render.cpp b/intern/openvdb/intern/openvdb_render.cpp
index fd9b319..c0d55c7 100644
--- a/intern/openvdb/intern/openvdb_render.cpp
+++ b/intern/openvdb/intern/openvdb_render.cpp
@@ -171,7 +171,7 @@ void OpenVDBPrimitive_draw_tree(OpenVDBPrimitive *vdb_prim, const bool draw_root
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
}
-void OpenVDBPrimitive_draw_values(OpenVDBPrimitive *vdb_prim)
+void OpenVDBPrimitive_draw_values(OpenVDBPrimitive *vdb_prim, float tolerance, float point_size)
{
using namespace openvdb;
using namespace openvdb::math;
@@ -182,7 +182,7 @@ void OpenVDBPrimitive_draw_values(OpenVDBPrimitive *vdb_prim)
for (FloatGrid::ValueOnCIter iter = grid->cbeginValueOn(); iter; ++iter) {
float value = iter.getValue();
- if (value < 0.1f) {
+ if (value < tolerance) {
continue;
}
@@ -191,7 +191,7 @@ void OpenVDBPrimitive_draw_values(OpenVDBPrimitive *vdb_prim)
add_point(&vertices, &colors, point, color);
}
- glPointSize(2.0f);
+ glPointSize(point_size);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
glEnable(GL_BLEND);
diff --git a/intern/openvdb/intern/openvdb_render.h b/intern/openvdb/intern/openvdb_render.h
index 5b2a4bd..03db84a 100644
--- a/intern/openvdb/intern/openvdb_render.h
+++ b/intern/openvdb/intern/openvdb_render.h
@@ -9,7 +9,7 @@ void OpenVDBPrimitive_draw_tree(OpenVDBPrimitive *vdb_prim, const bool draw_root
const bool draw_level_1, const bool draw_level_2,
const bool draw_leaves);
-void OpenVDBPrimitive_draw_values(OpenVDBPrimitive *vdb_prim);
+void OpenVDBPrimitive_draw_values(OpenVDBPrimitive *vdb_prim, float tolerance, float point_size);
}
diff --git a/intern/openvdb/openvdb_capi.cpp b/intern/openvdb/openvdb_capi.cpp
index a75feeb..d3241df 100644
--- a/intern/openvdb/openvdb_capi.cpp
+++ b/intern/openvdb/openvdb_capi.cpp
@@ -247,7 +247,7 @@ void OpenVDB_draw_primitive(OpenVDBPrimitive *vdb_prim,
internal::OpenVDBPrimitive_draw_tree(vdb_prim, draw_root, draw_level_1, draw_level_2, draw_leaves);
}
-void OpenVDB_draw_primitive_values(struct OpenVDBPrimitive *vdb_prim)
+void OpenVDB_draw_primitive_values(struct OpenVDBPrimitive *vdb_prim, float tolerance, float point_size)
{
- internal::OpenVDBPrimitive_draw_values(vdb_prim);
+ internal::OpenVDBPrimitive_draw_values(vdb_prim, tolerance, point_size);
}
diff --git a/intern/openvdb/openvdb_capi.h b/intern/openvdb/openvdb_capi.h
index 4ad22aa..d15d616 100644
--- a/intern/openvdb/openvdb_capi.h
+++ b/intern/openvdb/openvdb_capi.h
@@ -124,7 +124,7 @@ void OpenVDB_draw_primitive(struct OpenVDBPrimitive *vdb_prim,
const bool draw_level_2,
const bool draw_leaves);
-void OpenVDB_draw_primitive_values(struct OpenVDBPrimitive *vdb_prim);
+void OpenVDB_draw_primitive_values(struct OpenVDBPrimitive *vdb_prim, float tolerance, float point_size);
#ifdef __cplusplus
}
diff --git a/release/scripts/startup/bl_ui/properties_physics_smoke.py b/release/scripts/startup/bl_ui/properties_physics_smoke.py
index f85fb9b..ff103b1 100644
--- a/release/scripts/startup/bl_ui/properties_physics_smoke.py
+++ b/release/scripts/startup/bl_ui/properties_physics_smoke.py
@@ -372,11 +372,15 @@ 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")
+ draw_data = domain.vdb_draw_data
+ layout.label(text="Draw OpenVDB Data:")
+ layout.prop_menu_enum(draw_data, "show_tree")
+ layout.prop(draw_data, "voxel_drawing")
+
+ if draw_data.voxel_drawing in { 'POINT' }:
+ row = layout.row()
+ row.prop(draw_data, "tolerance")
+ row.prop(draw_data, "point_size")
class PHYSICS_PT_smoke_field_weights(PhysicButtonsPanel, Panel):
diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c
index d4fc415..fe59dd7 100644
--- a/source/blender/blenkernel/intern/smoke.c
+++ b/source/blender/blenkernel/intern/smoke.c
@@ -413,6 +413,8 @@ static void smokeModifier_freeDomain(SmokeModifierData *smd)
MEM_freeN(cache);
}
+ MEM_freeN(smd->domain->vdb_draw_data);
+
MEM_freeN(smd->domain);
smd->domain = NULL;
}
@@ -583,6 +585,7 @@ void smokeModifier_createType(struct SmokeModifierData *smd)
smd->domain->effector_weights = BKE_add_effector_weights(NULL);
smd->domain->use_openvdb = false;
+ smd->domain->vdb_draw_data = MEM_callocN(sizeof(OpenVDBDrawData), "OpenVDBDrawData");
}
else if (smd->type & MOD_SMOKE_TYPE_FLOW)
{
@@ -2723,7 +2726,7 @@ static void smokeModifier_process(SmokeModifierData *smd, Scene *scene, Object *
return;
}
-#if 0
+#if 1
/* try to read from openvdb cache */
vdb_cache = BKE_openvdb_get_current_cache(sds);
if (sds->use_openvdb && vdb_cache) {
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index c8b1eea..0164ad8 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -4821,6 +4821,8 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
cache->reader = NULL;
cache->writer = NULL;
}
+
+ smd->domain->vdb_draw_data = newdataadr(fd, smd->domain->vdb_draw_data);
}
}
else if (smd->type == MOD_SMOKE_TYPE_FLOW) {
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index c709ab0..f3e93e9 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -1568,6 +1568,8 @@ static void write_modifiers(WriteData *wd, ListBase *modbase)
writestruct(wd, DATA, "OpenVDBCache", 1, cache);
}
+ writestruct(wd, DATA, "OpenVDBDrawData", 1, smd->domain->vdb_draw_data);
+
}
else if (smd->type & MOD_SMOKE_TYPE_FLOW)
writestruct(wd, DATA, "SmokeFlowSettings", 1, smd->flow);
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index cdf8ae6..a613a02 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -8020,6 +8020,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
if (smd->domain) {
SmokeDomainSettings *sds = smd->domain;
float viewnormal[3];
+ bool render_volume = !sds->use_openvdb;
glLoadMatrixf(rv3d->viewmat);
glMultMatrixf(ob->obmat);
@@ -8055,19 +8056,34 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
#ifdef WITH_OPENVDB
{
- 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);
+ OpenVDBDrawData *draw_data = sds->vdb_draw_data;
+ bool draw_root, draw_level_1, draw_level_2;
+ bool draw_leaves, draw_voxels;
+
+ if (!draw_data) {
+ draw_data = sds->vdb_draw_data = MEM_callocN(sizeof(OpenVDBDrawData), "OpenVDBDrawData");
+ }
+
+ draw_root = (draw_data->flags & DRAW_ROOT);
+ draw_level_1 = (draw_data->flags & DRAW_LEVEL_1);
+ draw_level_2 = (draw_data->flags & DRAW_LEVEL_2);
+ draw_leaves = (draw_data->flags & DRAW_LEAVES);
+ draw_voxels = (draw_data->flags & DRAW_VOXELS);
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 (draw_voxels && draw_data->voxel_drawing == DRAW_VOXELS_POINT)
+ OpenVDB_draw_primitive_values(sds->density, draw_data->tolerance, draw_data->point_size);
+ if (draw_voxels && draw_data->voxel_drawing == DRAW_VOXELS_VOLUME)
+ render_volume = true;
}
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);
+ if (draw_voxels && draw_data->voxel_drawing == DRAW_VOXELS_POINT)
+ OpenVDB_draw_primitive_values(sds->density_high, draw_data->tolerance, draw_data->point_size);
+ if (draw_voxels && draw_data->voxel_drawing == DRAW_VOXELS_VOLUME)
+ render_volume = true;
}
glMultMatrixf(sds->fluidmat);
}
@@ -8075,7 +8091,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
}
/* don't show smoke before simulation starts, this could be made an option in the future */
- if (!smd->domain->use_openvdb && smd->domain->fluid && CFRA >= smd->domain->point_cache[0]->startframe) {
+ if (render_volume && 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 6f2351d..07c3eca 100644
--- a/source/blender/makesdna/DNA_smoke_types.h
+++ b/source/blender/makesdna/DNA_smoke_types.h
@@ -153,8 +153,9 @@ typedef struct SmokeDomainSettings {
float flame_smoke_color[3];
struct ListBase vdb_caches;
- short use_openvdb, draw_flags, pad[2];
+ short use_openvdb, pad[3];
struct OpenVDBPrimitive *density, *density_high;
+ struct OpenVDBDrawData *vdb_draw_data;
} SmokeDomainSettings;
typedef struct OpenVDBCache {
@@ -167,6 +168,13 @@ typedef struct OpenVDBCache {
short flags, compression, pad[2];
} OpenVDBCache;
+typedef struct OpenVDBDrawData {
+ float tolerance; /* minimun value a voxel should have to be drawn */
+ float point_size; /* size of the voxels */
+ short flags; /* which level of the tree to draw
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list