forked from bartvdbraak/blender
Fix #34350: Maya Keyboard map preset problems
Two main things: - Made a python operator for selection in a viewport which will de-select everything if nothing is under the mouse. To do so needed to modify VIEW3D_OT_select, so invoke sets mouse location which is later used by exec function. This way it's possible to select stuff from python defined operator. Not best-ever solution since ideally exec() shall not do OpenGL stuff, but we've got this issue in some other operators. We'll solve this later. - Used a keymap from Gianmichele Mariani as a reference, updated his keymap to latest changes in operators. We shall match Maya keymap much better now, thanks for the keymap dude!
This commit is contained in:
parent
dee74c299f
commit
75f1157b80
@ -7,4 +7,4 @@ bpy.context.user_preferences.inputs.select_mouse = 'LEFT'
|
|||||||
bpy.context.user_preferences.inputs.view_zoom_method = 'DOLLY'
|
bpy.context.user_preferences.inputs.view_zoom_method = 'DOLLY'
|
||||||
bpy.context.user_preferences.inputs.view_zoom_axis = 'HORIZONTAL'
|
bpy.context.user_preferences.inputs.view_zoom_axis = 'HORIZONTAL'
|
||||||
bpy.context.user_preferences.inputs.view_rotate_method = 'TURNTABLE'
|
bpy.context.user_preferences.inputs.view_rotate_method = 'TURNTABLE'
|
||||||
bpy.context.user_preferences.inputs.invert_mouse_zoom = True
|
bpy.context.user_preferences.inputs.invert_mouse_zoom = False
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -19,7 +19,9 @@
|
|||||||
# <pep8-80 compliant>
|
# <pep8-80 compliant>
|
||||||
|
|
||||||
import bpy
|
import bpy
|
||||||
|
import mathutils
|
||||||
from bpy.types import Operator
|
from bpy.types import Operator
|
||||||
|
from bpy.props import BoolProperty
|
||||||
|
|
||||||
|
|
||||||
class VIEW3D_OT_edit_mesh_extrude_individual_move(Operator):
|
class VIEW3D_OT_edit_mesh_extrude_individual_move(Operator):
|
||||||
@ -88,3 +90,79 @@ class VIEW3D_OT_edit_mesh_extrude_move(Operator):
|
|||||||
|
|
||||||
def invoke(self, context, event):
|
def invoke(self, context, event):
|
||||||
return self.execute(context)
|
return self.execute(context)
|
||||||
|
|
||||||
|
|
||||||
|
class VIEW3D_OT_select_or_deselect_all(Operator):
|
||||||
|
"Select element under the mouse, delect everything is there's nothing under the mouse"
|
||||||
|
bl_label = "Select or Delect All"
|
||||||
|
bl_idname = "view3d.select_or_deselect_all"
|
||||||
|
|
||||||
|
extend = BoolProperty(
|
||||||
|
name="Extend",
|
||||||
|
description="Extend selection instead of deselecting everything first",
|
||||||
|
default=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
toggle = BoolProperty(
|
||||||
|
name="Toggle",
|
||||||
|
description="Toggle the selection",
|
||||||
|
default=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
deselect = BoolProperty(
|
||||||
|
name="Deselect",
|
||||||
|
description="Remove from selection",
|
||||||
|
default=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
center = BoolProperty(
|
||||||
|
name="Center",
|
||||||
|
description="Use the object center when selecting, in editmode used to extend object selection",
|
||||||
|
default=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
enumerate = BoolProperty(
|
||||||
|
name="Enumerate",
|
||||||
|
description="List objects under the mouse (object mode only)",
|
||||||
|
default=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
object = BoolProperty(
|
||||||
|
name="Object",
|
||||||
|
description="Use object selection (editmode only)",
|
||||||
|
default=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
def invoke(self, context, event):
|
||||||
|
x = event.mouse_region_x
|
||||||
|
y = event.mouse_region_y
|
||||||
|
|
||||||
|
if self.extend == False:
|
||||||
|
active_object = context.active_object
|
||||||
|
|
||||||
|
if active_object:
|
||||||
|
if active_object.mode == 'EDIT':
|
||||||
|
if active_object.type == 'MESH':
|
||||||
|
bpy.ops.mesh.select_all(action='DESELECT')
|
||||||
|
elif active_object.type == 'CURVE':
|
||||||
|
bpy.ops.curve.select_all(action='DESELECT')
|
||||||
|
elif active_object.type == 'SURFACE':
|
||||||
|
bpy.ops.curve.select_all(action='DESELECT')
|
||||||
|
elif active_object.type == 'LATTICE':
|
||||||
|
bpy.ops.lattice.select_all(action='DESELECT')
|
||||||
|
elif active_object.type == 'META':
|
||||||
|
bpy.ops.mball.select_all(action='DESELECT')
|
||||||
|
elif active_object.type == 'ARMATURE':
|
||||||
|
bpy.ops.armature.select_all(action='DESELECT')
|
||||||
|
else:
|
||||||
|
bpy.ops.object.select_all(action='DESELECT')
|
||||||
|
else:
|
||||||
|
bpy.ops.object.select_all(action='DESELECT')
|
||||||
|
|
||||||
|
return bpy.ops.view3d.select(extend=self.extend,
|
||||||
|
deselect=self.deselect,
|
||||||
|
toggle=self.toggle,
|
||||||
|
center=self.center,
|
||||||
|
enumerate=self.enumerate,
|
||||||
|
object=self.object,
|
||||||
|
location=(x, y))
|
||||||
|
@ -2195,7 +2195,7 @@ static bool mouse_weight_paint_vertex_select(bContext *C, const int mval[2], boo
|
|||||||
/* ****** Mouse Select ****** */
|
/* ****** Mouse Select ****** */
|
||||||
|
|
||||||
|
|
||||||
static int view3d_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
static int view3d_select_exec(bContext *C, wmOperator *op)
|
||||||
{
|
{
|
||||||
Object *obedit = CTX_data_edit_object(C);
|
Object *obedit = CTX_data_edit_object(C);
|
||||||
Object *obact = CTX_data_active_object(C);
|
Object *obact = CTX_data_active_object(C);
|
||||||
@ -2206,6 +2206,9 @@ static int view3d_select_invoke(bContext *C, wmOperator *op, const wmEvent *even
|
|||||||
bool enumerate = RNA_boolean_get(op->ptr, "enumerate");
|
bool enumerate = RNA_boolean_get(op->ptr, "enumerate");
|
||||||
bool object = RNA_boolean_get(op->ptr, "object");
|
bool object = RNA_boolean_get(op->ptr, "object");
|
||||||
bool retval = false;
|
bool retval = false;
|
||||||
|
int location[2];
|
||||||
|
|
||||||
|
RNA_int_get_array(op->ptr, "location", location);
|
||||||
|
|
||||||
view3d_operator_needs_opengl(C);
|
view3d_operator_needs_opengl(C);
|
||||||
|
|
||||||
@ -2221,27 +2224,27 @@ static int view3d_select_invoke(bContext *C, wmOperator *op, const wmEvent *even
|
|||||||
|
|
||||||
if (obedit && object == false) {
|
if (obedit && object == false) {
|
||||||
if (obedit->type == OB_MESH)
|
if (obedit->type == OB_MESH)
|
||||||
retval = EDBM_select_pick(C, event->mval, extend, deselect, toggle);
|
retval = EDBM_select_pick(C, location, extend, deselect, toggle);
|
||||||
else if (obedit->type == OB_ARMATURE)
|
else if (obedit->type == OB_ARMATURE)
|
||||||
retval = mouse_armature(C, event->mval, extend, deselect, toggle);
|
retval = mouse_armature(C, location, extend, deselect, toggle);
|
||||||
else if (obedit->type == OB_LATTICE)
|
else if (obedit->type == OB_LATTICE)
|
||||||
retval = mouse_lattice(C, event->mval, extend, deselect, toggle);
|
retval = mouse_lattice(C, location, extend, deselect, toggle);
|
||||||
else if (ELEM(obedit->type, OB_CURVE, OB_SURF))
|
else if (ELEM(obedit->type, OB_CURVE, OB_SURF))
|
||||||
retval = mouse_nurb(C, event->mval, extend, deselect, toggle);
|
retval = mouse_nurb(C, location, extend, deselect, toggle);
|
||||||
else if (obedit->type == OB_MBALL)
|
else if (obedit->type == OB_MBALL)
|
||||||
retval = mouse_mball(C, event->mval, extend, deselect, toggle);
|
retval = mouse_mball(C, location, extend, deselect, toggle);
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (obact && obact->mode & OB_MODE_SCULPT)
|
else if (obact && obact->mode & OB_MODE_SCULPT)
|
||||||
return OPERATOR_CANCELLED;
|
return OPERATOR_CANCELLED;
|
||||||
else if (obact && obact->mode & OB_MODE_PARTICLE_EDIT)
|
else if (obact && obact->mode & OB_MODE_PARTICLE_EDIT)
|
||||||
return PE_mouse_particles(C, event->mval, extend, deselect, toggle);
|
return PE_mouse_particles(C, location, extend, deselect, toggle);
|
||||||
else if (obact && paint_facesel_test(obact))
|
else if (obact && paint_facesel_test(obact))
|
||||||
retval = paintface_mouse_select(C, obact, event->mval, extend, deselect, toggle);
|
retval = paintface_mouse_select(C, obact, location, extend, deselect, toggle);
|
||||||
else if (paint_vertsel_test(obact))
|
else if (paint_vertsel_test(obact))
|
||||||
retval = mouse_weight_paint_vertex_select(C, event->mval, extend, deselect, toggle, obact);
|
retval = mouse_weight_paint_vertex_select(C, location, extend, deselect, toggle, obact);
|
||||||
else
|
else
|
||||||
retval = mouse_select(C, event->mval, extend, deselect, toggle, center, enumerate);
|
retval = mouse_select(C, location, extend, deselect, toggle, center, enumerate);
|
||||||
|
|
||||||
/* passthrough allows tweaks
|
/* passthrough allows tweaks
|
||||||
* FINISHED to signal one operator worked
|
* FINISHED to signal one operator worked
|
||||||
@ -2252,8 +2255,17 @@ static int view3d_select_invoke(bContext *C, wmOperator *op, const wmEvent *even
|
|||||||
return OPERATOR_PASS_THROUGH; /* nothing selected, just passthrough */
|
return OPERATOR_PASS_THROUGH; /* nothing selected, just passthrough */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int view3d_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||||
|
{
|
||||||
|
RNA_int_set_array(op->ptr, "location", event->mval);
|
||||||
|
|
||||||
|
return view3d_select_exec(C, op);
|
||||||
|
}
|
||||||
|
|
||||||
void VIEW3D_OT_select(wmOperatorType *ot)
|
void VIEW3D_OT_select(wmOperatorType *ot)
|
||||||
{
|
{
|
||||||
|
PropertyRNA *prop;
|
||||||
|
|
||||||
/* identifiers */
|
/* identifiers */
|
||||||
ot->name = "Activate/Select";
|
ot->name = "Activate/Select";
|
||||||
ot->description = "Activate/select item(s)";
|
ot->description = "Activate/select item(s)";
|
||||||
@ -2261,6 +2273,7 @@ void VIEW3D_OT_select(wmOperatorType *ot)
|
|||||||
|
|
||||||
/* api callbacks */
|
/* api callbacks */
|
||||||
ot->invoke = view3d_select_invoke;
|
ot->invoke = view3d_select_invoke;
|
||||||
|
ot->exec = view3d_select_exec;
|
||||||
ot->poll = ED_operator_view3d_active;
|
ot->poll = ED_operator_view3d_active;
|
||||||
|
|
||||||
/* flags */
|
/* flags */
|
||||||
@ -2272,6 +2285,9 @@ void VIEW3D_OT_select(wmOperatorType *ot)
|
|||||||
RNA_def_boolean(ot->srna, "center", 0, "Center", "Use the object center when selecting, in editmode used to extend object selection");
|
RNA_def_boolean(ot->srna, "center", 0, "Center", "Use the object center when selecting, in editmode used to extend object selection");
|
||||||
RNA_def_boolean(ot->srna, "enumerate", 0, "Enumerate", "List objects under the mouse (object mode only)");
|
RNA_def_boolean(ot->srna, "enumerate", 0, "Enumerate", "List objects under the mouse (object mode only)");
|
||||||
RNA_def_boolean(ot->srna, "object", 0, "Object", "Use object selection (editmode only)");
|
RNA_def_boolean(ot->srna, "object", 0, "Object", "Use object selection (editmode only)");
|
||||||
|
|
||||||
|
prop = RNA_def_int_vector(ot->srna, "location", 2, NULL, INT_MIN, INT_MAX, "Location", "Mouse location", INT_MIN, INT_MAX);
|
||||||
|
RNA_def_property_flag(prop, PROP_HIDDEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user