[Bf-blender-cvs] [70b9018e84a] temp-transform-conversions-split: Transform: Move Object conversion to its own file

mano-wii noreply at git.blender.org
Wed Sep 4 23:52:58 CEST 2019


Commit: 70b9018e84a0a8e6dc97388ca682a5740019d8bc
Author: mano-wii
Date:   Wed Sep 4 18:46:35 2019 -0300
Branches: temp-transform-conversions-split
https://developer.blender.org/rB70b9018e84a0a8e6dc97388ca682a5740019d8bc

Transform: Move Object conversion to its own file

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

M	source/blender/editors/transform/CMakeLists.txt
M	source/blender/editors/transform/transform.h
M	source/blender/editors/transform/transform_conversions.c
M	source/blender/editors/transform/transform_conversions.h
A	source/blender/editors/transform/transform_conversions_object.c

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

diff --git a/source/blender/editors/transform/CMakeLists.txt b/source/blender/editors/transform/CMakeLists.txt
index 7e59a3bc8b7..ce092899f40 100644
--- a/source/blender/editors/transform/CMakeLists.txt
+++ b/source/blender/editors/transform/CMakeLists.txt
@@ -50,6 +50,7 @@ set(SRC
   transform_conversions_mball.c
   transform_conversions_mesh.c
   transform_conversions_nla.c
+  transform_conversions_object.c
   transform_conversions_particle.c
   transform_conversions_sequencer.c
   transform_generics.c
diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h
index 5cab833f0f2..88bff208349 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -1142,7 +1142,4 @@ bool checkUseAxisMatrix(TransInfo *t);
        th != tc_end; \
        th++, i++)
 
-void trans_obdata_in_obmode_update_all(struct TransInfo *t);
-void trans_obchild_in_obmode_update_all(struct TransInfo *t);
-
 #endif
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index f7b4012c84f..7bfcd60f6c1 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -21,29 +21,18 @@
  * \ingroup edtransform
  */
 
-#include <string.h>
-#include <math.h>
-#include <limits.h>
-
-#include "DNA_brush_types.h"
+#include "DNA_anim_types.h"
 #include "DNA_armature_types.h"
+#include "DNA_brush_types.h"
 #include "DNA_mesh_types.h"
-#include "DNA_node_types.h"
-#include "DNA_screen_types.h"
 #include "DNA_space_types.h"
-#include "DNA_sequence_types.h"
-#include "DNA_view3d_types.h"
 #include "DNA_constraint_types.h"
-#include "DNA_scene_types.h"
-#include "DNA_meshdata_types.h"
 #include "DNA_gpencil_types.h"
-#include "DNA_movieclip_types.h"
 #include "DNA_mask_types.h"
 
 #include "MEM_guardedalloc.h"
 
 #include "BLI_math.h"
-#include "BLI_utildefines.h"
 #include "BLI_listbase.h"
 #include "BLI_string.h"
 #include "BLI_kdtree.h"
@@ -57,7 +46,6 @@
 #include "BKE_layer.h"
 #include "BKE_key.h"
 #include "BKE_main.h"
-#include "BKE_mesh.h"
 #include "BKE_modifier.h"
 #include "BKE_movieclip.h"
 #include "BKE_nla.h"
@@ -94,14 +82,12 @@
 #include "WM_api.h" /* for WM_event_add_notifier to deal with stabilization nodes */
 #include "WM_types.h"
 
-#include "UI_view2d.h"
 #include "UI_interface.h"
 
 #include "RNA_access.h"
 
 #include "DEG_depsgraph.h"
 #include "DEG_depsgraph_build.h"
-#include "DEG_depsgraph_query.h"
 
 #include "transform.h"
 #include "transform_conversions.h"
@@ -1784,7 +1770,7 @@ void flushTransGraphData(TransInfo *t)
   }
 }
 
