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>2019-02-25 16:58:35 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-02-25 17:37:49 +0300
commit86c0ee80209cdd52e4b360ffcf854144922ac2e6 (patch)
tree722f7ddcfaa702cf834d4fe2b8d63f1a2638398c /source/blender/blenkernel/intern/scene.c
parent213ac7b1aceea3b5a210e86a07402d4415c9a6b6 (diff)
3D View: support for editing cursor rotation
Add buttons for editing the cursor rotation as well as rotation modes, similar to object and pose bones.
Diffstat (limited to 'source/blender/blenkernel/intern/scene.c')
-rw-r--r--source/blender/blenkernel/intern/scene.c99
1 files changed, 98 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index b055c3695bc..c73c6ef6ac2 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -547,7 +547,10 @@ void BKE_scene_init(Scene *sce)
BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(sce, id));
- unit_qt(sce->cursor.rotation);
+
+ sce->cursor.rotation_mode = ROT_MODE_XYZ;
+ sce->cursor.rotation_quaternion[0] = 1.0f;
+ sce->cursor.rotation_axis[1] = 1.0f;
sce->r.mode = R_OSA;
sce->r.cfra = 1;
@@ -2242,3 +2245,97 @@ int BKE_scene_transform_orientation_get_index(
}
/** \} */
+
+
+/* -------------------------------------------------------------------- */
+/** \name Scene Cursor Rotation
+ *
+ * Matches #BKE_object_rot_to_mat3 and #BKE_object_mat3_to_rot.
+ * \{ */
+
+void BKE_scene_cursor_rot_to_mat3(const View3DCursor *cursor, float mat[3][3])
+{
+ if (cursor->rotation_mode > 0) {
+ eulO_to_mat3(mat, cursor->rotation_euler, cursor->rotation_mode);
+ }
+ else if (cursor->rotation_mode == ROT_MODE_AXISANGLE) {
+ axis_angle_to_mat3(mat, cursor->rotation_axis, cursor->rotation_angle);
+ }
+ else {
+ float tquat[4];
+ normalize_qt_qt(tquat, cursor->rotation_quaternion);
+ quat_to_mat3(mat, tquat);
+ }
+}
+
+void BKE_scene_cursor_rot_to_quat(const View3DCursor *cursor, float quat[4])
+{
+ if (cursor->rotation_mode > 0) {
+ eulO_to_quat(quat, cursor->rotation_euler, cursor->rotation_mode);
+ }
+ else if (cursor->rotation_mode == ROT_MODE_AXISANGLE) {
+ axis_angle_to_quat(quat, cursor->rotation_axis, cursor->rotation_angle);
+ }
+ else {
+ normalize_qt_qt(quat, cursor->rotation_quaternion);
+ }
+}
+
+void BKE_scene_cursor_mat3_to_rot(View3DCursor *cursor, const float mat[3][3], bool use_compat)
+{
+ BLI_ASSERT_UNIT_M3(mat);
+
+ switch (cursor->rotation_mode) {
+ case ROT_MODE_QUAT:
+ {
+ mat3_normalized_to_quat(cursor->rotation_quaternion, mat);
+ break;
+ }
+ case ROT_MODE_AXISANGLE:
+ {
+ mat3_to_axis_angle(cursor->rotation_axis, &cursor->rotation_angle, mat);
+ break;
+ }
+ default:
+ {
+ if (use_compat) {
+ mat3_to_compatible_eulO(cursor->rotation_euler, cursor->rotation_euler, cursor->rotation_mode, mat);
+ }
+ else {
+ mat3_to_eulO(cursor->rotation_euler, cursor->rotation_mode, mat);
+ }
+ break;
+ }
+ }
+}
+
+void BKE_scene_cursor_quat_to_rot(View3DCursor *cursor, const float quat[4], bool use_compat)
+{
+ BLI_ASSERT_UNIT_QUAT(quat);
+
+ switch (cursor->rotation_mode) {
+ case ROT_MODE_QUAT:
+ {
+ copy_qt_qt(cursor->rotation_quaternion, quat);
+ break;
+ }
+ case ROT_MODE_AXISANGLE:
+ {
+ quat_to_axis_angle(cursor->rotation_axis, &cursor->rotation_angle, quat);
+ break;
+ }
+ default:
+ {
+ if (use_compat) {
+ quat_to_compatible_eulO(cursor->rotation_euler, cursor->rotation_euler, cursor->rotation_mode, quat);
+ }
+ else {
+ quat_to_eulO(cursor->rotation_euler, cursor->rotation_mode, quat);
+ }
+ break;
+ }
+ }
+}
+
+
+/** \} */