Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/object/object_hook.c
| Show First 20 Lines • Show All 442 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, SceneLayer *sl, Object *obedit) | static Object *add_hook_object_new(Main *bmain, Scene *scene, ViewLayer *sl, Object *obedit) | ||||
| { | { | ||||
| Base *base, *basedit; | Base *base, *basedit; | ||||
| Object *ob; | Object *ob; | ||||
| ob = BKE_object_add(bmain, scene, sl, OB_EMPTY, NULL); | ob = BKE_object_add(bmain, scene, sl, OB_EMPTY, NULL); | ||||
| basedit = BKE_scene_layer_base_find(sl, obedit); | basedit = BKE_view_layer_base_find(sl, obedit); | ||||
| base = sl->basact; | base = sl->basact; | ||||
| base->lay = ob->lay = obedit->lay; | base->lay = ob->lay = obedit->lay; | ||||
| BLI_assert(sl->basact->object == ob); | BLI_assert(sl->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 */ | ||||
| sl->basact = basedit; | sl->basact = basedit; | ||||
| return ob; | return ob; | ||||
| } | } | ||||
| static int add_hook_object(const bContext *C, Main *bmain, Scene *scene, SceneLayer *sl, Object *obedit, Object *ob, int mode, ReportList *reports) | static int add_hook_object(const bContext *C, Main *bmain, Scene *scene, ViewLayer *sl, Object *obedit, Object *ob, int mode, ReportList *reports) | ||||
| { | { | ||||
| ModifierData *md = NULL; | ModifierData *md = NULL; | ||||
| HookModifierData *hmd = NULL; | HookModifierData *hmd = NULL; | ||||
| EvaluationContext eval_ctx; | EvaluationContext eval_ctx; | ||||
| float cent[3]; | float cent[3]; | ||||
| float pose_mat[4][4]; | float pose_mat[4][4]; | ||||
| int tot, ok, *indexar; | int tot, ok, *indexar; | ||||
| char name[MAX_NAME]; | char name[MAX_NAME]; | ||||
| ▲ Show 20 Lines • Show All 78 Lines • ▼ Show 20 Lines | static int add_hook_object(const bContext *C, Main *bmain, Scene *scene, ViewLayer *sl, Object *obedit, Object *ob, int mode, ReportList *reports) | ||||
| return true; | return true; | ||||
| } | } | ||||
| static int object_add_hook_selob_exec(bContext *C, wmOperator *op) | static int object_add_hook_selob_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| SceneLayer *sl = CTX_data_scene_layer(C); | ViewLayer *sl = CTX_data_view_layer(C); | ||||
| Object *obedit = CTX_data_edit_object(C); | Object *obedit = CTX_data_edit_object(C); | ||||
| Object *obsel = NULL; | Object *obsel = NULL; | ||||
| const bool use_bone = RNA_boolean_get(op->ptr, "use_bone"); | const bool use_bone = RNA_boolean_get(op->ptr, "use_bone"); | ||||
| const int mode = use_bone ? OBJECT_ADDHOOK_SELOB_BONE : OBJECT_ADDHOOK_SELOB; | const int mode = use_bone ? OBJECT_ADDHOOK_SELOB_BONE : OBJECT_ADDHOOK_SELOB; | ||||
| CTX_DATA_BEGIN (C, Object *, ob, selected_objects) | CTX_DATA_BEGIN (C, Object *, ob, selected_objects) | ||||
| { | { | ||||
| if (ob != obedit) { | if (ob != obedit) { | ||||
| Show All 39 Lines | void OBJECT_OT_hook_add_selob(wmOperatorType *ot) | ||||
| RNA_def_boolean(ot->srna, "use_bone", false, "Active Bone", | RNA_def_boolean(ot->srna, "use_bone", false, "Active Bone", | ||||
| "Assign the hook to the hook objects active bone"); | "Assign the hook to the hook objects active bone"); | ||||
| } | } | ||||
| static int object_add_hook_newob_exec(bContext *C, wmOperator *op) | static int object_add_hook_newob_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| SceneLayer *sl = CTX_data_scene_layer(C); | ViewLayer *sl = CTX_data_view_layer(C); | ||||
| Object *obedit = CTX_data_edit_object(C); | Object *obedit = CTX_data_edit_object(C); | ||||
| if (add_hook_object(C, bmain, scene, sl, obedit, NULL, OBJECT_ADDHOOK_NEWOB, op->reports)) { | if (add_hook_object(C, bmain, scene, sl, obedit, NULL, OBJECT_ADDHOOK_NEWOB, op->reports)) { | ||||
| WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); | WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); | ||||
| WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, obedit); | WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, obedit); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| else { | else { | ||||
| ▲ Show 20 Lines • Show All 291 Lines • Show Last 20 Lines | |||||