-/* *********************** Object Transform data ******************* */
+/* *********************** Transform data ******************* */
 
 /* Little helper function for ObjectToTransData used to give certain
  * constraints (ChildOf, FollowPath, and others that may be added)
@@ -1850,338 +1836,6 @@ bool constraints_list_needinv(TransInfo *t, ListBase *list)
   return false;
 }
 
-/* transcribe given object into TransData for Transforming */
-static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob)
-{
-  Scene *scene = t->scene;
-  bool constinv;
-  bool skip_invert = false;
-
-  if (t->mode != TFM_DUMMY && ob->rigidbody_object) {
-    float rot[3][3], scale[3];
-    float ctime = BKE_scene_frame_get(scene);
-
-    /* only use rigid body transform if simulation is running,
-     * avoids problems with initial setup of rigid bodies */
-    if (BKE_rigidbody_check_sim_running(scene->rigidbody_world, ctime)) {
-
-      /* save original object transform */
-      copy_v3_v3(td->ext->oloc, ob->loc);
-
-      if (ob->rotmode > 0) {
-        copy_v3_v3(td->ext->orot, ob->rot);
-      }
-      else if (ob->rotmode == ROT_MODE_AXISANGLE) {
-        td->ext->orotAngle = ob->rotAngle;
-        copy_v3_v3(td->ext->orotAxis, ob->rotAxis);
-      }
-      else {
-        copy_qt_qt(td->ext->oquat, ob->quat);
-      }
-      /* update object's loc/rot to get current rigid body transform */
-      mat4_to_loc_rot_size(ob->loc, rot, scale, ob->obmat);
-      sub_v3_v3(ob->loc, ob->dloc);
-      BKE_object_mat3_to_rot(ob, rot, false); /* drot is already corrected here */
-    }
-  }
-
-  /* axismtx has the real orientation */
-  copy_m3_m4(td->axismtx, ob->obmat);
-  normalize_m3(td->axismtx);
-
-  td->con = ob->constraints.first;
-
-  /* hack: temporarily disable tracking and/or constraints when getting
-   * object matrix, if tracking is on, or if constraints don't need
-   * inverse correction to stop it from screwing up space conversion
-   * matrix later
-   */
-  constinv = constraints_list_needinv(t, &ob->constraints);
-
-  /* disable constraints inversion for dummy pass */
-  if (t->mode == TFM_DUMMY) {
-    skip_invert = true;
-  }
-
-  /* NOTE: This is not really following copy-on-write design and we should not
-   * be re-evaluating the evaluated object. But as the comment above mentioned
-   * this is part of a hack.
-   * More proper solution would be to make a shallow copy of the object  and
-   * evaluate that, and access matrix of that evaluated copy of the object.
-   * Might be more tricky than it sounds, if some logic later on accesses the
-   * object matrix via td->ob->obmat. */
-  Object *object_eval = DEG_get_evaluated_object(t->depsgraph, ob);
-  if (skip_invert == false && constinv == false) {
-    object_eval->transflag |= OB_NO_CONSTRAINTS; /* BKE_object_where_is_calc checks this */
-    /* It is possible to have transform data initialization prior to a
-     * complete dependency graph evaluated. Happens, for example, when
-     * changing transformation mode. */
-    BKE_object_tfm_copy(object_eval, ob);
-    BKE_object_where_is_calc(t->depsgraph, t->scene, object_eval);
-    object_eval->transflag &= ~OB_NO_CONSTRAINTS;
-  }
-  else {
-    BKE_object_where_is_calc(t->depsgraph, t->scene, object_eval);
-  }
-  /* Copy newly evaluated fields to the original object, similar to how
-   * active dependency graph will do it. */
-  copy_m4_m4(ob->obmat, object_eval->obmat);
-  /* Only copy negative scale flag, this is the only flag which is modified by
-   * the BKE_object_where_is_calc(). The rest of the flags we need to keep,
-   * otherwise we might loose dupli flags  (see T61787). */
-  ob->transflag &= ~OB_NEG_SCALE;
-  ob->transflag |= (object_eval->transflag & OB_NEG_SCALE);
-
-  td->ob = ob;
-
-  td->loc = ob->loc;
-  copy_v3_v3(td->iloc, td->loc);
-
-  if (ob->rotmode > 0) {
-    td->ext->rot = ob->rot;
-    td->ext->rotAxis = NULL;
-    td->ext->rotAngle = NULL;
-    td->ext->quat = NULL;
-
-    copy_v3_v3(td->ext->irot, ob->rot);
-    copy_v3_v3(td->ext->drot, ob->drot);
-  }
-  else if (ob->rotmode == ROT_MODE_AXISANGLE) {
-    td->ext->rot = NULL;
-    td->ext->rotAxis = ob->rotAxis;
-    td->ext->rotAngle = &ob->rotAngle;
-    td->ext->quat = NULL;
-
-    td->ext->irotAngle = ob->rotAngle;
-    copy_v3_v3(td->ext->irotAxis, ob->rotAxis);
-    // td->ext->drotAngle = ob->drotAngle;          // XXX, not implemented
-    // copy_v3_v3(td->ext->drotAxis, ob->drotAxis); // XXX, not implemented
-  }
-  else {
-    td->ext->rot = NULL;
-    td->ext->rotAxis = NULL;
-    td->ext->rotAngle = NULL;
-    td->ext->quat = ob->quat;
-
-    copy_qt_qt(td->ext->iquat, ob->quat);
-    copy_qt_qt(td->ext->dquat, ob->dquat);
-  }
-  td->ext->rotOrder = ob->rotmode;
-
-  td->ext->size = ob->scale;
-  copy_v3_v3(td->ext->isize, ob->scale);
-  copy_v3_v3(td->ext->dscale, ob->dscale);
-
-  copy_v3_v3(td->center, ob->obmat[3]);
-
-  copy_m4_m4(td->ext->obmat, ob->obmat);
-
-  /* is there a need to set the global<->data space conversion matrices? */
-  if (ob->parent || constinv) {
-    float obmtx[3][3], totmat[3][3], obinv[3][3];
-
-    /* Get the effect of parenting, and/or certain constraints.
-     * NOTE: some Constraints, and also Tracking should never get this
-     *       done, as it doesn't work well.
-     */
-    BKE_object_to_mat3(ob, obmtx);
-    copy_m3_m4(totmat, ob->obmat);
-    invert_m3_m3(obinv, totmat);
-    mul_m3_m3m3(td->smtx, obmtx, obinv);
-    invert_m3_m3(td->mtx, td->smtx);
-  }
-  else {
-    /* no conversion to/from dataspace */
-    unit_m3(td->smtx);
-    unit_m3(td->mtx);
-  }
-}
-
-static void trans_object_base_deps_flag_prepare(ViewLayer *view_layer)
-{
-  for (Base *base = view_layer->object_bases.first; base; base = base->next) {
-    base->object->id.tag &= ~LIB_TAG_DOIT;
-  }
-}
-
-static void set_trans_object_base_deps_flag_cb(ID *id,
-                                               eDepsObjectComponentType component,
-                                               void *UNUSED(user_data))
-{
-  /* Here we only handle object IDs. */
-  if (GS(id->name) != ID_OB) {
-    return;
-  }
-  if (!ELEM(component, DEG_OB_COMP_TRANSFORM, DEG_OB_COMP_GEOMETRY)) {
-    return;
-  }
-  id->tag |= LIB_TAG_DOIT;
-}
-
-static void flush_trans_object_base_deps_flag(Depsgraph *depsgraph, Object *object)
-{
-  object->id.tag |= LIB_TAG_DOIT;
-  DEG_foreach_dependent_ID_component(
-      depsgraph, &object->id, DEG_OB_COMP_TRANSFORM, set_trans_object_base_deps_flag_cb, NULL);
-}
-
-static void trans_object_base_deps_flag_finish(const TransInfo *t, ViewLayer *view_layer)
-{
-
-  if ((t->options & CTX_OBMODE_XFORM_OBDATA) == 0) {
-    for (Base *base = view_layer->object_bases.first; base; base = base->next) {
-      if (base->object->id.tag & LIB_TAG_DOIT) {
-        base->flag_legacy |= BA_SNAP_FIX_DEPS_FIASCO;
-      }
-    }
-  }
-}
-
-/* sets flags in Bases to define whether they take part in transform */
-/* it deselects Bases, so we have to call the clear function always after */
-static void set_trans_object_base_flags(TransInfo *t)
-{
-  Main *bmain = CTX_data_main(t->context);
-  ViewLayer *view_layer = t->view_layer;
-  View3D *v3d = t->view;
-  Scene *scene = t->scene;
-  Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer, true);
-  /* NOTE: if Base selected and has parent selected:
-   *   base->flag_legacy = BA_WAS_SEL
-   */
-  /* Don't do it if we're not actually going to recalculate anything. */
-  if (t->mode == TFM_DUMMY) {
-    return;
-  }


@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list