Manipulator: view-selected support
Only applies to selected manipulators (currently not used for regular manipulators).
This commit is contained in:
@@ -3069,6 +3069,8 @@ static int viewselected_exec(bContext *C, wmOperator *op)
|
||||
SceneLayer *sl = CTX_data_scene_layer(C);
|
||||
bGPdata *gpd = CTX_data_gpencil_data(C);
|
||||
const bool is_gp_edit = ((gpd) && (gpd->flag & GP_DATA_STROKE_EDITMODE));
|
||||
const bool is_face_map = ((is_gp_edit == false) && ar->manipulator_map &&
|
||||
WM_manipulatormap_is_any_selected(ar->manipulator_map));
|
||||
Object *ob = OBACT_NEW;
|
||||
Object *obedit = CTX_data_edit_object(C);
|
||||
float min[3], max[3];
|
||||
@@ -3080,8 +3082,7 @@ static int viewselected_exec(bContext *C, wmOperator *op)
|
||||
const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
|
||||
|
||||
INIT_MINMAX(min, max);
|
||||
|
||||
if (is_gp_edit) {
|
||||
if (is_gp_edit || is_face_map) {
|
||||
ob = NULL;
|
||||
}
|
||||
|
||||
@@ -3113,6 +3114,9 @@ static int viewselected_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
CTX_DATA_END;
|
||||
}
|
||||
else if (is_face_map) {
|
||||
ok = WM_manipulatormap_minmax(ar->manipulator_map, true, true, min, max);
|
||||
}
|
||||
else if (obedit) {
|
||||
ok = ED_view3d_minmax_verts(obedit, min, max); /* only selected */
|
||||
}
|
||||
|
||||
@@ -207,6 +207,9 @@ void WM_manipulatormap_add_handlers(struct ARegion *ar, struct wmManipulatorMap
|
||||
bool WM_manipulatormap_select_all(struct bContext *C, struct wmManipulatorMap *mmap, const int action);
|
||||
bool WM_manipulatormap_cursor_set(const struct wmManipulatorMap *mmap, struct wmWindow *win);
|
||||
bool WM_manipulatormap_is_any_selected(const struct wmManipulatorMap *mmap);
|
||||
bool WM_manipulatormap_minmax(
|
||||
const struct wmManipulatorMap *mmap, bool use_hidden, bool use_select,
|
||||
float r_min[3], float r_max[3]);
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* wmManipulatorMapType */
|
||||
|
||||
@@ -140,6 +140,27 @@ bool WM_manipulatormap_is_any_selected(const wmManipulatorMap *mmap)
|
||||
return mmap->mmap_context.selected_len != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* \note We could use a callback to define bounds, for now just use matrix location.
|
||||
*/
|
||||
bool WM_manipulatormap_minmax(
|
||||
const wmManipulatorMap *mmap, bool UNUSED(use_hidden), bool use_select,
|
||||
float r_min[3], float r_max[3])
|
||||
{
|
||||
if (use_select) {
|
||||
int i;
|
||||
for (i = 0; i < mmap->mmap_context.selected_len; i++) {
|
||||
minmax_v3v3_v3(r_min, r_max, mmap->mmap_context.selected[i]->matrix_basis[3]);
|
||||
}
|
||||
return i != 0;
|
||||
}
|
||||
else {
|
||||
bool ok = false;
|
||||
BLI_assert(!"TODO");
|
||||
return ok;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and returns idname hash table for (visible) manipulators in \a mmap
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user