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>2011-05-23 06:23:03 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-05-23 06:23:03 +0400
commit0d26333eb502d9a25e0b82aa5b5276b4767a08f0 (patch)
treef8f9d28e53e3ad1d19445f6836c74c41b042250f /source/blender/editors/space_view3d/view3d_edit.c
parentbf65ed94472ea66983081bdbacac5d1f11feb68c (diff)
fix view3d_persp_mat4, which gave incorrect translation, rename to ED_view3d_to_m4. added doxygen docs.
Diffstat (limited to 'source/blender/editors/space_view3d/view3d_edit.c')
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c40
1 files changed, 13 insertions, 27 deletions
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index fd9658a9b88..f039a3a7571 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -3523,25 +3523,6 @@ void viewmoveNDOF(Scene *scene, ARegion *ar, View3D *v3d, int UNUSED(mode))
}
#endif // if 0, unused NDof code
-/* give a 4x4 matrix from a perspective view, only needs viewquat, ofs and dist
- * basically the same as...
- * rv3d->persp= RV3D_PERSP
- * setviewmatrixview3d(scene, v3d, rv3d);
- * setcameratoview3d(v3d, rv3d, v3d->camera);
- * ...but less of a hassle
- * */
-void view3d_persp_mat4(RegionView3D *rv3d, float mat[][4])
-{
- float qt[4], dvec[3];
- copy_qt_qt(qt, rv3d->viewquat);
- qt[0]= -qt[0];
- quat_to_mat4(mat, qt);
- mat[3][2] -= rv3d->dist;
- translate_m4(mat, rv3d->ofs[0], rv3d->ofs[1], rv3d->ofs[2]);
- mul_v3_v3fl(dvec, mat[2], -rv3d->dist);
- sub_v3_v3v3(mat[3], dvec, rv3d->ofs);
-}
-
/* Gets the view trasnformation from a camera
* currently dosnt take camzoom into account
@@ -3577,6 +3558,16 @@ void ED_view3d_from_m4(float mat[][4], float ofs[3], float quat[4], float *dist)
}
}
+void ED_view3d_to_m4(float mat[][4], const float ofs[3], const float quat[4], const float dist)
+{
+ float iviewquat[4]= {-quat[0], quat[1], quat[2], quat[3]};
+ float dvec[3]= {0.0f, 0.0f, dist};
+
+ quat_to_mat4(mat, iviewquat);
+ mul_mat3_m4_v3(mat, dvec);
+ sub_v3_v3v3(mat[3], dvec, ofs);
+}
+
/* object -> view */
void ED_view3d_from_object(Object *ob, float ofs[3], float quat[4], float *dist, float *lens)
@@ -3591,12 +3582,7 @@ void ED_view3d_from_object(Object *ob, float ofs[3], float quat[4], float *dist,
/* view -> object */
void ED_view3d_to_object(Object *ob, const float ofs[3], const float quat[4], const float dist)
{
- float mat4[4][4];
- float dvec[3]= {0.0f, 0.0f, dist};
- float iviewquat[4]= {-quat[0], quat[1], quat[2], quat[3]};
-
- quat_to_mat4(mat4, iviewquat);
- mul_mat3_m4_v3(mat4, dvec);
- sub_v3_v3v3(mat4[3], dvec, ofs);
- object_apply_mat4(ob, mat4, TRUE, TRUE);
+ float mat[4][4];
+ ED_view3d_to_m4(mat, ofs, quat, dist);
+ object_apply_mat4(ob, mat, TRUE, TRUE);
}