[Bf-blender-cvs] [ec5fc1adccb] master: Cleanup: Move transform_mode_init to transform_mode API

Germano Cavalcante noreply at git.blender.org
Fri Feb 21 14:43:55 CET 2020


Commit: ec5fc1adccb0cc7a9d10bf9e3004e9d792349294
Author: Germano Cavalcante
Date:   Fri Feb 21 10:42:56 2020 -0300
Branches: master
https://developer.blender.org/rBec5fc1adccb0cc7a9d10bf9e3004e9d792349294

Cleanup: Move transform_mode_init to transform_mode API

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

M	source/blender/editors/transform/transform.c
M	source/blender/editors/transform/transform_mode.c
M	source/blender/editors/transform/transform_mode.h

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

diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index ac1f3c312d1..bc81817647e 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -25,7 +25,6 @@
 
 #include "MEM_guardedalloc.h"
 
-#include "DNA_armature_types.h"
 #include "DNA_gpencil_types.h"
 #include "DNA_mask_types.h"
 #include "DNA_mesh_types.h"
@@ -859,155 +858,6 @@ static void transform_event_xyz_constraint(TransInfo *t, short key_type, char cm
   }
 }
 
-static void transform_mode_init(TransInfo *t, wmOperator *op, int mode)
-{
-  t->mode = mode;
-
-  switch (mode) {
-    case TFM_TRANSLATION:
-      initTranslation(t);
-      break;
-    case TFM_ROTATION:
-      initRotation(t);
-      break;
-    case TFM_RESIZE:
-      initResize(t);
-      break;
-    case TFM_SKIN_RESIZE:
-      initSkinResize(t);
-      break;
-    case TFM_TOSPHERE:
-      initToSphere(t);
-      break;
-    case TFM_SHEAR:
-      initShear(t);
-      break;
-    case TFM_BEND:
-      initBend(t);
-      break;
-    case TFM_SHRINKFATTEN:
-      initShrinkFatten(t);
-      break;
-    case TFM_TILT:
-      initTilt(t);
-      break;
-    case TFM_CURVE_SHRINKFATTEN:
-      initCurveShrinkFatten(t);
-      break;
-    case TFM_MASK_SHRINKFATTEN:
-      initMaskShrinkFatten(t);
-      break;
-    case TFM_GPENCIL_SHRINKFATTEN:
-      initGPShrinkFatten(t);
-      break;
-    case TFM_TRACKBALL:
-      initTrackball(t);
-      break;
-    case TFM_PUSHPULL:
-      initPushPull(t);
-      break;
-    case TFM_CREASE:
-      initCrease(t);
-      break;
-    case TFM_BONESIZE: { /* used for both B-Bone width (bonesize) as for deform-dist (envelope) */
-      /* Note: we have to pick one, use the active object. */
-      TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_OK(t);
-      bArmature *arm = tc->poseobj->data;
-      if (arm->drawtype == ARM_ENVELOPE) {
-        initBoneEnvelope(t);
-        t->mode = TFM_BONE_ENVELOPE_DIST;
-      }
-      else {
-        initBoneSize(t);
-      }
-      break;
-    }
-    case TFM_BONE_ENVELOPE:
-      initBoneEnvelope(t);
-      break;
-    case TFM_BONE_ENVELOPE_DIST:
-      initBoneEnvelope(t);
-      t->mode = TFM_BONE_ENVELOPE_DIST;
-      break;
-    case TFM_EDGE_SLIDE:
-    case TFM_VERT_SLIDE: {
-      const bool use_even = (op ? RNA_boolean_get(op->ptr, "use_even") : false);
-      const bool flipped = (op ? RNA_boolean_get(op->ptr, "flipped") : false);
-      const bool use_clamp = (op ? RNA_boolean_get(op->ptr, "use_clamp") : true);
-      if (mode == TFM_EDGE_SLIDE) {
-        const bool use_double_side = (op ? !RNA_boolean_get(op->ptr, "single_side") : true);
-        initEdgeSlide_ex(t, use_double_side, use_even, flipped, use_clamp);
-      }
-      else {
-        initVertSlide_ex(t, use_even, flipped, use_clamp);
-      }
-      break;
-    }
-    case TFM_BONE_ROLL:
-      initBoneRoll(t);
-      break;
-    case TFM_TIME_TRANSLATE:
-      initTimeTranslate(t);
-      break;
-    case TFM_TIME_SLIDE:
-      initTimeSlide(t);
-      break;
-    case TFM_TIME_SCALE:
-      initTimeScale(t);
-      break;
-    case TFM_TIME_DUPLICATE:
-      /* same as TFM_TIME_EXTEND, but we need the mode info for later
-       * so that duplicate-culling will work properly
-       */
-      if (ELEM(t->spacetype, SPACE_GRAPH, SPACE_NLA)) {
-        initTranslation(t);
-      }
-      else {
-        initTimeTranslate(t);
-      }
-      t->mode = mode;
-      break;
-    case TFM_TIME_EXTEND:
-      /* now that transdata has been made, do like for TFM_TIME_TRANSLATE (for most Animation
-       * Editors because they have only 1D transforms for time values) or TFM_TRANSLATION
-       * (for Graph/NLA Editors only since they uses 'standard' transforms to get 2D movement)
-       * depending on which editor this was called from
-       */
-      if (ELEM(t->spacetype, SPACE_GRAPH, SPACE_NLA)) {
-        initTranslation(t);
-      }
-      else {
-        initTimeTranslate(t);
-      }
-      break;
-    case TFM_BAKE_TIME:
-      initBakeTime(t);
-      break;
-    case TFM_MIRROR:
-      initMirror(t);
-      break;
-    case TFM_BWEIGHT:
-      initBevelWeight(t);
-      break;
-    case TFM_ALIGN:
-      initAlign(t);
-      break;
-    case TFM_SEQ_SLIDE:
-      initSeqSlide(t);
-      break;
-    case TFM_NORMAL_ROTATION:
-      initNormalRotation(t);
-      break;
-    case TFM_GPENCIL_OPACITY:
-      initGPOpacity(t);
-      break;
-  }
-
-  /* TODO(germano): Some of these operations change the `t->mode`.
-   * This can be bad for Redo.
-   * BLI_assert(t->mode == mode); */
-}
-
 int transformEvent(TransInfo *t, const wmEvent *event)
 {
   char cmode = constraintModeToChar(t);
diff --git a/source/blender/editors/transform/transform_mode.c b/source/blender/editors/transform/transform_mode.c
index e681b649451..cdd29ccf24f 100644
--- a/source/blender/editors/transform/transform_mode.c
+++ b/source/blender/editors/transform/transform_mode.c
@@ -24,8 +24,10 @@
 #include <stdlib.h>
 
 #include "DNA_anim_types.h"
+#include "DNA_armature_types.h"
 #include "DNA_constraint_types.h"
 #include "DNA_gpencil_types.h"
+#include "DNA_windowmanager_types.h"
 
 #include "BLI_listbase.h"
 #include "BLI_math.h"
@@ -35,6 +37,8 @@
 #include "BKE_context.h"
 #include "BKE_nla.h"
 
+#include "RNA_access.h"
+
 #include "ED_screen.h"
 
 #include "UI_interface.h"
@@ -484,7 +488,7 @@ static void constraintSizeLim(TransInfo *t, TransData *td)
 }
 
 /* -------------------------------------------------------------------- */
