[Bf-blender-cvs] [abaa861] openvdb: Move openvdb utilities into their own files/directory.
Kévin Dietrich
noreply at git.blender.org
Fri Jun 5 14:06:10 CEST 2015
Commit: abaa8617d7ca2a95e0ad5f468641a2365fb785b1
Author: Kévin Dietrich
Date: Mon May 11 08:19:21 2015 +0200
Branches: openvdb
https://developer.blender.org/rBabaa8617d7ca2a95e0ad5f468641a2365fb785b1
Move openvdb utilities into their own files/directory.
===================================================================
M build_files/cmake/macros.cmake
M intern/smoke/CMakeLists.txt
M intern/smoke/extern/smoke_API.h
M intern/smoke/intern/FLUID_3D.h
D intern/smoke/intern/openvdb_convert.cpp
M intern/smoke/intern/smoke_API.cpp
M source/blender/CMakeLists.txt
M source/blender/blenkernel/CMakeLists.txt
M source/blender/blenkernel/intern/smoke.c
A source/blender/openvdb/CMakeLists.txt
A source/blender/openvdb/intern/openvdb_smoke_export.cpp
A source/blender/openvdb/openvdb_capi.cpp
A source/blender/openvdb/openvdb_capi.h
A source/blender/openvdb/openvdb_intern.h
A source/blender/openvdb/openvdb_util.cpp
A source/blender/openvdb/openvdb_util.h
===================================================================
diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake
index bd353c2..f145688 100644
--- a/build_files/cmake/macros.cmake
+++ b/build_files/cmake/macros.cmake
@@ -661,6 +661,10 @@ macro(SETUP_BLENDER_SORTED_LIBS)
list_insert_after(BLENDER_SORTED_LIBS "ge_logic_ngnetwork" "extern_bullet")
endif()
+ if(WITH_OPENVDB)
+ list(APPEND BLENDER_SORTED_LIBS bf_openvdb)
+ endif()
+
foreach(SORTLIB ${BLENDER_SORTED_LIBS})
set(REMLIB ${SORTLIB})
foreach(SEARCHLIB ${BLENDER_LINK_LIBS})
diff --git a/intern/smoke/CMakeLists.txt b/intern/smoke/CMakeLists.txt
index e4f2038..8cda0fd 100644
--- a/intern/smoke/CMakeLists.txt
+++ b/intern/smoke/CMakeLists.txt
@@ -31,8 +31,6 @@ set(INC
set(INC_SYS
${BULLET_INCLUDE_DIRS}
${PNG_INCLUDE_DIRS}
- ${OPENEXR_INCLUDE_DIRS}
- ${OPENVDB_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIRS}
)
@@ -56,7 +54,6 @@ set(SRC
intern/LU_HELPER.h
intern/MERSENNETWISTER.h
intern/OBSTACLE.h
- intern/openvdb_convert.cpp
intern/spectrum.h
intern/SPHERE.h
intern/VEC3.h
diff --git a/intern/smoke/extern/smoke_API.h b/intern/smoke/extern/smoke_API.h
index 61f7dba..08dbded 100644
--- a/intern/smoke/extern/smoke_API.h
+++ b/intern/smoke/extern/smoke_API.h
@@ -113,40 +113,6 @@ void smoke_ensure_heat(struct FLUID_3D *fluid);
void smoke_ensure_fire(struct FLUID_3D *fluid, struct WTURBULENCE *wt);
void smoke_ensure_colors(struct FLUID_3D *fluid, struct WTURBULENCE *wt, float init_r, float init_g, float init_b);
-/* This duplicates a few properties from SmokeDomainSettings,
- * but it's more convenient/readable to pass a struct than having a huge set of
- * parameters to a function
- */
-typedef struct FluidDomainDescr {
- float obmat[4][4];
- float fluidmat[4][4];
- float fluidmathigh[4][4];
- int shift[3];
- float obj_shift_f[3];
- int fluid_fields;
- float active_color[3];
- int active_fields;
-} FluidDomainDescr;
-
-
-enum {
- OPENVDB_NO_ERROR = 0,
- OPENVDB_ARITHM_ERROR = 1,
- OPENVDB_ILLEGAL_ERROR = 2,
- OPENVDB_INDEX_ERROR = 3,
- OPENVDB_IO_ERROR = 4,
- OPENVDB_KEY_ERROR = 5,
- OPENVDB_LOOKUP_ERROR = 6,
- OPENVDB_IMPL_ERROR = 7,
- OPENVDB_REF_ERROR = 8,
- OPENVDB_TYPE_ERROR = 9,
- OPENVDB_VALUE_ERROR = 10,
- OPENVDB_UNKNOWN_ERROR = 11,
-};
-
-void smoke_vdb_export(struct FLUID_3D *fluid, struct WTURBULENCE *wt, FluidDomainDescr descr, const char *filename, float *shadow);
-int smoke_vdb_import(struct FLUID_3D *fluid, struct WTURBULENCE *wt, FluidDomainDescr *descr, const char *filename, float *shadow);
-
#ifdef __cplusplus
}
#endif
diff --git a/intern/smoke/intern/FLUID_3D.h b/intern/smoke/intern/FLUID_3D.h
index 9b3e751..cd2147b 100644
--- a/intern/smoke/intern/FLUID_3D.h
+++ b/intern/smoke/intern/FLUID_3D.h
@@ -42,7 +42,6 @@
using namespace std;
using namespace BasicVector;
struct WTURBULENCE;
-struct FluidDomainDescr;
struct FLUID_3D
{
@@ -262,10 +261,4 @@ struct FLUID_3D
// static void writeProjectedIntern(const float *field, Vec3Int res, int dir1, int dir2, string prefix, int picCnt, float scale=1.);
};
-/**
- * the following functions are defined in openvdb_convert.cpp
- */
-void OpenVDB_export_fluid(FLUID_3D *fluid, WTURBULENCE *wt, FluidDomainDescr descr, const char *filename, float *shadow);
-void OpenVDB_import_fluid(FLUID_3D *fluid, WTURBULENCE *wt, FluidDomainDescr *descr, const char *filename, float *shadow);
-
#endif
diff --git a/intern/smoke/intern/smoke_API.cpp b/intern/smoke/intern/smoke_API.cpp
index 1670adc..d79aaf7 100644
--- a/intern/smoke/intern/smoke_API.cpp
+++ b/intern/smoke/intern/smoke_API.cpp
@@ -506,82 +506,3 @@ extern "C" void smoke_ensure_colors(FLUID_3D *fluid, WTURBULENCE *wt, float init
wt->initColors(init_r, init_g, init_b);
}
}
-
-#include <openvdb/Exceptions.h>
-
-static void catch_exception(int &ret)
-{
- try {
- throw;
- }
- catch (const openvdb::ArithmeticError &e) {
- std::cerr << e.what() << std::endl;
- ret = OPENVDB_ARITHM_ERROR;
- }
- catch (const openvdb::IllegalValueException &e) {
- std::cerr << e.what() << std::endl;
- ret = OPENVDB_ILLEGAL_ERROR;
- }
- catch (const openvdb::IndexError &e) {
- std::cerr << e.what() << std::endl;
- ret = OPENVDB_INDEX_ERROR;
- }
- catch (const openvdb::IoError &e) {
- std::cerr << e.what() << std::endl;
- ret = OPENVDB_IO_ERROR;
- }
- catch (const openvdb::KeyError &e) {
- std::cerr << e.what() << std::endl;
- ret = OPENVDB_KEY_ERROR;
- }
- catch (const openvdb::LookupError &e) {
- std::cerr << e.what() << std::endl;
- ret = OPENVDB_LOOKUP_ERROR;
- }
- catch (const openvdb::NotImplementedError &e) {
- std::cerr << e.what() << std::endl;
- ret = OPENVDB_IMPL_ERROR;
- }
- catch (const openvdb::ReferenceError &e) {
- std::cerr << e.what() << std::endl;
- ret = OPENVDB_REF_ERROR;
- }
- catch (const openvdb::TypeError &e) {
- std::cerr << e.what() << std::endl;
- ret = OPENVDB_TYPE_ERROR;
- }
- catch (const openvdb::ValueError &e) {
- std::cerr << e.what() << std::endl;
- ret = OPENVDB_VALUE_ERROR;
- }
- catch (...) {
- std::cerr << "Unknown error in OpenVDB library..." << std::endl;
- ret = OPENVDB_UNKNOWN_ERROR;
- }
-}
-
-extern "C" void smoke_vdb_export(FLUID_3D *fluid, WTURBULENCE *wt, FluidDomainDescr descr, const char *filename, float *shadow)
-{
- int ret = OPENVDB_NO_ERROR;
-
- try {
- OpenVDB_export_fluid(fluid, wt, descr, filename, shadow);
- }
- catch (...) {
- catch_exception(ret);
- }
-}
-
-extern "C" int smoke_vdb_import(FLUID_3D *fluid, WTURBULENCE *wt, FluidDomainDescr *descr, const char *filename, float *shadow)
-{
- int ret = OPENVDB_NO_ERROR;
-
- try {
- OpenVDB_import_fluid(fluid, wt, descr, filename, shadow);
- }
- catch (...) {
- catch_exception(ret);
- }
-
- return ret;
-}
diff --git a/source/blender/CMakeLists.txt b/source/blender/CMakeLists.txt
index d87d5df..810d06c 100644
--- a/source/blender/CMakeLists.txt
+++ b/source/blender/CMakeLists.txt
@@ -151,3 +151,6 @@ if(WITH_FREESTYLE)
add_subdirectory(freestyle)
endif()
+if(WITH_OPENVDB)
+ add_subdirectory(openvdb)
+endif()
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index 67c8f0f..51ee86b 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -36,6 +36,7 @@ set(INC
../bmesh
../modifiers
../nodes
+ ../openvdb
../physics
../render/extern/include
../../../intern/ghost
diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c
index 8ad86f5..b38b1ba 100644
--- a/source/blender/blenkernel/intern/smoke.c
+++ b/source/blender/blenkernel/intern/smoke.c
@@ -90,6 +90,7 @@
/* #define USE_SMOKE_COLLISION_DM */
#include "smoke_API.h"
+#include "openvdb_capi.h"
#ifdef WITH_SMOKE
@@ -3126,7 +3127,7 @@ void smokeModifier_OpenVDB_export(SmokeModifierData *smd, Scene *scene, Object *
cache_filename(filename, sds->path, relbase, fr);
smokeModifier_process(smd, scene, ob, dm, false);
- smoke_vdb_export(sds->fluid, sds->wt, descr, filename, sds->shadow);
+ OpenVDB_export_fluid(sds->fluid, sds->wt, descr, filename, sds->shadow);
progress = (fr - sds->startframe) / (float)sds->endframe;
@@ -3158,7 +3159,7 @@ void smokeModifier_OpenVDB_import(SmokeModifierData *smd, Scene *scene, Object *
cache_filename(filename, sds->path, relbase, curframe);
- ret = smoke_vdb_import(sds->fluid, sds->wt, &descr, filename, sds->shadow);
+ ret = OpenVDB_import_fluid(sds->fluid, sds->wt, &descr, filename, sds->shadow);
if (ret == OPENVDB_IO_ERROR) {
/* TODO(kevin): report error "OpenVDB import error, see console for details" */
diff --git a/source/blender/openvdb/CMakeLists.txt b/source/blender/openvdb/CMakeLists.txt
new file mode 100644
index 0000000..eb50baa
--- /dev/null
+++ b/source/blender/openvdb/CMakeLists.txt
@@ -0,0 +1,62 @@
+# ***** BEGIN GPL LICENSE BLOCK *****
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# The Original Code is Copyright (C) 2015, Blender Foundation
+# All rights reserved.
+#
+# The Original Code is: all of this file.
+#
+# Contributor(s): Kevin Dietrich.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+set(INC
+ .
+ intern
+ ../blenkernel
+ ../blenlib
+ ../makesdna
+ ../../../intern/smoke/intern
+)
+
+set(INC_SYS
+
+)
+
+set(SRC
+ openvdb_capi.h
+)
+
+if(WITH_OPENVDB)
+ add_definitions(
+ -DWITH_OPENVDB
+ )
+
+ list(APPEND INC_SYS
+ ${OPENEXR_INCLUDE_DIRS}
+ ${OPENVDB_INCLUDE_DIRS}
+ )
+
+ list(APPEND SRC
+ intern/openvdb_smoke_export.cpp
+ openvdb_capi.cpp
+ openvdb_util.cpp
+
+ openvdb_intern.h
+ )
+endif()
+
+blender_add_lib(bf_openvdb "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/intern/smoke/intern/openvdb_convert.cpp b/source/blender/openvdb/intern/openvdb_smoke_export.cpp
similarity index 99%
rename from intern/smoke/intern/openvdb_convert.cpp
rename to source/blender/openvdb/intern/openvdb_smoke_export.cpp
index 7a7851f..2ea8326 100644
--- a/intern/smoke/intern/openvdb_convert.cpp
+++ b/source/blender/openvdb/intern/openvdb_smoke_export.cpp
@@ -29,12 +29,16 @@
#include <openvdb/tools/Dense.h>
#include <openvdb/tools/LevelSetUtil.h>
+#include "openvdb_capi.h"
+#include "openvdb_intern.h"
+
#include "FLUID_3D.h"
#include "WTURBULENCE.h"
-#include "../extern/smoke_API.h"
using namespace openvdb;
+namespace internal {
+
template <typename GridType, typename T>
static void OpenVDB_export_grid(GridPtrVec &gridVec,
const std::string &name,
@@ -323,3 +327,5 @@ void OpenVDB_import_fluid(FLUID_3D *fluid, WTURBULENC
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list