[Bf-blender-cvs] [7b6deb2] openvdb: Make OpenVDB cache properties its own struct/linked list, including some operators to add caches to, move caches around and remove caches from the list.

Kévin Dietrich noreply at git.blender.org
Fri Jun 5 14:06:42 CEST 2015


Commit: 7b6deb2a4663dece035596b62b0e7a1d7de93305
Author: Kévin Dietrich
Date:   Sun May 17 15:33:18 2015 +0200
Branches: openvdb
https://developer.blender.org/rB7b6deb2a4663dece035596b62b0e7a1d7de93305

Make OpenVDB cache properties its own struct/linked list, including some
operators to add caches to, move caches around and remove caches from
the list.

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

M	release/scripts/startup/bl_ui/properties_physics_smoke.py
M	source/blender/blenkernel/BKE_smoke.h
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/object/object_intern.h
M	source/blender/editors/object/object_modifier.c
M	source/blender/editors/object/object_ops.c
M	source/blender/makesdna/DNA_smoke_types.h
M	source/blender/makesrna/RNA_access.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 270f091..a89db20 100644
--- a/release/scripts/startup/bl_ui/properties_physics_smoke.py
+++ b/release/scripts/startup/bl_ui/properties_physics_smoke.py
@@ -18,7 +18,7 @@
 
 # <pep8 compliant>
 import bpy
