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:
-rw-r--r--source/blender/editors/include/ED_manipulator_library.h14
-rw-r--r--source/blender/editors/manipulator_library/arrow3d_manipulator.c75
-rw-r--r--source/blender/editors/manipulator_library/dial3d_manipulator.c38
-rw-r--r--source/blender/editors/manipulator_library/grab3d_manipulator.c38
-rw-r--r--source/blender/editors/manipulator_library/primitive3d_manipulator.c66
-rw-r--r--source/blender/editors/mesh/editmesh_bisect.c16
-rw-r--r--source/blender/editors/mesh/editmesh_extrude.c20
-rw-r--r--source/blender/editors/space_node/node_manipulators.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_manipulators.c24
-rw-r--r--source/blender/editors/transform/transform_manipulator.c21
-rw-r--r--source/blender/editors/transform/transform_manipulator2d.c6
-rw-r--r--source/blender/windowmanager/manipulators/WM_manipulator_api.h16
-rw-r--r--source/blender/windowmanager/manipulators/intern/wm_manipulator.c58
13 files changed, 158 insertions, 236 deletions
diff --git a/source/blender/editors/include/ED_manipulator_library.h b/source/blender/editors/include/ED_manipulator_library.h
index 8d74ed941d0..421fdbf1212 100644
--- a/source/blender/editors/include/ED_manipulator_library.h
+++ b/source/blender/editors/include/ED_manipulator_library.h
@@ -77,8 +77,6 @@ enum {
};
void ED_manipulator_arrow3d_set_style(struct wmManipulator *mpr, int style);
-void ED_manipulator_arrow3d_set_direction(struct wmManipulator *mpr, const float direction[3]);
-void ED_manipulator_arrow3d_set_up_vector(struct wmManipulator *mpr, const float direction[3]);
void ED_manipulator_arrow3d_set_line_len(struct wmManipulator *mpr, const float len);
void ED_manipulator_arrow3d_set_ui_range(struct wmManipulator *mpr, const float min, const float max);
void ED_manipulator_arrow3d_set_range_fac(struct wmManipulator *mpr, const float range_fac);
@@ -117,11 +115,9 @@ enum {
};
void ED_manipulator_dial3d_set_style(struct wmManipulator *mpr, int style);
-void ED_manipulator_dial3d_set_up_vector(
- struct wmManipulator *mpr, const float direction[3]);
-void ED_manipulator_dial3d_set_start_vector(
- struct wmManipulator *mpr, const bool enabled, const float direction[3]);
-void ED_manipulator_dial3d_set_double_helper(
+void ED_manipulator_dial3d_set_use_start_y_axis(
+ struct wmManipulator *mpr, const bool enabled);
+void ED_manipulator_dial3d_set_use_double_helper(
struct wmManipulator *mpr, const bool enabled);
/* -------------------------------------------------------------------- */
@@ -132,8 +128,6 @@ enum {
};
void ED_manipulator_grab3d_set_style(struct wmManipulator *mpr, int style);
-void ED_manipulator_grab3d_set_up_vector(
- struct wmManipulator *mpr, const float direction[3]);
/* -------------------------------------------------------------------- */
@@ -144,8 +138,6 @@ enum {
};
void ED_manipulator_primitive3d_set_style(struct wmManipulator *mpr, int style);
-void ED_manipulator_primitive3d_set_direction(struct wmManipulator *mpr, const float direction[3]);
-void ED_manipulator_primitive3d_set_up_vector(struct wmManipulator *mpr, const float direction[3]);
#endif /* __ED_MANIPULATOR_LIBRARY_H__ */
diff --git a/source/blender/editors/manipulator_library/arrow3d_manipulator.c b/source/blender/editors/manipulator_library/arrow3d_manipulator.c
index 1d3cb281af1..7c688ea077f 100644
--- a/source/blender/editors/manipulator_library/arrow3d_manipulator.c
+++ b/source/blender/editors/manipulator_library/arrow3d_manipulator.c
@@ -32,6 +32,10 @@
*
* \brief Simple arrow manipulator which is dragged into a certain direction.
* The arrow head can have varying shapes, e.g. cone, box, etc.
+ *
+ * - `matrix[0]` is derived from Y and Z.
+ * - `matrix[1]` is 'up' for manipulator types that have an up.
+ * - `matrix[2]` is the arrow direction (for all arrowes).
*/
#include "BIF_gl.h"
@@ -81,8 +85,6 @@ typedef struct ArrowManipulator3D {
int flag;
float len; /* arrow line length */
- float direction[3];
- float up[3];
float aspect[2]; /* cone style only */
} ArrowManipulator3D;
@@ -94,7 +96,7 @@ static void manipulator_arrow_matrix_world_get(wmManipulator *mpr, float r_matri
ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr;
copy_m4_m4(r_matrix, arrow->manipulator.matrix);
- madd_v3_v3fl(r_matrix[3], arrow->direction, arrow->data.offset);
+ madd_v3_v3fl(r_matrix[3], arrow->manipulator.matrix[2], arrow->data.offset);
}
static void arrow_draw_geom(const ArrowManipulator3D *arrow, const bool select, const float color[4])
@@ -186,31 +188,17 @@ static void arrow_draw_geom(const ArrowManipulator3D *arrow, const bool select,
static void arrow_draw_intern(ArrowManipulator3D *arrow, const bool select, const bool highlight)
{
- const float up[3] = {0.0f, 0.0f, 1.0f};
float col[4];
- float rot[3][3];
- float mat[4][4];
float final_matrix[4][4];
manipulator_color_get(&arrow->manipulator, highlight, col);
manipulator_arrow_matrix_world_get(&arrow->manipulator, final_matrix);
- if (arrow->flag & ARROW_UP_VECTOR_SET) {
- copy_v3_v3(rot[2], arrow->direction);
- copy_v3_v3(rot[1], arrow->up);
- cross_v3_v3v3(rot[0], arrow->up, arrow->direction);
- }
- else {
- rotation_between_vecs_to_mat3(rot, up, arrow->direction);
- }
- copy_m4_m3(mat, rot);
- copy_v3_v3(mat[3], final_matrix[3]);
- mul_mat3_m4_fl(mat, arrow->manipulator.scale);
+ mul_mat3_m4_fl(final_matrix, arrow->manipulator.scale);
+ mul_m4_m4m4(final_matrix, final_matrix, arrow->manipulator.matrix_offset);
gpuPushMatrix();
- gpuMultMatrix(mat);
- gpuMultMatrix(arrow->manipulator.matrix_offset);
-
+ gpuMultMatrix(final_matrix);
glEnable(GL_BLEND);
arrow_draw_geom(arrow, select, col);
glDisable(GL_BLEND);
@@ -219,13 +207,13 @@ static void arrow_draw_intern(ArrowManipulator3D *arrow, const bool select, cons
if (arrow->manipulator.interaction_data) {
ManipulatorInteraction *inter = arrow->manipulator.interaction_data;
+ float offset_matrix[4][4];
- copy_m4_m3(mat, rot);
- copy_v3_v3(mat[3], inter->init_matrix[3]);
- mul_mat3_m4_fl(mat, inter->init_scale);
+ copy_m4_m4(offset_matrix, inter->init_matrix);
+ mul_mat3_m4_fl(offset_matrix, inter->init_scale);
gpuPushMatrix();
- gpuMultMatrix(mat);
+ gpuMultMatrix(offset_matrix);
gpuMultMatrix(arrow->manipulator.matrix_offset);
glEnable(GL_BLEND);
@@ -271,7 +259,7 @@ static void manipulator_arrow_modal(bContext *C, wmManipulator *mpr, const wmEve
copy_v3_v3(orig_origin, inter->init_matrix[3]);
orig_origin[3] = 1.0f;
- add_v3_v3v3(offset, orig_origin, arrow->direction);
+ add_v3_v3v3(offset, orig_origin, arrow->manipulator.matrix[2]);
offset[3] = 1.0f;
/* calculate view vector */
@@ -285,7 +273,7 @@ static void manipulator_arrow_modal(bContext *C, wmManipulator *mpr, const wmEve
/* first determine if view vector is really close to the direction. If it is, we use
* vertical movement to determine offset, just like transform system does */
- if (RAD2DEG(acos(dot_v3v3(viewvec, arrow->direction))) > 5.0f) {
+ if (RAD2DEG(acos(dot_v3v3(viewvec, arrow->manipulator.matrix[2]))) > 5.0f) {
/* multiply to projection space */
mul_m4_v4(rv3d->persmat, orig_origin);
mul_v4_fl(orig_origin, 1.0f / orig_origin[3]);
@@ -330,11 +318,11 @@ static void manipulator_arrow_modal(bContext *C, wmManipulator *mpr, const wmEve
cross_v3_v3v3(plane, tangent, viewvec);
const float plane_offset = dot_v3v3(plane, offset);
- const float plane_dir = dot_v3v3(plane, arrow->direction);
+ const float plane_dir = dot_v3v3(plane, arrow->manipulator.matrix[2]);
const float fac = (plane_dir != 0.0f) ? (plane_offset / plane_dir) : 0.0f;
facdir = (fac < 0.0) ? -1.0 : 1.0;
if (isfinite(fac)) {
- mul_v3_v3fl(offset, arrow->direction, fac);
+ mul_v3_v3fl(offset, arrow->manipulator.matrix[2], fac);
}
}
else {
@@ -373,14 +361,11 @@ static void manipulator_arrow_setup(wmManipulator *mpr)
{
ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr;
- const float dir_default[3] = {0.0f, 0.0f, 1.0f};
-
arrow->manipulator.flag |= WM_MANIPULATOR_DRAW_ACTIVE;
arrow->style = -1;
arrow->len = 1.0f;
arrow->data.range_fac = 1.0f;
- copy_v3_v3(arrow->direction, dir_default);
}
static void manipulator_arrow_invoke(
@@ -449,34 +434,6 @@ void ED_manipulator_arrow3d_set_style(struct wmManipulator *mpr, int style)
}
/**
- * Define direction the arrow will point towards
- */
-void ED_manipulator_arrow3d_set_direction(wmManipulator *mpr, const float direction[3])
-{
- ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr;
-
- copy_v3_v3(arrow->direction, direction);
- normalize_v3(arrow->direction);
-}
-
-/**
- * Define up-direction of the arrow manipulator
- */
-void ED_manipulator_arrow3d_set_up_vector(wmManipulator *mpr, const float direction[3])
-{
- ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr;
-
- if (direction) {
- copy_v3_v3(arrow->up, direction);
- normalize_v3(arrow->up);
- arrow->flag |= ARROW_UP_VECTOR_SET;
- }
- else {
- arrow->flag &= ~ARROW_UP_VECTOR_SET;
- }
-}
-
-/**
* Define a custom arrow line length
*/
void ED_manipulator_arrow3d_set_line_len(wmManipulator *mpr, const float len)
diff --git a/source/blender/editors/manipulator_library/dial3d_manipulator.c b/source/blender/editors/manipulator_library/dial3d_manipulator.c
index 0aa3e929439..f4459b6bef2 100644
--- a/source/blender/editors/manipulator_library/dial3d_manipulator.c
+++ b/source/blender/editors/manipulator_library/dial3d_manipulator.c
@@ -32,6 +32,10 @@
*
* \brief Circle shaped manipulator for circular interaction.
* Currently no own handling, use with operator only.
+ *
+ * - `matrix[0]` is derived from Y and Z.
+ * - `matrix[1]` is 'up' when DialManipulator.use_start_y_axis is set.
+ * - `matrix[2]` is the axis the dial rotates around (all dials).
*/
#include "BIF_gl.h"
@@ -69,12 +73,10 @@ static void manipulator_dial_modal(bContext *C, wmManipulator *mpr, const wmEven
typedef struct DialManipulator {
wmManipulator manipulator;
int style;
- float direction[3];
/* Optional, for drawing the start of the pie based on on a vector
* instead of the initial mouse location. Only for display. */
- float start_direction[3];
- uint use_start_direction : 1;
+ uint use_start_y_axis : 1;
/* Show 2x helper angles (a mirrored segment).
* Use when the dial represents a plane. */
@@ -108,7 +110,7 @@ static void dial_calc_matrix(const DialManipulator *dial, float mat[4][4])
float rot[3][3];
const float up[3] = {0.0f, 0.0f, 1.0f};
- rotation_between_vecs_to_mat3(rot, up, dial->direction);
+ rotation_between_vecs_to_mat3(rot, up, dial->manipulator.matrix[2]);
copy_m4_m3(mat, rot);
copy_v3_v3(mat[3], dial->manipulator.matrix[3]);
mul_mat3_m4_fl(mat, dial->manipulator.scale);
@@ -209,7 +211,7 @@ static void dial_ghostarc_get_angles(
/* we might need to invert the direction of the angles */
float view_vec[3], axis_vec[3];
ED_view3d_global_to_vector(rv3d, dial->manipulator.matrix[3], view_vec);
- normalize_v3_v3(axis_vec, dial->direction);
+ normalize_v3_v3(axis_vec, dial->manipulator.matrix[2]);
float proj_outer_rel[3];
mul_v3_project_m4_v3(proj_outer_rel, mat, co_outer);
@@ -240,7 +242,7 @@ static void dial_ghostarc_get_angles(
sub_v3_v3(proj_mval_new_rel, dial->manipulator.matrix[3]);
/* Start direction from mouse or set by user */
- const float *proj_init_rel = dial->use_start_direction ? dial->start_direction : proj_mval_init_rel;
+ const float *proj_init_rel = dial->use_start_y_axis ? dial->manipulator.matrix[1] : proj_mval_init_rel;
/* return angles */
const float start = angle_wrap_rad(angle_signed_on_axis_v3v3_v3(proj_outer_rel, proj_init_rel, axis_vec));
@@ -411,7 +413,7 @@ static void manipulator_dial_setup(wmManipulator *mpr)
dial->style = -1;
/* defaults */
- copy_v3_v3(dial->direction, dir_default);
+ copy_v3_v3(dial->manipulator.matrix[2], dir_default);
}
static void manipulator_dial_invoke(
@@ -444,30 +446,14 @@ void ED_manipulator_dial3d_set_style(struct wmManipulator *mpr, int style)
dial->style = style;
}
-/**
- * Define up-direction of the dial manipulator
- */
-void ED_manipulator_dial3d_set_up_vector(wmManipulator *mpr, const float direction[3])
+void ED_manipulator_dial3d_set_use_start_y_axis(wmManipulator *mpr, const bool enabled)
{
ASSERT_TYPE_CHECK(mpr);
DialManipulator *dial = (DialManipulator *)mpr;
-
- copy_v3_v3(dial->direction, direction);
- normalize_v3(dial->direction);
-}
-
-void ED_manipulator_dial3d_set_start_vector(wmManipulator *mpr, const bool enabled, const float direction[3])
-{
- ASSERT_TYPE_CHECK(mpr);
- DialManipulator *dial = (DialManipulator *)mpr;
-
- dial->use_start_direction = enabled;
- if (enabled) {
- normalize_v3_v3(dial->start_direction, direction);
- }
+ dial->use_start_y_axis = enabled;
}
-void ED_manipulator_dial3d_set_double_helper(wmManipulator *mpr, const bool enabled)
+void ED_manipulator_dial3d_set_use_double_helper(wmManipulator *mpr, const bool enabled)
{
ASSERT_TYPE_CHECK(mpr);
DialManipulator *dial = (DialManipulator *)mpr;
diff --git a/source/blender/editors/manipulator_library/grab3d_manipulator.c b/source/blender/editors/manipulator_library/grab3d_manipulator.c
index e9c9f13cb19..c794c99160c 100644
--- a/source/blender/editors/manipulator_library/grab3d_manipulator.c
+++ b/source/blender/editors/manipulator_library/grab3d_manipulator.c
@@ -26,6 +26,11 @@
* 3D Manipulator
*
* \brief Simple manipulator to grab and translate.
+ *
+ * - `matrix[0]` is derived from Y and Z.
+ * - `matrix[1]` currently not used.
+ * - `matrix[2]` is the widget direction (for all manipulators).
+ *
*/
#include "BIF_gl.h"
@@ -60,7 +65,6 @@ static void manipulator_grab_modal(bContext *C, wmManipulator *mpr, const wmEven
typedef struct GrabManipulator {
wmManipulator manipulator;
int style;
- float direction[3];
} GrabManipulator;
typedef struct GrabInteraction {
@@ -79,18 +83,6 @@ typedef struct GrabInteraction {
#define DIAL_WIDTH 1.0f
#define DIAL_RESOLUTION 32
-
-static void grab_calc_matrix(const GrabManipulator *grab, float mat[4][4])
-{
- float rot[3][3];
- const float up[3] = {0.0f, 0.0f, 1.0f};
-
- rotation_between_vecs_to_mat3(rot, up, grab->direction);
- copy_m4_m3(mat, rot);
- copy_v3_v3(mat[3], grab->manipulator.matrix[3]);
- mul_mat3_m4_fl(mat, grab->manipulator.scale);
-}
-
/* -------------------------------------------------------------------- */
static void grab_geom_draw(
@@ -152,7 +144,8 @@ static void grab3d_draw_intern(
manipulator_color_get(&grab->manipulator, highlight, col);
- grab_calc_matrix(grab, mat);
+ copy_m4_m4(mat, grab->manipulator.matrix);
+ mul_mat3_m4_fl(mat, grab->manipulator.scale);
gpuPushMatrix();
if (grab->manipulator.interaction_data) {
@@ -221,12 +214,7 @@ static void manipulator_grab_setup(wmManipulator *mpr)
{
GrabManipulator *grab = (GrabManipulator *)mpr;
- const float dir_default[3] = {0.0f, 0.0f, 1.0f};
-
grab->style = -1;
-
- /* defaults */
- copy_v3_v3(grab->direction, dir_default);
}
static void manipulator_grab_invoke(
@@ -259,18 +247,6 @@ void ED_manipulator_grab3d_set_style(wmManipulator *mpr, int style)
grab->style = style;
}
-/**
- * Define up-direction of the grab3d manipulator
- */
-void ED_manipulator_grab3d_set_up_vector(wmManipulator *mpr, const float direction[3])
-{
- ASSERT_TYPE_CHECK(mpr);
- GrabManipulator *grab = (GrabManipulator *)mpr;
-
- copy_v3_v3(grab->direction, direction);
- normalize_v3(grab->direction);
-}
-
static void MANIPULATOR_WT_grab_3d(wmManipulatorType *wt)
{
/* identifiers */
diff --git a/source/blender/editors/manipulator_library/primitive3d_manipulator.c b/source/blender/editors/manipulator_library/primitive3d_manipulator.c
index d8dbf4a52d6..ba728145163 100644
--- a/source/blender/editors/manipulator_library/primitive3d_manipulator.c
+++ b/source/blender/editors/manipulator_library/primitive3d_manipulator.c
@@ -51,19 +51,9 @@
/* own includes */
#include "manipulator_library_intern.h"
-
-/* PrimitiveManipulator->flag */
-enum {
- PRIM_UP_VECTOR_SET = (1 << 0),
-};
-
typedef struct PrimitiveManipulator {
wmManipulator manipulator;
-
- float direction[3];
- float up[3];
int style;
- int flag;
} PrimitiveManipulator;
@@ -102,32 +92,20 @@ static void manipulator_primitive_draw_intern(
const bool highlight)
{
float col_inner[4], col_outer[4];
- float rot[3][3];
float mat[4][4];
BLI_assert(prim->style != -1);
- if (prim->flag & PRIM_UP_VECTOR_SET) {
- copy_v3_v3(rot[2], prim->direction);
- copy_v3_v3(rot[1], prim->up);
- cross_v3_v3v3(rot[0], prim->up, prim->direction);
- }
- else {
- const float up[3] = {0.0f, 0.0f, 1.0f};
- rotation_between_vecs_to_mat3(rot, up, prim->direction);
- }
+ manipulator_color_get(&prim->manipulator, highlight, col_outer);
+ copy_v4_v4(col_inner, col_outer);
+ col_inner[3] *= 0.5f;
- copy_m4_m3(mat, rot);
- copy_v3_v3(mat[3], prim->manipulator.matrix[3]);
+ copy_m4_m4(mat, prim->manipulator.matrix);
mul_mat3_m4_fl(mat, prim->manipulator.scale);
gpuPushMatrix();
gpuMultMatrix(mat);
- manipulator_color_get(&prim->manipulator, highlight, col_outer);
- copy_v4_v4(col_inner, col_outer);
- col_inner[3] *= 0.5f;
-
glEnable(GL_BLEND);
gpuMultMatrix(prim->manipulator.matrix_offset);
manipulator_primitive_draw_geom(col_inner, col_outer, prim->style);
@@ -142,8 +120,7 @@ static void manipulator_primitive_draw_intern(
copy_v3_fl(col_outer, 0.5f);
col_outer[3] = 0.8f;
- copy_m4_m3(mat, rot);
- copy_v3_v3(mat[3], inter->init_matrix[3]);
+ copy_m4_m4(mat, inter->init_matrix);
mul_mat3_m4_fl(mat, inter->init_scale);
gpuPushMatrix();
@@ -177,13 +154,8 @@ static void manipulator_primitive_setup(wmManipulator *mpr)
{
PrimitiveManipulator *prim = (PrimitiveManipulator *)mpr;
- const float dir_default[3] = {0.0f, 0.0f, 1.0f};
-
prim->manipulator.flag |= WM_MANIPULATOR_DRAW_ACTIVE;
prim->style = -1;
-
- /* defaults */
- copy_v3_v3(prim->direction, dir_default);
}
static void manipulator_primitive_invoke(
@@ -211,34 +183,6 @@ void ED_manipulator_primitive3d_set_style(struct wmManipulator *mpr, int style)
prim->style = style;
}
-/**
- * Define direction the primitive will point towards
- */
-void ED_manipulator_primitive3d_set_direction(wmManipulator *mpr, const float direction[3])
-{
- ASSERT_TYPE_CHECK(mpr);
- PrimitiveManipulator *prim = (PrimitiveManipulator *)mpr;
-
- normalize_v3_v3(prim->direction, direction);
-}
-
-/**
- * Define up-direction of the primitive manipulator
- */
-void ED_manipulator_primitive3d_set_up_vector(wmManipulator *mpr, const float direction[3])
-{
- ASSERT_TYPE_CHECK(mpr);
- PrimitiveManipulator *prim = (PrimitiveManipulator *)mpr;
-
- if (direction) {
- normalize_v3_v3(prim->up, direction);
- prim->flag |= PRIM_UP_VECTOR_SET;
- }
- else {
- prim->flag &= ~PRIM_UP_VECTOR_SET;
- }
-}
-
static void MANIPULATOR_WT_primitive_3d(wmManipulatorType *wt)
{
/* identifiers */
diff --git a/source/blender/editors/mesh/editmesh_bisect.c b/source/blender/editors/mesh/editmesh_bisect.c
index 2145af0df86..0f291937156 100644
--- a/source/blender/editors/mesh/editmesh_bisect.c
+++ b/source/blender/editors/mesh/editmesh_bisect.c
@@ -425,11 +425,11 @@ static void manipulator_mesh_bisect_update_from_op(ManipulatorGroup *man)
RNA_property_float_get_array(op->ptr, man->data.prop_plane_co, plane_co);
RNA_property_float_get_array(op->ptr, man->data.prop_plane_no, plane_no);
- WM_manipulator_set_origin(man->translate_z, plane_co);
- WM_manipulator_set_origin(man->translate_c, plane_co);
- WM_manipulator_set_origin(man->rotate_c, plane_co);
+ WM_manipulator_set_matrix_location(man->translate_z, plane_co);
+ WM_manipulator_set_matrix_location(man->translate_c, plane_co);
+ WM_manipulator_set_matrix_location(man->rotate_c, plane_co);
- ED_manipulator_arrow3d_set_direction(man->translate_z, plane_no);
+ WM_manipulator_set_matrix_rotation_from_z_axis(man->translate_z, plane_no);
WM_manipulator_set_scale(man->translate_c, 0.2);
@@ -442,14 +442,14 @@ static void manipulator_mesh_bisect_update_from_op(ManipulatorGroup *man)
project_plane_normalized_v3_v3v3(man->data.rotate_up, man->data.rotate_up, man->data.rotate_axis);
normalize_v3(man->data.rotate_up);
- ED_manipulator_grab3d_set_up_vector(man->translate_c, plane_no);
- ED_manipulator_dial3d_set_up_vector(man->rotate_c, man->data.rotate_axis);
+ WM_manipulator_set_matrix_rotation_from_z_axis(man->translate_c, plane_no);
float plane_no_cross[3];
cross_v3_v3v3(plane_no_cross, plane_no, man->data.rotate_axis);
- ED_manipulator_dial3d_set_start_vector(man->rotate_c, true, plane_no_cross);
- ED_manipulator_dial3d_set_double_helper(man->rotate_c, true);
+ WM_manipulator_set_matrix_offset_rotation_from_yz_axis(man->rotate_c, plane_no_cross, man->data.rotate_axis);
+ ED_manipulator_dial3d_set_use_start_y_axis(man->rotate_c, true);
+ ED_manipulator_dial3d_set_use_double_helper(man->rotate_c, true);
}
}
diff --git a/source/blender/editors/mesh/editmesh_extrude.c b/source/blender/editors/mesh/editmesh_extrude.c
index 5b02bf2df8a..e722b89e9b1 100644
--- a/source/blender/editors/mesh/editmesh_extrude.c
+++ b/source/blender/editors/mesh/editmesh_extrude.c
@@ -858,13 +858,13 @@ static void manipulator_mesh_spin_update_from_op(ManipulatorSpinGroup *man)
RNA_property_float_get_array(op->ptr, man->data.prop_axis_co, plane_co);
RNA_property_float_get_array(op->ptr, man->data.prop_axis_no, plane_no);
- WM_manipulator_set_origin(man->translate_z, plane_co);
- WM_manipulator_set_origin(man->translate_c, plane_co);
- WM_manipulator_set_origin(man->rotate_c, plane_co);
- WM_manipulator_set_origin(man->angle_z, plane_co);
+ WM_manipulator_set_matrix_location(man->translate_z, plane_co);
+ WM_manipulator_set_matrix_location(man->translate_c, plane_co);
+ WM_manipulator_set_matrix_location(man->rotate_c, plane_co);
+ WM_manipulator_set_matrix_location(man->angle_z, plane_co);
- ED_manipulator_arrow3d_set_direction(man->translate_z, plane_no);
- ED_manipulator_dial3d_set_up_vector(man->angle_z, plane_no);
+ WM_manipulator_set_matrix_rotation_from_z_axis(man->translate_z, plane_no);
+ WM_manipulator_set_matrix_rotation_from_z_axis(man->angle_z, plane_no);
WM_manipulator_set_scale(man->translate_c, 0.2);
@@ -877,12 +877,12 @@ static void manipulator_mesh_spin_update_from_op(ManipulatorSpinGroup *man)
project_plane_normalized_v3_v3v3(man->data.rotate_up, man->data.rotate_up, man->data.rotate_axis);
normalize_v3(man->data.rotate_up);
- ED_manipulator_grab3d_set_up_vector(man->translate_c, plane_no);
- ED_manipulator_dial3d_set_up_vector(man->rotate_c, man->data.rotate_axis);
+ WM_manipulator_set_matrix_rotation_from_z_axis(man->translate_c, plane_no);
+ WM_manipulator_set_matrix_rotation_from_yz_axis(man->rotate_c, man->data.rotate_axis, plane_no);
/* show the axis instead of mouse cursor */
- ED_manipulator_dial3d_set_start_vector(man->rotate_c, true, plane_no);
- ED_manipulator_dial3d_set_double_helper(man->rotate_c, true);
+ ED_manipulator_dial3d_set_use_start_y_axis(man->rotate_c, true);
+ ED_manipulator_dial3d_set_use_double_helper(man->rotate_c, true);
}
}
diff --git a/source/blender/editors/space_node/node_manipulators.c b/source/blender/editors/space_node/node_manipulators.c
index db183483143..f1369fae94e 100644
--- a/source/blender/editors/space_node/node_manipulators.c
+++ b/source/blender/editors/space_node/node_manipulators.c
@@ -88,7 +88,7 @@ static void WIDGETGROUP_node_transform_refresh(const bContext *C, wmManipulatorG
const float h = (ibuf->y > 0) ? ibuf->y : 64.0f;
ED_manipulator_cage2d_transform_set_dims(cage, w, h);
- WM_manipulator_set_origin(cage, origin);
+ WM_manipulator_set_matrix_location(cage, origin);
WM_manipulator_set_flag(cage, WM_MANIPULATOR_HIDDEN, false);
/* need to set property here for undo. TODO would prefer to do this in _init */
diff --git a/source/blender/editors/space_view3d/view3d_manipulators.c b/source/blender/editors/space_view3d/view3d_manipulators.c
index a1fbb9b2957..7119ca80581 100644
--- a/source/blender/editors/space_view3d/view3d_manipulators.c
+++ b/source/blender/editors/space_view3d/view3d_manipulators.c
@@ -97,8 +97,8 @@ static void WIDGETGROUP_lamp_refresh(const bContext *C, wmManipulatorGroup *mgro
negate_v3_v3(dir, ob->obmat[2]);
- ED_manipulator_arrow3d_set_direction(wwrapper->manipulator, dir);
- WM_manipulator_set_origin(wwrapper->manipulator, ob->obmat[3]);
+ WM_manipulator_set_matrix_rotation_from_z_axis(wwrapper->manipulator, dir);
+ WM_manipulator_set_matrix_location(wwrapper->manipulator, ob->obmat[3]);
/* need to set property here for undo. TODO would prefer to do this in _init */
PointerRNA lamp_ptr;
@@ -230,9 +230,8 @@ static void WIDGETGROUP_camera_refresh(const bContext *C, wmManipulatorGroup *mg
negate_v3_v3(dir, ob->obmat[2]);
if (ca->flag & CAM_SHOWLIMITS) {
- ED_manipulator_arrow3d_set_direction(camgroup->dop_dist, dir);
- ED_manipulator_arrow3d_set_up_vector(camgroup->dop_dist, ob->obmat[1]);
- WM_manipulator_set_origin(camgroup->dop_dist, ob->obmat[3]);
+ WM_manipulator_set_matrix_location(camgroup->dop_dist, ob->obmat[3]);
+ WM_manipulator_set_matrix_rotation_from_yz_axis(camgroup->dop_dist, ob->obmat[1], dir);
WM_manipulator_set_scale(camgroup->dop_dist, ca->drawsize);
WM_manipulator_set_flag(camgroup->dop_dist, WM_MANIPULATOR_HIDDEN, false);
@@ -272,11 +271,11 @@ static void WIDGETGROUP_camera_refresh(const bContext *C, wmManipulatorGroup *mg
asp[0] = (sensor_fit == CAMERA_SENSOR_FIT_HOR) ? 1.0 : aspx / aspy;
asp[1] = (sensor_fit == CAMERA_SENSOR_FIT_HOR) ? aspy / aspx : 1.0f;
- ED_manipulator_arrow3d_set_up_vector(widget, ob->obmat[1]);
- ED_manipulator_arrow3d_set_direction(widget, dir);
+ WM_manipulator_set_matrix_location(widget, ob->obmat[3]);
+ WM_manipulator_set_matrix_rotation_from_yz_axis(widget, ob->obmat[1], dir);
+
ED_manipulator_arrow3d_cone_set_aspect(widget, asp);
- WM_manipulator_set_origin(widget, ob->obmat[3]);
- WM_manipulator_set_offset(widget, offset);
+ WM_manipulator_set_matrix_offset_location(widget, offset);
WM_manipulator_set_scale(widget, drawsize);
/* need to set property here for undo. TODO would prefer to do this in _init */
@@ -342,10 +341,9 @@ static void WIDGETGROUP_forcefield_refresh(const bContext *C, wmManipulatorGroup
PointerRNA field_ptr;
RNA_pointer_create(&ob->id, &RNA_FieldSettings, pd, &field_ptr);
-
- ED_manipulator_arrow3d_set_direction(wwrapper->manipulator, ob->obmat[2]);
- WM_manipulator_set_origin(wwrapper->manipulator, ob->obmat[3]);
- WM_manipulator_set_offset(wwrapper->manipulator, ofs);
+ WM_manipulator_set_matrix_location(wwrapper->manipulator, ob->obmat[3]);
+ WM_manipulator_set_matrix_rotation_from_z_axis(wwrapper->manipulator, ob->obmat[2]);
+ WM_manipulator_set_matrix_offset_location(wwrapper->manipulator, ofs);
WM_manipulator_set_flag(wwrapper->manipulator, WM_MANIPULATOR_HIDDEN, false);
WM_manipulator_property_def_rna(wwrapper->manipulator, "offset", &field_ptr, "strength", -1);
}
diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c
index 748cfc288c0..38d41f6dc3a 100644
--- a/source/blender/editors/transform/transform_manipulator.c
+++ b/source/blender/editors/transform/transform_manipulator.c
@@ -1149,7 +1149,7 @@ static void manipulator_modal(
if (calc_manipulator_stats(C)) {
manipulator_prepare_mat(C, v3d, rv3d);
- WM_manipulator_set_origin(widget, rv3d->twmat[3]);
+ WM_manipulator_set_matrix_location(widget, rv3d->twmat[3]);
}
ED_region_tag_redraw(ar);
@@ -1199,7 +1199,7 @@ static void WIDGETGROUP_manipulator_setup(const bContext *UNUSED(C), wmManipulat
const float ofs_ax = 11.0f;
const float ofs[3] = {ofs_ax, ofs_ax, 0.0f};
WM_manipulator_set_scale(axis, 0.07f);
- WM_manipulator_set_offset(axis, ofs);
+ WM_manipulator_set_matrix_offset_location(axis, ofs);
break;
}
case MAN_AXIS_TRANS_C:
@@ -1260,7 +1260,7 @@ static void WIDGETGROUP_manipulator_refresh(const bContext *C, wmManipulatorGrou
const short axis_type = manipulator_get_axis_type(man, axis);
const int aidx_norm = manipulator_index_normalize(axis_idx);
- WM_manipulator_set_origin(axis, rv3d->twmat[3]);
+ WM_manipulator_set_matrix_location(axis, rv3d->twmat[3]);
switch (axis_idx) {
case MAN_AXIS_TRANS_X:
@@ -1275,15 +1275,15 @@ static void WIDGETGROUP_manipulator_refresh(const bContext *C, wmManipulatorGrou
manipulator_line_range(v3d, axis_type, &start_co[2], &len);
- ED_manipulator_arrow3d_set_direction(axis, rv3d->twmat[aidx_norm]);
+ WM_manipulator_set_matrix_rotation_from_z_axis(axis, rv3d->twmat[aidx_norm]);
ED_manipulator_arrow3d_set_line_len(axis, len);
- WM_manipulator_set_offset(axis, start_co);
+ WM_manipulator_set_matrix_offset_location(axis, start_co);
break;
}
case MAN_AXIS_ROT_X:
case MAN_AXIS_ROT_Y:
case MAN_AXIS_ROT_Z:
- ED_manipulator_dial3d_set_up_vector(axis, rv3d->twmat[aidx_norm]);
+ WM_manipulator_set_matrix_rotation_from_z_axis(axis, rv3d->twmat[aidx_norm]);
break;
case MAN_AXIS_TRANS_XY:
case MAN_AXIS_TRANS_YZ:
@@ -1291,9 +1291,12 @@ static void WIDGETGROUP_manipulator_refresh(const bContext *C, wmManipulatorGrou
case MAN_AXIS_SCALE_XY:
case MAN_AXIS_SCALE_YZ:
case MAN_AXIS_SCALE_ZX:
- ED_manipulator_primitive3d_set_direction(axis, rv3d->twmat[aidx_norm - 1 < 0 ? 2 : aidx_norm - 1]);
- ED_manipulator_primitive3d_set_up_vector(axis, rv3d->twmat[aidx_norm + 1 > 2 ? 0 : aidx_norm + 1]);
+ {
+ const float *y_axis = rv3d->twmat[aidx_norm + 1 > 2 ? 0 : aidx_norm + 1];
+ const float *z_axis = rv3d->twmat[aidx_norm - 1 < 0 ? 2 : aidx_norm - 1];
+ WM_manipulator_set_matrix_rotation_from_yz_axis(axis, y_axis, z_axis);
break;
+ }
}
}
MAN_ITER_AXES_END;
@@ -1344,7 +1347,7 @@ static void WIDGETGROUP_manipulator_draw_prepare(const bContext *C, wmManipulato
case MAN_AXIS_ROT_C:
case MAN_AXIS_SCALE_C:
case MAN_AXIS_ROT_T:
- ED_manipulator_dial3d_set_up_vector(axis, rv3d->viewinv[2]);
+ WM_manipulator_set_matrix_rotation_from_z_axis(axis, rv3d->viewinv[2]);
break;
}
}
diff --git a/source/blender/editors/transform/transform_manipulator2d.c b/source/blender/editors/transform/transform_manipulator2d.c
index 0ea50b604fb..0035910f8d7 100644
--- a/source/blender/editors/transform/transform_manipulator2d.c
+++ b/source/blender/editors/transform/transform_manipulator2d.c
@@ -175,7 +175,7 @@ static void manipulator2d_modal(
manipulator2d_calc_origin(C, origin);
manipulator2d_origin_to_region(ar, origin);
- WM_manipulator_set_origin(widget, origin);
+ WM_manipulator_set_matrix_location(widget, origin);
ED_region_tag_redraw(ar);
}
@@ -197,7 +197,7 @@ void ED_widgetgroup_manipulator2d_setup(const bContext *UNUSED(C), wmManipulator
/* set up widget data */
ED_manipulator_arrow2d_set_angle(axis, -M_PI_2 * axis_idx);
ED_manipulator_arrow2d_set_line_len(axis, 0.8f);
- WM_manipulator_set_offset(axis, offset);
+ WM_manipulator_set_matrix_offset_location(axis, offset);
WM_manipulator_set_line_width(axis, MANIPULATOR_AXIS_LINE_WIDTH);
WM_manipulator_set_scale(axis, U.manipulator_scale);
WM_manipulator_set_color(axis, col);
@@ -232,7 +232,7 @@ void ED_widgetgroup_manipulator2d_draw_prepare(const bContext *C, wmManipulatorG
MAN2D_ITER_AXES_BEGIN(axis, axis_idx)
{
- WM_manipulator_set_origin(axis, origin);
+ WM_manipulator_set_matrix_location(axis, origin);
}
MAN2D_ITER_AXES_END;
}
diff --git a/source/blender/windowmanager/manipulators/WM_manipulator_api.h b/source/blender/windowmanager/manipulators/WM_manipulator_api.h
index 13c5e024b9d..f613ca60329 100644
--- a/source/blender/windowmanager/manipulators/WM_manipulator_api.h
+++ b/source/blender/windowmanager/manipulators/WM_manipulator_api.h
@@ -69,8 +69,20 @@ struct PointerRNA *WM_manipulator_set_operator(struct wmManipulator *, const cha
/* callbacks */
void WM_manipulator_set_fn_custom_modal(struct wmManipulator *mpr, wmManipulatorFnModal fn);
-void WM_manipulator_set_origin(struct wmManipulator *mpr, const float origin[3]);
-void WM_manipulator_set_offset(struct wmManipulator *mpr, const float offset[3]);
+void WM_manipulator_set_matrix_location(
+ struct wmManipulator *mpr, const float origin[3]);
+void WM_manipulator_set_matrix_rotation_from_z_axis(
+ struct wmManipulator *mpr, const float z_axis[3]);
+void WM_manipulator_set_matrix_rotation_from_yz_axis(
+ struct wmManipulator *mpr, const float y_axis[3], const float z_axis[3]);
+
+void WM_manipulator_set_matrix_offset_location(
+ struct wmManipulator *mpr, const float origin[3]);
+void WM_manipulator_set_matrix_offset_rotation_from_z_axis(
+ struct wmManipulator *mpr, const float z_axis[3]);
+void WM_manipulator_set_matrix_offset_rotation_from_yz_axis(
+ struct wmManipulator *mpr, const float y_axis[3], const float z_axis[3]);
+
void WM_manipulator_set_flag(struct wmManipulator *mpr, const int flag, const bool enable);
void WM_manipulator_set_scale(struct wmManipulator *mpr, float scale);
void WM_manipulator_set_line_width(struct wmManipulator *mpr, const float line_width);
diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulator.c b/source/blender/windowmanager/manipulators/intern/wm_manipulator.c
index c28f8ecd331..b842d2143d9 100644
--- a/source/blender/windowmanager/manipulators/intern/wm_manipulator.c
+++ b/source/blender/windowmanager/manipulators/intern/wm_manipulator.c
@@ -215,12 +215,66 @@ PointerRNA *WM_manipulator_set_operator(wmManipulator *mpr, const char *opname)
return NULL;
}
-void WM_manipulator_set_origin(wmManipulator *mpr, const float origin[3])
+static void wm_manipulator_set_matrix_rotation_from_z_axis__internal(
+ float matrix[4][4], const float z_axis[3])
+{
+ /* old code, seems we can use simpler method */
+#if 0
+ const float z_global[3] = {0.0f, 0.0f, 1.0f};
+ float rot[3][3];
+
+ rotation_between_vecs_to_mat3(rot, z_global, z_axis);
+ copy_v3_v3(matrix[0], rot[0]);
+ copy_v3_v3(matrix[1], rot[1]);
+ copy_v3_v3(matrix[2], rot[2]);
+#else
+ normalize_v3_v3(matrix[2], z_axis);
+ ortho_basis_v3v3_v3(matrix[0], matrix[1], matrix[2]);
+#endif
+
+}
+
+static void wm_manipulator_set_matrix_rotation_from_yz_axis__internal(
+ float matrix[4][4], const float y_axis[3], const float z_axis[3])
+{
+ normalize_v3_v3(matrix[1], y_axis);
+ normalize_v3_v3(matrix[2], z_axis);
+ cross_v3_v3v3(matrix[0], matrix[1], matrix[2]);
+ normalize_v3(matrix[0]);
+}
+
+/**
+ * wmManipulator.matrix utils.
+ */
+void WM_manipulator_set_matrix_rotation_from_z_axis(
+ wmManipulator *mpr, const float z_axis[3])
+{
+ wm_manipulator_set_matrix_rotation_from_z_axis__internal(mpr->matrix, z_axis);
+}
+void WM_manipulator_set_matrix_rotation_from_yz_axis(
+ wmManipulator *mpr, const float y_axis[3], const float z_axis[3])
+{
+ wm_manipulator_set_matrix_rotation_from_yz_axis__internal(mpr->matrix, y_axis, z_axis);
+}
+void WM_manipulator_set_matrix_location(wmManipulator *mpr, const float origin[3])
{
copy_v3_v3(mpr->matrix[3], origin);
}
-void WM_manipulator_set_offset(wmManipulator *mpr, const float offset[3])
+/**
+ * wmManipulator.matrix_offset utils.
+ */
+void WM_manipulator_set_matrix_offset_rotation_from_z_axis(
+ wmManipulator *mpr, const float z_axis[3])
+{
+ wm_manipulator_set_matrix_rotation_from_z_axis__internal(mpr->matrix_offset, z_axis);
+}
+void WM_manipulator_set_matrix_offset_rotation_from_yz_axis(
+ wmManipulator *mpr, const float y_axis[3], const float z_axis[3])
+{
+ wm_manipulator_set_matrix_rotation_from_yz_axis__internal(mpr->matrix_offset, y_axis, z_axis);
+}
+void WM_manipulator_set_matrix_offset_location(wmManipulator *mpr, const float offset[3])
{
copy_v3_v3(mpr->matrix_offset[3], offset);
}