Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/object/object_hook.c
| Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | |||||
| #include "BKE_layer.h" | #include "BKE_layer.h" | ||||
| #include "BKE_main.h" | #include "BKE_main.h" | ||||
| #include "BKE_modifier.h" | #include "BKE_modifier.h" | ||||
| #include "BKE_object.h" | #include "BKE_object.h" | ||||
| #include "BKE_report.h" | #include "BKE_report.h" | ||||
| #include "BKE_scene.h" | #include "BKE_scene.h" | ||||
| #include "BKE_deform.h" | #include "BKE_deform.h" | ||||
| #include "BKE_editmesh.h" | #include "BKE_editmesh.h" | ||||
| #include "BKE_workspace.h" | |||||
| #include "DEG_depsgraph.h" | #include "DEG_depsgraph.h" | ||||
| #include "DEG_depsgraph_build.h" | #include "DEG_depsgraph_build.h" | ||||
| #include "RNA_define.h" | #include "RNA_define.h" | ||||
| #include "RNA_access.h" | #include "RNA_access.h" | ||||
| #include "RNA_enum_types.h" | #include "RNA_enum_types.h" | ||||
| ▲ Show 20 Lines • Show All 376 Lines • ▼ Show 20 Lines | if (obedit) { | ||||
| if (ED_operator_editsurfcurve(C)) return 1; | if (ED_operator_editsurfcurve(C)) return 1; | ||||
| if (ED_operator_editlattice(C)) return 1; | if (ED_operator_editlattice(C)) return 1; | ||||
| //if (ED_operator_editmball(C)) return 1; | //if (ED_operator_editmball(C)) return 1; | ||||
| } | } | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| static Object *add_hook_object_new(Main *bmain, Scene *scene, ViewLayer *view_layer, Object *obedit) | static Object *add_hook_object_new( | ||||
| Main *bmain, Scene *scene, | |||||
| ViewLayer *view_layer, Object *obedit, | |||||
| WorkSpace *workspace) | |||||
| { | { | ||||
| Base *base, *basedit; | Base *base, *basedit; | ||||
| Object *ob; | Object *ob; | ||||
| ob = BKE_object_add(bmain, scene, view_layer, OB_EMPTY, NULL); | ob = BKE_object_add(bmain, scene, view_layer, workspace, OB_EMPTY, NULL); | ||||
| basedit = BKE_view_layer_base_find(view_layer, obedit); | basedit = BKE_view_layer_base_find(view_layer, obedit); | ||||
| base = view_layer->basact; | base = view_layer->basact; | ||||
| base->lay = ob->lay = obedit->lay; | base->lay = ob->lay = obedit->lay; | ||||
| BLI_assert(view_layer->basact->object == ob); | BLI_assert(view_layer->basact->object == ob); | ||||
| /* icky, BKE_object_add sets new base as active. | /* icky, BKE_object_add sets new base as active. | ||||
| * so set it back to the original edit object */ | * so set it back to the original edit object */ | ||||
| view_layer->basact = basedit; | view_layer->basact = basedit; | ||||
| BKE_workspace_active_base_changed(workspace, view_layer); | |||||
| return ob; | return ob; | ||||
| } | } | ||||
| static int add_hook_object(const bContext *C, Main *bmain, Scene *scene, ViewLayer *view_layer, Object *obedit, Object *ob, int mode, ReportList *reports) | static int add_hook_object(const bContext *C, Main *bmain, Scene *scene, ViewLayer *view_layer, Object *obedit, Object *ob, int mode, ReportList *reports) | ||||
| { | { | ||||
| ModifierData *md = NULL; | ModifierData *md = NULL; | ||||
| HookModifierData *hmd = NULL; | HookModifierData *hmd = NULL; | ||||
| Show All 9 Lines | static int add_hook_object(const bContext *C, Main *bmain, Scene *scene, ViewLayer *view_layer, Object *obedit, Object *ob, int mode, ReportList *reports) | ||||
| if (!ok) { | if (!ok) { | ||||
| BKE_report(reports, RPT_ERROR, "Requires selected vertices or active vertex group"); | BKE_report(reports, RPT_ERROR, "Requires selected vertices or active vertex group"); | ||||
| return false; | return false; | ||||
| } | } | ||||
| if (mode == OBJECT_ADDHOOK_NEWOB && !ob) { | if (mode == OBJECT_ADDHOOK_NEWOB && !ob) { | ||||
| ob = add_hook_object_new(bmain, scene, view_layer, obedit); | ob = add_hook_object_new(bmain, scene, view_layer, obedit, CTX_wm_workspace(C)); | ||||
| /* transform cent to global coords for loc */ | /* transform cent to global coords for loc */ | ||||
| mul_v3_m4v3(ob->loc, obedit->obmat, cent); | mul_v3_m4v3(ob->loc, obedit->obmat, cent); | ||||
| } | } | ||||
| md = obedit->modifiers.first; | md = obedit->modifiers.first; | ||||
| while (md && modifierType_getInfo(md->type)->type == eModifierTypeType_OnlyDeform) { | while (md && modifierType_getInfo(md->type)->type == eModifierTypeType_OnlyDeform) { | ||||
| md = md->next; | md = md->next; | ||||
| ▲ Show 20 Lines • Show All 421 Lines • Show Last 20 Lines | |||||