[Bf-blender-cvs] [46e0ec05ef1] master: Cleanup: Move each special_aftertrans_update to their respective TransData file

Germano Cavalcante noreply at git.blender.org
Wed Jun 10 01:35:14 CEST 2020


Commit: 46e0ec05ef1fb75fb3e5b4a713a5302ace49e546
Author: Germano Cavalcante
Date:   Tue Jun 9 20:27:40 2020 -0300
Branches: master
https://developer.blender.org/rB46e0ec05ef1fb75fb3e5b4a713a5302ace49e546

Cleanup: Move each special_aftertrans_update to their respective TransData file

===================================================================

M	source/blender/editors/transform/transform_convert.c
M	source/blender/editors/transform/transform_convert.h
M	source/blender/editors/transform/transform_convert_action.c
M	source/blender/editors/transform/transform_convert_armature.c
M	source/blender/editors/transform/transform_convert_graph.c
M	source/blender/editors/transform/transform_convert_mask.c
M	source/blender/editors/transform/transform_convert_mesh.c
M	source/blender/editors/transform/transform_convert_nla.c
M	source/blender/editors/transform/transform_convert_node.c
M	source/blender/editors/transform/transform_convert_object.c
M	source/blender/editors/transform/transform_convert_sequencer.c
M	source/blender/editors/transform/transform_convert_tracking.c

===================================================================

diff --git a/source/blender/editors/transform/transform_convert.c b/source/blender/editors/transform/transform_convert.c
index d71843346f1..fcca9b06451 100644
--- a/source/blender/editors/transform/transform_convert.c
+++ b/source/blender/editors/transform/transform_convert.c
@@ -22,66 +22,36 @@
  */
 
 #include "DNA_anim_types.h"
-#include "DNA_armature_types.h"
 #include "DNA_constraint_types.h"
-#include "DNA_gpencil_types.h"
-#include "DNA_mask_types.h"
-#include "DNA_space_types.h"
 
 #include "MEM_guardedalloc.h"
 
 #include "BLI_kdtree.h"
 #include "BLI_listbase.h"
 #include "BLI_math.h"
-#include "BLI_string.h"
 
 #include "BKE_action.h"
 #include "BKE_anim_data.h"
-#include "BKE_animsys.h"
-#include "BKE_armature.h"
 #include "BKE_context.h"
-#include "BKE_editmesh.h"
 #include "BKE_fcurve.h"
 #include "BKE_global.h"
-#include "BKE_gpencil.h"
-#include "BKE_key.h"
 #include "BKE_layer.h"
 #include "BKE_lib_id.h"
 #include "BKE_main.h"
-#include "BKE_mask.h"
 #include "BKE_modifier.h"
 #include "BKE_nla.h"
-#include "BKE_node.h"
-#include "BKE_pointcache.h"
-#include "BKE_rigidbody.h"
 #include "BKE_scene.h"
-#include "BKE_tracking.h"
 
-#include "BIK_api.h"
-
-#include "ED_anim_api.h"
-#include "ED_armature.h"
-#include "ED_clip.h"
-#include "ED_image.h"
 #include "ED_keyframes_edit.h"
 #include "ED_keyframing.h"
-#include "ED_markers.h"
-#include "ED_mask.h"
-#include "ED_mesh.h"
-#include "ED_node.h"
-#include "ED_object.h"
 #include "ED_particle.h"
 #include "ED_screen.h"
 #include "ED_screen_types.h"
 
 #include "UI_view2d.h"
 
-#include "WM_api.h" /* for WM_event_add_notifier to deal with stabilization nodes */
 #include "WM_types.h"
 
-#include "RNA_access.h"
-
-#include "DEG_depsgraph.h"
 #include "DEG_depsgraph_build.h"
 
 #include "transform.h"
@@ -375,190 +345,6 @@ static void set_prop_dist(TransInfo *t, const bool with_dist)
 
 /** \} */
 
