Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKévin Dietrich <kevin.dietrich@mailoo.org>2018-01-29 20:37:35 +0300
committerKévin Dietrich <kevin.dietrich@mailoo.org>2018-02-24 15:37:08 +0300
commit6d8a4c10b65c45b2bcc2eca7779cc541af0562fb (patch)
treeed38f480124b6c90b2663bb6c16fff14ccef8068 /intern/openvdb
parent0aec2dcd3ae0ed382ffe7b3311a4e30fc88398e4 (diff)
OpenVDB : use underscores instead of spaces in grid names.
Some other software cannot handle grid names with spaces in them. We still check for names with spaces so as to not break old files. This fixes T53802.
Diffstat (limited to 'intern/openvdb')
-rw-r--r--intern/openvdb/intern/openvdb_dense_convert.cc15
-rw-r--r--intern/openvdb/intern/openvdb_dense_convert.h20
2 files changed, 30 insertions, 5 deletions
diff --git a/intern/openvdb/intern/openvdb_dense_convert.cc b/intern/openvdb/intern/openvdb_dense_convert.cc
index ef52408bd93..10d5fb6402a 100644
--- a/intern/openvdb/intern/openvdb_dense_convert.cc
+++ b/intern/openvdb/intern/openvdb_dense_convert.cc
@@ -165,4 +165,19 @@ void OpenVDB_import_grid_vector(
}
}
+openvdb::Name do_name_versionning(const openvdb::Name &name)
+{
+ openvdb::Name temp_name = name;
+
+ if (temp_name.find("_low", temp_name.size() - 4, 4) == temp_name.size() - 4) {
+ return temp_name.replace(temp_name.size() - 4, 4, " low");
+ }
+
+ if (temp_name.find("_old", temp_name.size() - 4, 4) == temp_name.size() - 4) {
+ return temp_name.replace(temp_name.size() - 4, 4, " old");
+ }
+
+ return temp_name;
+}
+
} /* namespace internal */
diff --git a/intern/openvdb/intern/openvdb_dense_convert.h b/intern/openvdb/intern/openvdb_dense_convert.h
index 284fd1ceeae..7882cafa06e 100644
--- a/intern/openvdb/intern/openvdb_dense_convert.h
+++ b/intern/openvdb/intern/openvdb_dense_convert.h
@@ -40,6 +40,10 @@
namespace internal {
+/* Verify that the name does not correspond to the old format, in which case we
+ * need to replace the '_low' ending with ' low'. See T53802. */
+openvdb::Name do_name_versionning(const openvdb::Name &name);
+
openvdb::Mat4R convertMatrix(const float mat[4][4]);
template <typename GridType, typename T>
@@ -87,13 +91,19 @@ void OpenVDB_import_grid(
{
using namespace openvdb;
- if (!reader->hasGrid(name)) {
- std::fprintf(stderr, "OpenVDB grid %s not found in file!\n", name.c_str());
- memset(*data, 0, sizeof(T) * res[0] * res[1] * res[2]);
- return;
+ openvdb::Name temp_name = name;
+
+ if (!reader->hasGrid(temp_name)) {
+ temp_name = do_name_versionning(temp_name);
+
+ if (!reader->hasGrid(temp_name)) {
+ std::fprintf(stderr, "OpenVDB grid %s not found in file!\n", temp_name.c_str());
+ memset(*data, 0, sizeof(T) * res[0] * res[1] * res[2]);
+ return;
+ }
}
- typename GridType::Ptr grid = gridPtrCast<GridType>(reader->getGrid(name));
+ typename GridType::Ptr grid = gridPtrCast<GridType>(reader->getGrid(temp_name));
typename GridType::ConstAccessor acc = grid->getConstAccessor();
math::Coord xyz;