[Bf-blender-cvs] [5e82b83] openvdb: Cycles: add OpenVDBManager::delete_sampler convenience function.

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


Commit: 5e82b837d96f371bec77dc168e188561fb671807
Author: Kévin Dietrich
Date:   Mon May 18 21:43:55 2015 +0200
Branches: openvdb
https://developer.blender.org/rB5e82b837d96f371bec77dc168e188561fb671807

Cycles: add OpenVDBManager::delete_sampler convenience function.

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

M	intern/cycles/render/openvdb.cpp
M	intern/cycles/render/openvdb.h

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

diff --git a/intern/cycles/render/openvdb.cpp b/intern/cycles/render/openvdb.cpp
index f7eb2b2..3150c03f 100644
--- a/intern/cycles/render/openvdb.cpp
+++ b/intern/cycles/render/openvdb.cpp
@@ -55,6 +55,30 @@ static inline void catch_exceptions()
 	}
 }
 
+void OpenVDBManager::delete_sampler(int grid_type, int sampling, size_t slot)
+{
+	if(grid_type == NODE_VDB_FLOAT) {
+		if(sampling == OPENVDB_SAMPLE_POINT) {
+			delete float_samplers_p[slot];
+			float_samplers_p[slot] = NULL;
+		}
+		else {
+			delete float_samplers_b[slot];
+			float_samplers_b[slot] = NULL;
+		}
+	}
+	else {
+		if(sampling == OPENVDB_SAMPLE_POINT) {
+			delete vec3s_samplers_p[slot];
+			vec3s_samplers_p[slot] = NULL;
+		}
+		else {
+			delete vec3s_samplers_b[slot];
+			vec3s_samplers_b[slot] = NULL;
+		}
+	}
+}
+
 int OpenVDBManager::find_existing_slot(const string &filename, const string &name, int sampling, int grid_type)
 {
 	for(size_t i = 0; i < current_grids.size(); ++i) {
@@ -64,30 +88,11 @@ int OpenVDBManager::find_existing_slot(const string &filename, const string &nam
 			if(grid.sampling == sampling) {
 				return grid.slot;
 			}
-			/* sampling was changed, remove the sampler */
 			else {
-				if(grid_type == NODE_VDB_FLOAT) {
-					if(grid.sampling == OPENVDB_SAMPLE_POINT) {
-						delete float_samplers_p[grid.slot];
-						float_samplers_p[grid.slot] = NULL;
-					}
-					else {
-						delete float_samplers_b[grid.slot];
-						float_samplers_b[grid.slot] = NULL;
-					}
-				}
-				else {
-					if(grid.sampling == OPENVDB_SAMPLE_POINT) {
-						delete vec3s_samplers_p[grid.slot];
-						vec3s_samplers_p[grid.slot] = NULL;
-					}
-					else {
-						delete vec3s_samplers_b[grid.slot];
-						vec3s_samplers_b[grid.slot] = NULL;
-					}
-				}
+				/* sampling was changed, remove the sampler */
+				delete_sampler(grid_type, grid.sampling, grid.slot);
 
-				/* remove grid description too */
+				/* remove the grid description too */
 				std::swap(current_grids[i], current_grids.back());
 				current_grids.pop_back();
 				break;
@@ -278,6 +283,13 @@ void OpenVDBManager::device_free(Device *device, DeviceScene *dscene)
 	(void)dscene;
 }
 
+void OpenVDBManager::delete_sampler(int grid_type, int sampling, size_t slot)
+{
+	(void)grid_type;
+	(void)sampling;
+	(void)slot;
+}
+
 #endif
 
 CCL_NAMESPACE_END
diff --git a/intern/cycles/render/openvdb.h b/intern/cycles/render/openvdb.h
index 41dd340..07c1a0a 100644
--- a/intern/cycles/render/openvdb.h
+++ b/intern/cycles/render/openvdb.h
@@ -42,6 +42,7 @@ public:
 
 	int add_volume(const string &filename, const string &name, int sampling, int grid_type);
 	int find_existing_slot(const string &filename, const string &name, int sampling, int grid_type);
+	void delete_sampler(int grid_type, int sampling, size_t slot);
 
 	void device_update(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress);
 	void device_free(Device *device, DeviceScene *dscene);




More information about the Bf-blender-cvs mailing list