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@stuvel.eu>2018-01-16 17:05:31 +0300
committerSybren A. Stüvel <sybren@stuvel.eu>2018-01-16 18:03:21 +0300
commit6db0fd65abc6e6d0fb75f35771eee5ca8f113147 (patch)
tree27064d6ad3ca4acc8a8ede05bbde2e63b1b38cde /source/blender/alembic
parent0bdb1eab82f6582a2df1f55f19a03653846104a0 (diff)
T53711: Alembic don´t import vertex colors correctly
An index stored in Alembic wasn't used. Often this index is a no-op (i.e. index[n] = n), in which case the result was fine. However, when it isn't, it caused issues.
Diffstat (limited to 'source/blender/alembic')
-rw-r--r--source/blender/alembic/intern/abc_customdata.cc17
1 files changed, 15 insertions, 2 deletions
diff --git a/source/blender/alembic/intern/abc_customdata.cc b/source/blender/alembic/intern/abc_customdata.cc
index 8b526616053..ddc83a6aa60 100644
--- a/source/blender/alembic/intern/abc_customdata.cc
+++ b/source/blender/alembic/intern/abc_customdata.cc
@@ -285,6 +285,7 @@ static void read_custom_data_mcols(const std::string & iobject_full_name,
{
C3fArraySamplePtr c3f_ptr = C3fArraySamplePtr();
C4fArraySamplePtr c4f_ptr = C4fArraySamplePtr();
+ Alembic::Abc::UInt32ArraySamplePtr indices(NULL);
bool use_c3f_ptr;
bool is_facevarying;
@@ -299,6 +300,7 @@ static void read_custom_data_mcols(const std::string & iobject_full_name,
config.totloop == sample.getIndices()->size();
c3f_ptr = sample.getVals();
+ indices = sample.getIndices();
use_c3f_ptr = true;
}
else if (IC4fGeomParam::matches(prop_header)) {
@@ -311,6 +313,7 @@ static void read_custom_data_mcols(const std::string & iobject_full_name,
config.totloop == sample.getIndices()->size();
c4f_ptr = sample.getVals();
+ indices = sample.getIndices();
use_c3f_ptr = false;
}
else {
@@ -331,6 +334,12 @@ static void read_custom_data_mcols(const std::string & iobject_full_name,
size_t color_index;
bool bounds_warning_given = false;
+ /* The colors can go through two layers of indexing. Often the 'indices'
+ * array doesn't do anything (i.e. indices[n] = n), but when it does, it's
+ * important. Blender 2.79 writes indices incorrectly (see T53745), which
+ * is why we have to check for indices->size() > 0 */
+ bool use_dual_indexing = is_facevarying && indices->size() > 0;
+
for (int i = 0; i < config.totpoly; ++i) {
MPoly *poly = &mpolys[i];
MCol *cface = &cfaces[poly->loopstart + poly->totloop];
@@ -340,9 +349,13 @@ static void read_custom_data_mcols(const std::string & iobject_full_name,
--cface;
--mloop;
+ color_index = is_facevarying ? face_index : mloop->v;
+ if (use_dual_indexing) {
+ color_index = (*indices)[color_index];
+ }
if (use_c3f_ptr) {
color_index = mcols_out_of_bounds_check(
- is_facevarying ? face_index : mloop->v,
+ color_index,
c3f_ptr->size(),
iobject_full_name, prop_header,
bounds_warning_given);
@@ -355,7 +368,7 @@ static void read_custom_data_mcols(const std::string & iobject_full_name,
}
else {
color_index = mcols_out_of_bounds_check(
- is_facevarying ? face_index : mloop->v,
+ color_index,
c4f_ptr->size(),
iobject_full_name, prop_header,
bounds_warning_given);