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>2017-06-17 22:38:10 +0300
committerCampbell Barton <ideasman42@gmail.com>2017-06-17 22:38:10 +0300
commit49be79693c6d2e3be20b2cd0ecf81e76a7121b2f (patch)
treeec7913671e48abc263c95ef323186f3b57daead7 /source/blender/windowmanager
parent83c28ff96a5745c7f5713665890211657b45a35f (diff)
Manipulator: use matrix instead of origin
This avoids having to use manipulator-type specific functions to set the orientation. And will make it simpler to access transformation from Python. Currently the matrix is still used as an offset in places. Also per-type orientation values still need to be removed.
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r--source/blender/windowmanager/manipulators/WM_manipulator_types.h10
-rw-r--r--source/blender/windowmanager/manipulators/intern/wm_manipulator.c18
-rw-r--r--source/blender/windowmanager/manipulators/wm_manipulator_fn.h2
3 files changed, 17 insertions, 13 deletions
diff --git a/source/blender/windowmanager/manipulators/WM_manipulator_types.h b/source/blender/windowmanager/manipulators/WM_manipulator_types.h
index ec009a5e7a0..eb8641fcd7e 100644
--- a/source/blender/windowmanager/manipulators/WM_manipulator_types.h
+++ b/source/blender/windowmanager/manipulators/WM_manipulator_types.h
@@ -75,9 +75,9 @@ struct wmManipulator {
int highlight_part;
/* center of manipulator in space, 2d or 3d */
- float origin[3];
+ float matrix[4][4];
/* custom offset from origin */
- float offset[3];
+ float matrix_offset[4][4];
/* runtime property, set the scale while drawing on the viewport */
float scale;
/* user defined scale, in addition to the original one */
@@ -193,9 +193,9 @@ typedef struct wmManipulatorType {
/* manipulator-specific handler to update manipulator attributes based on the property value */
wmManipulatorFnPropertyUpdate property_update;
- /* returns the final position which may be different from the origin, depending on the manipulator.
- * used in calculations of scale */
- wmManipulatorFnPositionGet position_get;
+ /* Returns the final transformation which may be different from the 'matrix',
+ * depending on the manipulator. */
+ wmManipulatorFnMatrixWorldGet matrix_world_get;
/* activate a manipulator state when the user clicks on it */
wmManipulatorFnInvoke invoke;
diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulator.c b/source/blender/windowmanager/manipulators/intern/wm_manipulator.c
index f24bdb6e697..c28f8ecd331 100644
--- a/source/blender/windowmanager/manipulators/intern/wm_manipulator.c
+++ b/source/blender/windowmanager/manipulators/intern/wm_manipulator.c
@@ -73,6 +73,10 @@ static wmManipulator *wm_manipulator_create(
wmManipulator *mpr = MEM_callocN(wt->struct_size, __func__);
mpr->type = wt;
+
+ unit_m4(mpr->matrix);
+ unit_m4(mpr->matrix_offset);
+
return mpr;
}
@@ -213,12 +217,12 @@ PointerRNA *WM_manipulator_set_operator(wmManipulator *mpr, const char *opname)
void WM_manipulator_set_origin(wmManipulator *mpr, const float origin[3])
{
- copy_v3_v3(mpr->origin, origin);
+ copy_v3_v3(mpr->matrix[3], origin);
}
void WM_manipulator_set_offset(wmManipulator *mpr, const float offset[3])
{
- copy_v3_v3(mpr->offset, offset);
+ copy_v3_v3(mpr->matrix_offset[3], offset);
}
void WM_manipulator_set_flag(wmManipulator *mpr, const int flag, const bool enable)
@@ -361,14 +365,14 @@ void wm_manipulator_calculate_scale(wmManipulator *mpr, const bContext *C)
if (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_SCALE_3D) {
if (rv3d /*&& (U.manipulator_flag & V3D_DRAW_MANIPULATOR) == 0*/) { /* UserPref flag might be useful for later */
- if (mpr->type->position_get) {
- float position[3];
+ if (mpr->type->matrix_world_get) {
+ float matrix_world[4][4];
- mpr->type->position_get(mpr, position);
- scale = ED_view3d_pixel_size(rv3d, position) * (float)U.manipulator_scale;
+ mpr->type->matrix_world_get(mpr, matrix_world);
+ scale = ED_view3d_pixel_size(rv3d, matrix_world[3]) * (float)U.manipulator_scale;
}
else {
- scale = ED_view3d_pixel_size(rv3d, mpr->origin) * (float)U.manipulator_scale;
+ scale = ED_view3d_pixel_size(rv3d, mpr->matrix[3]) * (float)U.manipulator_scale;
}
}
else {
diff --git a/source/blender/windowmanager/manipulators/wm_manipulator_fn.h b/source/blender/windowmanager/manipulators/wm_manipulator_fn.h
index 90eaba74de1..619911b94d7 100644
--- a/source/blender/windowmanager/manipulators/wm_manipulator_fn.h
+++ b/source/blender/windowmanager/manipulators/wm_manipulator_fn.h
@@ -52,7 +52,7 @@ typedef void (*wmManipulatorFnDrawSelect)(const struct bContext *, struct wmM
typedef int (*wmManipulatorFnTestSelect)(struct bContext *, struct wmManipulator *, const struct wmEvent *);
typedef void (*wmManipulatorFnModal)(struct bContext *, struct wmManipulator *, const struct wmEvent *, const int);
typedef void (*wmManipulatorFnPropertyUpdate)(struct wmManipulator *, struct wmManipulatorProperty *);
-typedef void (*wmManipulatorFnPositionGet)(struct wmManipulator *, float[]);
+typedef void (*wmManipulatorFnMatrixWorldGet)(struct wmManipulator *, float[4][4]);
typedef void (*wmManipulatorFnInvoke)(struct bContext *, struct wmManipulator *, const struct wmEvent *);
typedef void (*wmManipulatorFnExit)(struct bContext *, struct wmManipulator *, const bool);
typedef int (*wmManipulatorFnCursorGet)(struct wmManipulator *);