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
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')
-rw-r--r--source/blender/editors/space_view3d/view3d_manipulator_camera.c67
-rw-r--r--source/blender/editors/space_view3d/view3d_manipulator_empty.c63
-rw-r--r--source/blender/editors/space_view3d/view3d_manipulator_lamp.c45
3 files changed, 55 insertions, 120 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,
});
diff --git a/source/blender/editors/space_view3d/view3d_manipulator_empty.c b/source/blender/editors/space_view3d/view3d_manipulator_empty.c
index dcf766ee591..4c5f3c259f7 100644
--- a/source/blender/editors/space_view3d/view3d_manipulator_empty.c
+++ b/source/blender/editors/space_view3d/view3d_manipulator_empty.c
@@ -62,63 +62,46 @@ struct EmptyImageWidgetGroup {
};
/* translate callbacks */
-static void manipulator_empty_image_prop_size_get(
- const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop,
+static void manipulator_empty_image_prop_matrix_get(
+ const wmManipulator *mpr, wmManipulatorProperty *mpr_prop,
void *value_p)
{
- float *value = value_p;
+ float (*matrix)[4] = value_p;
+ BLI_assert(mpr_prop->type->array_length == 16);
struct EmptyImageWidgetGroup *imgroup = mpr_prop->custom_func.user_data;
const Object *ob = imgroup->state.ob;
- value[0] = ob->empty_drawsize;
- value[1] = ob->empty_drawsize;
-}
-static void manipulator_empty_image_prop_size_set(
- const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop,
- const void *value_p)
-{
- const float *value = value_p;
- BLI_assert(mpr_prop->type->array_length == 2);
- struct EmptyImageWidgetGroup *imgroup = mpr_prop->custom_func.user_data;
- Object *ob = imgroup->state.ob;
- ob->empty_drawsize = value[0];
-}
-
-/* translate callbacks */
-static void manipulator_empty_image_prop_offset_get(
- const wmManipulator *mpr, wmManipulatorProperty *mpr_prop,
- void *value_p)
-{
- float *value = value_p;
- BLI_assert(mpr_prop->type->array_length == 2);
- const struct EmptyImageWidgetGroup *imgroup = mpr_prop->custom_func.user_data;
- const Object *ob = imgroup->state.ob;
+ unit_m4(matrix);
+ matrix[0][0] = ob->empty_drawsize;
+ matrix[1][1] = ob->empty_drawsize;
float dims[2] = {0.0f, 0.0f};
RNA_float_get_array(mpr->ptr, "dimensions", dims);
dims[0] *= ob->empty_drawsize;
dims[1] *= ob->empty_drawsize;
- value[0] = (ob->ima_ofs[0] * dims[0]) + (0.5f * dims[0]);
- value[1] = (ob->ima_ofs[1] * dims[1]) + (0.5f * dims[1]);
+ matrix[3][0] = (ob->ima_ofs[0] * dims[0]) + (0.5f * dims[0]);
+ matrix[3][1] = (ob->ima_ofs[1] * dims[1]) + (0.5f * dims[1]);
}
-static void manipulator_empty_image_prop_offset_set(
+static void manipulator_empty_image_prop_matrix_set(
const wmManipulator *mpr, wmManipulatorProperty *mpr_prop,
const void *value_p)
{
- const float *value = value_p;
- BLI_assert(mpr_prop->type->array_length == 2);
+ const float (*matrix)[4] = value_p;
+ BLI_assert(mpr_prop->type->array_length == 16);
struct EmptyImageWidgetGroup *imgroup = mpr_prop->custom_func.user_data;
Object *ob = imgroup->state.ob;
+ ob->empty_drawsize = matrix[0][0];
+
float dims[2];
RNA_float_get_array(mpr->ptr, "dimensions", dims);
dims[0] *= ob->empty_drawsize;
dims[1] *= ob->empty_drawsize;
- ob->ima_ofs[0] = (value[0] - (0.5f * dims[0])) / dims[0];
- ob->ima_ofs[1] = (value[1] - (0.5f * dims[1])) / dims[1];
+ ob->ima_ofs[0] = (matrix[3][0] - (0.5f * dims[0])) / dims[0];
+ ob->ima_ofs[1] = (matrix[3][1] - (0.5f * dims[1])) / dims[1];
}
static bool WIDGETGROUP_empty_image_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt))
@@ -177,18 +160,10 @@ static void WIDGETGROUP_empty_image_refresh(const bContext *C, wmManipulatorGrou
RNA_float_set_array(mpr->ptr, "dimensions", imgroup->state.dims);
WM_manipulator_target_property_def_func(
- mpr, "scale",
- &(const struct wmManipulatorPropertyFnParams) {
- .value_get_fn = manipulator_empty_image_prop_size_get,
- .value_set_fn = manipulator_empty_image_prop_size_set,
- .range_get_fn = NULL,
- .user_data = imgroup,
- });
- WM_manipulator_target_property_def_func(
- mpr, "offset",
+ mpr, "matrix",
&(const struct wmManipulatorPropertyFnParams) {
- .value_get_fn = manipulator_empty_image_prop_offset_get,
- .value_set_fn = manipulator_empty_image_prop_offset_set,
+ .value_get_fn = manipulator_empty_image_prop_matrix_get,
+ .value_set_fn = manipulator_empty_image_prop_matrix_set,
.range_get_fn = NULL,
.user_data = imgroup,
});
diff --git a/source/blender/editors/space_view3d/view3d_manipulator_lamp.c b/source/blender/editors/space_view3d/view3d_manipulator_lamp.c
index 14894e1bc21..93b6b69a105 100644
--- a/source/blender/editors/space_view3d/view3d_manipulator_lamp.c
+++ b/source/blender/editors/space_view3d/view3d_manipulator_lamp.c
@@ -119,45 +119,36 @@ void VIEW3D_WGT_lamp_spot(wmManipulatorGroupType *wgt)
/** \name Area Lamp Manipulators
* \{ */
-/* translate callbacks */
-static void manipulator_area_lamp_prop_size_get(
+/* scale callbacks */
+static void manipulator_area_lamp_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);
- Lamp *la = mpr_prop->custom_func.user_data;
+ BLI_assert(mpr_prop->type->array_length == 16);
+ float (*matrix)[4] = value_p;
+ const Lamp *la = mpr_prop->custom_func.user_data;
- value[0] = la->area_size;
- value[1] = (la->area_shape == LA_AREA_RECT) ? la->area_sizey : la->area_size;
+ matrix[0][0] = la->area_size;
+ matrix[1][1] = (la->area_shape == LA_AREA_RECT) ? la->area_sizey : la->area_size;
}
-static void manipulator_area_lamp_prop_size_set(
+static void manipulator_area_lamp_prop_matrix_set(
const wmManipulator *UNUSED(mpr), wmManipulatorProperty *mpr_prop,
const void *value_p)
{
- const float *value = value_p;
-
- BLI_assert(mpr_prop->type->array_length == 2);
+ const float (*matrix)[4] = value_p;
+ BLI_assert(mpr_prop->type->array_length == 16);
Lamp *la = mpr_prop->custom_func.user_data;
+
if (la->area_shape == LA_AREA_RECT) {
- la->area_size = value[0];
- la->area_sizey = value[1];
+ la->area_size = len_v3(matrix[0]);
+ la->area_sizey = len_v3(matrix[1]);
}
else {
- la->area_size = value[0];
+ la->area_size = len_v3(matrix[0]);
}
}
-static void manipulator_area_lamp_prop_size_range(
- const wmManipulator *UNUSED(mpr), wmManipulatorProperty *UNUSED(mpr_prop),
- void *value_p)
-{
- float *value = value_p;
- value[0] = 0.0f;
- value[1] = FLT_MAX;
-}
-
static bool WIDGETGROUP_lamp_area_poll(const bContext *C, wmManipulatorGroupType *UNUSED(wgt))
{
Object *ob = CTX_data_active_object(C);
@@ -200,11 +191,11 @@ static void WIDGETGROUP_lamp_area_refresh(const bContext *C, wmManipulatorGroup
/* need to set property here for undo. TODO would prefer to do this in _init */
WM_manipulator_target_property_def_func(
- mpr, "scale",
+ mpr, "matrix",
&(const struct wmManipulatorPropertyFnParams) {
- .value_get_fn = manipulator_area_lamp_prop_size_get,
- .value_set_fn = manipulator_area_lamp_prop_size_set,
- .range_get_fn = manipulator_area_lamp_prop_size_range,
+ .value_get_fn = manipulator_area_lamp_prop_matrix_get,
+ .value_set_fn = manipulator_area_lamp_prop_matrix_set,
+ .range_get_fn = NULL,
.user_data = la,
});
}