[Bf-blender-cvs] [aec17a24f4e] collada: Cleanup Collada: Added new low level functions for later usage
Gaia Clary
noreply at git.blender.org
Wed Mar 28 21:30:19 CEST 2018
Commit: aec17a24f4ec229ff68c9a66e3611191c8e09132
Author: Gaia Clary
Date: Sun Mar 4 17:43:16 2018 +0100
Branches: collada
https://developer.blender.org/rBaec17a24f4ec229ff68c9a66e3611191c8e09132
Cleanup Collada: Added new low level functions for later usage
bc_get_action_id() : To create unique Collada conform identifiers
The following new functions handle conversions of matrices
to various forms:
bc_copy_darray_m4d() : Copy matrix to an array of floats
bc_copy_v44_m4d() : Copy matrix to a vector of vectors of floats
bc_copy_m4d_v44() : opposite of previous function
Note: The vector<vector<double>> matrix is needed so that i later can
easily store matrix data in another vector (containing matrix curves)
===================================================================
M source/blender/collada/collada_utils.cpp
M source/blender/collada/collada_utils.h
===================================================================
diff --git a/source/blender/collada/collada_utils.cpp b/source/blender/collada/collada_utils.cpp
index a70de989140..c60ffc46585 100644
--- a/source/blender/collada/collada_utils.cpp
+++ b/source/blender/collada/collada_utils.cpp
@@ -151,6 +151,16 @@ std::vector<bAction *> bc_getSceneActions()
return actions;
}
+std::string bc_get_action_id(std::string action_name, std::string ob_name, std::string channel_type, std::string axis_name, std::string axis_separator)
+{
+ std::string result = action_name + "_" + channel_type;
+ if (ob_name.length() > 0)
+ result = ob_name + "_" + result;
+ if (axis_name.length() > 0)
+ result += axis_separator + axis_name;
+ return translate_id(result);
+}
+
EvaluationContext *bc_get_evaluation_context()
{
Main *bmain = G.main;
@@ -916,7 +926,38 @@ void bc_copy_farray_m4(float *r, float a[4][4])
for (int i = 0; i < 4; i++)
for (int j = 0; j < 4; j++)
*r++ = a[i][j];
+}
+
+void bc_copy_darray_m4d(double *r, double a[4][4])
+{
+ for (int i = 0; i < 4; i++)
+ for (int j = 0; j < 4; j++)
+ *r++ = a[i][j];
+}
+void bc_copy_v44_m4d(std::vector<std::vector<double>> &r, double(&a)[4][4])
+{
+ for (int i = 0; i < 4; i++) {
+ for (int j = 0; j < 4; j++) {
+ r[i][j] = a[i][j];
+ }
+ }
+}
+
+void bc_copy_m4d_v44(double (&r)[4][4], std::vector<std::vector<double>> &a)
+{
+ for (int i = 0; i < 4; i++) {
+ for (int j = 0; j < 4; j++) {
+ r[i][j] = a[i][j];
+ }
+ }
+}
+
+void bc_append_darray_m4d(std::vector<double> &r, double a[4][4])
+{
+ for (int i = 0; i < 4; i++)
+ for (int j = 0; j < 4; j++)
+ r.push_back(a[i][j]);
}
/*
diff --git a/source/blender/collada/collada_utils.h b/source/blender/collada/collada_utils.h
index 533f5f30c50..f877c648a30 100644
--- a/source/blender/collada/collada_utils.h
+++ b/source/blender/collada/collada_utils.h
@@ -112,6 +112,7 @@ inline void bc_setSceneObjectAction(bAction *action, Object *ob)
ob->adt->action = action;
}
+std::string bc_get_action_id(std::string action_name, std::string ob_name, std::string channel_type, std::string axis_name, std::string axis_separator = "_");
extern float bc_get_float_value(const COLLADAFW::FloatOrDoubleArray& array, unsigned int index);
extern int bc_test_parent_loop(Object *par, Object *ob);
@@ -155,6 +156,10 @@ inline bool bc_in_range(float a, float b, float range) {
}
void bc_copy_m4_farray(float r[4][4], float *a);
void bc_copy_farray_m4(float *r, float a[4][4]);
+void bc_copy_darray_m4d(double *r, double a[4][4]);
+void bc_copy_m4d_v44(double(&r)[4][4], std::vector<std::vector<double>> &a);
+void bc_copy_v44_m4d(std::vector<std::vector<double>> &a, double(&r)[4][4]);
+void bc_append_darray_m4d(std::vector<double> &r, double a[4][4]);
extern void bc_sanitize_mat(float mat[4][4], int precision);
extern void bc_sanitize_mat(double mat[4][4], int precision);
More information about the Bf-blender-cvs
mailing list