diff options
Diffstat (limited to 'source/blender/editors/space_view3d/view3d_select.c')
-rw-r--r-- | source/blender/editors/space_view3d/view3d_select.c | 180 |
1 files changed, 90 insertions, 90 deletions
diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 02a26dca6d2..06481231259 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -303,25 +303,25 @@ static bool edge_fully_inside_rect(const rctf *rect, const float v1[2], const fl static bool edge_inside_rect(const rctf *rect, const float v1[2], const float v2[2]) { int d1, d2, d3, d4; - + /* check points in rect */ if (edge_fully_inside_rect(rect, v1, v2)) return 1; - + /* check points completely out rect */ if (v1[0] < rect->xmin && v2[0] < rect->xmin) return 0; if (v1[0] > rect->xmax && v2[0] > rect->xmax) return 0; if (v1[1] < rect->ymin && v2[1] < rect->ymin) return 0; if (v1[1] > rect->ymax && v2[1] > rect->ymax) return 0; - + /* simple check lines intersecting. */ d1 = (v1[1] - v2[1]) * (v1[0] - rect->xmin) + (v2[0] - v1[0]) * (v1[1] - rect->ymin); d2 = (v1[1] - v2[1]) * (v1[0] - rect->xmin) + (v2[0] - v1[0]) * (v1[1] - rect->ymax); d3 = (v1[1] - v2[1]) * (v1[0] - rect->xmax) + (v2[0] - v1[0]) * (v1[1] - rect->ymax); d4 = (v1[1] - v2[1]) * (v1[0] - rect->xmax) + (v2[0] - v1[0]) * (v1[1] - rect->ymin); - + if (d1 < 0 && d2 < 0 && d3 < 0 && d4 < 0) return 0; if (d1 > 0 && d2 > 0 && d3 > 0 && d4 > 0) return 0; - + return 1; } @@ -377,7 +377,7 @@ static void do_lasso_select_pose(ViewContext *vc, Object *ob, const int mcords[] ViewContext vc_tmp; LassoSelectUserData data; rcti rect; - + if ((ob->type != OB_ARMATURE) || (ob->pose == NULL)) { return; } @@ -418,7 +418,7 @@ static void do_lasso_select_objects( const bool extend, const bool select) { Base *base; - + if (extend == false && select) object_deselect_all_visible(vc->scene, vc->v3d); @@ -492,7 +492,7 @@ static void do_lasso_select_mesh(ViewContext *vc, const int mcords[][2], short m ToolSettings *ts = vc->scene->toolsettings; rcti rect; int bbsel; - + /* set editmesh */ vc->em = BKE_editmesh_from_object(vc->obedit); @@ -508,7 +508,7 @@ static void do_lasso_select_mesh(ViewContext *vc, const int mcords[][2], short m glLoadMatrixf(vc->rv3d->viewmat); bbsel = EDBM_backbuf_border_mask_init(vc, mcords, moves, rect.xmin, rect.ymin, rect.xmax, rect.ymax); - + if (ts->selectmode & SCE_SELECT_VERTEX) { if (bbsel) { edbm_backbuf_check_and_select_verts(vc->em, select); @@ -527,7 +527,7 @@ static void do_lasso_select_mesh(ViewContext *vc, const int mcords[][2], short m mesh_foreachScreenEdge(vc, do_lasso_select_mesh__doSelectEdge, &data, V3D_PROJ_TEST_CLIP_NEAR); } } - + if (ts->selectmode & SCE_SELECT_FACE) { if (bbsel) { edbm_backbuf_check_and_select_faces(vc->em, select); @@ -536,7 +536,7 @@ static void do_lasso_select_mesh(ViewContext *vc, const int mcords[][2], short m mesh_foreachScreenFace(vc, do_lasso_select_mesh__doSelectFace, &data, V3D_PROJ_TEST_CLIP_DEFAULT); } } - + EDBM_backbuf_free(); EDBM_selectmode_flush(vc->em); } @@ -791,7 +791,7 @@ static void do_lasso_select_paintface(ViewContext *vc, const int mcords[][2], sh BLI_lasso_boundbox(&rect, mcords, moves); EDBM_backbuf_border_mask_init(vc, mcords, moves, rect.xmin, rect.ymin, rect.xmax, rect.ymax); - + edbm_backbuf_check_and_select_tfaces(me, select); EDBM_backbuf_free(); @@ -803,19 +803,19 @@ static void do_lasso_select_paintface(ViewContext *vc, const int mcords[][2], sh static void do_lasso_select_node(int mcords[][2], short moves, const bool select) { SpaceNode *snode = sa->spacedata.first; - + bNode *node; rcti rect; int node_cent[2]; float node_centf[2]; - + BLI_lasso_boundbox(&rect, mcords, moves); - + /* store selection in temp test flag */ for (node = snode->edittree->nodes.first; node; node = node->next) { node_centf[0] = BLI_RCT_CENTER_X(&node->totr); node_centf[1] = BLI_RCT_CENTER_Y(&node->totr); - + ipoco_to_areaco_noclip(G.v2d, node_centf, node_cent); if (BLI_rcti_isect_pt_v(&rect, node_cent) && BLI_lasso_is_point_inside(mcords, moves, node_cent[0], node_cent[1])) { if (select) { @@ -887,18 +887,18 @@ static int view3d_lasso_select_exec(bContext *C, wmOperator *op) ViewContext vc; int mcords_tot; const int (*mcords)[2] = WM_gesture_lasso_path_to_array(C, op, &mcords_tot); - + if (mcords) { bool extend, select; view3d_operator_needs_opengl(C); - + /* setup view context for argument to callbacks */ ED_view3d_viewcontext_init(C, &vc); - + extend = RNA_boolean_get(op->ptr, "extend"); select = !RNA_boolean_get(op->ptr, "deselect"); view3d_lasso_select(C, &vc, mcords, mcords_tot, extend, select); - + MEM_freeN((void *)mcords); return OPERATOR_FINISHED; @@ -911,16 +911,16 @@ void VIEW3D_OT_select_lasso(wmOperatorType *ot) ot->name = "Lasso Select"; ot->description = "Select items using lasso selection"; ot->idname = "VIEW3D_OT_select_lasso"; - + ot->invoke = WM_gesture_lasso_invoke; ot->modal = WM_gesture_lasso_modal; ot->exec = view3d_lasso_select_exec; ot->poll = view3d_selectable_data; ot->cancel = WM_gesture_lasso_cancel; - + /* flags */ ot->flag = OPTYPE_UNDO; - + /* properties */ WM_operator_properties_gesture_lasso_select(ot); } @@ -1033,7 +1033,7 @@ void VIEW3D_OT_select_menu(wmOperatorType *ot) static void deselectall_except(Scene *scene, Base *b) /* deselect all except b */ { Base *base; - + for (base = FIRSTBASE; base; base = base->next) { if (base->flag & SELECT) { if (b != base) { @@ -1050,7 +1050,7 @@ static Base *object_mouse_select_menu( short baseCount = 0; bool ok; LinkNode *linklist = NULL; - + CTX_DATA_BEGIN (C, Base *, base, selectable_bases) { ok = false; @@ -1253,12 +1253,12 @@ static Base *mouse_select_eval_buffer( View3D *v3d = vc->v3d; Base *base, *basact = NULL; int a; - + if (do_nearest) { unsigned int min = 0xFFFFFFFF; int selcol = 0, notcol = 0; - - + + if (has_bones) { /* we skip non-bone hits */ for (a = 0; a < hits; a++) { @@ -1271,7 +1271,7 @@ static Base *mouse_select_eval_buffer( else { /* only exclude active object when it is selected... */ if (BASACT && (BASACT->flag & SELECT) && hits > 1) notcol = BASACT->selcol; - + for (a = 0; a < hits; a++) { if (min > buffer[4 * a + 1] && notcol != (buffer[4 * a + 3] & 0xFFFF)) { min = buffer[4 * a + 1]; @@ -1279,7 +1279,7 @@ static Base *mouse_select_eval_buffer( } } } - + base = FIRSTBASE; while (base) { if (BASE_SELECTABLE(v3d, base)) { @@ -1290,7 +1290,7 @@ static Base *mouse_select_eval_buffer( if (base) basact = base; } else { - + base = startbase; while (base) { /* skip objects with select restriction, to prevent prematurely ending this loop @@ -1300,7 +1300,7 @@ static Base *mouse_select_eval_buffer( if (base == NULL) base = FIRSTBASE; if (base == startbase) break; } - + if (BASE_SELECTABLE(v3d, base)) { for (a = 0; a < hits; a++) { if (has_bones) { @@ -1316,15 +1316,15 @@ static Base *mouse_select_eval_buffer( } } } - + if (basact) break; - + base = base->next; if (base == NULL) base = FIRSTBASE; if (base == startbase) break; } } - + return basact; } @@ -1336,18 +1336,18 @@ Base *ED_view3d_give_base_under_cursor(bContext *C, const int mval[2]) unsigned int buffer[MAXPICKBUF]; int hits; bool do_nearest; - + /* setup view context for argument to callbacks */ view3d_operator_needs_opengl(C); ED_view3d_viewcontext_init(C, &vc); - + hits = mixed_bones_object_selectbuffer(&vc, buffer, mval, false, false, &do_nearest); - + if (hits > 0) { const bool has_bones = selectbuffer_has_bones(buffer, hits); basact = mouse_select_eval_buffer(&vc, buffer, hits, vc.scene->base.first, has_bones, do_nearest); } - + return basact; } @@ -1386,7 +1386,7 @@ static bool ed_object_select_pick( int hits; const float mval_fl[2] = {(float)mval[0], (float)mval[1]}; - + /* setup view context for argument to callbacks */ ED_view3d_viewcontext_init(C, &vc); @@ -1395,15 +1395,15 @@ static bool ed_object_select_pick( /* signal for view3d_opengl_select to skip editmode objects */ vc.obedit = NULL; } - + /* always start list from basact in wire mode */ startbase = FIRSTBASE; if (BASACT && BASACT->next) startbase = BASACT->next; - + /* This block uses the control key to make the object selected by its center point rather than its contents */ /* in editmode do not activate */ if (obcenter) { - + /* note; shift+alt goes to group-flush-selecting */ if (enumerate) { basact = object_mouse_select_menu(C, &vc, NULL, 0, mval, toggle); @@ -1426,7 +1426,7 @@ static bool ed_object_select_pick( } } base = base->next; - + if (base == NULL) base = FIRSTBASE; if (base == startbase) break; } @@ -1454,7 +1454,7 @@ static bool ed_object_select_pick( else { basact = mouse_select_eval_buffer(&vc, buffer, hits, startbase, has_bones, do_nearest); } - + if (has_bones && basact) { if (basact->object->type == OB_CAMERA) { if (BASACT == basact) { @@ -1518,16 +1518,16 @@ static bool ed_object_select_pick( scene, basact, buffer, hits, extend, deselect, toggle, do_nearest)) { /* then bone is found */ - - /* we make the armature selected: + + /* we make the armature selected: * not-selected active object in posemode won't work well for tools */ basact->flag |= SELECT; basact->object->flag = basact->flag; - + retval = true; WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, basact->object); WM_event_add_notifier(C, NC_OBJECT | ND_BONE_ACTIVE, basact->object); - + /* in weightpaint, we use selected bone to select vertexgroup, so no switch to new active object */ if (BASACT && (BASACT->object->mode & OB_MODE_WEIGHT_PAINT)) { /* prevent activating */ @@ -1541,11 +1541,11 @@ static bool ed_object_select_pick( } } } - + /* so, do we have something selected? */ if (basact) { retval = true; - + if (vc.obedit) { /* only do select */ deselectall_except(scene, basact); @@ -1555,7 +1555,7 @@ static bool ed_object_select_pick( else if (BASE_SELECTABLE(v3d, basact)) { oldbasact = BASACT; - + if (extend) { ED_base_object_select(basact, BA_SELECT); } @@ -1751,7 +1751,7 @@ static void do_nurbs_box_select__doSelect( static int do_nurbs_box_select(ViewContext *vc, rcti *rect, bool select, bool extend) { BoxSelectUserData data; - + view3d_userdata_boxselect_init(&data, vc, rect, select); if (extend == false && select) { @@ -1785,7 +1785,7 @@ static int do_lattice_box_select(ViewContext *vc, rcti *rect, bool select, bool ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); /* for foreach's screen/vert projection */ lattice_foreachScreenVert(vc, do_lattice_box_select__doSelect, &data, V3D_PROJ_TEST_CLIP_DEFAULT); - + return OPERATOR_FINISHED; } @@ -1829,7 +1829,7 @@ static int do_mesh_box_select(ViewContext *vc, rcti *rect, bool select, bool ext BoxSelectUserData data; ToolSettings *ts = vc->scene->toolsettings; int bbsel; - + view3d_userdata_boxselect_init(&data, vc, rect, select); if (extend == false && select) @@ -1860,7 +1860,7 @@ static int do_mesh_box_select(ViewContext *vc, rcti *rect, bool select, bool ext mesh_foreachScreenEdge(vc, do_mesh_box_select__doSelectEdge, &data, V3D_PROJ_TEST_CLIP_NEAR); } } - + if (ts->selectmode & SCE_SELECT_FACE) { if (bbsel) { edbm_backbuf_check_and_select_faces(vc->em, select); @@ -1869,11 +1869,11 @@ static int do_mesh_box_select(ViewContext *vc, rcti *rect, bool select, bool ext mesh_foreachScreenFace(vc, do_mesh_box_select__doSelectFace, &data, V3D_PROJ_TEST_CLIP_DEFAULT); } } - + EDBM_backbuf_free(); - + EDBM_selectmode_flush(vc->em); - + return OPERATOR_FINISHED; } @@ -1890,7 +1890,7 @@ static int do_meta_box_select(ViewContext *vc, rcti *rect, bool select, bool ext if (extend == false && select) BKE_mball_deselect_all(mb); - + for (ml = mb->editelems->first; ml; ml = ml->next) { for (a = 0; a < hits; a++) { if (ml->selcol1 == buffer[(4 * a) + 3]) { @@ -1920,11 +1920,11 @@ static int do_armature_box_select(ViewContext *vc, rcti *rect, bool select, bool int hits; hits = view3d_opengl_select(vc, buffer, MAXPICKBUF, rect, VIEW3D_SELECT_ALL); - + /* clear flag we use to detect point was affected */ for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) ebone->flag &= ~BONE_DONE; - + if (extend == false && select) ED_armature_edit_deselect_all_visible(vc->obedit); @@ -1980,9 +1980,9 @@ static int do_armature_box_select(ViewContext *vc, rcti *rect, bool select, bool } } } - + ED_armature_edit_sync_selection(arm->edbo); - + return hits > 0 ? OPERATOR_FINISHED : OPERATOR_CANCELLED; } @@ -1996,12 +1996,12 @@ static int do_object_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, b int bone_selected = 0; int totobj = MAXPICKBUF; /* XXX solve later */ int hits; - + if ((ob) && (ob->mode & OB_MODE_POSE)) bone_only = 1; else bone_only = 0; - + if (extend == false && select) { if (bone_only) { CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones) @@ -2027,7 +2027,7 @@ static int do_object_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, b * is the same as the object, we have a hit and can move to the next color * and object pair, if not, just move to the next object, * keeping the same color until we have a hit. - * + * * The buffer order is defined by OGL standard, hopefully no stupid GFX card * does it incorrectly. */ @@ -2035,7 +2035,7 @@ static int do_object_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, b if (hits > 0) { /* no need to loop if there's no hit */ Base *base; col = vbuffer + 3; - + for (base = vc->scene->base.first; base && hits; base = base->next) { if (BASE_SELECTABLE(vc->v3d, base)) { while (base->selcol == (*col & 0xFFFF)) { /* we got an object */ @@ -2059,19 +2059,19 @@ static int do_object_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, b else if (!bone_only) { ED_base_object_select(base, select ? BA_SELECT : BA_DESELECT); } - + col += 4; /* next color */ hits--; if (hits == 0) break; } } - + if (bone_selected) { if (base->object && (base->object->type == OB_ARMATURE)) { bArmature *arm = base->object->data; - + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, base->object); - + if (arm && (arm->flag & ARM_HAS_VIZ_DEPS)) { /* mask modifier ('armature' mode), etc. */ DAG_id_tag_update(&ob->id, OB_RECALC_DATA); @@ -2079,7 +2079,7 @@ static int do_object_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, b } } } - + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, vc->scene); } MEM_freeN(vbuffer); @@ -2100,7 +2100,7 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op) /* setup view context for argument to callbacks */ ED_view3d_viewcontext_init(C, &vc); - + select = !RNA_boolean_get(op->ptr, "deselect"); extend = RNA_boolean_get(op->ptr, "extend"); WM_operator_properties_border_to_rcti(op, &rect); @@ -2164,7 +2164,7 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op) } return ret; -} +} /* *****************Selection Operators******************* */ @@ -2176,17 +2176,17 @@ void VIEW3D_OT_select_border(wmOperatorType *ot) ot->name = "Border Select"; ot->description = "Select items using border selection"; ot->idname = "VIEW3D_OT_select_border"; - + /* api callbacks */ ot->invoke = WM_gesture_border_invoke; ot->exec = view3d_borderselect_exec; ot->modal = WM_gesture_border_modal; ot->poll = view3d_selectable_data; ot->cancel = WM_gesture_border_cancel; - + /* flags */ ot->flag = OPTYPE_UNDO; - + /* rna */ WM_operator_properties_gesture_border_select(ot); } @@ -2286,7 +2286,7 @@ static int view3d_select_exec(bContext *C, wmOperator *op) retval = ED_mball_select_pick(C, location, extend, deselect, toggle); else if (obedit->type == OB_FONT) retval = ED_curve_editfont_select_pick(C, location, extend, deselect, toggle); - + } else if (obact && obact->mode & OB_MODE_PARTICLE_EDIT) return PE_mouse_particles(C, location, extend, deselect, toggle); @@ -2321,15 +2321,15 @@ void VIEW3D_OT_select(wmOperatorType *ot) ot->name = "Activate/Select"; ot->description = "Activate/select item(s)"; ot->idname = "VIEW3D_OT_select"; - + /* api callbacks */ ot->invoke = view3d_select_invoke; ot->exec = view3d_select_exec; ot->poll = ED_operator_view3d_active; - + /* flags */ ot->flag = OPTYPE_UNDO; - + /* properties */ WM_operator_properties_mouse_select(ot); @@ -2404,7 +2404,7 @@ static void mesh_circle_select(ViewContext *vc, const bool select, const int mva ToolSettings *ts = vc->scene->toolsettings; int bbsel; CircleSelectUserData data; - + bbsel = EDBM_backbuf_circle_init(vc, mval[0], mval[1], (short)(rad + 1.0f)); ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); /* for foreach's screen/vert projection */ @@ -2429,7 +2429,7 @@ static void mesh_circle_select(ViewContext *vc, const bool select, const int mva mesh_foreachScreenEdge(vc, mesh_circle_doSelectEdge, &data, V3D_PROJ_TEST_CLIP_NEAR); } } - + if (ts->selectmode & SCE_SELECT_FACE) { if (bbsel) { edbm_backbuf_check_and_select_faces(vc->em, select); @@ -2623,11 +2623,11 @@ static void do_circle_select_pose__doSelectBone( static void pose_circle_select(ViewContext *vc, const bool select, const int mval[2], float rad) { CircleSelectUserData data; - + view3d_userdata_circleselect_init(&data, vc, select, mval, rad); ED_view3d_init_mats_rv3d(vc->obact, vc->rv3d); /* for foreach's screen/vert projection */ - + pose_foreachScreenBone(vc, do_circle_select_pose__doSelectBone, &data, V3D_PROJ_TEST_CLIP_DEFAULT); if (data.is_changed) { @@ -2650,13 +2650,13 @@ static bool armature_circle_doSelectJoint(void *userData, EditBone *ebone, const if (head) { if (data->select) ebone->flag |= BONE_ROOTSEL; - else + else ebone->flag &= ~BONE_ROOTSEL; } else { if (data->select) ebone->flag |= BONE_TIPSEL; - else + else ebone->flag &= ~BONE_TIPSEL; } return 1; @@ -2853,13 +2853,13 @@ void VIEW3D_OT_select_circle(wmOperatorType *ot) ot->name = "Circle Select"; ot->description = "Select items using circle selection"; ot->idname = "VIEW3D_OT_select_circle"; - + ot->invoke = WM_gesture_circle_invoke; ot->modal = WM_gesture_circle_modal; ot->exec = view3d_circle_select_exec; ot->poll = view3d_selectable_data; ot->cancel = WM_gesture_circle_cancel; - + /* flags */ ot->flag = OPTYPE_UNDO; |