diff options
author | Lukas Tönne <lukas.toenne@gmail.com> | 2015-03-19 15:33:00 +0300 |
---|---|---|
committer | Lukas Tönne <lukas.toenne@gmail.com> | 2015-03-26 16:13:40 +0300 |
commit | b4f62f7866b9303ec28b047bb381c55505e59605 (patch) | |
tree | 977f1a0b1e111d8d77bd13cd416f6ad7b9e8d995 /source | |
parent | aeb4384d5aa5b12c52d68059e9ce8c0a93f08f0c (diff) |
Copy rgba components of MCol explicitly to the Alembic C4f type to avoid
potentially different ordering.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/pointcache/alembic/abc_customdata.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/source/blender/pointcache/alembic/abc_customdata.cpp b/source/blender/pointcache/alembic/abc_customdata.cpp index 92b09dfc564..145e19b8090 100644 --- a/source/blender/pointcache/alembic/abc_customdata.cpp +++ b/source/blender/pointcache/alembic/abc_customdata.cpp @@ -112,7 +112,16 @@ void write_sample<CD_MCOL>(CustomDataWriter *writer, OCompoundProperty &parent, { OC4fArrayProperty prop = writer->add_array_property<OC4fArrayProperty>(name, parent); - prop.set(OC4fArrayProperty::sample_type((C4f *)data, num_data)); + MCol *mcol = (MCol *)data; + + std::vector<C4f> mcol_data; + mcol_data.reserve(num_data); + for (int i = 0; i < num_data; ++i) { + mcol_data.push_back(C4f(mcol->r, mcol->g, mcol->b, mcol->a)); + + ++mcol; + } + prop.set(OC4fArrayProperty::sample_type(mcol_data)); } template <> @@ -220,7 +229,17 @@ PTCReadSampleResult read_sample<CD_MCOL>(CustomDataReader *reader, ICompoundProp if (sample->size() != num_data) return PTC_READ_SAMPLE_INVALID; - memcpy(data, sample->getData(), sizeof(C4f) * num_data); + MCol *mcol = (MCol *)data; + C4f *data_mcol = (C4f *)sample->getData(); + for (int i = 0; i < num_data; ++i) { + mcol->r = data_mcol->r; + mcol->g = data_mcol->g; + mcol->b = data_mcol->b; + mcol->a = data_mcol->a; + + ++data_mcol; + ++mcol; + } return PTC_READ_SAMPLE_EXACT; } |