Alembic: Renamed copy_zup_yup to copy_yup_from_zup (and same for zup_from_yup)
authorSybren A. Stüvel <sybren@stuvel.eu>
Fri, 3 Feb 2017 14:54:59 +0000 (15:54 +0100)
committerSybren A. Stüvel <sybren@stuvel.eu>
Wed, 8 Feb 2017 11:26:36 +0000 (12:26 +0100)
With the new names the arguments (yup, zup) are in the same order as
they appear in the function name. The old names used copy_src_dst(dst,
src), which I found very confusing. Furthermore, now it is clear from
where to where the copy is made.

This makes the function names a little bit longer, though. If that is
a real issue, we can just name them zup_from_yup(zup, yup).

Reviewed by: Kévin Dietrich

source/blender/alembic/intern/abc_curves.cc
source/blender/alembic/intern/abc_hair.cc
source/blender/alembic/intern/abc_mesh.cc
source/blender/alembic/intern/abc_nurbs.cc
source/blender/alembic/intern/abc_util.cc
source/blender/alembic/intern/abc_util.h

index 4ecb9d944f20c19cc904191c4be7cae71258ddfe..282777f3af01d95dac453c94690a1b909349a7a5 100644 (file)
@@ -102,7 +102,7 @@ void AbcCurveWriter::do_write()
                        const BPoint *point = nurbs->bp;
 
                        for (int i = 0; i < totpoint; ++i, ++point) {
-                               copy_zup_yup(temp_vert.getValue(), point->vec);
+                               copy_yup_from_zup(temp_vert.getValue(), point->vec);
                                verts.push_back(temp_vert);
                                weights.push_back(point->vec[3]);
                                widths.push_back(point->radius);
@@ -118,7 +118,7 @@ void AbcCurveWriter::do_write()
 
                        /* TODO(kevin): store info about handles, Alembic doesn't have this. */
                        for (int i = 0; i < totpoint; ++i, ++bezier) {
-                               copy_zup_yup(temp_vert.getValue(), bezier->vec[1]);
+                               copy_yup_from_zup(temp_vert.getValue(), bezier->vec[1]);
                                verts.push_back(temp_vert);
                                widths.push_back(bezier->radius);
                        }
@@ -322,7 +322,7 @@ void read_curve_sample(Curve *cu, const ICurvesSchema &schema, const float time)
                                weight = (*weights)[idx];
                        }
 
-                       copy_yup_zup(bp->vec, pos.getValue());
+                       copy_zup_from_yup(bp->vec, pos.getValue());
                        bp->vec[3] = weight;
                        bp->f1 = SELECT;
                        bp->radius = radius;
@@ -389,7 +389,7 @@ DerivedMesh *AbcCurveReader::read_derivedmesh(DerivedMesh */*dm*/, const float t
 
                                for (int i = 0; i < totpoint; ++i, ++point, ++vertex_idx) {
                                        const Imath::V3f &pos = (*positions)[vertex_idx];
-                                       copy_yup_zup(point->vec, pos.getValue());
+                                       copy_zup_from_yup(point->vec, pos.getValue());
                                }
                        }
                        else if (nurbs->bezt) {
@@ -397,7 +397,7 @@ DerivedMesh *AbcCurveReader::read_derivedmesh(DerivedMesh */*dm*/, const float t
 
                                for (int i = 0; i < totpoint; ++i, ++bezier, ++vertex_idx) {
                                        const Imath::V3f &pos = (*positions)[vertex_idx];
-                                       copy_yup_zup(bezier->vec[1], pos.getValue());
+                                       copy_zup_from_yup(bezier->vec[1], pos.getValue());
                                }
                        }
                }
index 14bcf6731ea51cb5d7e001c9e05c7b13eb955bc6..626883c86f55637062de9b64f4f1d5b9a77524a2 100644 (file)
@@ -164,7 +164,7 @@ void AbcHairWriter::write_hair_sample(DerivedMesh *dm,
 
                                        psys_interpolate_face(mverts, face, tface, NULL, mapfw, vec, normal, NULL, NULL, NULL, NULL);
 
-                                       copy_zup_yup(tmp_nor.getValue(), normal);
+                                       copy_yup_from_zup(tmp_nor.getValue(), normal);
                                        norm_values.push_back(tmp_nor);
                                }
                        }
