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:
authorSybren A. Stüvel <sybren>2020-09-29 15:34:01 +0300
committerSybren A. Stüvel <sybren@blender.org>2020-09-29 17:10:16 +0300
commitbab2260b59c7bffe1e16b5e860ac36b5fdc31bf0 (patch)
tree814d0b54a1618ce2c1359ac16888e10cb90479cf /source/blender/io
parent5845c06a63a6b96f038f5a46d538b0f9737102e9 (diff)
Fix T71981: Alembic vertex interpolation can jumble mesh
Add an option to disable Alembic vertex interpolation. Bump subversion from 5 to 6. Alembic stores mesh samples at specific time keys; when a frame in Blender maps to a timecode between two samples, Blender will interpolate the mesh vertex positions. This interpolation only happens when the mesh has a constant topology, but sometimes this was not detected properly when the vertices change order, but the number of mesh elements remains the same. This would result in a mesh with jumbled up vertices (T71981). With this patch, users have the ability to disable vertex interpolation. An alternative would be to have better detection of topology changes, but that that'll cause a considerable slowdown. Maniphest Tasks: T71981 Differential Revision: https://developer.blender.org/D9041
Diffstat (limited to 'source/blender/io')
-rw-r--r--source/blender/io/alembic/intern/abc_customdata.h1
-rw-r--r--source/blender/io/alembic/intern/abc_reader_mesh.cc17
-rw-r--r--source/blender/io/alembic/intern/abc_reader_mesh.h2
-rw-r--r--source/blender/io/alembic/intern/abc_reader_points.cc9
4 files changed, 19 insertions, 10 deletions
diff --git a/source/blender/io/alembic/intern/abc_customdata.h b/source/blender/io/alembic/intern/abc_customdata.h
index e98ec271b9f..4eb515f132c 100644
--- a/source/blender/io/alembic/intern/abc_customdata.h
+++ b/source/blender/io/alembic/intern/abc_customdata.h
@@ -66,6 +66,7 @@ struct CDStreamConfig {
float weight;
float time;
+ bool use_vertex_interpolation;
Alembic::AbcGeom::index_t index;
Alembic::AbcGeom::index_t ceil_index;
diff --git a/source/blender/io/alembic/intern/abc_reader_mesh.cc b/source/blender/io/alembic/intern/abc_reader_mesh.cc
index ead908e87c2..e69c0edfec8 100644
--- a/source/blender/io/alembic/intern/abc_reader_mesh.cc
+++ b/source/blender/io/alembic/intern/abc_reader_mesh.cc
@@ -155,8 +155,8 @@ static void read_mverts(CDStreamConfig &config, const AbcMeshData &mesh_data)
MVert *mverts = config.mvert;
const P3fArraySamplePtr &positions = mesh_data.positions;
- if (config.weight != 0.0f && mesh_data.ceil_positions != NULL &&
- mesh_data.ceil_positions->size() == positions->size()) {
+ if (config.use_vertex_interpolation && config.weight != 0.0f &&
+ mesh_data.ceil_positions != NULL && mesh_data.ceil_positions->size() == positions->size()) {
read_mverts_interp(mverts, positions, mesh_data.ceil_positions, config.weight);
return;
}
@@ -457,7 +457,7 @@ static void read_mesh_sample(const std::string &iobject_full_name,
}
}
-CDStreamConfig get_config(Mesh *mesh)
+CDStreamConfig get_config(Mesh *mesh, const bool use_vertex_interpolation)
{
CDStreamConfig config;
@@ -471,6 +471,7 @@ CDStreamConfig get_config(Mesh *mesh)
config.totpoly = mesh->totpoly;
config.loopdata = &mesh->ldata;
config.add_customdata_cb = add_customdata_cb;
+ config.use_vertex_interpolation = use_vertex_interpolation;
return config;
}
@@ -646,7 +647,9 @@ Mesh *AbcMeshReader::read_mesh(Mesh *existing_mesh,
}
}
- CDStreamConfig config = get_config(new_mesh ? new_mesh : existing_mesh);
+ Mesh *mesh_to_export = new_mesh ? new_mesh : existing_mesh;
+ const bool use_vertex_interpolation = read_flag & MOD_MESHSEQ_INTERPOLATE_VERTICES;
+ CDStreamConfig config = get_config(mesh_to_export, use_vertex_interpolation);
config.time = sample_sel.getRequestedTime();
config.modifier_error_message = err_str;
@@ -936,11 +939,13 @@ Mesh *AbcSubDReader::read_mesh(Mesh *existing_mesh,
}
/* Only read point data when streaming meshes, unless we need to create new ones. */
- CDStreamConfig config = get_config(new_mesh ? new_mesh : existing_mesh);
+ Mesh *mesh_to_export = new_mesh ? new_mesh : existing_mesh;
+ const bool use_vertex_interpolation = read_flag & MOD_MESHSEQ_INTERPOLATE_VERTICES;
+ CDStreamConfig config = get_config(mesh_to_export, use_vertex_interpolation);
config.time = sample_sel.getRequestedTime();
read_subd_sample(m_iobject.getFullName(), &settings, m_schema, sample_sel, config);
- return config.mesh;
+ return mesh_to_export;
}
} // namespace blender::io::alembic
diff --git a/source/blender/io/alembic/intern/abc_reader_mesh.h b/source/blender/io/alembic/intern/abc_reader_mesh.h
index a29eeb71dff..3329b723b77 100644
--- a/source/blender/io/alembic/intern/abc_reader_mesh.h
+++ b/source/blender/io/alembic/intern/abc_reader_mesh.h
@@ -81,6 +81,6 @@ void read_mverts(MVert *mverts,
const Alembic::AbcGeom::P3fArraySamplePtr positions,
const Alembic::AbcGeom::N3fArraySamplePtr normals);
-CDStreamConfig get_config(struct Mesh *mesh);
+CDStreamConfig get_config(struct Mesh *mesh, bool use_vertex_interpolation);
} // namespace blender::io::alembic
diff --git a/source/blender/io/alembic/intern/abc_reader_points.cc b/source/blender/io/alembic/intern/abc_reader_points.cc
index f8cc6b0314a..88b5088805f 100644
--- a/source/blender/io/alembic/intern/abc_reader_points.cc
+++ b/source/blender/io/alembic/intern/abc_reader_points.cc
@@ -27,6 +27,7 @@
#include "abc_util.h"
#include "DNA_mesh_types.h"
+#include "DNA_modifier_types.h"
#include "DNA_object_types.h"
#include "BKE_customdata.h"
@@ -125,7 +126,7 @@ void read_points_sample(const IPointsSchema &schema,
struct Mesh *AbcPointsReader::read_mesh(struct Mesh *existing_mesh,
const ISampleSelector &sample_sel,
- int /*read_flag*/,
+ int read_flag,
const char **err_str)
{
IPointsSchema::Sample sample;
@@ -150,10 +151,12 @@ struct Mesh *AbcPointsReader::read_mesh(struct Mesh *existing_mesh,
new_mesh = BKE_mesh_new_nomain(positions->size(), 0, 0, 0, 0);
}
- CDStreamConfig config = get_config(new_mesh ? new_mesh : existing_mesh);
+ Mesh *mesh_to_export = new_mesh ? new_mesh : existing_mesh;
+ const bool use_vertex_interpolation = read_flag & MOD_MESHSEQ_INTERPOLATE_VERTICES;
+ CDStreamConfig config = get_config(mesh_to_export, use_vertex_interpolation);
read_points_sample(m_schema, sample_sel, config);
- return new_mesh ? new_mesh : existing_mesh;
+ return mesh_to_export;
}
} // namespace blender::io::alembic