-/* -------------------------------------------------------------------- */
-/** \name Pose Mode
- * \{ */
-
-static short apply_targetless_ik(Object *ob)
-{
-  bPoseChannel *pchan, *parchan, *chanlist[256];
-  bKinematicConstraint *data;
-  int segcount, apply = 0;
-
-  /* now we got a difficult situation... we have to find the
-   * target-less IK pchans, and apply transformation to the all
-   * pchans that were in the chain */
-
-  for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
-    data = has_targetless_ik(pchan);
-    if (data && (data->flag & CONSTRAINT_IK_AUTO)) {
-
-      /* fill the array with the bones of the chain (armature.c does same, keep it synced) */
-      segcount = 0;
-
-      /* exclude tip from chain? */
-      if (!(data->flag & CONSTRAINT_IK_TIP)) {
-        parchan = pchan->parent;
-      }
-      else {
-        parchan = pchan;
-      }
-
-      /* Find the chain's root & count the segments needed */
-      for (; parchan; parchan = parchan->parent) {
-        chanlist[segcount] = parchan;
-        segcount++;
-
-        if (segcount == data->rootbone || segcount > 255) {
-          break;  // 255 is weak
-        }
-      }
-      for (; segcount; segcount--) {
-        Bone *bone;
-        float mat[4][4];
-
-        /* pose_mat(b) = pose_mat(b-1) * offs_bone * channel * constraint * IK  */
-        /* we put in channel the entire result of mat = (channel * constraint * IK) */
-        /* pose_mat(b) = pose_mat(b-1) * offs_bone * mat  */
-        /* mat = pose_mat(b) * inv(pose_mat(b-1) * offs_bone ) */
-
-        parchan = chanlist[segcount - 1];
-        bone = parchan->bone;
-        bone->flag |= BONE_TRANSFORM; /* ensures it gets an auto key inserted */
-
-        BKE_armature_mat_pose_to_bone(parchan, parchan->pose_mat, mat);
-        /* apply and decompose, doesn't work for constraints or non-uniform scale well */
-        {
-          float rmat3[3][3], qrmat[3][3], imat3[3][3], smat[3][3];
-
-          copy_m3_m4(rmat3, mat);
-          /* Make sure that our rotation matrix only contains rotation and not scale. */
-          normalize_m3(rmat3);
-
-          /* rotation */
-          /* [#22409] is partially caused by this, as slight numeric error introduced during
-           * the solving process leads to locked-axis values changing. However, we cannot modify
-           * the values here, or else there are huge discrepancies between IK-solver (interactive)
-           * and applied poses. */
-          BKE_pchan_mat3_to_rot(parchan, rmat3, false);
-
-          /* for size, remove rotation */
-          /* causes problems with some constraints (so apply only if needed) */
-          if (data->flag & CONSTRAINT_IK_STRETCH) {
-            BKE_pchan_rot_to_mat3(parchan, qrmat);
-            invert_m3_m3(imat3, qrmat);
-            mul_m3_m3m3(smat, rmat3, imat3);
-            mat3_to_size(parchan->size, smat);
-          }
-
-          /* causes problems with some constraints (e.g. childof), so disable this */
-          /* as it is IK shouldn't affect location directly */
-          /* copy_v3_v3(parchan->loc, mat[3]); */
-        }
-      }
-
-      apply = 1;
-      data->flag &= ~CONSTRAINT_IK_AUTO;
-    }
-  }
-
-  return apply;
-}
-
-static void bone_children_clear_transflag(int mode, short around, ListBase *lb)
-{
-  Bone *bone = lb->first;
-
-  for (; bone; bone = bone->next) {
-    if ((bone->flag & BONE_HINGE) && (bone->flag & BONE_CONNECTED)) {
-      bone->flag |= BONE_HINGE_CHILD_TRANSFORM;
-    }
-    else if ((bone->flag & BONE_TRANSFORM) && (mode == TFM_ROTATION || mode == TFM_TRACKBALL) &&
-             (around == V3D_AROUND_LOCAL_ORIGINS)) {
-      bone->flag |= BONE_TRANSFORM_CHILD;
-    }
-    else {
-      bone->flag &= ~BONE_TRANSFORM;
-    }
-
-    bone_children_clear_transflag(mode, around, &bone->childbase);
-  }
-}
-
-/* Sets transform flags in the bones.
- * Returns total number of bones with `BONE_TRANSFORM`. */
-int transform_convert_pose_transflags_update(Object *ob,
-                                             const int mode,
-                                             const short around,
-                                             bool has_translate_rotate[2])
-{
-  bArmature *arm = ob->data;
-  bPoseChannel *pchan;
-  Bone *bone;
-  int total = 0;
-
-  for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
-    bone = pchan->bone;
-    if (PBONE_VISIBLE(arm, bone)) {
-      if ((bone->flag & BONE_SELECTED)) {
-        bone->flag |= BONE_TRANSFORM;
-      }
-      else {
-        bone->flag &= ~BONE_TRANSFORM;
-      }
-
-      bone->flag &= ~BONE_HINGE_CHILD_TRANSFORM;
-      bone->flag &= ~BONE_TRANSFORM_CHILD;
-    }
-    else {
-      bone->flag &= ~BONE_TRANSFORM;
-    }
-  }
-
-  /* make sure no bone can be transformed when a parent is transformed */
-  /* since pchans are depsgraph sorted, the parents are in beginning of list */
-  if (!ELEM(mode, TFM_BONESIZE, TFM_BONE_ENVELOPE_DIST)) {
-    for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
-      bone = pchan->bone;
-      if (bone->flag & BONE_TRANSFORM) {
-        bone_children_clear_transflag(mode, around, &bone->childbase);
-      }
-    }
-  }
-  /* now count, and check if we have autoIK or have to switch from translate to rotate */
-  for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
-    bone = pchan->bone;
-    if (bone->flag & BONE_TRANSFORM) {
-      total++;
-
-      if (has_translate_rotate != NULL) {
-        if (has_targetless_ik(pchan) == NULL) {
-          if (pchan->parent && (pchan->bone->flag & BONE_CONNECTED)) {
-            if (pchan->bone->flag & BONE_HINGE_CHILD_TRANSFORM) {
-              has_translate_rotate[0] = true;
-            }
-          }
-          else {
-            if ((pchan->protectflag & OB_LOCK_LOC) != OB_LOCK_LOC) {
-              has_translate_rotate[0] = true;
-            }
-          }
-          if ((pchan->protectflag & OB_LOCK_ROT) != OB_LOCK_ROT) {
-            has_translate_rotate[1] = true;
-          }
-        }
-        else {
-          has_translate_rotate[0] = true;
-        }
-      }
-    }
-  }
-
-  return total;
-}
-
-/** \} */
-
 /* -------------------------------------------------------------------- */
 /** \name Pose Mode (Auto-IK)
  * \{ */