-/* Transform (Rotaion Utils) */
+/* Transform (Rotation Utils) */
 
 /** \name Transform Rotaion Utils
  * \{ */
@@ -1098,3 +1102,159 @@ void doAnimEdit_SnapFrame(
   }
 }
 /** \} */
+
+/* -------------------------------------------------------------------- */
+/* Transform Mode API */
+
+/** \name Transform Frame Utils
+ * \{ */
+
+void transform_mode_init(TransInfo *t, wmOperator *op, const int mode)
+{
+  t->mode = mode;
+
+  switch (mode) {
+    case TFM_TRANSLATION:
+      initTranslation(t);
+      break;
+    case TFM_ROTATION:
+      initRotation(t);
+      break;
+    case TFM_RESIZE:
+      initResize(t);
+      break;
+    case TFM_SKIN_RESIZE:
+      initSkinResize(t);
+      break;
+    case TFM_TOSPHERE:
+      initToSphere(t);
+      break;
+    case TFM_SHEAR:
+      initShear(t);
+      break;
+    case TFM_BEND:
+      initBend(t);
+      break;
+    case TFM_SHRINKFATTEN:
+      initShrinkFatten(t);
+      break;
+    case TFM_TILT:
+      initTilt(t);
+      break;
+    case TFM_CURVE_SHRINKFATTEN:
+      initCurveShrinkFatten(t);
+      break;
+    case TFM_MASK_SHRINKFATTEN:
+      initMaskShrinkFatten(t);
+      break;
+    case TFM_GPENCIL_SHRINKFATTEN:
+      initGPShrinkFatten(t);
+      break;
+    case TFM_TRACKBALL:
+      initTrackball(t);
+      break;
+    case TFM_PUSHPULL:
+      initPushPull(t);
+      break;
+    case TFM_CREASE:
+      initCrease(t);
+      break;
+    case TFM_BONESIZE: { /* used for both B-Bone width (bonesize) as for deform-dist (envelope) */
+      /* Note: we have to pick one, use the active object. */
+      TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_OK(t);
+      bArmature *arm = tc->poseobj->data;
+      if (arm->drawtype == ARM_ENVELOPE) {
+        initBoneEnvelope(t);
+        t->mode = TFM_BONE_ENVELOPE_DIST;
+      }
+      else {
+        initBoneSize(t);
+      }
+      break;
+    }
+    case TFM_BONE_ENVELOPE:
+      initBoneEnvelope(t);
+      break;
+    case TFM_BONE_ENVELOPE_DIST:
+      initBoneEnvelope(t);
+      t->mode = TFM_BONE_ENVELOPE_DIST;
+      break;
+    case TFM_EDGE_SLIDE:
+    case TFM_VERT_SLIDE: {
+      const bool use_even = (op ? RNA_boolean_get(op->ptr, "use_even") : false);
+      const bool flipped = (op ? RNA_boolean_get(op->ptr, "flipped") : false);
+      const bool use_clamp = (op ? RNA_boolean_get(op->ptr, "use_clamp") : true);
+      if (mode == TFM_EDGE_SLIDE) {
+        const bool use_double_side = (op ? !RNA_boolean_get(op->ptr, "single_side") : true);
+        initEdgeSlide_ex(t, use_double_side, use_even, flipped, use_clamp);
+      }
+      else {
+        initVertSlide_ex(t, use_even, flipped, use_clamp);
+      }
+      break;
+    }
+    case TFM_BONE_ROLL:
+      initBoneRoll(t);
+      break;
+    case TFM_TIME_TRANSLATE:
+      initTimeTranslate(t);
+      break;
+    case TFM_TIME_SLIDE:
+      initTimeSlide(t);
+      break;
+    case TFM_TIME_SCALE:
+      initTimeScale(t);
+      break;
+    case TFM_TIME_DUPLICATE:
+      /* same as TFM_TIME_EXTEND, but we need the mode info for later
+       * so that duplicate-culling will work properly
+       */
+      if (ELEM(t->spacetype, SPACE_GRAPH, SPACE_NLA)) {
+        initTranslation(t);
+      }
+      else {
+        initTimeTranslate(t);
+      }
+      break;
+    case TFM_TIME_EXTEND:
+      /* now that transdata has been made, do like for TFM_TIME_TRANSLATE (for most Animation
+       * Editors because they have only 1D transforms for time values) or TFM_TRANSLATION
+       * (for Graph/NLA Editors only since they uses 'standard' transforms to get 2D movement)
+       * depending on which editor this was called from
+       */
+      if (ELEM(t->spacetype, SPACE_GRAPH, SPACE_NLA)) {
+        initTranslation(t);
+      }
+      else {
+        initTimeTranslate(t);
+      }
+      break;
+    case TFM_BAKE_TIME:
+      initBakeTime(t);
+      break;
+    case TFM_MIRROR:
+      initMirror(t);
+      break;
+    case TFM_BWEIGHT:
+      initBevelWeight(t);
+      break;
+    case TFM_ALIGN:
+      initAlign(t);
+      break;
+    case TFM_SEQ_SLIDE:
+      initSeqSlide(t);
+      break;
+    case TFM_NORMAL_ROTATION:
+      initNormalRotation(t);
+      break;
+    case TFM_GPENCIL_OPACITY:
+      initGPOpacity(t);
+      break;
+  }
+
+  /* TODO(germano): Some of these operations change the `t->mode`.
+   * This can be bad for Redo.
+   * BLI_assert(t->mode == mode); */
+}
+
+/** \} */
diff --git a/source/blender/editors/transform/transform_mode.h b/source/blender/editors/transform/transform_mode.h
index bb036a69a88..a8a930cc156 100644
--- a/source/blender/editors/transform/transfor

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list