-from bpy.types import Panel
+from bpy.types import Panel, UIList
 
 from bl_ui.properties_physics_common import (
         point_cache_ui,
@@ -313,6 +313,15 @@ class PHYSICS_PT_smoke_cache(PhysicButtonsPanel, Panel):
         point_cache_ui(self, context, cache, (cache.is_baked is False), 'SMOKE')
 
 
+class DATA_UL_openvdb_caches(UIList):
+    def draw_items(self, context, layout, item, icon, active_data, active_propname, index):
+        if self.layout_type in {'DEFAULT', 'COMPACT'}:
+            layout.prop(item, "name", text="", emboss=False, icon_value=icon)
+        elif self.layout_type in {'GRID'}:
+            layout.alignement = 'CENTER'
+            layout.label(text="", icon_value=icon)
+
+
 class PHYSICS_PT_smoke_openvdb(PhysicButtonsPanel, Panel):
     bl_label = "OpenVDB export"
     bl_options = {'DEFAULT_CLOSED'}
@@ -333,10 +342,28 @@ class PHYSICS_PT_smoke_openvdb(PhysicButtonsPanel, Panel):
         domain = context.smoke.domain_settings
 
         layout.active = domain.use_openvdb
-        layout.prop(domain, "filepath")
-        row = layout.row(align=True)
-        row.prop(domain, "frame_start")
-        row.prop(domain, "frame_end")
+
+        row = layout.row()
+        row.template_list("DATA_UL_openvdb_caches", "", domain, "cache", domain, "active_openvdb_cache_index", rows=3)
+
+        col = row.column()
+        sub = col.row()
+        subsub = sub.column(align=True)
+        subsub.operator("object.openvdb_cache_add", icon='ZOOMIN', text="")
+        subsub.operator("object.openvdb_cache_remove", icon='ZOOMOUT', text="")
+        sub = col.row()
+        subsub = sub.column(align=True)
+        subsub.operator("object.openvdb_cache_move", icon='MOVE_UP_VEC', text="").direction = 'UP'
+        subsub.operator("object.openvdb_cache_move", icon='MOVE_DOWN_VEC', text="").direction = 'DOWN'
+
+        cache = domain.active_openvdb_cache
+
+        if cache:
+            layout.prop(cache, "filepath")
+            row = layout.row(align=True)
+            row.prop(cache, "frame_start")
+            row.prop(cache, "frame_end")
+
         layout.operator("object.smoke_vdb_export")
         layout.operator("object.smoke_vdb_transform_update")
 
diff --git a/source/blender/blenkernel/BKE_smoke.h b/source/blender/blenkernel/BKE_smoke.h
index 1955e0c..b9bde18 100644
--- a/source/blender/blenkernel/BKE_smoke.h
+++ b/source/blender/blenkernel/BKE_smoke.h
@@ -65,4 +65,6 @@ void smokeModifier_OpenVDB_update_transform(struct SmokeModifierData *smd,
 
 void smokeModifier_OpenVDB_import(struct SmokeModifierData *smd, struct Scene *scene, struct Object *ob);
 
+struct OpenVDBCache *BKE_openvdb_get_current_cache(struct SmokeDomainSettings *sds);
+
 #endif /* __BKE_SMOKE_H__ */
diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c
index b4f8a06..ae92d95 100644
--- a/source/blender/blenkernel/intern/smoke.c
+++ b/source/blender/blenkernel/intern/smoke.c
@@ -377,6 +377,8 @@ static void smokeModifier_freeDomain(SmokeModifierData *smd)
 {
 	if (smd->domain)
 	{
+		OpenVDBCache *cache = smd->domain->vdb_caches.first;
+
 		if (smd->domain->shadow)
 			MEM_freeN(smd->domain->shadow);
 		smd->domain->shadow = NULL;
@@ -399,6 +401,10 @@ static void smokeModifier_freeDomain(SmokeModifierData *smd)
 
 		MEM_freeN(smd->domain);
 		smd->domain = NULL;
+
+		for (; cache; cache = cache->next) {
+			MEM_freeN(cache);
+		}
 	}
 }
 
@@ -567,8 +573,6 @@ void smokeModifier_createType(struct SmokeModifierData *smd)
 			smd->domain->effector_weights = BKE_add_effector_weights(NULL);
 
 			smd->domain->use_openvdb = false;
-			smd->domain->startframe = 1;
-			smd->domain->endframe = 250;
 		}
 		else if (smd->type & MOD_SMOKE_TYPE_FLOW)
 		{
@@ -3090,10 +3094,9 @@ static void set_fluid_description(SmokeDomainSettings *sds, const FluidDomainDes
 	copy_v3_v3(sds->active_color, descr.active_color);
 }
 
-static void cache_filename(char *string, const char *path, const char *relbase, int frame)
+static void cache_filename(char *string, const char *path, const char *fname, const char *relbase, int frame)
 {
 	char cachepath[FILE_MAX];
-	const char *fname = "smoke_export_";
 
 	BLI_join_dirfile(cachepath, sizeof(cachepath), path, fname);
 
@@ -3111,6 +3114,7 @@ void smokeModifier_OpenVDB_export(SmokeModifierData *smd, Scene *scene, Object *
                                   update_cb update, void *update_cb_data)
 {
 	SmokeDomainSettings *sds = smd->domain;
+	OpenVDBCache *cache;
 	FluidDomainDescr descr;
 	int orig_frame, fr, cancel = 0;
 	float progress;
@@ -3119,18 +3123,20 @@ void smokeModifier_OpenVDB_export(SmokeModifierData *smd, Scene *scene, Object *
 
 	orig_frame = scene->r.cfra;
 
-	for (fr = sds->startframe; fr <= sds->endframe; fr++) {
+	cache = BKE_openvdb_get_current_cache(sds);
+
+	for (fr = cache->startframe; fr <= cache->endframe; fr++) {
 		/* smd->time is overwritten with scene->r.cfra in smokeModifier_process,
 		 * so we can't use it here... */
 		scene->r.cfra = fr;
 
-		cache_filename(filename, sds->path, relbase, fr);
+		cache_filename(filename, cache->path, cache->name, relbase, fr);
 
 		smokeModifier_process(smd, scene, ob, dm, false);
 		descr = get_fluid_description(sds);
 		OpenVDB_export_fluid(sds->fluid, sds->wt, descr, filename, sds->shadow);
 
-		progress = (fr - sds->startframe) / (float)sds->endframe;
+		progress = (fr - cache->startframe) / (float)cache->endframe;
 
 		update(update_cb_data, progress, &cancel);
 
@@ -3148,17 +3154,22 @@ void smokeModifier_OpenVDB_export(SmokeModifierData *smd, Scene *scene, Object *
 void smokeModifier_OpenVDB_import(SmokeModifierData *smd, Scene *scene, Object *ob)
 {
 	SmokeDomainSettings *sds = smd->domain;
+	OpenVDBCache *cache;
 	FluidDomainDescr descr;
-	int startframe = sds->startframe, endframe = sds->endframe;
+	int startframe, endframe;
 	char filename[FILE_MAX];
 	const char *relbase = modifier_path_relbase(ob);
 	int ret = OPENVDB_NO_ERROR;
 
+	cache = BKE_openvdb_get_current_cache(sds);
+	startframe = cache->startframe;
+	endframe = cache->endframe;
+
 	if (CFRA < startframe && CFRA > endframe) {
 		return;
 	}
 
-	cache_filename(filename, sds->path, relbase, CFRA);
+	cache_filename(filename, cache->path, cache->name, relbase, CFRA);
 
 	ret = OpenVDB_import_fluid(sds->fluid, sds->wt, &descr, filename, sds->shadow);
 
@@ -3187,6 +3198,7 @@ void smokeModifier_OpenVDB_update_transform(SmokeModifierData *smd,
                                             void *update_cb_data)
 {
 	SmokeDomainSettings *sds = smd->domain;
+	OpenVDBCache *cache;
 	int orig_frame, fr, cancel = 0;
 	float progress;
 	const char *relbase = modifier_path_relbase(ob);
@@ -3194,17 +3206,19 @@ void smokeModifier_OpenVDB_update_transform(SmokeModifierData *smd,
 
 	orig_frame = scene->r.cfra;
 
-	for (fr = sds->startframe; fr <= sds->endframe; fr++) {
-		FluidDomainDescr descr = get_fluid_description(sds, ob);
+	cache = BKE_openvdb_get_current_cache(sds);
+
+	for (fr = cache->startframe; fr <= cache->endframe; fr++) {
+		FluidDomainDescr descr = get_fluid_description(sds);
 		/* smd->time is overwritten with scene->r.cfra in smokeModifier_process,
 		 * so we can't use it here... */
 		scene->r.cfra = fr;
 
-		cache_filename(filename, sds->path, relbase, fr);
+		cache_filename(filename, cache->path, cache->name, relbase, fr);
 
 		OpenVDB_update_fluid_transform(filename, descr);
 
-		progress = (fr - sds->startframe) / (float)sds->endframe;
+		progress = (fr - cache->startframe) / (float)cache->endframe;
 
 		update(update_cb_data, progress, &cancel);
 
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index c736e54..ef75501 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -4801,6 +4801,8 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
 					BLI_listbase_clear(&smd->domain->ptcaches[1]);
 					smd->domain->point_cache[1] = NULL;
 				}
+
+				link_list(fd, &smd->domain->vdb_caches);
 			}
 			else if (smd->type == MOD_SMOKE_TYPE_FLOW) {
 				smd->domain = NULL;
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 285c50a..36a0fdd 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -1524,6 +1524,7 @@ static void write_modifiers(WriteData *wd, ListBase *modbase)
 		}
 		else if (md->type==eModifierType_Smoke) {
 			SmokeModifierData *smd = (SmokeModifierData*) md;
+			OpenVDBCache *cache;
 			
 			if (smd->type & MOD_SMOKE_TYPE_DOMAIN) {
 				if (smd->domain) {
@@ -1546,6 +1547,12 @@ static void write_modifiers(WriteData *wd, ListBase *modbase)
 					
 					writestruct(wd, DATA, "EffectorWeights", 1, smd->domain->effector_weights);
 				}
+
+				cache = smd->domain->vdb_caches.first;
+				for (; cache; cache = cache->next) {
+					writestruct(wd, DATA, "OpenVDBCache", 1, cache);
+				}
+
 			}
 			else if (smd->type & MOD_SMOKE_TYPE_FLOW)
 				writestruct(wd, DATA, "SmokeFlowSettings", 1, smd->flow);
diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h
index dda38f0..d58e9b3 100644
--- a/source/blender/editors/object/object_intern.h
+++ b/source/blender/editors/object/object_intern.h
@@ -186,6 +186,9 @@ void OBJECT_OT_skin_armature_create(struct wmOperatorType *ot);
 void OBJECT_OT_laplaciandeform_bind(struct wmOperatorType *ot);
 void OBJECT_OT_smoke_vdb_export(struct wmOperatorType *ot);
 void OBJECT_OT_smoke_vdb_transform_update(struct wmOperatorType *ot);
+void OBJECT_OT_openvdb_cache_add(struct wmOperatorType *ot);
+void OBJECT_OT_openvdb_cache_remove(struct wmOperatorType *ot);
+void OBJECT_OT_openvdb_cache_move(struct wmOperatorType *ot);
 
 /* object_constraint.c */
 void OBJECT_OT_constraint_add(struct wmOperatorType *ot);
di

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list