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>2017-05-23 15:19:38 +0300
committerSybren A. Stüvel <sybren@stuvel.eu>2017-05-23 18:27:15 +0300
commitcc0cc880de5a66d72f571bec4c7d3eb1219aefc0 (patch)
tree10b259980d5c325ee867f2bf72e0b80d8b956222 /source/blender/alembic
parent96e068d3aa916bcc8152aedffafe1f8ddd7d27a1 (diff)
Alembic: reduced code duplication in read_mcols()
A big chunk of code was copied between the if and else bodies. By using a boolean to store whether the c3f_ptr or c4f_ptr should be used, the in-loop condition is kept as simple as possible.
Diffstat (limited to 'source/blender/alembic')
-rw-r--r--source/blender/alembic/intern/abc_customdata.cc36
1 files changed, 16 insertions, 20 deletions
diff --git a/source/blender/alembic/intern/abc_customdata.cc b/source/blender/alembic/intern/abc_customdata.cc
index 5fa3d10fa16..c42e5f808b5 100644
--- a/source/blender/alembic/intern/abc_customdata.cc
+++ b/source/blender/alembic/intern/abc_customdata.cc
@@ -228,38 +228,34 @@ using Alembic::AbcGeom::IC4fGeomParam;
using Alembic::AbcGeom::IV2fGeomParam;
static void read_mcols(const CDStreamConfig &config, void *data,
- const C3fArraySamplePtr &c3f_ptr, const C4fArraySamplePtr &c4f_ptr)
+ const C3fArraySamplePtr &c3f_ptr,
+ const C4fArraySamplePtr &c4f_ptr)
{
MCol *cfaces = static_cast<MCol *>(data);
MPoly *polys = config.mpoly;
MLoop *mloops = config.mloop;
- if (c3f_ptr) {
- for (int i = 0; i < config.totpoly; ++i) {
- MPoly *p = &polys[i];
- MCol *cface = &cfaces[p->loopstart + p->totloop];
- MLoop *mloop = &mloops[p->loopstart + p->totloop];
+ /* Either one or the other should be given. */
+ BLI_assert(c3f_ptr || c4f_ptr);
+ const bool use_c3f_ptr = (c3f_ptr.get() != nullptr);
- for (int j = 0; j < p->totloop; ++j) {
- cface--;
- mloop--;
+ for (int i = 0; i < config.totpoly; ++i) {
+ MPoly *p = &polys[i];
+ MCol *cface = &cfaces[p->loopstart + p->totloop];
+ MLoop *mloop = &mloops[p->loopstart + p->totloop];
+
+ for (int j = 0; j < p->totloop; ++j) {
+ cface--;
+ mloop--;
+
+ if (use_c3f_ptr) {
const Imath::C3f &color = (*c3f_ptr)[mloop->v];
cface->a = FTOCHAR(color[0]);
cface->r = FTOCHAR(color[1]);
cface->g = FTOCHAR(color[2]);
cface->b = 255;
}
- }
- }
- else if (c4f_ptr) {
- for (int i = 0; i < config.totpoly; ++i) {
- MPoly *p = &polys[i];
- MCol *cface = &cfaces[p->loopstart + p->totloop];
- MLoop *mloop = &mloops[p->loopstart + p->totloop];
-
- for (int j = 0; j < p->totloop; ++j) {
- cface--;
- mloop--;
+ else {
const Imath::C4f &color = (*c4f_ptr)[mloop->v];
cface->a = FTOCHAR(color[0]);
cface->r = FTOCHAR(color[1]);