[Bf-blender-cvs] [bd96249] openvdb: Apply patch in a new branch, to clean the history a bit

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


Commit: bd96249455f6f01aa447951ba7eeb3542b4c7761
Author: Kévin Dietrich
Date:   Sun May 10 15:53:34 2015 +0200
Branches: openvdb
https://developer.blender.org/rBbd96249455f6f01aa447951ba7eeb3542b4c7761

Apply patch in a new branch, to clean the history a bit

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

M	CMakeLists.txt
A	build_files/cmake/Modules/FindOpenVDB.cmake
M	build_files/cmake/macros.cmake
M	intern/cycles/CMakeLists.txt
M	intern/cycles/app/cycles_xml.cpp
M	intern/cycles/blender/blender_shader.cpp
M	intern/cycles/kernel/CMakeLists.txt
M	intern/cycles/kernel/kernel.cpp
M	intern/cycles/kernel/kernel_compat_cpu.h
M	intern/cycles/kernel/kernel_globals.h
M	intern/cycles/kernel/svm/svm.h
A	intern/cycles/kernel/svm/svm_openvdb.h
M	intern/cycles/kernel/svm/svm_types.h
M	intern/cycles/render/CMakeLists.txt
M	intern/cycles/render/nodes.cpp
M	intern/cycles/render/nodes.h
A	intern/cycles/render/openvdb.cpp
A	intern/cycles/render/openvdb.h
M	intern/cycles/render/scene.cpp
M	intern/cycles/render/scene.h
M	intern/cycles/render/svm.cpp
M	intern/cycles/render/svm.h
M	intern/cycles/util/CMakeLists.txt
A	intern/cycles/util/util_openvdb.h
M	intern/smoke/CMakeLists.txt
M	intern/smoke/extern/smoke_API.h
M	intern/smoke/intern/FLUID_3D.h
A	intern/smoke/intern/openvdb_convert.cpp
M	intern/smoke/intern/smoke_API.cpp
M	release/datafiles/locale
M	release/scripts/addons
M	release/scripts/addons_contrib
M	release/scripts/startup/bl_ui/properties_physics_smoke.py
M	release/scripts/startup/nodeitems_builtins.py
M	source/blender/blenkernel/BKE_node.h
M	source/blender/blenkernel/BKE_smoke.h
M	source/blender/blenkernel/intern/node.c
M	source/blender/blenkernel/intern/smoke.c
M	source/blender/editors/object/CMakeLists.txt
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/editors/space_node/drawnode.c
M	source/blender/makesdna/DNA_node_types.h
M	source/blender/makesdna/DNA_smoke_types.h
M	source/blender/makesrna/intern/rna_nodetree.c
M	source/blender/makesrna/intern/rna_smoke.c
M	source/blender/nodes/CMakeLists.txt
M	source/blender/nodes/NOD_shader.h
M	source/blender/nodes/NOD_static_types.h
A	source/blender/nodes/shader/nodes/node_shader_openvdb.c
M	source/blender/windowmanager/WM_api.h

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

diff --git a/CMakeLists.txt b/CMakeLists.txt
index ae2c67b..b7c41bd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -222,6 +222,7 @@ option(WITH_GAMEENGINE    "Enable Game Engine" ${_init_GAMEENGINE})
 option(WITH_PLAYER        "Build Player" OFF)
 option(WITH_OPENCOLORIO   "Enable OpenColorIO color management" ${_init_OPENCOLORIO})
 option(WITH_COMPOSITOR    "Enable the tile based nodal compositor" ON)
+option(WITH_OPENVDB       "Enable features relying on OpenVDB" ON)
 
 # GHOST Windowing Library Options
 option(WITH_GHOST_DEBUG   "Enable debugging output for the GHOST library" OFF)
@@ -1059,6 +1060,23 @@ if(UNIX AND NOT APPLE)
 		endif()
 	endif()
 
+	if(WITH_OPENVDB)
+		find_package_wrapper(OpenVDB)
+
+		set(TBB ${LIBDIR}/tbb)
+		set(TBB_LIBRARIES tbb)
+		set(TBB_LIBPATH ${TBB}/lib)
+
+		set(OPENVDB_LIBRARIES ${OPENVDB_LIBRARIES} ${BOOST_LIBRARIES} ${ZLIB_LIBRARIES} ${TBB_LIBRARIES})
+		set(OPENVDB_LIBPATH)  # TODO, remove and reference the absolute path everywhere
+		set(OPENVDB_DEFINITIONS)
+
+		if(NOT OPENVDB_FOUND)
+			set(WITH_OPENVDB OFF)
+			message(STATUS "OpenVDB not found")
+		endif()
+	endif()
+
 	if(WITH_LLVM)
         find_package_wrapper(LLVM)
 
