Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2013-07-27 18:44:52 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-07-27 18:44:52 +0400
commitaaa284f5055cc8197b48325b9ce98ecfa3d770fc (patch)
tree5b5939ad862580802975a77b031d0274712bce4d
parentd7ff7ad3e9da1a7fd322e37382d4c28f7b84b036 (diff)
cleanup ED_view3d_from_m4() ambiguity with NULL checks, now assert if dist is set up but ofs.
also small optimization for matrix conversion.
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index a361d1419d4..7b8c197f3e6 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -4200,28 +4200,27 @@ float ED_view3d_offset_distance(float mat[4][4], const float ofs[3], const float
*/
void ED_view3d_from_m4(float mat[4][4], float ofs[3], float quat[4], float *dist)
{
+ float nmat[3][3];
+
+ /* dist depends on offset */
+ BLI_assert(dist == NULL || ofs != NULL);
+
+ copy_m3_m4(nmat, mat);
+ normalize_m3(nmat);
+
/* Offset */
if (ofs)
negate_v3_v3(ofs, mat[3]);
/* Quat */
if (quat) {
- float imat[4][4];
- normalize_m4_m4(imat, mat);
- invert_m4(imat);
- mat4_to_quat(quat, imat);
+ float imat[3][3];
+ invert_m3_m3(imat, nmat);
+ mat3_to_quat(quat, imat);
}
- if (dist) {
- float nmat[3][3];
- float vec[3];
-
- vec[0] = 0.0f;
- vec[1] = 0.0f;
- vec[2] = -(*dist);
-
- copy_m3_m4(nmat, mat);
- normalize_m3(nmat);
+ if (ofs && dist) {
+ float vec[3] = {0.0f, 0.0f, -(*dist)};
mul_m3_v3(nmat, vec);
sub_v3_v3(ofs, vec);