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-08-30 18:38:51 +0300
committerCampbell Barton <ideasman42@gmail.com>2017-08-30 19:00:16 +0300
commit00ba48a6997d5421a899101b696e5f86c0bdef0a (patch)
tree8f54f9cd478f88134bea37bb2143e73f83d9a19a /source/blender/editors/space_view3d/view3d_manipulator_camera.c
parentb448b025c70ab4e6966d3469dc71a5318d3ef731 (diff)
Manipulator: replace old cage2d manipulator
Mostly internal changes, keeping both manipulators could have worked but there was no point long term. There are still some glitches to resolve, will work on those next.
Diffstat (limited to 'source/blender/editors/space_view3d/view3d_manipulator_camera.c')
-rw-r--r--source/blender/editors/space_view3d/view3d_manipulator_camera.c67
1 files changed, 18 insertions, 49 deletions
diff --git a/source/blender/editors/space_view3d/view3d_manipulator_camera.c b/source/blender/editors/space_view3d/view3d_manipulator_camera.c
index e93c2aaf735..948758318f5 100644
--- a/source/blender/editors/space_view3d/view3d_manipulator_camera.c
+++ b/source/blender/editors/space_view3d/view3d_manipulator_camera.c
@@ -120,6 +120,7 @@ static void WIDGETGROUP_camera_setup(const bContext *C, wmManipulatorGroup *mgro
{
wmManipulator *mpr;
mpr = camgroup->focal_len = WM_manipulator_new_ptr(wt_arrow, mgroup, NULL);
+ mpr->flag |= WM_MANIPULATOR_DRAW_NO_SCALE;
RNA_enum_set(mpr->ptr, "draw_style", ED_MANIPULATOR_ARROW_STYLE_CONE);
RNA_enum_set(mpr->ptr, "draw_options", ED_MANIPULATOR_ARROW_STYLE_CONSTRAINED);
@@ -128,6 +129,7 @@ static void WIDGETGROUP_camera_setup(const bContext *C, wmManipulatorGroup *mgro
cameragroup_property_setup(mpr, ob, ca, false);
mpr = camgroup->ortho_scale = WM_manipulator_new_ptr(wt_arrow, mgroup, NULL);
+ mpr->flag |= WM_MANIPULATOR_DRAW_NO_SCALE;
RNA_enum_set(mpr->ptr, "draw_style", ED_MANIPULATOR_ARROW_STYLE_CONE);
RNA_enum_set(mpr->ptr, "draw_options", ED_MANIPULATOR_ARROW_STYLE_CONSTRAINED);
@@ -240,57 +242,33 @@ struct CameraViewWidgetGroup {
};
/* scale callbacks */
-static void manipulator_render_border_prop_size_get(
+static void manipulator_render_border_prop_matrix_get(
const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop,
void *value_p)
{
- float *value = value_p;
- BLI_assert(mpr_prop->type->array_length == 2);
+ float (*matrix)[4] = value_p;
+ BLI_assert(mpr_prop->type->array_length == 16);
struct CameraViewWidgetGroup *viewgroup = mpr_prop->custom_func.user_data;
const rctf *border = viewgroup->state.edit_border;
- value[0] = BLI_rctf_size_x(border);
- value[1] = BLI_rctf_size_y(border);
+ unit_m4(matrix);
+ matrix[0][0] = BLI_rctf_size_x(border);
+ matrix[1][1] = BLI_rctf_size_y(border);
+ matrix[3][0] = BLI_rctf_cent_x(border);
+ matrix[3][1] = BLI_rctf_cent_y(border);
}
-static void manipulator_render_border_prop_size_set(
+static void manipulator_render_border_prop_matrix_set(
const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop,
const void *value_p)
{
- const float *value = value_p;
+ const float (*matrix)[4] = value_p;
struct CameraViewWidgetGroup *viewgroup = mpr_prop->custom_func.user_data;
rctf *border = viewgroup->state.edit_border;
- BLI_assert(mpr_prop->type->array_length == 2);
+ BLI_assert(mpr_prop->type->array_length == 16);
- BLI_rctf_resize(border, value[0], value[1]);
- BLI_rctf_isect(&(rctf){.xmin = 0, .ymin = 0, .xmax = 1, .ymax = 1}, border, border);
-}
-
-/* offset callbacks */
-static void manipulator_render_border_prop_offset_get(
- const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop,
- void *value_p)
-{
- float *value = value_p;
- BLI_assert(mpr_prop->type->array_length == 2);
- struct CameraViewWidgetGroup *viewgroup = mpr_prop->custom_func.user_data;
- const rctf *border = viewgroup->state.edit_border;
-
- value[0] = BLI_rctf_cent_x(border);
- value[1] = BLI_rctf_cent_y(border);
-}
-
-static void manipulator_render_border_prop_offset_set(
- const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop,
- const void *value_p)
-{
- const float *value = value_p;
- struct CameraViewWidgetGroup *viewgroup = mpr_prop->custom_func.user_data;
- rctf *border = viewgroup->state.edit_border;
-
- BLI_assert(mpr_prop->type->array_length == 2);
-
- BLI_rctf_recenter(border, value[0], value[1]);
+ BLI_rctf_resize(border, len_v3(matrix[0]), len_v3(matrix[1]));
+ BLI_rctf_recenter(border, matrix[3][0], matrix[3][1]);
BLI_rctf_isect(&(rctf){.xmin = 0, .ymin = 0, .xmax = 1, .ymax = 1}, border, border);
}
@@ -382,19 +360,10 @@ static void WIDGETGROUP_camera_view_refresh(const bContext *C, wmManipulatorGrou
}
WM_manipulator_target_property_def_func(
- mpr, "offset",
- &(const struct wmManipulatorPropertyFnParams) {
- .value_get_fn = manipulator_render_border_prop_offset_get,
- .value_set_fn = manipulator_render_border_prop_offset_set,
- .range_get_fn = NULL,
- .user_data = viewgroup,
- });
-
- WM_manipulator_target_property_def_func(
- mpr, "scale",
+ mpr, "matrix",
&(const struct wmManipulatorPropertyFnParams) {
- .value_get_fn = manipulator_render_border_prop_size_get,
- .value_set_fn = manipulator_render_border_prop_size_set,
+ .value_get_fn = manipulator_render_border_prop_matrix_get,
+ .value_set_fn = manipulator_render_border_prop_matrix_set,
.range_get_fn = NULL,
.user_data = viewgroup,
});