@@ -1480,7 +1498,14 @@ elseif(WIN32)
 			set(OPENCOLORIO_LIBPATH ${LIBDIR}/opencolorio/lib)
 			set(OPENCOLORIO_DEFINITIONS)
 		endif()
-		
+
+		if(WITH_OPENVDB)
+			set(OPENVDB ${LIBDIR}/openvdb)
+			set(OPENVDB_INCLUDE_DIRS ${OPENVDB}/include)
+			set(OPENVDB_LIBRARIES openvdb ${TBB_LIBRARIES})
+			set(OPENVDB_LIBPATH ${LIBDIR}/openvdb/lib)
+			set(OPENVDB_DEFINITIONS)
+		endif()
 
 		if(WITH_MOD_CLOTH_ELTOPO)
 			set(LAPACK ${LIBDIR}/lapack)
diff --git a/build_files/cmake/Modules/FindOpenVDB.cmake b/build_files/cmake/Modules/FindOpenVDB.cmake
new file mode 100644
index 0000000..116f642
--- /dev/null
+++ b/build_files/cmake/Modules/FindOpenVDB.cmake
@@ -0,0 +1,74 @@
+# - Find OPENVDB library
+# Find the native OPENVDB includes and library
+# This module defines
+#  OPENVDB_INCLUDE_DIRS, where to find openvdb.h, Set when
+#                            OPENVDB_INCLUDE_DIR is found.
+#  OPENVDB_LIBRARIES, libraries to link against to use OPENVDB.
+#  OPENVDB_ROOT_DIR, The base directory to search for OPENVDB.
+#                        This can also be an environment variable.
+#  OPENVDB_FOUND, If false, do not try to use OPENVDB.
+#
+# also defined, but not for general use are
+#  OPENVDB_LIBRARY, where to find the OPENVDB library.
+
+#=============================================================================
+# Copyright 2015 Blender Foundation.
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+
+# If OPENVDB_ROOT_DIR was defined in the environment, use it.
+IF(NOT OPENVDB_ROOT_DIR AND NOT $ENV{OPENVDB_ROOT_DIR} STREQUAL "")
+	SET(OPENVDB_ROOT_DIR $ENV{OPENVDB_ROOT_DIR})
+ENDIF()
+
+SET(_openvdb_SEARCH_DIRS
+	${OPENVDB_ROOT_DIR}
+	/usr/local
+	/sw # Fink
+	/opt/local # DarwinPorts
+	/opt/csw # Blastwave
+	/opt/lib/openvdb
+)
+
+FIND_PATH(OPENVDB_INCLUDE_DIR
+	NAMES
+		openvdb/openvdb.h
+	HINTS
+		${_openvdb_SEARCH_DIRS}
+	PATH_SUFFIXES
+		include
+)
+
+FIND_LIBRARY(OPENVDB_LIBRARY
+	NAMES
+		openvdb
+	HINTS
+		${_openvdb_SEARCH_DIRS}
+	PATH_SUFFIXES
+		lib64 lib
+)
+
+# handle the QUIETLY and REQUIRED arguments and set OPENVDB_FOUND to TRUE if
+# all listed variables are TRUE
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(OPENVDB DEFAULT_MSG
+                                  OPENVDB_LIBRARY
+                                  OPENVDB_INCLUDE_DIR)
+
+IF(OPENVDB_FOUND)
+	SET(OPENVDB_LIBRARIES ${OPENVDB_LIBRARY})
+	SET(OPENVDB_INCLUDE_DIRS ${OPENVDB_INCLUDE_DIR})
+ENDIF(OPENVDB_FOUND)
+
+MARK_AS_ADVANCED(
+	OPENVDB_INCLUDE_DIR
+	OPENVDB_LIBRARY
+)
+
+UNSET(_openvdb_SEARCH_DIRS)
diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake
index 8b2f3f1..bd353c2 100644
--- a/build_files/cmake/macros.cmake
+++ b/build_files/cmake/macros.cmake
@@ -255,6 +255,9 @@ macro(SETUP_LIBDIRS)
 	if(WITH_OPENCOLORIO)
 		link_directories(${OPENCOLORIO_LIBPATH})
 	endif()
