[Bf-blender-cvs] [235932b] openvdb: Fix various cleanup issues and inconsistencies.

Lukas Tönne noreply at git.blender.org
Sun Nov 13 21:44:53 CET 2016


Commit: 235932ba2e2d33b15b436b40f48106451d34eb74
Author: Lukas Tönne
Date:   Sun Nov 13 15:14:16 2016 +0100
Branches: openvdb
https://developer.blender.org/rB235932ba2e2d33b15b436b40f48106451d34eb74

Fix various cleanup issues and inconsistencies.

All volumes are held in the scene volumes list now, so VolumeManager doesn't need
to free them explicitly.

The ImageManager reference in VoxelAttribute is an artifact from smoke rendering,
this should be phased out eventually and can be assumed to be NULL for Volumes.

Make sure the VolumeManager cleans up the device memory properly, in particular
the ray intersector instances must be freed.

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

M	intern/cycles/render/attribute.cpp
M	intern/cycles/render/scene.cpp
M	intern/cycles/render/volume.cpp

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

diff --git a/intern/cycles/render/attribute.cpp b/intern/cycles/render/attribute.cpp
index 97f9868..12fa58a 100644
--- a/intern/cycles/render/attribute.cpp
+++ b/intern/cycles/render/attribute.cpp
@@ -33,7 +33,8 @@ Attribute::~Attribute()
 		VoxelAttribute *voxel_data = data_voxel();
 
 		if(voxel_data && voxel_data->slot != -1) {
-			voxel_data->manager->remove_image(voxel_data->slot);
+			if (voxel_data->manager)
+				voxel_data->manager->remove_image(voxel_data->slot);
 		}
 	}
 }
diff --git a/intern/cycles/render/scene.cpp b/intern/cycles/render/scene.cpp
index cb057be..bfe7fd8 100644
--- a/intern/cycles/render/scene.cpp
+++ b/intern/cycles/render/scene.cpp
@@ -85,12 +85,15 @@ void Scene::free_memory(bool final)
 		delete l;
 	foreach(ParticleSystem *p, particle_systems)
 		delete p;
+	foreach(Volume *v, volumes)
+		delete v;
 
 	shaders.clear();
 	meshes.clear();
 	objects.clear();
 	lights.clear();
 	particle_systems.clear();
+	volumes.clear();
 
 	if(device) {
 		camera->device_free(device, &dscene, this);
diff --git a/intern/cycles/render/volume.cpp b/intern/cycles/render/volume.cpp
index 47c9e91..c8b4fe6 100644
--- a/intern/cycles/render/volume.cpp
+++ b/intern/cycles/render/volume.cpp
@@ -50,15 +50,6 @@ VolumeManager::VolumeManager()
 
 VolumeManager::~VolumeManager()
 {
-	for (size_t i = 0; i < volumes.size(); ++i) {
-		Volume *volume = volumes[i];
-
-#ifdef WITH_OPENVDB
-		volume->scalar_grids.clear();
-		volume->vector_grids.clear();
-#endif
-	}
-
 	current_grids.clear();
 }
 
@@ -510,8 +501,20 @@ void VolumeManager::device_update(Device *device, DeviceScene *dscene, Scene *sc
 	need_update = false;
 }
 
-void VolumeManager::device_free(Device */*device*/, DeviceScene */*dscene*/)
+void VolumeManager::device_free(Device *device, DeviceScene *dscene)
 {
+#ifdef WITH_OPENVDB
+	OpenVDBGlobals *vdb = device->vdb_memory();
+	for (size_t i = 0; i < vdb->scalar_main_isectors.size(); ++i) {
+		delete vdb->scalar_main_isectors[i];
+	}
+	for (size_t i = 0; i < vdb->vector_main_isectors.size(); ++i) {
+		delete vdb->vector_main_isectors[i];
+	}
+#endif
+	
+	device->tex_free(dscene->vol_shader);
+	dscene->vol_shader.clear();
 }
 
 void VolumeManager::tag_update(Scene */*scene*/)




More information about the Bf-blender-cvs mailing list