Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/constraint.c
| Show First 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | |||||
| #include "DNA_lattice_types.h" | #include "DNA_lattice_types.h" | ||||
| #include "DNA_movieclip_types.h" | #include "DNA_movieclip_types.h" | ||||
| #include "DNA_scene_types.h" | #include "DNA_scene_types.h" | ||||
| #include "DNA_tracking_types.h" | #include "DNA_tracking_types.h" | ||||
| #include "BKE_action.h" | #include "BKE_action.h" | ||||
| #include "BKE_anim_path.h" | #include "BKE_anim_path.h" | ||||
| #include "BKE_animsys.h" | |||||
| #include "BKE_armature.h" | #include "BKE_armature.h" | ||||
| #include "BKE_bvhutils.h" | #include "BKE_bvhutils.h" | ||||
| #include "BKE_cachefile.h" | #include "BKE_cachefile.h" | ||||
| #include "BKE_camera.h" | #include "BKE_camera.h" | ||||
| #include "BKE_constraint.h" | #include "BKE_constraint.h" | ||||
| #include "BKE_curve.h" | #include "BKE_curve.h" | ||||
| #include "BKE_deform.h" | #include "BKE_deform.h" | ||||
| #include "BKE_displist.h" | #include "BKE_displist.h" | ||||
| ▲ Show 20 Lines • Show All 2,556 Lines • ▼ Show 20 Lines | if (con && list) { | ||||
| bActionConstraint *data = con->data; | bActionConstraint *data = con->data; | ||||
| bConstraintTarget *ct = list->first; | bConstraintTarget *ct = list->first; | ||||
| /* the following macro is used for all standard single-target constraints */ | /* the following macro is used for all standard single-target constraints */ | ||||
| SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, no_copy); | SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, no_copy); | ||||
| } | } | ||||
| } | } | ||||
| static void actcon_get_tarmat(struct Depsgraph *UNUSED(depsgraph), | static void actcon_get_tarmat(struct Depsgraph *depsgraph, | ||||
| bConstraint *con, | bConstraint *con, | ||||
| bConstraintOb *cob, | bConstraintOb *cob, | ||||
| bConstraintTarget *ct, | bConstraintTarget *ct, | ||||
| float UNUSED(ctime)) | float UNUSED(ctime)) | ||||
| { | { | ||||
| bActionConstraint *data = con->data; | bActionConstraint *data = con->data; | ||||
| if (VALID_CONS_TARGET(ct)) { | if (VALID_CONS_TARGET(ct)) { | ||||
| Show All 37 Lines | if (VALID_CONS_TARGET(ct)) { | ||||
| } | } | ||||
| BLI_assert((unsigned int)axis < 3); | BLI_assert((unsigned int)axis < 3); | ||||
| /* Target defines the animation */ | /* Target defines the animation */ | ||||
| s = (vec[axis] - data->min) / (data->max - data->min); | s = (vec[axis] - data->min) / (data->max - data->min); | ||||
| CLAMP(s, 0, 1); | CLAMP(s, 0, 1); | ||||
| t = (s * (data->end - data->start)) + data->start; | t = (s * (data->end - data->start)) + data->start; | ||||
| const AnimationEvalContext anim_eval_context = BKE_animsys_eval_context_construct(depsgraph, | |||||
| t); | |||||
| if (G.debug & G_DEBUG) { | if (G.debug & G_DEBUG) { | ||||
| printf("do Action Constraint %s - Ob %s Pchan %s\n", | printf("do Action Constraint %s - Ob %s Pchan %s\n", | ||||
| con->name, | con->name, | ||||
| cob->ob->id.name + 2, | cob->ob->id.name + 2, | ||||
| (cob->pchan) ? cob->pchan->name : NULL); | (cob->pchan) ? cob->pchan->name : NULL); | ||||
| } | } | ||||
| /* Get the appropriate information from the action */ | /* Get the appropriate information from the action */ | ||||
| if (cob->type == CONSTRAINT_OBTYPE_OBJECT || (data->flag & ACTCON_BONE_USE_OBJECT_ACTION)) { | if (cob->type == CONSTRAINT_OBTYPE_OBJECT || (data->flag & ACTCON_BONE_USE_OBJECT_ACTION)) { | ||||
| Object workob; | Object workob; | ||||
| /* evaluate using workob */ | /* evaluate using workob */ | ||||
| /* FIXME: we don't have any consistent standards on limiting effects on object... */ | /* FIXME: we don't have any consistent standards on limiting effects on object... */ | ||||
| what_does_obaction(cob->ob, &workob, NULL, data->act, NULL, t); | what_does_obaction(cob->ob, &workob, NULL, data->act, NULL, &anim_eval_context); | ||||
| BKE_object_to_mat4(&workob, ct->matrix); | BKE_object_to_mat4(&workob, ct->matrix); | ||||
| } | } | ||||
| else if (cob->type == CONSTRAINT_OBTYPE_BONE) { | else if (cob->type == CONSTRAINT_OBTYPE_BONE) { | ||||
| Object workob; | Object workob; | ||||
| bPose pose = {{0}}; | bPose pose = {{0}}; | ||||
| bPoseChannel *pchan, *tchan; | bPoseChannel *pchan, *tchan; | ||||
| /* make a copy of the bone of interest in the temp pose before evaluating action, | /* make a copy of the bone of interest in the temp pose before evaluating action, | ||||
| * so that it can get set - we need to manually copy over a few settings, | * so that it can get set - we need to manually copy over a few settings, | ||||
| * including rotation order, otherwise this fails. */ | * including rotation order, otherwise this fails. */ | ||||
| pchan = cob->pchan; | pchan = cob->pchan; | ||||
| tchan = BKE_pose_channel_verify(&pose, pchan->name); | tchan = BKE_pose_channel_verify(&pose, pchan->name); | ||||
| tchan->rotmode = pchan->rotmode; | tchan->rotmode = pchan->rotmode; | ||||
| /* evaluate action using workob (it will only set the PoseChannel in question) */ | /* evaluate action using workob (it will only set the PoseChannel in question) */ | ||||
| what_does_obaction(cob->ob, &workob, &pose, data->act, pchan->name, t); | what_does_obaction(cob->ob, &workob, &pose, data->act, pchan->name, &anim_eval_context); | ||||
| /* convert animation to matrices for use here */ | /* convert animation to matrices for use here */ | ||||
| BKE_pchan_calc_mat(tchan); | BKE_pchan_calc_mat(tchan); | ||||
| copy_m4_m4(ct->matrix, tchan->chan_mat); | copy_m4_m4(ct->matrix, tchan->chan_mat); | ||||
| /* Clean up */ | /* Clean up */ | ||||
| BKE_pose_free_data(&pose); | BKE_pose_free_data(&pose); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 3,356 Lines • Show Last 20 Lines | |||||