diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-08-02 10:17:31 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-08-02 10:17:31 +0300 |
commit | a3a6b71a9d29d2936bb14eb95f5073d68601cf36 (patch) | |
tree | 5ee481bf2b189e3760caf7e95bb6f9129265482b /source/blender/blenkernel | |
parent | 0e308b07a025d98955824267f0b769475d7061db (diff) |
Cleanup: pass const matrices
Also order return matrices last.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_armature.h | 22 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_curve.h | 6 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_gpencil_geom.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_lattice.h | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_mesh.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_object.h | 28 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/armature.c | 42 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/curve.c | 11 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/gpencil_geom.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/lattice.c | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/mball_tessellate.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/mesh.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 104 |
13 files changed, 124 insertions, 107 deletions
diff --git a/source/blender/blenkernel/BKE_armature.h b/source/blender/blenkernel/BKE_armature.h index 6fb6675a05a..301aa4538a7 100644 --- a/source/blender/blenkernel/BKE_armature.h +++ b/source/blender/blenkernel/BKE_armature.h @@ -123,22 +123,24 @@ void get_objectspace_bone_matrix(struct Bone *bone, float M_accumulatedMatrix[4][4], int root, int posed); -void vec_roll_to_mat3(const float vec[3], const float roll, float mat[3][3]); -void vec_roll_to_mat3_normalized(const float nor[3], const float roll, float mat[3][3]); +void vec_roll_to_mat3(const float vec[3], const float roll, float r_mat[3][3]); +void vec_roll_to_mat3_normalized(const float nor[3], const float roll, float r_mat[3][3]); void mat3_to_vec_roll(const float mat[3][3], float r_vec[3], float *r_roll); void mat3_vec_to_roll(const float mat[3][3], const float vec[3], float *r_roll); /* Common Conversions Between Co-ordinate Spaces */ -void BKE_armature_mat_world_to_pose(struct Object *ob, float inmat[4][4], float outmat[4][4]); +void BKE_armature_mat_world_to_pose(struct Object *ob, + const float inmat[4][4], + float outmat[4][4]); void BKE_armature_loc_world_to_pose(struct Object *ob, const float inloc[3], float outloc[3]); void BKE_armature_mat_pose_to_bone(struct bPoseChannel *pchan, - float inmat[4][4], + const float inmat[4][4], float outmat[4][4]); void BKE_armature_loc_pose_to_bone(struct bPoseChannel *pchan, const float inloc[3], float outloc[3]); void BKE_armature_mat_bone_to_pose(struct bPoseChannel *pchan, - float inmat[4][4], + const float inmat[4][4], float outmat[4][4]); void BKE_armature_mat_pose_to_delta(float delta_mat[4][4], float pose_mat[4][4], @@ -147,13 +149,13 @@ void BKE_armature_mat_pose_to_delta(float delta_mat[4][4], void BKE_armature_mat_pose_to_bone_ex(struct Depsgraph *depsgraph, struct Object *ob, struct bPoseChannel *pchan, - float inmat[4][4], + const float inmat[4][4], float outmat[4][4]); -void BKE_pchan_mat3_to_rot(struct bPoseChannel *pchan, float mat[3][3], bool use_compat); -void BKE_pchan_rot_to_mat3(const struct bPoseChannel *pchan, float mat[3][3]); -void BKE_pchan_apply_mat4(struct bPoseChannel *pchan, float mat[4][4], bool use_comat); -void BKE_pchan_to_mat4(const struct bPoseChannel *pchan, float chan_mat[4][4]); +void BKE_pchan_mat3_to_rot(struct bPoseChannel *pchan, const float mat[3][3], bool use_compat); +void BKE_pchan_rot_to_mat3(const struct bPoseChannel *pchan, float r_mat[3][3]); +void BKE_pchan_apply_mat4(struct bPoseChannel *pchan, const float mat[4][4], bool use_comat); +void BKE_pchan_to_mat4(const struct bPoseChannel *pchan, float r_mat[4][4]); void BKE_pchan_calc_mat(struct bPoseChannel *pchan); /* Simple helper, computes the offset bone matrix. */ diff --git a/source/blender/blenkernel/BKE_curve.h b/source/blender/blenkernel/BKE_curve.h index ca41e51984b..3f7b978287d 100644 --- a/source/blender/blenkernel/BKE_curve.h +++ b/source/blender/blenkernel/BKE_curve.h @@ -98,15 +98,15 @@ bool BKE_curve_minmax(struct Curve *cu, bool use_radius, float min[3], float max bool BKE_curve_center_median(struct Curve *cu, float cent[3]); bool BKE_curve_center_bounds(struct Curve *cu, float cent[3]); void BKE_curve_transform_ex(struct Curve *cu, - float mat[4][4], + const float mat[4][4], const bool do_keys, const bool do_props, const float unit_scale); void BKE_curve_transform(struct Curve *cu, - float mat[4][4], + const float mat[4][4], const bool do_keys, const bool do_props); -void BKE_curve_translate(struct Curve *cu, float offset[3], const bool do_keys); +void BKE_curve_translate(struct Curve *cu, const float offset[3], const bool do_keys); void BKE_curve_material_index_remove(struct Curve *cu, int index); bool BKE_curve_material_index_used(struct Curve *cu, int index); void BKE_curve_material_index_clear(struct Curve *cu); diff --git a/source/blender/blenkernel/BKE_gpencil_geom.h b/source/blender/blenkernel/BKE_gpencil_geom.h index 964764d99e7..c97461fb0c8 100644 --- a/source/blender/blenkernel/BKE_gpencil_geom.h +++ b/source/blender/blenkernel/BKE_gpencil_geom.h @@ -76,7 +76,7 @@ void BKE_gpencil_stroke_fill_triangulate(struct bGPDstroke *gps); void BKE_gpencil_stroke_geometry_update(struct bGPDstroke *gps); void BKE_gpencil_stroke_uv_update(struct bGPDstroke *gps); -void BKE_gpencil_transform(struct bGPdata *gpd, float mat[4][4]); +void BKE_gpencil_transform(struct bGPdata *gpd, const float mat[4][4]); typedef struct GPencilPointCoordinates { /* This is used when doing "move only origin" in object_data_transform.c. diff --git a/source/blender/blenkernel/BKE_lattice.h b/source/blender/blenkernel/BKE_lattice.h index bb23ad63020..fdcea95704f 100644 --- a/source/blender/blenkernel/BKE_lattice.h +++ b/source/blender/blenkernel/BKE_lattice.h @@ -67,8 +67,8 @@ void BKE_lattice_minmax_dl(struct Object *ob, struct Lattice *lt, float min[3], void BKE_lattice_minmax(struct Lattice *lt, float min[3], float max[3]); void BKE_lattice_center_median(struct Lattice *lt, float cent[3]); void BKE_lattice_center_bounds(struct Lattice *lt, float cent[3]); -void BKE_lattice_translate(struct Lattice *lt, float offset[3], bool do_keys); -void BKE_lattice_transform(struct Lattice *lt, float mat[4][4], bool do_keys); +void BKE_lattice_translate(struct Lattice *lt, const float offset[3], bool do_keys); +void BKE_lattice_transform(struct Lattice *lt, const float mat[4][4], bool do_keys); bool BKE_lattice_is_any_selected(const struct Lattice *lt); diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h index b2510be656e..e0bedd20617 100644 --- a/source/blender/blenkernel/BKE_mesh.h +++ b/source/blender/blenkernel/BKE_mesh.h @@ -231,7 +231,7 @@ void BKE_mesh_nomain_to_meshkey(struct Mesh *mesh_src, struct Mesh *mesh_dst, st /* vertex level transformations & checks (no derived mesh) */ bool BKE_mesh_minmax(const struct Mesh *me, float r_min[3], float r_max[3]); -void BKE_mesh_transform(struct Mesh *me, float mat[4][4], bool do_keys); +void BKE_mesh_transform(struct Mesh *me, const float mat[4][4], bool do_keys); void BKE_mesh_translate(struct Mesh *me, const float offset[3], const bool do_keys); void BKE_mesh_ensure_navmesh(struct Mesh *me); diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index f2a022c84a3..7f2bdccf3a4 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -144,21 +144,21 @@ struct Object *BKE_object_duplicate(struct Main *bmain, void BKE_object_obdata_size_init(struct Object *ob, const float scale); -void BKE_object_scale_to_mat3(struct Object *ob, float mat[3][3]); -void BKE_object_rot_to_mat3(const struct Object *ob, float mat[3][3], bool use_drot); -void BKE_object_mat3_to_rot(struct Object *ob, float mat[3][3], bool use_compat); -void BKE_object_to_mat3(struct Object *ob, float mat[3][3]); -void BKE_object_to_mat4(struct Object *ob, float mat[4][4]); +void BKE_object_scale_to_mat3(struct Object *ob, float r_mat[3][3]); +void BKE_object_rot_to_mat3(const struct Object *ob, float r_mat[3][3], bool use_drot); +void BKE_object_mat3_to_rot(struct Object *ob, float r_mat[3][3], bool use_compat); +void BKE_object_to_mat3(struct Object *ob, float r_mat[3][3]); +void BKE_object_to_mat4(struct Object *ob, float r_mat[4][4]); void BKE_object_apply_mat4(struct Object *ob, - float mat[4][4], + const float mat[4][4], const bool use_compat, const bool use_parent); void BKE_object_apply_mat4_ex(struct Object *ob, - float mat[4][4], + const float mat[4][4], struct Object *parent, - float parentinv[4][4], + const float parentinv[4][4], const bool use_compat); -void BKE_object_matrix_local_get(struct Object *ob, float mat[4][4]); +void BKE_object_matrix_local_get(struct Object *ob, float r_mat[4][4]); bool BKE_object_pose_context_check(const struct Object *ob); struct Object *BKE_object_pose_armature_get(struct Object *ob); @@ -188,7 +188,7 @@ struct Base **BKE_object_pose_base_array_get(struct ViewLayer *view_layer, struct View3D *v3d, unsigned int *r_bases_len); -void BKE_object_get_parent_matrix(struct Object *ob, struct Object *par, float parentmat[4][4]); +void BKE_object_get_parent_matrix(struct Object *ob, struct Object *par, float r_parentmat[4][4]); void BKE_object_where_is_calc(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob); void BKE_object_where_is_calc_ex(struct Depsgraph *depsgraph, struct Scene *scene, @@ -199,7 +199,7 @@ void BKE_object_where_is_calc_time(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, float ctime); -void BKE_object_where_is_calc_mat4(struct Object *ob, float obmat[4][4]); +void BKE_object_where_is_calc_mat4(struct Object *ob, float r_obmat[4][4]); /* possibly belong in own moduke? */ struct BoundBox *BKE_boundbox_alloc_unit(void); @@ -207,12 +207,12 @@ void BKE_boundbox_init_from_minmax(struct BoundBox *bb, const float min[3], cons void BKE_boundbox_calc_center_aabb(const struct BoundBox *bb, float r_cent[3]); void BKE_boundbox_calc_size_aabb(const struct BoundBox *bb, float r_size[3]); void BKE_boundbox_minmax(const struct BoundBox *bb, - float obmat[4][4], + const float obmat[4][4], float r_min[3], float r_max[3]); struct BoundBox *BKE_object_boundbox_get(struct Object *ob); -void BKE_object_dimensions_get(struct Object *ob, float vec[3]); +void BKE_object_dimensions_get(struct Object *ob, float r_vec[3]); void BKE_object_dimensions_set_ex(struct Object *ob, const float value[3], int axis_mask, @@ -233,7 +233,7 @@ bool BKE_object_minmax_dupli(struct Depsgraph *depsgraph, /* sometimes min-max isn't enough, we need to loop over each point */ void BKE_object_foreach_display_point(struct Object *ob, - float obmat[4][4], + const float obmat[4][4], void (*func_cb)(const float[3], void *), void *user_data); void BKE_scene_foreach_display_point(struct Depsgraph *depsgraph, diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index d1d6cc63174..c977ebe4ae2 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -1382,7 +1382,7 @@ void get_objectspace_bone_matrix(struct Bone *bone, } /* Convert World-Space Matrix to Pose-Space Matrix */ -void BKE_armature_mat_world_to_pose(Object *ob, float inmat[4][4], float outmat[4][4]) +void BKE_armature_mat_world_to_pose(Object *ob, const float inmat[4][4], float outmat[4][4]) { float obmat[4][4]; @@ -1674,7 +1674,9 @@ void BKE_bone_parent_transform_apply(const struct BoneParentTransform *bpt, /* Convert Pose-Space Matrix to Bone-Space Matrix. * NOTE: this cannot be used to convert to pose-space transforms of the supplied * pose-channel into its local space (i.e. 'visual'-keyframing) */ -void BKE_armature_mat_pose_to_bone(bPoseChannel *pchan, float inmat[4][4], float outmat[4][4]) +void BKE_armature_mat_pose_to_bone(bPoseChannel *pchan, + const float inmat[4][4], + float outmat[4][4]) { BoneParentTransform bpt; @@ -1684,7 +1686,9 @@ void BKE_armature_mat_pose_to_bone(bPoseChannel *pchan, float inmat[4][4], float } /* Convert Bone-Space Matrix to Pose-Space Matrix. */ -void BKE_armature_mat_bone_to_pose(bPoseChannel *pchan, float inmat[4][4], float outmat[4][4]) +void BKE_armature_mat_bone_to_pose(bPoseChannel *pchan, + const float inmat[4][4], + float outmat[4][4]) { BoneParentTransform bpt; @@ -1720,7 +1724,7 @@ void BKE_armature_loc_pose_to_bone(bPoseChannel *pchan, const float inloc[3], fl void BKE_armature_mat_pose_to_bone_ex(struct Depsgraph *depsgraph, Object *ob, bPoseChannel *pchan, - float inmat[4][4], + const float inmat[4][4], float outmat[4][4]) { bPoseChannel work_pchan = *pchan; @@ -1741,7 +1745,7 @@ void BKE_armature_mat_pose_to_bone_ex(struct Depsgraph *depsgraph, /** * Same as #BKE_object_mat3_to_rot(). */ -void BKE_pchan_mat3_to_rot(bPoseChannel *pchan, float mat[3][3], bool use_compat) +void BKE_pchan_mat3_to_rot(bPoseChannel *pchan, const float mat[3][3], bool use_compat) { BLI_ASSERT_UNIT_M3(mat); @@ -1766,17 +1770,17 @@ void BKE_pchan_mat3_to_rot(bPoseChannel *pchan, float mat[3][3], bool use_compat /** * Same as #BKE_object_rot_to_mat3(). */ -void BKE_pchan_rot_to_mat3(const bPoseChannel *pchan, float mat[3][3]) +void BKE_pchan_rot_to_mat3(const bPoseChannel *pchan, float r_mat[3][3]) { /* rotations may either be quats, eulers (with various rotation orders), or axis-angle */ if (pchan->rotmode > 0) { /* euler rotations (will cause gimble lock, * but this can be alleviated a bit with rotation orders) */ - eulO_to_mat3(mat, pchan->eul, pchan->rotmode); + eulO_to_mat3(r_mat, pchan->eul, pchan->rotmode); } else if (pchan->rotmode == ROT_MODE_AXISANGLE) { /* axis-angle - not really that great for 3D-changing orientations */ - axis_angle_to_mat3(mat, pchan->rotAxis, pchan->rotAngle); + axis_angle_to_mat3(r_mat, pchan->rotAxis, pchan->rotAngle); } else { /* quats are normalized before use to eliminate scaling issues */ @@ -1786,7 +1790,7 @@ void BKE_pchan_rot_to_mat3(const bPoseChannel *pchan, float mat[3][3]) * since this was kindof evil in some cases but if this proves to be too problematic, * switch back to the old system of operating directly on the stored copy. */ normalize_qt_qt(quat, pchan->quat); - quat_to_mat3(mat, quat); + quat_to_mat3(r_mat, quat); } } @@ -1794,7 +1798,7 @@ void BKE_pchan_rot_to_mat3(const bPoseChannel *pchan, float mat[3][3]) * Apply a 4x4 matrix to the pose bone, * similar to #BKE_object_apply_mat4(). */ -void BKE_pchan_apply_mat4(bPoseChannel *pchan, float mat[4][4], bool use_compat) +void BKE_pchan_apply_mat4(bPoseChannel *pchan, const float mat[4][4], bool use_compat) { float rot[3][3]; mat4_to_loc_rot_size(pchan->loc, rot, pchan->size, mat); @@ -1998,7 +2002,7 @@ void mat3_vec_to_roll(const float mat[3][3], const float vec[3], float *r_roll) * └ -2 * x * z, x^2 - z^2 ┘ * </pre> */ -void vec_roll_to_mat3_normalized(const float nor[3], const float roll, float mat[3][3]) +void vec_roll_to_mat3_normalized(const float nor[3], const float roll, float r_mat[3][3]) { #define THETA_THRESHOLD_NEGY 1.0e-9f #define THETA_THRESHOLD_NEGY_CLOSE 1.0e-5f @@ -2052,18 +2056,18 @@ void vec_roll_to_mat3_normalized(const float nor[3], const float roll, float mat axis_angle_normalized_to_mat3(rMatrix, nor, roll); /* Combine and output result */ - mul_m3_m3m3(mat, rMatrix, bMatrix); + mul_m3_m3m3(r_mat, rMatrix, bMatrix); #undef THETA_THRESHOLD_NEGY #undef THETA_THRESHOLD_NEGY_CLOSE } -void vec_roll_to_mat3(const float vec[3], const float roll, float mat[3][3]) +void vec_roll_to_mat3(const float vec[3], const float roll, float r_mat[3][3]) { float nor[3]; normalize_v3_v3(nor, vec); - vec_roll_to_mat3_normalized(nor, roll, mat); + vec_roll_to_mat3_normalized(nor, roll, r_mat); } /** \} */ @@ -2418,8 +2422,10 @@ void BKE_pose_rebuild(Main *bmain, Object *ob, bArmature *arm, const bool do_id_ /** \name Pose Solver * \{ */ -/* loc/rot/size to given mat4 */ -void BKE_pchan_to_mat4(const bPoseChannel *pchan, float chan_mat[4][4]) +/** + * Convert the loc/rot/size to \a r_chanmat (typically #bPoseChannel.chan_mat). + */ +void BKE_pchan_to_mat4(const bPoseChannel *pchan, float r_chanmat[4][4]) { float smat[3][3]; float rmat[3][3]; @@ -2433,12 +2439,12 @@ void BKE_pchan_to_mat4(const bPoseChannel *pchan, float chan_mat[4][4]) /* calculate matrix of bone (as 3x3 matrix, but then copy the 4x4) */ mul_m3_m3m3(tmat, rmat, smat); - copy_m4_m3(chan_mat, tmat); + copy_m4_m3(r_chanmat, tmat); /* prevent action channels breaking chains */ /* need to check for bone here, CONSTRAINT_TYPE_ACTION uses this call */ if ((pchan->bone == NULL) || !(pchan->bone->flag & BONE_CONNECTED)) { - copy_v3_v3(chan_mat[3], pchan->loc); + copy_v3_v3(r_chanmat[3], pchan->loc); } } diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index acc3c52c08c..e126fb7f632 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -5110,8 +5110,11 @@ bool BKE_curve_center_bounds(Curve *cu, float cent[3]) return false; } -void BKE_curve_transform_ex( - Curve *cu, float mat[4][4], const bool do_keys, const bool do_props, const float unit_scale) +void BKE_curve_transform_ex(Curve *cu, + const float mat[4][4], + const bool do_keys, + const bool do_props, + const float unit_scale) { Nurb *nu; BPoint *bp; @@ -5174,13 +5177,13 @@ void BKE_curve_transform_ex( } } -void BKE_curve_transform(Curve *cu, float mat[4][4], const bool do_keys, const bool do_props) +void BKE_curve_transform(Curve *cu, const float mat[4][4], const bool do_keys, const bool do_props) { float unit_scale = mat4_to_scale(mat); BKE_curve_transform_ex(cu, mat, do_keys, do_props, unit_scale); } -void BKE_curve_translate(Curve *cu, float offset[3], const bool do_keys) +void BKE_curve_translate(Curve *cu, const float offset[3], const bool do_keys) { ListBase *nurb_lb = BKE_curve_nurbs_get(cu); Nurb *nu; diff --git a/source/blender/blenkernel/intern/gpencil_geom.c b/source/blender/blenkernel/intern/gpencil_geom.c index 53bfd3aa8ff..14eb6bb4f4c 100644 --- a/source/blender/blenkernel/intern/gpencil_geom.c +++ b/source/blender/blenkernel/intern/gpencil_geom.c @@ -2427,7 +2427,7 @@ void BKE_gpencil_convert_mesh(Main *bmain, * \param gpd: Grease pencil data-block * \param mat: Transformation matrix */ -void BKE_gpencil_transform(bGPdata *gpd, float mat[4][4]) +void BKE_gpencil_transform(bGPdata *gpd, const float mat[4][4]) { if (gpd == NULL) { return; diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index 8820434cbcf..4d523ffa2e0 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -672,7 +672,7 @@ void BKE_lattice_center_bounds(Lattice *lt, float cent[3]) mid_v3_v3v3(cent, min, max); } -void BKE_lattice_transform(Lattice *lt, float mat[4][4], bool do_keys) +void BKE_lattice_transform(Lattice *lt, const float mat[4][4], bool do_keys) { BPoint *bp = lt->def; int i = lt->pntsu * lt->pntsv * lt->pntsw; @@ -694,7 +694,7 @@ void BKE_lattice_transform(Lattice *lt, float mat[4][4], bool do_keys) } } -void BKE_lattice_translate(Lattice *lt, float offset[3], bool do_keys) +void BKE_lattice_translate(Lattice *lt, const float offset[3], bool do_keys) { int i, numVerts; diff --git a/source/blender/blenkernel/intern/mball_tessellate.c b/source/blender/blenkernel/intern/mball_tessellate.c index ad178e76ef6..72b99bea0f4 100644 --- a/source/blender/blenkernel/intern/mball_tessellate.c +++ b/source/blender/blenkernel/intern/mball_tessellate.c @@ -315,7 +315,7 @@ static float densfunc(const MetaElem *ball, float x, float y, float z) float dist2; float dvec[3] = {x, y, z}; - mul_m4_v3((float(*)[4])ball->imat, dvec); + mul_m4_v3((const float(*)[4])ball->imat, dvec); switch (ball->type) { case MB_BALL: diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 48baedadd73..048af022adb 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -1305,7 +1305,7 @@ bool BKE_mesh_minmax(const Mesh *me, float r_min[3], float r_max[3]) return (me->totvert != 0); } -void BKE_mesh_transform(Mesh *me, float mat[4][4], bool do_keys) +void BKE_mesh_transform(Mesh *me, const float mat[4][4], bool do_keys) { int i; MVert *mvert = me->mvert; diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index f77c79a2be7..fe559d2a44e 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2344,7 +2344,7 @@ void BKE_object_tfm_copy(Object *object_dst, const Object *object_src) #undef TFMCPY4D } -void BKE_object_to_mat3(Object *ob, float mat[3][3]) /* no parent */ +void BKE_object_to_mat3(Object *ob, float r_mat[3][3]) /* no parent */ { float smat[3][3]; float rmat[3][3]; @@ -2355,38 +2355,38 @@ void BKE_object_to_mat3(Object *ob, float mat[3][3]) /* no parent */ /* rot */ BKE_object_rot_to_mat3(ob, rmat, true); - mul_m3_m3m3(mat, rmat, smat); + mul_m3_m3m3(r_mat, rmat, smat); } -void BKE_object_to_mat4(Object *ob, float mat[4][4]) +void BKE_object_to_mat4(Object *ob, float r_mat[4][4]) { float tmat[3][3]; BKE_object_to_mat3(ob, tmat); - copy_m4_m3(mat, tmat); + copy_m4_m3(r_mat, tmat); - add_v3_v3v3(mat[3], ob->loc, ob->dloc); + add_v3_v3v3(r_mat[3], ob->loc, ob->dloc); } -void BKE_object_matrix_local_get(struct Object *ob, float mat[4][4]) +void BKE_object_matrix_local_get(struct Object *ob, float r_mat[4][4]) { if (ob->parent) { float par_imat[4][4]; BKE_object_get_parent_matrix(ob, ob->parent, par_imat); invert_m4(par_imat); - mul_m4_m4m4(mat, par_imat, ob->obmat); + mul_m4_m4m4(r_mat, par_imat, ob->obmat); } else { - copy_m4_m4(mat, ob->obmat); + copy_m4_m4(r_mat, ob->obmat); } } /** * \return success if \a mat is set. */ -static bool ob_parcurve(Object *ob, Object *par, float mat[4][4]) +static bool ob_parcurve(Object *ob, Object *par, float r_mat[4][4]) { Curve *cu = par->data; float vec[4], dir[3], quat[4], radius, ctime; @@ -2420,34 +2420,34 @@ static bool ob_parcurve(Object *ob, Object *par, float mat[4][4]) } CLAMP(ctime, 0.0f, 1.0f); - unit_m4(mat); + unit_m4(r_mat); /* vec: 4 items! */ if (where_on_path(par, ctime, vec, dir, (cu->flag & CU_FOLLOW) ? quat : NULL, &radius, NULL)) { if (cu->flag & CU_FOLLOW) { quat_apply_track(quat, ob->trackflag, ob->upflag); normalize_qt(quat); - quat_to_mat4(mat, quat); + quat_to_mat4(r_mat, quat); } if (cu->flag & CU_PATH_RADIUS) { float tmat[4][4], rmat[4][4]; scale_m4_fl(tmat, radius); - mul_m4_m4m4(rmat, tmat, mat); - copy_m4_m4(mat, rmat); + mul_m4_m4m4(rmat, tmat, r_mat); + copy_m4_m4(r_mat, rmat); } - copy_v3_v3(mat[3], vec); + copy_v3_v3(r_mat[3], vec); } return true; } -static void ob_parbone(Object *ob, Object *par, float mat[4][4]) +static void ob_parbone(Object *ob, Object *par, float r_mat[4][4]) { bPoseChannel *pchan; float vec[3]; if (par->type != OB_ARMATURE) { - unit_m4(mat); + unit_m4(r_mat); return; } @@ -2456,7 +2456,7 @@ static void ob_parbone(Object *ob, Object *par, float mat[4][4]) if (!pchan || !pchan->bone) { CLOG_ERROR( &LOG, "Object %s with Bone parent: bone %s doesn't exist", ob->id.name + 2, ob->parsubstr); - unit_m4(mat); + unit_m4(r_mat); return; } @@ -2464,15 +2464,15 @@ static void ob_parbone(Object *ob, Object *par, float mat[4][4]) if (pchan->bone->flag & BONE_RELATIVE_PARENTING) { /* the new option uses the root - expected behavior, but differs from old... */ /* XXX check on version patching? */ - copy_m4_m4(mat, pchan->chan_mat); + copy_m4_m4(r_mat, pchan->chan_mat); } else { - copy_m4_m4(mat, pchan->pose_mat); + copy_m4_m4(r_mat, pchan->pose_mat); /* but for backwards compatibility, the child has to move to the tail */ - copy_v3_v3(vec, mat[1]); + copy_v3_v3(vec, r_mat[1]); mul_v3_fl(vec, pchan->bone->length); - add_v3_v3(mat[3], vec); + add_v3_v3(r_mat[3], vec); } } @@ -2594,7 +2594,7 @@ static void give_parvert(Object *par, int nr, float vec[3]) } } -static void ob_parvert3(Object *ob, Object *par, float mat[4][4]) +static void ob_parvert3(Object *ob, Object *par, float r_mat[4][4]) { /* in local ob space */ @@ -2607,16 +2607,16 @@ static void ob_parvert3(Object *ob, Object *par, float mat[4][4]) tri_to_quat(q, v1, v2, v3); quat_to_mat3(cmat, q); - copy_m4_m3(mat, cmat); + copy_m4_m3(r_mat, cmat); - mid_v3_v3v3v3(mat[3], v1, v2, v3); + mid_v3_v3v3v3(r_mat[3], v1, v2, v3); } else { - unit_m4(mat); + unit_m4(r_mat); } } -void BKE_object_get_parent_matrix(Object *ob, Object *par, float parentmat[4][4]) +void BKE_object_get_parent_matrix(Object *ob, Object *par, float r_parentmat[4][4]) { float tmat[4][4]; float vec[3]; @@ -2632,31 +2632,31 @@ void BKE_object_get_parent_matrix(Object *ob, Object *par, float parentmat[4][4] } if (ok) { - mul_m4_m4m4(parentmat, par->obmat, tmat); + mul_m4_m4m4(r_parentmat, par->obmat, tmat); } else { - copy_m4_m4(parentmat, par->obmat); + copy_m4_m4(r_parentmat, par->obmat); } break; case PARBONE: ob_parbone(ob, par, tmat); - mul_m4_m4m4(parentmat, par->obmat, tmat); + mul_m4_m4m4(r_parentmat, par->obmat, tmat); break; case PARVERT1: - unit_m4(parentmat); + unit_m4(r_parentmat); give_parvert(par, ob->par1, vec); - mul_v3_m4v3(parentmat[3], par->obmat, vec); + mul_v3_m4v3(r_parentmat[3], par->obmat, vec); break; case PARVERT3: ob_parvert3(ob, par, tmat); - mul_m4_m4m4(parentmat, par->obmat, tmat); + mul_m4_m4m4(r_parentmat, par->obmat, tmat); break; case PARSKEL: - copy_m4_m4(parentmat, par->obmat); + copy_m4_m4(r_parentmat, par->obmat); break; } } @@ -2672,7 +2672,7 @@ void BKE_object_get_parent_matrix(Object *ob, Object *par, float parentmat[4][4] * (without its own matrix applied) */ static void solve_parenting( - Object *ob, Object *par, float obmat[4][4], float r_originmat[3][3], const bool set_origin) + Object *ob, Object *par, const bool set_origin, float r_obmat[4][4], float r_originmat[3][3]) { float totmat[4][4]; float tmat[4][4]; @@ -2684,7 +2684,7 @@ static void solve_parenting( /* total */ mul_m4_m4m4(tmat, totmat, ob->parentinv); - mul_m4_m4m4(obmat, tmat, locmat); + mul_m4_m4m4(r_obmat, tmat, locmat); if (r_originmat) { /* usable originmat */ @@ -2714,7 +2714,7 @@ static void object_where_is_calc_ex(Depsgraph *depsgraph, Object *par = ob->parent; /* calculate parent matrix */ - solve_parenting(ob, par, ob->obmat, r_originmat, true); + solve_parenting(ob, par, true, ob->obmat, r_originmat); } else { BKE_object_to_mat4(ob, ob->obmat); @@ -2757,14 +2757,14 @@ void BKE_object_where_is_calc_time(Depsgraph *depsgraph, Scene *scene, Object *o * constraints -- assume dependencies are already solved by depsgraph. * no changes to object and it's parent would be done. * used for bundles orientation in 3d space relative to parented blender camera */ -void BKE_object_where_is_calc_mat4(Object *ob, float obmat[4][4]) +void BKE_object_where_is_calc_mat4(Object *ob, float r_obmat[4][4]) { if (ob->parent) { Object *par = ob->parent; - solve_parenting(ob, par, obmat, NULL, false); + solve_parenting(ob, par, false, r_obmat, NULL); } else { - BKE_object_to_mat4(ob, obmat); + BKE_object_to_mat4(ob, r_obmat); } } @@ -2825,8 +2825,11 @@ void BKE_object_workob_calc_parent(Depsgraph *depsgraph, Scene *scene, Object *o * \param use_compat: true to ensure that rotations are set using the * min difference between the old and new orientation. */ -void BKE_object_apply_mat4_ex( - Object *ob, float mat[4][4], Object *parent, float parentinv[4][4], const bool use_compat) +void BKE_object_apply_mat4_ex(Object *ob, + const float mat[4][4], + Object *parent, + const float parentinv[4][4], + const bool use_compat) { /* see BKE_pchan_apply_mat4() for the equivalent 'pchan' function */ @@ -2867,7 +2870,7 @@ void BKE_object_apply_mat4_ex( /* XXX: should be removed after COW operators port to use BKE_object_apply_mat4_ex directly */ void BKE_object_apply_mat4(Object *ob, - float mat[4][4], + const float mat[4][4], const bool use_compat, const bool use_parent) { @@ -2917,7 +2920,10 @@ void BKE_boundbox_calc_size_aabb(const BoundBox *bb, float r_size[3]) r_size[2] = 0.5f * fabsf(bb->vec[0][2] - bb->vec[1][2]); } -void BKE_boundbox_minmax(const BoundBox *bb, float obmat[4][4], float r_min[3], float r_max[3]) +void BKE_boundbox_minmax(const BoundBox *bb, + const float obmat[4][4], + float r_min[3], + float r_max[3]) { int i; for (i = 0; i < 8; i++) { @@ -3009,7 +3015,7 @@ void BKE_object_boundbox_calc_from_mesh(struct Object *ob, struct Mesh *me_eval) * \warning Setting dimensions is prone to feedback loops in evaluation. * \{ */ -void BKE_object_dimensions_get(Object *ob, float vec[3]) +void BKE_object_dimensions_get(Object *ob, float r_vec[3]) { BoundBox *bb = NULL; @@ -3019,12 +3025,12 @@ void BKE_object_dimensions_get(Object *ob, float vec[3]) mat4_to_size(scale, ob->obmat); - vec[0] = fabsf(scale[0]) * (bb->vec[4][0] - bb->vec[0][0]); - vec[1] = fabsf(scale[1]) * (bb->vec[2][1] - bb->vec[0][1]); - vec[2] = fabsf(scale[2]) * (bb->vec[1][2] - bb->vec[0][2]); + r_vec[0] = fabsf(scale[0]) * (bb->vec[4][0] - bb->vec[0][0]); + r_vec[1] = fabsf(scale[1]) * (bb->vec[2][1] - bb->vec[0][1]); + r_vec[2] = fabsf(scale[2]) * (bb->vec[1][2] - bb->vec[0][2]); } else { - zero_v3(vec); + zero_v3(r_vec); } } @@ -3293,7 +3299,7 @@ bool BKE_object_minmax_dupli(Depsgraph *depsgraph, } void BKE_object_foreach_display_point(Object *ob, - float obmat[4][4], + const float obmat[4][4], void (*func_cb)(const float[3], void *), void *user_data) { |