+	if(WITH_OPENVDB)
+		link_directories(${OPENVDB_LIBPATH})
+	endif()
 	if(WITH_IMAGE_OPENJPEG AND WITH_SYSTEM_OPENJPEG)
 		link_directories(${OPENJPEG_LIBPATH})
 	endif()
@@ -357,6 +360,9 @@ macro(setup_liblinks
 	if(WITH_OPENCOLORIO)
 		target_link_libraries(${target} ${OPENCOLORIO_LIBRARIES})
 	endif()
+	if(WITH_OPENVDB)
+		target_link_libraries(${target} ${OPENVDB_LIBRARIES})
+	endif()
 	if(WITH_CYCLES_OSL)
 		target_link_libraries(${target} ${OSL_LIBRARIES})
 	endif()
diff --git a/intern/cycles/CMakeLists.txt b/intern/cycles/CMakeLists.txt
index c4cadfe..fd21080 100644
--- a/intern/cycles/CMakeLists.txt
+++ b/intern/cycles/CMakeLists.txt
@@ -197,6 +197,7 @@ include_directories(
 	${OPENIMAGEIO_INCLUDE_DIRS}/OpenImageIO
 	${OPENEXR_INCLUDE_DIR}
 	${OPENEXR_INCLUDE_DIRS}
+	${OPENVDB_INCLUDE_DIRS}
 	${PUGIXML_INCLUDE_DIR}
 )
 
diff --git a/intern/cycles/app/cycles_xml.cpp b/intern/cycles/app/cycles_xml.cpp
index 1cfc814..b58061b 100644
--- a/intern/cycles/app/cycles_xml.cpp
+++ b/intern/cycles/app/cycles_xml.cpp
@@ -712,6 +712,13 @@ static void xml_read_shader_graph(const XMLReadState& state, Shader *shader, pug
 			xml_read_enum(&vtransform->convert_to, VectorTransformNode::convert_space_enum, node, "convert_to");
 			snode = vtransform;
 		}
+		else if(string_iequals(node.name(), "openvdb")) {
+			OpenVDBNode *vdbnode = new OpenVDBNode();
+			xml_read_string(&vdbnode->filename, node, "src");
+			vdbnode->filename = path_join(state.base, vdbnode->filename);
+
+			snode = vdbnode;
+		}
 		else if(string_iequals(node.name(), "connect")) {
 			/* connect nodes */
 			vector<string> from_tokens, to_tokens;
diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp
index d3b01fb..8cfcd38 100644
--- a/intern/cycles/blender/blender_shader.cpp
+++ b/intern/cycles/blender/blender_shader.cpp
@@ -736,6 +736,13 @@ static ShaderNode *add_node(Scene *scene,
 		uvm->from_dupli = b_uvmap_node.from_dupli();
 		node = uvm;
 	}
+	else if(b_node.is_a(&RNA_ShaderNodeOpenVDB)) {
+		BL::ShaderNodeOpenVDB b_vdb_node(b_node);
+		OpenVDBNode *vdb_node = new OpenVDBNode();
+		vdb_node->filename = b_vdb_node.filename();
+		vdb_node->sampling = b_vdb_node.sampling();
+		node = vdb_node;
+	}
 
 	if(node)
 		graph->add(node);
diff --git a/intern/cycles/kernel/CMakeLists.txt b/intern/cycles/kernel/CMakeLists.txt
index 85b2760..71264ed 100644
--- a/intern/cycles/kernel/CMakeLists.txt
+++ b/intern/cycles/kernel/CMakeLists.txt
@@ -115,6 +115,7 @@ set(SRC_SVM_HEADERS
 	svm/svm_noise.h
 	svm/svm_noisetex.h
 	svm/svm_normal.h
+	svm/svm_openvdb.h
 	svm/svm_ramp.h
 	svm/svm_sepcomb_hsv.h
 	svm/svm_sepcomb_vector.h
diff --git a/intern/cycles/kernel/kernel.cpp b/intern/cycles/kernel/kernel.cpp
index a7eaa75..7817c67 100644
--- a/intern/cycles/kernel/kernel.cpp
+++ b/intern/cycles/kernel/kernel.cpp
@@ -33,6 +33,14 @@ void kernel_const_copy(KernelGlobals *kg, const char *name, void *host, size_t s
 {
 	if(strcmp(name, "__data") == 0)
 		memcpy(&kg->__data, host, size);
+	else if(strcmp(name, "__vdb_float_samplers_p") == 0)
+		kg->vdb_float_samplers_p.insert(kg->vdb_float_samplers_p.begin() + size, (vdb_fsampler_p *)host);
+	else if(strcmp(name, "__vdb_float_samplers_b") == 0)
+		kg->vdb_float_samplers_b.insert(kg->vdb_float_samplers_b.begin() + size, (vdb_fsampler_b *)host);
+	else if(strcmp(name, "__vdb_vec3s_samplers_p") == 0)
+		kg->vdb_vec3s_samplers_p.insert(kg->vdb_vec3s_samplers_p.begin() + size, (vdb_vsampler_p *)host);
+	else if(strcmp(name, "__vdb_vec3s_samplers_b") == 0)
+		kg->vdb_vec3s_samplers_b.insert(kg->vdb_vec3s_samplers_b.begin() + size, (vdb_vsampler_b *)host);
 	else
 		assert(0);
 }
diff --git a/intern/cycles/kernel/kernel_compat_cpu.h b/intern/cycles/kernel/kernel_compat_cpu.h
index 7a5f70f..6da0021 100644
--- a/intern/cycles/kernel/kernel_compat_cpu.h
+++ b/intern/cycles/kernel/kernel_compat_cpu.h
@@ -39,6 +39,8 @@
 #include "util_simd.h"
 #include "util_half.h"
 #include "util_types.h"
+#include "util_openvdb.h"
+#include "util_vector.h"
 
 #define ccl_addr_space
 
diff --git a/intern/cycles/kernel/kernel_globals.h b/intern/cycles/kernel/kernel_globals.h
index 17fa189..f168440 100644
--- a/intern/cycles/kernel/kernel_globals.h
+++ b/intern/cycles/kernel/kernel_globals.h
@@ -38,6 +38,12 @@ typedef struct KernelGlobals {
 	texture_image_uchar4 texture_byte_images[MAX_BYTE_IMAGES];
 	texture_image_float4 texture_float_images[MAX_FLOAT_IMAGES];
 
+	/* We can't use arrays here as grid samplers don't have a default constructor */
+	vector<vdb_fsampler_p*> vdb_float_samplers_p;
+	vector<vdb_fsampler_b*> vdb_float_samplers_b;
+	vector<vdb_vsampler_p*> vdb_vec3s_samplers_p;
+	vector<vdb_vsampler_b*> vdb_vec3s_samplers_b;
+
 #define KERNEL_TEX(type, ttype, name) ttype name;
 #define KERNEL_IMAGE_TEX(type, ttype, name)
 #include "kernel_textures.h"
diff --git a/intern/cycles/kernel/svm/svm.h b/intern/cycles/kernel/svm/svm.h
index e5e25eb..9ec4c55 100644
--- a/intern/cycles/kernel/svm/svm.h
+++ b/intern/cycles/kernel/svm/svm.h
@@ -168,6 +168,7 @@ CCL_NAMESPACE_END
 #include "svm_wave.h"
 #include "svm_math.h"
 #include "svm_mix.h"
+#include "svm_openvdb.h"
 #include "svm_ramp.h"
 #include "svm_sepcomb_hsv.h"
 #include "svm_sepcomb_vector.h"
@@ -434,7 +435,10 @@ ccl_device_noinline void svm_eval_nodes(KernelGlobals *kg, ShaderData *sd, Shade
 				break;
 			case NODE_NORMAL_MAP:
 				svm_node_normal_map(kg, sd, stack, node);
-				break;	
+				break;
+			case NODE_OPENVDB:
+				svm_node_openvdb(kg, sd, stack, node);
+				break;
 			case NODE_END:
 			default:
 				return;
diff --git a/intern/cycles/kernel/svm/svm_openvdb.h b/intern/cycles/kernel/svm/svm_openvdb.h
new file mode 100644
index 0000000..74fdae0
--- /dev/null
+++ b/intern/cycles/kernel/svm/svm_openvdb.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2015 Blender Foundation
+ *
+ * Licensed unde

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list