Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/constraint.c
| Show First 20 Lines • Show All 362 Lines • ▼ Show 20 Lines | |||||
| /* ------------ General Target Matrix Tools ---------- */ | /* ------------ General Target Matrix Tools ---------- */ | ||||
| /* function that sets the given matrix based on given vertex group in mesh */ | /* function that sets the given matrix based on given vertex group in mesh */ | ||||
| static void contarget_get_mesh_mat(Object *ob, const char *substring, float mat[4][4]) | static void contarget_get_mesh_mat(Object *ob, const char *substring, float mat[4][4]) | ||||
| { | { | ||||
| /* when not in EditMode, use the 'final' evaluated mesh, depsgraph | /* when not in EditMode, use the 'final' evaluated mesh, depsgraph | ||||
| * ensures we build with CD_MDEFORMVERT layer | * ensures we build with CD_MDEFORMVERT layer | ||||
| */ | */ | ||||
| Mesh *me_eval = ob->runtime.mesh_eval; | Mesh *me_eval = BKE_object_get_evaluated_mesh(ob); | ||||
| BMEditMesh *em = BKE_editmesh_from_object(ob); | BMEditMesh *em = BKE_editmesh_from_object(ob); | ||||
| float plane[3]; | float plane[3]; | ||||
| float imat[3][3], tmat[3][3]; | float imat[3][3], tmat[3][3]; | ||||
| const int defgroup = defgroup_name_index(ob, substring); | const int defgroup = defgroup_name_index(ob, substring); | ||||
| /* initialize target matrix using target matrix */ | /* initialize target matrix using target matrix */ | ||||
| copy_m4_m4(mat, ob->obmat); | copy_m4_m4(mat, ob->obmat); | ||||
| ▲ Show 20 Lines • Show All 3,589 Lines • ▼ Show 20 Lines | static void shrinkwrap_get_tarmat(struct Depsgraph *UNUSED(depsgraph), | ||||
| if (VALID_CONS_TARGET(ct) && (ct->tar->type == OB_MESH)) { | if (VALID_CONS_TARGET(ct) && (ct->tar->type == OB_MESH)) { | ||||
| bool fail = false; | bool fail = false; | ||||
| float co[3] = {0.0f, 0.0f, 0.0f}; | float co[3] = {0.0f, 0.0f, 0.0f}; | ||||
| bool track_normal = false; | bool track_normal = false; | ||||
| float track_no[3] = {0.0f, 0.0f, 0.0f}; | float track_no[3] = {0.0f, 0.0f, 0.0f}; | ||||
| SpaceTransform transform; | SpaceTransform transform; | ||||
| Mesh *target_eval = ct->tar->runtime.mesh_eval; | Mesh *target_eval = BKE_object_get_evaluated_mesh(ct->tar); | ||||
| copy_m4_m4(ct->matrix, cob->matrix); | copy_m4_m4(ct->matrix, cob->matrix); | ||||
| bool do_track_normal = (scon->flag & CON_SHRINKWRAP_TRACK_NORMAL) != 0; | bool do_track_normal = (scon->flag & CON_SHRINKWRAP_TRACK_NORMAL) != 0; | ||||
| ShrinkwrapTreeData tree; | ShrinkwrapTreeData tree; | ||||
| if (BKE_shrinkwrap_init_tree( | if (BKE_shrinkwrap_init_tree( | ||||
| &tree, target_eval, scon->shrinkType, scon->shrinkMode, do_track_normal)) { | &tree, target_eval, scon->shrinkType, scon->shrinkMode, do_track_normal)) { | ||||
| ▲ Show 20 Lines • Show All 751 Lines • ▼ Show 20 Lines | if (len > FLT_EPSILON) { | ||||
| zero_v3(rmat[3]); | zero_v3(rmat[3]); | ||||
| mul_m4_m4m4(cob->matrix, cob->matrix, rmat); | mul_m4_m4m4(cob->matrix, cob->matrix, rmat); | ||||
| copy_v3_v3(cob->matrix[3], disp); | copy_v3_v3(cob->matrix[3], disp); | ||||
| } | } | ||||
| if (data->depth_ob) { | if (data->depth_ob) { | ||||
| Object *depth_ob = data->depth_ob; | Object *depth_ob = data->depth_ob; | ||||
| Mesh *target_eval = depth_ob->runtime.mesh_eval; | Mesh *target_eval = BKE_object_get_evaluated_mesh(depth_ob); | ||||
| if (target_eval) { | if (target_eval) { | ||||
| BVHTreeFromMesh treeData = NULL_BVHTreeFromMesh; | BVHTreeFromMesh treeData = NULL_BVHTreeFromMesh; | ||||
| BVHTreeRayHit hit; | BVHTreeRayHit hit; | ||||
| float ray_start[3], ray_end[3], ray_nor[3], imat[4][4]; | float ray_start[3], ray_end[3], ray_nor[3], imat[4][4]; | ||||
| int result; | int result; | ||||
| invert_m4_m4(imat, depth_ob->obmat); | invert_m4_m4(imat, depth_ob->obmat); | ||||
| ▲ Show 20 Lines • Show All 1,077 Lines • Show Last 20 Lines | |||||