@@ -198,7 +198,7 @@ void AbcHairWriter::write_hair_sample(DerivedMesh *dm,
                                                MVert *mv = mverts + vtx[o];
 
                                                normal_short_to_float_v3(normal, mv->no);
-                                               copy_zup_yup(tmp_nor.getValue(), normal);
+                                               copy_yup_from_zup(tmp_nor.getValue(), normal);
                                                norm_values.push_back(tmp_nor);
                                                found = true;
                                                break;
index bdd75f93189c26a6140d7ed875d487278fd4a2e1..8bc9c33505428b8087b908f8eee134c1e63ca214 100644 (file)
@@ -112,7 +112,7 @@ static void get_vertices(DerivedMesh *dm, std::vector<Imath::V3f> &points)
        MVert *verts = dm->getVertArray(dm);
 
        for (int i = 0, e = dm->getNumVerts(dm); i < e; ++i) {
-               copy_zup_yup(points[i].getValue(), verts[i].co);
+               copy_yup_from_zup(points[i].getValue(), verts[i].co);
        }
 }
 
@@ -182,7 +182,7 @@ static void get_vertex_normals(DerivedMesh *dm, std::vector<Imath::V3f> &normals
 
        for (int i = 0, e = dm->getNumVerts(dm); i < e; ++i) {
                normal_short_to_float_v3(no, verts[i].no);
-               copy_zup_yup(normals[i].getValue(), no);
+               copy_yup_from_zup(normals[i].getValue(), no);
        }
 }
 
@@ -211,7 +211,7 @@ static void get_loop_normals(DerivedMesh *dm, std::vector<Imath::V3f> &normals)
 
                        for (int j = 0; j < mp->totloop; --ml, ++j, ++loop_index) {
                                const int index = ml->v;
-                               copy_zup_yup(normals[loop_index].getValue(), lnors[index]);
+                               copy_yup_from_zup(normals[loop_index].getValue(), lnors[index]);
                        }
                }
        }
@@ -226,14 +226,14 @@ static void get_loop_normals(DerivedMesh *dm, std::vector<Imath::V3f> &normals)
                                BKE_mesh_calc_poly_normal(mp, ml - (mp->totloop - 1), verts, no);
 
                                for (int j = 0; j < mp->totloop; --ml, ++j, ++loop_index) {
-                                       copy_zup_yup(normals[loop_index].getValue(), no);
+                                       copy_yup_from_zup(normals[loop_index].getValue(), no);
                                }
                        }
                        else {
                                /* Smooth shaded, use individual vert normals. */
                                for (int j = 0; j < mp->totloop; --ml, ++j, ++loop_index) {
                                        normal_short_to_float_v3(no, verts[ml->v].no);
-                                       copy_zup_yup(normals[loop_index].getValue(), no);
+                                       copy_yup_from_zup(normals[loop_index].getValue(), no);
                                }
                        }
                }
@@ -590,7 +590,7 @@ void AbcMeshWriter::getVelocities(DerivedMesh *dm, std::vector<Imath::V3f> &vels
                float *mesh_vels = reinterpret_cast<float *>(fss->meshVelocities);
 
                for (int i = 0; i < totverts; ++i) {
-                       copy_zup_yup(vels[i].getValue(), mesh_vels);
+                       copy_yup_from_zup(vels[i].getValue(), mesh_vels);
                        mesh_vels += 3;
                }
        }
@@ -726,7 +726,7 @@ static void read_mverts_interp(MVert *mverts, const P3fArraySamplePtr &positions
                const Imath::V3f &ceil_pos = (*ceil_positions)[i];
 
                interp_v3_v3v3(tmp, floor_pos.getValue(), ceil_pos.getValue(), weight);
-               copy_yup_zup(mvert.co, tmp);
+               copy_zup_from_yup(mvert.co, tmp);
 
                mvert.bweight = 0;
        }
