Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/object/object_hook.c
| Show First 20 Lines • Show All 522 Lines • ▼ Show 20 Lines | static int add_hook_object(const bContext *C, | ||||
| Scene *scene, | Scene *scene, | ||||
| ViewLayer *view_layer, | ViewLayer *view_layer, | ||||
| View3D *v3d, | View3D *v3d, | ||||
| Object *obedit, | Object *obedit, | ||||
| Object *ob, | Object *ob, | ||||
| int mode, | int mode, | ||||
| ReportList *reports) | ReportList *reports) | ||||
| { | { | ||||
| Depsgraph *depsgraph = CTX_data_depsgraph(C); | Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | ||||
| ModifierData *md = NULL; | ModifierData *md = NULL; | ||||
| HookModifierData *hmd = NULL; | HookModifierData *hmd = NULL; | ||||
| 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]; | ||||
| ok = object_hook_index_array(bmain, scene, obedit, &tot, &indexar, name, cent); | ok = object_hook_index_array(bmain, scene, obedit, &tot, &indexar, name, cent); | ||||
| ▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | if (mode == OBJECT_ADDHOOK_SELOB_BONE) { | ||||
| } | } | ||||
| } | } | ||||
| copy_v3_v3(hmd->cent, cent); | copy_v3_v3(hmd->cent, cent); | ||||
| /* matrix calculus */ | /* matrix calculus */ | ||||
| /* vert x (obmat x hook->imat) x hook->obmat x ob->imat */ | /* vert x (obmat x hook->imat) x hook->obmat x ob->imat */ | ||||
| /* (parentinv ) */ | /* (parentinv ) */ | ||||
| Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob); | Scene *scene_eval = DEG_get_evaluated_scene(depsgraph); | ||||
| BKE_object_transform_copy(ob_eval, ob); | Object *object_eval = DEG_get_evaluated_object(depsgraph, ob); | ||||
| BKE_object_where_is_calc(depsgraph, scene, ob_eval); | BKE_object_transform_copy(object_eval, ob); | ||||
| BKE_object_where_is_calc(depsgraph, scene_eval, object_eval); | |||||
| invert_m4_m4(ob_eval->imat, ob_eval->obmat); | invert_m4_m4(object_eval->imat, object_eval->obmat); | ||||
| /* apparently this call goes from right to left... */ | /* apparently this call goes from right to left... */ | ||||
| mul_m4_series(hmd->parentinv, pose_mat, ob_eval->imat, obedit->obmat); | mul_m4_series(hmd->parentinv, pose_mat, object_eval->imat, obedit->obmat); | ||||
| DEG_relations_tag_update(bmain); | DEG_relations_tag_update(bmain); | ||||
| 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) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 374 Lines • Show Last 20 Lines | |||||