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>2018-05-06 19:35:39 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-05-06 19:35:39 +0300
commita3e74acd9ee2879898389cb9d33950f44494932e (patch)
tree7d821b4c8b2076542e12b0afef1c7950570bb291 /source/blender/editors/object
parentc769b1a5533bb0fcf04452cde4d81dd77f7ae03b (diff)
parent046904e3fc6d5a9b10215d97ffc71f08bce37a41 (diff)
Merge branch 'master' into blender2.8
Diffstat (limited to 'source/blender/editors/object')
-rw-r--r--source/blender/editors/object/object_add.c67
1 files changed, 33 insertions, 34 deletions
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index 7327c563104..c2934b916d0 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -170,45 +170,44 @@ void ED_object_location_from_view(bContext *C, float loc[3])
copy_v3_v3(loc, cursor);
}
-void ED_object_rotation_from_view(bContext *C, float rot[3], const char align_axis)
+void ED_object_rotation_from_quat(float rot[3], const float viewquat[4], const char align_axis)
{
- RegionView3D *rv3d = CTX_wm_region_view3d(C);
-
BLI_assert(align_axis >= 'X' && align_axis <= 'Z');
- if (rv3d) {
- float quat[4];
-
- switch (align_axis) {
- case 'X':
- {
- float quat_y[4];
- axis_angle_to_quat(quat_y, rv3d->viewinv[1], -M_PI_2);
- mul_qt_qtqt(quat, rv3d->viewquat, quat_y);
- quat[0] = -quat[0];
-
- quat_to_eul(rot, quat);
- break;
- }
- case 'Y':
- {
- copy_qt_qt(quat, rv3d->viewquat);
- quat[0] = -quat[0];
-
- quat_to_eul(rot, quat);
- rot[0] -= (float)M_PI_2;
- break;
- }
- case 'Z':
- {
- copy_qt_qt(quat, rv3d->viewquat);
- quat[0] = -quat[0];
-
- quat_to_eul(rot, quat);
- break;
- }
+ switch (align_axis) {
+ case 'X':
+ {
+ /* Same as 'rv3d->viewinv[1]' */
+ float axis_y[4] = {0.0f, 1.0f, 0.0f};
+ float quat_y[4], quat[4];
+ axis_angle_to_quat(quat_y, axis_y, M_PI_2);
+ mul_qt_qtqt(quat, viewquat, quat_y);
+ quat_to_eul(rot, quat);
+ break;
+ }
+ case 'Y':
+ {
+ quat_to_eul(rot, viewquat);
+ rot[0] -= (float)M_PI_2;
+ break;
+ }
+ case 'Z':
+ {
+ quat_to_eul(rot, viewquat);
+ break;
}
+ }
+}
+void ED_object_rotation_from_view(bContext *C, float rot[3], const char align_axis)
+{
+ RegionView3D *rv3d = CTX_wm_region_view3d(C);
+ BLI_assert(align_axis >= 'X' && align_axis <= 'Z');
+ if (rv3d) {
+ float viewquat[4];
+ copy_qt_qt(viewquat, rv3d->viewquat);
+ viewquat[0] *= -1.0f;
+ ED_object_rotation_from_quat(rot, viewquat, align_axis);
}
else {
zero_v3(rot);