@@ -755,7 +755,7 @@ void read_mverts(MVert *mverts, const P3fArraySamplePtr &positions, const N3fArr
                MVert &mvert = mverts[i];
                Imath::V3f pos_in = (*positions)[i];
 
-               copy_yup_zup(mvert.co, pos_in.getValue());
+               copy_zup_from_yup(mvert.co, pos_in.getValue());
 
                mvert.bweight = 0;
 
@@ -765,7 +765,7 @@ void read_mverts(MVert *mverts, const P3fArraySamplePtr &positions, const N3fArr
                        short no[3];
                        normal_float_to_short_v3(no, nor_in.getValue());
 
-                       copy_yup_zup(mvert.no, no);
+                       copy_zup_from_yup(mvert.no, no);
                }
        }
 }
index 4f57dfdae9ed0db25b6adee9fd2c10c9e693d96a..d0b9561f67987b3bb2041914f73f882636c3984b 100644 (file)
@@ -153,7 +153,7 @@ void AbcNurbsWriter::do_write()
                const BPoint *bp = nu->bp;
 
                for (int i = 0; i < size; ++i, ++bp) {
-                       copy_zup_yup(positions[i].getValue(), bp->vec);
+                       copy_yup_from_zup(positions[i].getValue(), bp->vec);
                        weights[i] = bp->vec[3];
                }
 
@@ -281,7 +281,7 @@ void AbcNurbsReader::readObjectData(Main *bmain, float time)
                                posw_in = (*weights)[i];
                        }
 
-                       copy_yup_zup(bp->vec, pos_in.getValue());
+                       copy_zup_from_yup(bp->vec, pos_in.getValue());
                        bp->vec[3] = posw_in;
                        bp->f1 = SELECT;
                        bp->radius = 1.0f;
index f8ce72d845d517603cfc8b5db8392d347590cd97..08c94f437e6d7764ed2930653780a4c660d73957 100644 (file)
@@ -197,7 +197,7 @@ void create_transform_matrix(float r_mat[4][4])
        copy_m4_m3(transform_mat, rot_mat);
 
        /* Add translation to transformation matrix. */
-       copy_yup_zup(transform_mat[3], loc);
+       copy_zup_from_yup(transform_mat[3], loc);
 
        /* Create scale matrix. */
        scale_mat[0][0] = scale[0];
@@ -417,7 +417,7 @@ void create_transform_matrix(Object *obj, float transform_mat[4][4])
        copy_m4_m3(transform_mat, rot_mat);
 
        /* Add translation to transformation matrix. */
-       copy_zup_yup(transform_mat[3], loc);
+       copy_yup_from_zup(transform_mat[3], loc);
 
        /* Create scale matrix. */
        scale_mat[0][0] = scale[0];
index 60a96855d14131a81d1905c2da022070bad57591..a7ac9df91c7bdef0dec732ab0671fe76d71d4e71 100644 (file)
@@ -116,14 +116,14 @@ AbcObjectReader *create_reader(const Alembic::AbcGeom::IObject &object, ImportSe
 
 /* Copy from Y-up to Z-up. */
 
-ABC_INLINE void copy_yup_zup(float zup[3], const float yup[3])
+ABC_INLINE void copy_zup_from_yup(float zup[3], const float yup[3])
 {
        zup[0] = yup[0];
        zup[1] = -yup[2];
        zup[2] = yup[1];
 }
 
-ABC_INLINE void copy_yup_zup(short zup[3], const short yup[3])
+ABC_INLINE void copy_zup_from_yup(short zup[3], const short yup[3])
 {
        zup[0] = yup[0];
        zup[1] = -yup[2];
@@ -132,14 +132,14 @@ ABC_INLINE void copy_yup_zup(short zup[3], const short yup[3])
 
 /* Copy from Z-up to Y-up. */
 
-ABC_INLINE void copy_zup_yup(float yup[3], const float zup[3])
+ABC_INLINE void copy_yup_from_zup(float yup[3], const float zup[3])
 {
        yup[0] = zup[0];
        yup[1] = zup[2];
        yup[2] = -zup[1];
 }
 
-ABC_INLINE void copy_zup_yup(short yup[3], const short zup[3])
+ABC_INLINE void copy_yup_from_zup(short yup[3], const short zup[3])
 {
        yup[0] = zup[0];
        yup[1] = zup[2];