diff options
author | Lukas Tönne <lukas.toenne@gmail.com> | 2022-07-26 00:43:48 +0300 |
---|---|---|
committer | Lukas Tönne <lukas.toenne@gmail.com> | 2022-07-26 00:43:48 +0300 |
commit | f081e76037432cb926be45e980eac201d337032c (patch) | |
tree | dd1225521c12ea21c0b0c3d51ec1ae3f8730755f /source/blender/blenkernel/intern/constraint.c | |
parent | fa2084ae58a77b1201289b6bedac427f73c762d1 (diff) | |
parent | 462f99bf38648a08226b1fba423315aec2bc577b (diff) |
Merge branch 'master' into geometry-nodes-iterative-cachegeometry-nodes-rigid-body-integration
Diffstat (limited to 'source/blender/blenkernel/intern/constraint.c')
-rw-r--r-- | source/blender/blenkernel/intern/constraint.c | 43 |
1 files changed, 19 insertions, 24 deletions
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index aa09541c043..0534899a86c 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -116,7 +116,6 @@ void BKE_constraint_unique_name(bConstraint *con, ListBase *list) /* ----------------- Evaluation Loop Preparation --------------- */ -/* package an object/bone for use in constraint evaluation */ bConstraintOb *BKE_constraints_make_evalob( Depsgraph *depsgraph, Scene *scene, Object *ob, void *subdata, short datatype) { @@ -5845,9 +5844,12 @@ static bConstraint *add_new_constraint(Object *ob, return con; } -bool BKE_constraint_target_uses_bbone(struct bConstraint *con, - struct bConstraintTarget *UNUSED(ct)) +bool BKE_constraint_target_uses_bbone(struct bConstraint *con, struct bConstraintTarget *ct) { + if (ct->flag & CONSTRAINT_TAR_CUSTOM_SPACE) { + return false; + } + return (con->flag & CONSTRAINT_BBONE_SHAPE) || (con->type == CONSTRAINT_TYPE_ARMATURE); } @@ -6260,6 +6262,9 @@ void BKE_constraint_target_matrix_get(struct Depsgraph *depsgraph, } } + /* Initialize the custom space for use in calculating the matrices. */ + BKE_constraint_custom_object_space_init(cob, con); + /* get targets - we only need the first one though (and there should only be one) */ cti->get_constraint_targets(con, &targets); @@ -6323,33 +6328,23 @@ void BKE_constraint_targets_for_solving_get(struct Depsgraph *depsgraph, } } -void BKE_constraint_custom_object_space_get(float r_mat[4][4], bConstraint *con) +void BKE_constraint_custom_object_space_init(bConstraintOb *cob, bConstraint *con) { - if (!con || - (con->ownspace != CONSTRAINT_SPACE_CUSTOM && con->tarspace != CONSTRAINT_SPACE_CUSTOM)) { - return; - } - bConstraintTarget *ct; - ListBase target = {NULL, NULL}; - SINGLETARGET_GET_TARS(con, con->space_object, con->space_subtarget, ct, &target); - - /* Basically default_get_tarmat but without the unused parameters. */ - if (VALID_CONS_TARGET(ct)) { - constraint_target_to_mat4(ct->tar, - ct->subtarget, + if (con && con->space_object && is_custom_space_needed(con)) { + /* Basically default_get_tarmat but without the unused parameters. */ + constraint_target_to_mat4(con->space_object, + con->space_subtarget, NULL, - ct->matrix, + cob->space_obj_world_matrix, CONSTRAINT_SPACE_WORLD, CONSTRAINT_SPACE_WORLD, 0, 0); - copy_m4_m4(r_mat, ct->matrix); - } - else { - unit_m4(r_mat); + + return; } - SINGLETARGET_FLUSH_TARS(con, con->space_object, con->space_subtarget, ct, &target, true); + unit_m4(cob->space_obj_world_matrix); } /* ---------- Evaluation ----------- */ @@ -6394,8 +6389,8 @@ void BKE_constraints_solve(struct Depsgraph *depsgraph, */ enf = con->enforce; - /* Get custom space matrix. */ - BKE_constraint_custom_object_space_get(cob->space_obj_world_matrix, con); + /* Initialize the custom space for use in calculating the matrices. */ + BKE_constraint_custom_object_space_init(cob, con); /* make copy of world-space matrix pre-constraint for use with blending later */ copy_m4_m4(oldmat, cob->matrix); |