Cleanup: Alembic, renamed and moved convert_matrix function

The `convert_matrix()` function just converts between the Alembic and
Blender matrix data types, and doesn't do any coordinate system conversion.
To clarify this, the function has now been renamed to
`convert_matrix_datatype()`.

I also moved the implementations next to each other in the source file,
so that it's visible that there are actually two of them.

No functional changes.
This commit is contained in:
Sybren A. Stüvel
2020-02-14 15:41:02 +01:00
parent 451bd5fd79
commit fb2f100d89
4 changed files with 15 additions and 16 deletions

View File

@@ -339,7 +339,7 @@ void AbcObjectReader::read_matrix(float r_mat[4][4] /* local matrix */,
}
const Imath::M44d matrix = get_matrix(schema, time);
convert_matrix(matrix, r_mat);
convert_matrix_datatype(matrix, r_mat);
copy_m44_axis_swap(r_mat, r_mat, ABC_ZUP_FROM_YUP);
/* Convert from Maya to Blender camera orientation. Children of this camera

View File

@@ -105,7 +105,7 @@ void AbcTransformWriter::do_write()
yup_mat[3][3] /= m_settings.global_scale; /* normalise the homogeneous component */
}
m_matrix = convert_matrix(yup_mat);
m_matrix = convert_matrix_datatype(yup_mat);
m_sample.setMatrix(m_matrix);
m_sample.setInheritsXforms(m_inherits_xform);
m_schema.set(m_sample);

View File

@@ -86,7 +86,7 @@ std::string get_object_dag_path_name(const Object *const ob, Object *dupli_paren
return name;
}
Imath::M44d convert_matrix(float mat[4][4])
Imath::M44d convert_matrix_datatype(float mat[4][4])
{
Imath::M44d m;
@@ -99,6 +99,15 @@ Imath::M44d convert_matrix(float mat[4][4])
return m;
}
void convert_matrix_datatype(const Imath::M44d &xform, float r_mat[4][4])
{
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
r_mat[i][j] = static_cast<float>(xform[i][j]);
}
}
}
void split(const std::string &s, const char delim, std::vector<std::string> &tokens)
{
tokens.clear();
@@ -224,15 +233,6 @@ void copy_m44_axis_swap(float dst_mat[4][4], float src_mat[4][4], AbcAxisSwapMod
mul_m4_m4m4(dst_mat, dst_mat, dst_scale_mat);
}
void convert_matrix(const Imath::M44d &xform, float r_mat[4][4])
{
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
r_mat[i][j] = static_cast<float>(xform[i][j]);
}
}
}
/* Recompute transform matrix of object in new coordinate system
* (from Z-Up to Y-Up). */
void create_transform_matrix(Object *obj,

View File

@@ -52,7 +52,9 @@ std::string get_id_name(const Object *const ob);
std::string get_object_dag_path_name(const Object *const ob, Object *dupli_parent);
/* Convert from float to Alembic matrix representations. Does NOT convert from Z-up to Y-up. */
Imath::M44d convert_matrix(float mat[4][4]);
Imath::M44d convert_matrix_datatype(float mat[4][4]);
/* Convert from Alembic to float matrix representations. Does NOT convert from Y-up to Z-up. */
void convert_matrix_datatype(const Imath::M44d &xform, float r_mat[4][4]);
typedef enum {
ABC_MATRIX_WORLD = 1,
@@ -70,9 +72,6 @@ template<class TContainer> bool begins_with(const TContainer &input, const TCont
return input.size() >= match.size() && std::equal(match.begin(), match.end(), input.begin());
}
/* Convert from Alembic to float matrix representations. Does NOT convert from Y-up to Z-up. */
void convert_matrix(const Imath::M44d &xform, float r_mat[4][4]);
template<typename Schema>
void get_min_max_time_ex(const Schema &schema, chrono_t &min, chrono_t &max)
{