@@ -642,50 +428,6 @@ void transform_autoik_update(TransInfo *t, short mode)
   }
 }
 
-/* frees temporal IKs */
-static void pose_grab_with_ik_clear(Main *bmain, Object *ob)
-{
-  bKinematicConstraint *data;
-  bPoseChannel *pchan;
-  bConstraint *con, *next;
-  bool relations_changed = false;
-
-  for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
-    /* clear all temporary lock flags */
-    pchan->ikflag &= ~(BONE_IK_NO_XDOF_TEMP | BONE_IK_NO_YDOF_TEMP | BONE_IK_NO_ZDOF_TEMP);
-
-    pchan->constflag &= ~(PCHAN_HAS_IK | PCHAN_HAS_TARGET);
-
-    /* remove all temporary IK-constraints added */
-    for (con = pchan->constraints.first; con; con = next) {
-      next = con->next;
-      if (con->type == CONSTRAINT_TYPE_KINEMATIC) {
-        data = con->data;
-        if (data->flag & CONSTRAINT_IK_TEMP) {
-          relations_changed = true;
-
-          /* iTaSC needs clear for removed constraints */
-          BIK_clear_data(ob->pose);
-
-          BLI_remlink(&pchan->constraints, con);
-          MEM_freeN(con->data);
-          MEM_freeN(con);
-          continue;
-        }
-        pchan->constflag |= PCHAN_HAS_IK;
-        if (data->tar == NULL || (data->tar->type == OB_ARMATURE && data->subtarget[0] == 0)) {
-          pchan->constflag |= PCHAN_HAS_TARGET;
-        }
-      }
-    }
-  }
-
-  if (relations_changed) {
-    /* TODO(sergey): Consider doing partial update only. */
-    DEG_relations_tag_update(bmain);
-  }
-}
-
 /** \} */
 
 /* -------------------------------------------------------------------- */
@@ -900,92 +642,6 @@ bool FrameOnMouseSide(char side, float frame, float cframe)
 /** \name Animation Editor
  * \{ */
 
-static int masklay_shape_cmp_frame(void *thunk, const void *a, const void *b)
-{
-  const MaskLayerShape *frame_a = a;
-  const MaskLayerShape *frame_b = b;
-
-  if (frame_a->frame < frame_b->frame) {
-    return -1;
-  }
-  if (frame_a->frame > frame_b->frame) {
-    return 1;
-  }
-  *((bool *)thunk) = true;
-  /* selected last *

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list