static bool edbm_bevel_calc(wmOperator *op) { BevelData *opdata = op->customdata; BMEditMesh *em = opdata->em; BMOperator bmop; const float offset = RNA_float_get(op->ptr, "offset"); const int offset_type = RNA_enum_get(op->ptr, "offset_type"); const int segments = RNA_int_get(op->ptr, "segments"); const float profile = RNA_float_get(op->ptr, "profile"); const bool vertex_only = RNA_boolean_get(op->ptr, "vertex_only"); const bool clamp_overlap = RNA_boolean_get(op->ptr, "clamp_overlap"); int material = RNA_int_get(op->ptr, "material"); const bool loop_slide = RNA_boolean_get(op->ptr, "loop_slide"); /* revert to original mesh */ if (opdata->is_modal) { EDBM_redo_state_restore(opdata->mesh_backup, em, false); } if (em->ob) { material = CLAMPIS(material, -1, em->ob->totcol - 1); } EDBM_op_init(em, &bmop, op, "bevel geom=%hev offset=%f segments=%i vertex_only=%b offset_type=%i profile=%f clamp_overlap=%b " "material=%i loop_slide=%b", BM_ELEM_SELECT, offset, segments, vertex_only, offset_type, profile, clamp_overlap, material, loop_slide); BMO_op_exec(em->bm, &bmop); if (offset != 0.0f) { /* not essential, but we may have some loose geometry that * won't get bevel'd and better not leave it selected */ EDBM_flag_disable_all(em, BM_ELEM_SELECT); BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "faces.out", BM_FACE, BM_ELEM_SELECT, true); } /* no need to de-select existing geometry */ if (!EDBM_op_finish(em, &bmop, op, true)) { return false; } EDBM_mesh_normals_update(opdata->em); EDBM_update_generic(opdata->em, true, true); return true; }
static bool edbm_bevel_calc(wmOperator *op) { BevelData *opdata = op->customdata; BMEditMesh *em; BMOperator bmop; bool changed = false; const float offset = get_bevel_offset(op); const int offset_type = RNA_enum_get(op->ptr, "offset_type"); const int segments = RNA_int_get(op->ptr, "segments"); const float profile = RNA_float_get(op->ptr, "profile"); const bool vertex_only = RNA_boolean_get(op->ptr, "vertex_only"); const bool clamp_overlap = RNA_boolean_get(op->ptr, "clamp_overlap"); int material = RNA_int_get(op->ptr, "material"); const bool loop_slide = RNA_boolean_get(op->ptr, "loop_slide"); const bool mark_seam = RNA_boolean_get(op->ptr, "mark_seam"); const bool mark_sharp = RNA_boolean_get(op->ptr, "mark_sharp"); const bool harden_normals = RNA_boolean_get(op->ptr, "harden_normals"); const int face_strength_mode = RNA_enum_get(op->ptr, "face_strength_mode"); const int miter_outer = RNA_enum_get(op->ptr, "miter_outer"); const int miter_inner = RNA_enum_get(op->ptr, "miter_inner"); const float spread = RNA_float_get(op->ptr, "spread"); for (uint ob_index = 0; ob_index < opdata->ob_store_len; ob_index++) { em = opdata->ob_store[ob_index].em; /* revert to original mesh */ if (opdata->is_modal) { EDBM_redo_state_restore(opdata->ob_store[ob_index].mesh_backup, em, false); } if (em->ob) { material = CLAMPIS(material, -1, em->ob->totcol - 1); } Mesh *me = em->ob->data; if (harden_normals && !(me->flag & ME_AUTOSMOOTH)) { /* harden_normals only has a visible effect if autosmooth is on, so turn it on */ me->flag |= ME_AUTOSMOOTH; } EDBM_op_init(em, &bmop, op, "bevel geom=%hev offset=%f segments=%i vertex_only=%b offset_type=%i profile=%f " "clamp_overlap=%b material=%i loop_slide=%b mark_seam=%b mark_sharp=%b " "harden_normals=%b face_strength_mode=%i " "miter_outer=%i miter_inner=%i spread=%f smoothresh=%f", BM_ELEM_SELECT, offset, segments, vertex_only, offset_type, profile, clamp_overlap, material, loop_slide, mark_seam, mark_sharp, harden_normals, face_strength_mode, miter_outer, miter_inner, spread, me->smoothresh); BMO_op_exec(em->bm, &bmop); if (offset != 0.0f) { /* not essential, but we may have some loose geometry that * won't get bevel'd and better not leave it selected */ EDBM_flag_disable_all(em, BM_ELEM_SELECT); BMO_slot_buffer_hflag_enable( em->bm, bmop.slots_out, "faces.out", BM_FACE, BM_ELEM_SELECT, true); } /* no need to de-select existing geometry */ if (!EDBM_op_finish(em, &bmop, op, true)) { continue; } EDBM_mesh_normals_update(em); EDBM_update_generic(em, true, true); changed = true; } return changed; }
void ED_object_enter_editmode(bContext *C, int flag) { Scene *scene= CTX_data_scene(C); Base *base= NULL; Object *ob; ScrArea *sa= CTX_wm_area(C); View3D *v3d= NULL; int ok= 0; if (scene->id.lib) return; if (sa && sa->spacetype==SPACE_VIEW3D) v3d= sa->spacedata.first; if ((flag & EM_IGNORE_LAYER)==0) { base= CTX_data_active_base(C); /* active layer checked here for view3d */ if (base==NULL) return; else if (v3d && (base->lay & v3d->lay)==0) return; else if (!v3d && (base->lay & scene->lay)==0) return; } else { base= scene->basact; } if (ELEM3(NULL, base, base->object, base->object->data)) return; ob = base->object; if (object_data_is_libdata(ob)) { error_libdata(); return; } if (flag & EM_WAITCURSOR) waitcursor(1); ob->restore_mode = ob->mode; /* note, when switching scenes the object can have editmode data but * not be scene->obedit: bug 22954, this avoids calling self eternally */ if ((ob->restore_mode & OB_MODE_EDIT)==0) ED_object_toggle_modes(C, ob->mode); ob->mode= OB_MODE_EDIT; if (ob->type==OB_MESH) { BMEditMesh *em; ok= 1; scene->obedit = ob; /* context sees this */ EDBM_mesh_make(CTX_data_tool_settings(C), scene, ob); em = BMEdit_FromObject(ob); if (LIKELY(em)) { /* order doesn't matter */ EDBM_mesh_normals_update(em); BMEdit_RecalcTessellation(em); BM_mesh_select_mode_flush(em->bm); } WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_EDITMODE_MESH, scene); } else if (ob->type==OB_ARMATURE) { bArmature *arm= base->object->data; if (!arm) return; /* * The function object_data_is_libdata make a problem here, the * check for ob->proxy return 0 and let blender enter to edit mode * this causes a crash when you try leave the edit mode. * The problem is that i can't remove the ob->proxy check from * object_data_is_libdata that prevent the bugfix #6614, so * i add this little hack here. */ if (arm->id.lib) { error_libdata(); return; } ok=1; scene->obedit= ob; ED_armature_to_edit(ob); /* to ensure all goes in restposition and without striding */ DAG_id_tag_update(&ob->id, OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME); // XXX: should this be OB_RECALC_DATA? WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_EDITMODE_ARMATURE, scene); } else if (ob->type==OB_FONT) { scene->obedit= ob; // XXX for context ok= 1; make_editText(ob); WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_EDITMODE_TEXT, scene); } else if (ob->type==OB_MBALL) { scene->obedit= ob; // XXX for context ok= 1; make_editMball(ob); WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_EDITMODE_MBALL, scene); } else if (ob->type==OB_LATTICE) { scene->obedit= ob; // XXX for context ok= 1; make_editLatt(ob); WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_EDITMODE_LATTICE, scene); } else if (ob->type==OB_SURF || ob->type==OB_CURVE) { ok= 1; scene->obedit= ob; // XXX for context make_editNurb(ob); WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_EDITMODE_CURVE, scene); } if (ok) { DAG_id_tag_update(&ob->id, OB_RECALC_DATA); } else { scene->obedit= NULL; // XXX for context ob->mode &= ~OB_MODE_EDIT; WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_OBJECT, scene); } if (flag & EM_DO_UNDO) ED_undo_push(C, "Enter Editmode"); if (flag & EM_WAITCURSOR) waitcursor(0); }