Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenkernel/intern/armature.c')
-rw-r--r--source/blender/blenkernel/intern/armature.c221
1 files changed, 30 insertions, 191 deletions
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index 5704ef6e42f..1a9f0a9130d 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -69,8 +69,6 @@
#include "CLG_log.h"
-static CLG_LogRef LOG = {"bke.armature"};
-
/* -------------------------------------------------------------------- */
/** \name Prototypes
* \{ */
@@ -2296,161 +2294,6 @@ void BKE_armature_where_is(bArmature *arm)
/** \name Pose Rebuild
* \{ */
-/* if bone layer is protected, copy the data from from->pose
- * when used with linked libraries this copies from the linked pose into the local pose */
-static void pose_proxy_sync(Object *ob, Object *from, int layer_protected)
-{
- bPose *pose = ob->pose, *frompose = from->pose;
- bPoseChannel *pchan, *pchanp;
- bConstraint *con;
- int error = 0;
-
- if (frompose == NULL) {
- return;
- }
-
- /* in some cases when rigs change, we can't synchronize
- * to avoid crashing check for possible errors here */
- for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
- if (pchan->bone->layer & layer_protected) {
- if (BKE_pose_channel_find_name(frompose, pchan->name) == NULL) {
- CLOG_ERROR(&LOG,
- "failed to sync proxy armature because '%s' is missing pose channel '%s'",
- from->id.name,
- pchan->name);
- error = 1;
- }
- }
- }
-
- if (error) {
- return;
- }
-
- /* clear all transformation values from library */
- BKE_pose_rest(frompose, false);
-
- /* copy over all of the proxy's bone groups */
- /* TODO: for later
- * - implement 'local' bone groups as for constraints
- * NOTE: this isn't trivial, as bones reference groups by index not by pointer,
- * so syncing things correctly needs careful attention */
- BLI_freelistN(&pose->agroups);
- BLI_duplicatelist(&pose->agroups, &frompose->agroups);
- pose->active_group = frompose->active_group;
-
- for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
- pchanp = BKE_pose_channel_find_name(frompose, pchan->name);
-
- if (UNLIKELY(pchanp == NULL)) {
- /* happens for proxies that become invalid because of a missing link
- * for regular cases it shouldn't happen at all */
- }
- else if (pchan->bone->layer & layer_protected) {
- ListBase proxylocal_constraints = {NULL, NULL};
- bPoseChannel pchanw;
-
- /* copy posechannel to temp, but restore important pointers */
- pchanw = *pchanp;
- pchanw.bone = pchan->bone;
- pchanw.prev = pchan->prev;
- pchanw.next = pchan->next;
- pchanw.parent = pchan->parent;
- pchanw.child = pchan->child;
- pchanw.custom_tx = pchan->custom_tx;
- pchanw.bbone_prev = pchan->bbone_prev;
- pchanw.bbone_next = pchan->bbone_next;
-
- pchanw.mpath = pchan->mpath;
- pchan->mpath = NULL;
-
- /* Reset runtime data, we don't want to share that with the proxy. */
- BKE_pose_channel_runtime_reset_on_copy(&pchanw.runtime);
-
- /* this is freed so copy a copy, else undo crashes */
- if (pchanw.prop) {
- pchanw.prop = IDP_CopyProperty(pchanw.prop);
-
- /* use the values from the existing props */
- if (pchan->prop) {
- IDP_SyncGroupValues(pchanw.prop, pchan->prop);
- }
- }
-
- /* Constraints - proxy constraints are flushed... local ones are added after
- * 1: extract constraints not from proxy (CONSTRAINT_PROXY_LOCAL) from pchan's constraints.
- * 2: copy proxy-pchan's constraints on-to new.
- * 3: add extracted local constraints back on top.
- *
- * Note for BKE_constraints_copy:
- * When copying constraints, disable 'do_extern' otherwise
- * we get the libs direct linked in this blend.
- */
- BKE_constraints_proxylocal_extract(&proxylocal_constraints, &pchan->constraints);
- BKE_constraints_copy(&pchanw.constraints, &pchanp->constraints, false);
- BLI_movelisttolist(&pchanw.constraints, &proxylocal_constraints);
-
- /* constraints - set target ob pointer to own object */
- for (con = pchanw.constraints.first; con; con = con->next) {
- const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
- ListBase targets = {NULL, NULL};
- bConstraintTarget *ct;
-
- if (cti && cti->get_constraint_targets) {
- cti->get_constraint_targets(con, &targets);
-
- for (ct = targets.first; ct; ct = ct->next) {
- if (ct->tar == from) {
- ct->tar = ob;
- }
- }
-
- if (cti->flush_constraint_targets) {
- cti->flush_constraint_targets(con, &targets, 0);
- }
- }
- }
-
- /* free stuff from current channel */
- BKE_pose_channel_free(pchan);
-
- /* copy data in temp back over to the cleaned-out (but still allocated) original channel */
- *pchan = pchanw;
- if (pchan->custom) {
- id_us_plus(&pchan->custom->id);
- }
- }
- else {
- /* always copy custom shape */
- pchan->custom = pchanp->custom;
- if (pchan->custom) {
- id_us_plus(&pchan->custom->id);
- }
- if (pchanp->custom_tx) {
- pchan->custom_tx = BKE_pose_channel_find_name(pose, pchanp->custom_tx->name);
- }
-
- /* ID-Property Syncing */
- {
- IDProperty *prop_orig = pchan->prop;
- if (pchanp->prop) {
- pchan->prop = IDP_CopyProperty(pchanp->prop);
- if (prop_orig) {
- /* copy existing values across when types match */
- IDP_SyncGroupValues(pchan->prop, prop_orig);
- }
- }
- else {
- pchan->prop = NULL;
- }
- if (prop_orig) {
- IDP_FreeProperty(prop_orig);
- }
- }
- }
- }
-}
-
/**
* \param r_last_visited_bone_p: The last bone handled by the last call to this function.
*/
@@ -2579,16 +2422,6 @@ void BKE_pose_rebuild(Main *bmain, Object *ob, bArmature *arm, const bool do_id_
// printf("rebuild pose %s, %d bones\n", ob->id.name, counter);
- /* synchronize protected layers with proxy */
- /* HACK! To preserve 2.7x behavior that you always can pose even locked bones,
- * do not do any restoration if this is a COW temp copy! */
- /* Switched back to just NO_MAIN tag, for some reasons (c)
- * using COW tag was working this morning, but not anymore... */
- if (ob->proxy != NULL && (ob->id.tag & LIB_TAG_NO_MAIN) == 0) {
- BKE_object_copy_proxy_drivers(ob, ob->proxy);
- pose_proxy_sync(ob, ob->proxy, arm->layer_protected);
- }
-
BKE_pose_update_constraint_flags(pose); /* for IK detection for example */
pose->flag &= ~POSE_RECALC;
@@ -2846,6 +2679,35 @@ BoundBox *BKE_armature_boundbox_get(Object *ob)
return ob->runtime.bb;
}
+void BKE_pchan_minmax(const Object *ob, const bPoseChannel *pchan, float r_min[3], float r_max[3])
+{
+ const bArmature *arm = ob->data;
+ const bPoseChannel *pchan_tx = (pchan->custom && pchan->custom_tx) ? pchan->custom_tx : pchan;
+ const BoundBox *bb_custom = ((pchan->custom) && !(arm->flag & ARM_NO_CUSTOM)) ?
+ BKE_object_boundbox_get(pchan->custom) :
+ NULL;
+ if (bb_custom) {
+ float mat[4][4], smat[4][4], rmat[4][4], tmp[4][4];
+ scale_m4_fl(smat, PCHAN_CUSTOM_BONE_LENGTH(pchan));
+ rescale_m4(smat, pchan->custom_scale_xyz);
+ eulO_to_mat4(rmat, pchan->custom_rotation_euler, ROT_MODE_XYZ);
+ copy_m4_m4(tmp, pchan_tx->pose_mat);
+ translate_m4(tmp,
+ pchan->custom_translation[0],
+ pchan->custom_translation[1],
+ pchan->custom_translation[2]);
+ mul_m4_series(mat, ob->obmat, tmp, rmat, smat);
+ BKE_boundbox_minmax(bb_custom, mat, r_min, r_max);
+ }
+ else {
+ float vec[3];
+ mul_v3_m4v3(vec, ob->obmat, pchan_tx->pose_head);
+ minmax_v3v3_v3(r_min, r_max, vec);
+ mul_v3_m4v3(vec, ob->obmat, pchan_tx->pose_tail);
+ minmax_v3v3_v3(r_min, r_max, vec);
+ }
+}
+
bool BKE_pose_minmax(Object *ob, float r_min[3], float r_max[3], bool use_hidden, bool use_select)
{
bool changed = false;
@@ -2859,31 +2721,8 @@ bool BKE_pose_minmax(Object *ob, float r_min[3], float r_max[3], bool use_hidden
* (editarmature.c:2592)... Skip in this case too! */
if (pchan->bone && (!((use_hidden == false) && (PBONE_VISIBLE(arm, pchan->bone) == false)) &&
!((use_select == true) && ((pchan->bone->flag & BONE_SELECTED) == 0)))) {
- bPoseChannel *pchan_tx = (pchan->custom && pchan->custom_tx) ? pchan->custom_tx : pchan;
- BoundBox *bb_custom = ((pchan->custom) && !(arm->flag & ARM_NO_CUSTOM)) ?
- BKE_object_boundbox_get(pchan->custom) :
- NULL;
- if (bb_custom) {
- float mat[4][4], smat[4][4], rmat[4][4], tmp[4][4];
- scale_m4_fl(smat, PCHAN_CUSTOM_BONE_LENGTH(pchan));
- rescale_m4(smat, pchan->custom_scale_xyz);
- eulO_to_mat4(rmat, pchan->custom_rotation_euler, ROT_MODE_XYZ);
- copy_m4_m4(tmp, pchan_tx->pose_mat);
- translate_m4(tmp,
- pchan->custom_translation[0],
- pchan->custom_translation[1],
- pchan->custom_translation[2]);
- mul_m4_series(mat, ob->obmat, tmp, rmat, smat);
- BKE_boundbox_minmax(bb_custom, mat, r_min, r_max);
- }
- else {
- float vec[3];
- mul_v3_m4v3(vec, ob->obmat, pchan_tx->pose_head);
- minmax_v3v3_v3(r_min, r_max, vec);
- mul_v3_m4v3(vec, ob->obmat, pchan_tx->pose_tail);
- minmax_v3v3_v3(r_min, r_max, vec);
- }
+ BKE_pchan_minmax(ob, pchan, r_min, r_max);
changed = true;
}
}