Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/object/object_hook.c
| Show First 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | |||||
| #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 "DEG_depsgraph.h" | #include "DEG_depsgraph.h" | ||||
| #include "DEG_depsgraph_build.h" | #include "DEG_depsgraph_build.h" | ||||
| #include "DEG_depsgraph_query.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" | ||||
| #include "ED_curve.h" | #include "ED_curve.h" | ||||
| #include "ED_mesh.h" | #include "ED_mesh.h" | ||||
| #include "ED_screen.h" | #include "ED_screen.h" | ||||
| ▲ Show 20 Lines • Show All 459 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_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 ) */ | ||||
| BKE_object_where_is_calc(CTX_data_depsgraph(C), scene, ob); | Scene *scene_eval = DEG_get_evaluated_scene(depsgraph); | ||||
| Object *object_eval = DEG_get_evaluated_object(depsgraph, ob); | |||||
| BKE_object_transform_copy(object_eval, ob); | |||||
| BKE_object_where_is_calc(depsgraph, scene_eval, object_eval); | |||||
| invert_m4_m4(ob->imat, ob->obmat); | invert_m4_m4(ob->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->imat, obedit->obmat); | mul_m4_series(hmd->parentinv, pose_mat, ob->imat, obedit->obmat); | ||||
| DEG_relations_tag_update(bmain); | DEG_relations_tag_update(bmain); | ||||
| return true; | return true; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 376 Lines • Show Last 20 Lines | |||||