diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-04-29 12:12:44 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-04-29 12:13:20 +0400 |
commit | 409fb4da0ce671d9c5cf54cb327770d6b4e97cb2 (patch) | |
tree | 37f4c7705463122fdf3d3e16a16a9d1feb89c967 /source | |
parent | d8282da5452b9bb8487d9bce611b922244a74a08 (diff) |
Code cleanup: remove redundant matrix initialization
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/armature.c | 9 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 5 | ||||
-rw-r--r-- | source/blender/blenlib/intern/math_geom.c | 3 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt.c | 3 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_snap.c | 2 | ||||
-rw-r--r-- | source/blender/editors/transform/transform.c | 3 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_constraints.c | 3 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_manipulator.c | 4 | ||||
-rw-r--r-- | source/blender/python/mathutils/mathutils_Matrix.c | 34 | ||||
-rw-r--r-- | source/blender/render/intern/source/zbuf.c | 4 |
10 files changed, 40 insertions, 30 deletions
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 3920f595514..6d01d9ff14b 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -594,7 +594,6 @@ static void pchan_b_bone_defmats(bPoseChannel *pchan, bPoseChanDeform *pdef_info Mat4 b_bone[MAX_BBONE_SUBDIV], b_bone_rest[MAX_BBONE_SUBDIV]; Mat4 *b_bone_mats; DualQuat *b_bone_dual_quats = NULL; - float tmat[4][4] = MAT4_UNITY; int a; b_bone_spline_setup(pchan, 0, b_bone); @@ -620,6 +619,8 @@ static void pchan_b_bone_defmats(bPoseChannel *pchan, bPoseChanDeform *pdef_info * - transform back into global space */ for (a = 0; a < bone->segments; a++) { + float tmat[4][4]; + invert_m4_m4(tmat, b_bone_rest[a].mat); mul_serie_m4(b_bone_mats[a + 1].mat, pchan->chan_mat, bone->arm_mat, b_bone[a].mat, tmat, b_bone_mats[0].mat, @@ -1108,10 +1109,11 @@ void BKE_armature_mat_world_to_pose(Object *ob, float inmat[4][4], float outmat[ * pose-channel into its local space (i.e. 'visual'-keyframing) */ void BKE_armature_loc_world_to_pose(Object *ob, const float inloc[3], float outloc[3]) { - float xLocMat[4][4] = MAT4_UNITY; + float xLocMat[4][4]; float nLocMat[4][4]; /* build matrix for location */ + unit_m4(xLocMat); copy_v3_v3(xLocMat[3], inloc); /* get bone-space cursor matrix and extract location */ @@ -1277,10 +1279,11 @@ void BKE_armature_mat_bone_to_pose(bPoseChannel *pchan, float inmat[4][4], float * pose-channel into its local space (i.e. 'visual'-keyframing) */ void BKE_armature_loc_pose_to_bone(bPoseChannel *pchan, const float inloc[3], float outloc[3]) { - float xLocMat[4][4] = MAT4_UNITY; + float xLocMat[4][4]; float nLocMat[4][4]; /* build matrix for location */ + unit_m4(xLocMat); copy_v3_v3(xLocMat[3], inloc); /* get bone-space cursor matrix and extract location */ diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index f6018409c62..6f4fe636de3 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2323,7 +2323,7 @@ void BKE_object_where_is_calc_time_ex(Scene *scene, Object *ob, float ctime, if (ob->parent) { Object *par = ob->parent; - float slowmat[4][4] = MAT4_UNITY; + float slowmat[4][4]; /* calculate parent matrix */ solve_parenting(scene, ob, par, ob->obmat, slowmat, r_originmat, true); @@ -2369,9 +2369,10 @@ void BKE_object_where_is_calc_time(Scene *scene, Object *ob, float ctime) * used for bundles orientation in 3d space relative to parented blender camera */ void BKE_object_where_is_calc_mat4(Scene *scene, Object *ob, float obmat[4][4]) { - float slowmat[4][4] = MAT4_UNITY; if (ob->parent) { + float slowmat[4][4]; + Object *par = ob->parent; solve_parenting(scene, ob, par, obmat, slowmat, NULL, false); diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index a12896049f5..58bb7c1f121 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -2996,9 +2996,10 @@ void polarview_m4(float Vm[4][4], float dist, float azimuth, float incidence, fl void lookat_m4(float mat[4][4], float vx, float vy, float vz, float px, float py, float pz, float twist) { float sine, cosine, hyp, hyp1, dx, dy, dz; - float mat1[4][4] = MAT4_UNITY; + float mat1[4][4]; unit_m4(mat); + unit_m4(mat1); rotate_m4(mat, 'Z', -twist); diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index d8816e73dff..b2e5207a69c 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -781,7 +781,8 @@ static float calc_overlap(StrokeCache *cache, const char symm, const char axis, flip_v3_v3(mirror, cache->true_location, symm); if (axis != 0) { - float mat[4][4] = MAT4_UNITY; + float mat[4][4]; + unit_m4(mat); rotate_m4(mat, axis, angle); mul_m4_v3(mat, mirror); } diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c index 26ebd1ddf63..8e6deeddc39 100644 --- a/source/blender/editors/space_view3d/view3d_snap.c +++ b/source/blender/editors/space_view3d/view3d_snap.c @@ -414,7 +414,7 @@ static void bundle_midpoint(Scene *scene, Object *ob, float vec[3]) MovieTracking *tracking; MovieTrackingObject *object; bool ok = false; - float min[3], max[3], mat[4][4], pos[3], cammat[4][4] = MAT4_UNITY; + float min[3], max[3], mat[4][4], pos[3], cammat[4][4]; if (!clip) return; diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index b52fba36cac..2cec4d61e3e 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -945,7 +945,6 @@ static void transform_event_xyz_constraint(TransInfo *t, short key_type, char cm int transformEvent(TransInfo *t, const wmEvent *event) { - float mati[3][3] = MAT3_UNITY; char cmode = constraintModeToChar(t); bool handled = false; @@ -1306,7 +1305,9 @@ int transformEvent(TransInfo *t, const wmEvent *event) } else { /* bit hackish... but it prevents mmb select to print the orientation from menu */ + float mati[3][3]; strcpy(t->spacename, "global"); + unit_m3(mati); initSelectConstraint(t, mati); } postSelectConstraint(t); diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c index 4cc8833ba1e..749c45e316b 100644 --- a/source/blender/editors/transform/transform_constraints.c +++ b/source/blender/editors/transform/transform_constraints.c @@ -625,8 +625,9 @@ void setUserConstraint(TransInfo *t, short orientation, int mode, const char fte switch (orientation) { case V3D_MANIP_GLOBAL: { - float mtx[3][3] = MAT3_UNITY; + float mtx[3][3]; BLI_snprintf(text, sizeof(text), ftext, IFACE_("global")); + unit_m3(mtx); setConstraint(t, mtx, mode, text); break; } diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c index a2b53da831b..aaa67e58eaf 100644 --- a/source/blender/editors/transform/transform_manipulator.c +++ b/source/blender/editors/transform/transform_manipulator.c @@ -1507,7 +1507,9 @@ static void draw_manipulator_rotate_cyl( /* Screen aligned view rot circle */ if (drawflags & MAN_ROT_V) { - float unitmat[4][4] = MAT4_UNITY; + float unitmat[4][4]; + + unit_m4(unitmat); if (is_picksel) glLoadName(MAN_ROT_V); UI_ThemeColor(TH_TRANSFORM); diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c index 1c8718aa122..3b526f885de 100644 --- a/source/blender/python/mathutils/mathutils_Matrix.c +++ b/source/blender/python/mathutils/mathutils_Matrix.c @@ -550,7 +550,9 @@ PyDoc_STRVAR(C_Matrix_Translation_doc, ); static PyObject *C_Matrix_Translation(PyObject *cls, PyObject *value) { - float mat[4][4] = MAT4_UNITY; + float mat[4][4]; + + unit_m4(mat); if (mathutils_array_parse(mat[3], 3, 4, value, "mathutils.Matrix.Translation(vector), invalid vector arg") == -1) return NULL; @@ -1013,7 +1015,7 @@ PyDoc_STRVAR(Matrix_resize_4x4_doc, ); static PyObject *Matrix_resize_4x4(MatrixObject *self) { - float mat[4][4] = MAT4_UNITY; + float mat[4][4]; int col; if (self->wrapped == Py_WRAP) { @@ -1029,7 +1031,7 @@ static PyObject *Matrix_resize_4x4(MatrixObject *self) return NULL; } - self->matrix = PyMem_Realloc(self->matrix, (sizeof(float) * 16)); + self->matrix = PyMem_Realloc(self->matrix, (sizeof(float) * (MATRIX_MAX_DIM * MATRIX_MAX_DIM))); if (self->matrix == NULL) { PyErr_SetString(PyExc_MemoryError, "Matrix.resize_4x4(): " @@ -1037,6 +1039,8 @@ static PyObject *Matrix_resize_4x4(MatrixObject *self) return NULL; } + unit_m4(mat); + for (col = 0; col < self->num_col; col++) { memcpy(mat[col], MATRIX_COL_PTR(self, col), self->num_row * sizeof(float)); } @@ -1177,10 +1181,7 @@ static PyObject *Matrix_invert(MatrixObject *self) int x, y, z = 0; float det = 0.0f; - float mat[16] = {0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f}; + float mat[MATRIX_MAX_DIM * MATRIX_MAX_DIM]; if (BaseMath_ReadCallback(self) == -1) return NULL; @@ -1811,7 +1812,7 @@ static PyObject *Matrix_item_col(MatrixObject *self, int col) static int Matrix_ass_item_row(MatrixObject *self, int row, PyObject *value) { int col; - float vec[4]; + float vec[MATRIX_MAX_DIM]; if (BaseMath_ReadCallback(self) == -1) return -1; @@ -1836,7 +1837,7 @@ static int Matrix_ass_item_row(MatrixObject *self, int row, PyObject *value) static int Matrix_ass_item_col(MatrixObject *self, int col, PyObject *value) { int row; - float vec[4]; + float vec[MATRIX_MAX_DIM]; if (BaseMath_ReadCallback(self) == -1) return -1; @@ -1904,7 +1905,7 @@ static int Matrix_ass_slice(MatrixObject *self, int begin, int end, PyObject *va else { const int size = end - begin; int row, col; - float mat[16]; + float mat[MATRIX_MAX_DIM * MATRIX_MAX_DIM]; float vec[4]; if (PySequence_Fast_GET_SIZE(value_fast) != size) { @@ -1946,7 +1947,7 @@ static int Matrix_ass_slice(MatrixObject *self, int begin, int end, PyObject *va *------------------------obj + obj------------------------------*/ static PyObject *Matrix_add(PyObject *m1, PyObject *m2) { - float mat[16]; + float mat[MATRIX_MAX_DIM * MATRIX_MAX_DIM]; MatrixObject *mat1 = NULL, *mat2 = NULL; mat1 = (MatrixObject *)m1; @@ -1978,7 +1979,7 @@ static PyObject *Matrix_add(PyObject *m1, PyObject *m2) * subtraction */ static PyObject *Matrix_sub(PyObject *m1, PyObject *m2) { - float mat[16]; + float mat[MATRIX_MAX_DIM * MATRIX_MAX_DIM]; MatrixObject *mat1 = NULL, *mat2 = NULL; mat1 = (MatrixObject *)m1; @@ -2010,7 +2011,7 @@ static PyObject *Matrix_sub(PyObject *m1, PyObject *m2) * multiplication */ static PyObject *matrix_mul_float(MatrixObject *mat, const float scalar) { - float tmat[16]; + float tmat[MATRIX_MAX_DIM * MATRIX_MAX_DIM]; mul_vn_vn_fl(tmat, mat->matrix, mat->num_col * mat->num_row, scalar); return Matrix_CreatePyObject(tmat, mat->num_col, mat->num_row, Py_NEW, Py_TYPE(mat)); } @@ -2035,10 +2036,7 @@ static PyObject *Matrix_mul(PyObject *m1, PyObject *m2) if (mat1 && mat2) { /* MATRIX * MATRIX */ - float mat[16] = {0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f}; + float mat[MATRIX_MAX_DIM * MATRIX_MAX_DIM]; int col, row, item; @@ -2071,7 +2069,7 @@ static PyObject *Matrix_mul(PyObject *m1, PyObject *m2) /* MATRIX * VECTOR */ if (VectorObject_Check(m2)) { VectorObject *vec2 = (VectorObject *)m2; - float tvec[4]; + float tvec[MATRIX_MAX_DIM]; if (BaseMath_ReadCallback(vec2) == -1) return NULL; if (column_vector_multiplication(tvec, vec2, mat1) == -1) { diff --git a/source/blender/render/intern/source/zbuf.c b/source/blender/render/intern/source/zbuf.c index 03eac8cb38b..a9253a8e635 100644 --- a/source/blender/render/intern/source/zbuf.c +++ b/source/blender/render/intern/source/zbuf.c @@ -1831,7 +1831,9 @@ void zbuf_render_project(float winmat[4][4], const float co[3], float ho[4]) void zbuf_make_winmat(Render *re, float winmat[4][4]) { if (re->r.mode & R_PANORAMA) { - float panomat[4][4]= MAT4_UNITY; + float panomat[4][4]; + + unit_m4(panomat); panomat[0][0]= re->panoco; panomat[0][2]= re->panosi; |