[Bf-blender-cvs] [2f99e68af4b] temp-transform-conversions-split: Transform: Move Particle conversion to its own file

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


Commit: 2f99e68af4bef286f0f1081f70b5971c72185288
Author: mano-wii
Date:   Wed Sep 4 16:24:05 2019 -0300
Branches: temp-transform-conversions-split
https://developer.blender.org/rB2f99e68af4bef286f0f1081f70b5971c72185288

Transform: Move Particle conversion to its own file

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

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

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

diff --git a/source/blender/editors/transform/CMakeLists.txt b/source/blender/editors/transform/CMakeLists.txt
index 590a5768a36..fe7aaf13683 100644
--- a/source/blender/editors/transform/CMakeLists.txt
+++ b/source/blender/editors/transform/CMakeLists.txt
@@ -47,6 +47,7 @@ set(SRC
   transform_conversions_lattice.c
   transform_conversions_mball.c
   transform_conversions_mesh.c
+  transform_conversions_particle.c
   transform_generics.c
   transform_gizmo_2d.c
   transform_gizmo_3d.c
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index 99d932e3036..d5e0b919431 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -877,149 +877,6 @@ TransDataCurveHandleFlags *initTransDataCurveHandles(TransData *td, struct BezTr
 }
 
 /* ******************* particle edit **************** */
-static void createTransParticleVerts(bContext *C, TransInfo *t)
-{
-  FOREACH_TRANS_DATA_CONTAINER (t, tc) {
-
-    TransData *td = NULL;
-    TransDataExtension *tx;
-    Object *ob = CTX_data_active_object(C);
-    ParticleEditSettings *pset = PE_settings(t->scene);
-    PTCacheEdit *edit = PE_get_current(t->scene, ob);
-    ParticleSystem *psys = NULL;
-    PTCacheEditPoint *point;
-    PTCacheEditKey *key;
-    float mat[4][4];
-    int i, k, transformparticle;
-    int count = 0, hasselected = 0;
-    const bool is_prop_edit = (t->flag & T_PROP_EDIT) != 0;
-
-    if (edit == NULL || t->settings->particle.selectmode == SCE_SELECT_PATH) {
-      return;
-    }
-
-    psys = edit->psys;
-
-    for (i = 0, point = edit->points; i < edit->totpoint; i++, point++) {
-      point->flag &= ~PEP_TRANSFORM;
-      transformparticle = 0;
-
-      if ((point->flag & PEP_HIDE) == 0) {
-        for (k = 0, key = point->keys; k < point->totkey; k++, key++) {
-          if ((key->flag & PEK_HIDE) == 0) {
-            if (key->flag & PEK_SELECT) {
-              hasselected = 1;
-              transformparticle = 1;
-            }
-            else if (is_prop_edit) {
-              transformparticle = 1;
-            }
-          }
-        }
-      }
-
-      if (transformparticle) {
-        count += point->totkey;
-        point->flag |= PEP_TRANSFORM;
-      }
-    }
-
-    /* note: in prop mode we need at least 1 selected */
-    if (hasselected == 0) {
-      return;
-    }
-
-    tc->data_len = count;
-    td = tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransObData(Particle Mode)");
-
-    if (t->mode == TFM_BAKE_TIME) {
-      tx = tc->data_ext = MEM_callocN(tc->data_len * sizeof(TransDataExtension),
-                                      "Particle_TransExtension");
-    }
-    else {
-      tx = tc->data_ext = NULL;
-    }
-
-    unit_m4(mat);
-
-    invert_m4_m4(ob->imat, ob->obmat);
-
-    for (i = 0, point = edit->points; i < edit->totpoint; i++, point++) {
-      TransData *head, *tail;
-      head = tail = td;
-
-      if (!(point->flag & PEP_TRANSFORM)) {
-        continue;
-      }
-
-      if (psys && !(psys->flag & PSYS_GLOBAL_HAIR)) {
-        ParticleSystemModifierData *psmd_eval = edit->psmd_eval;
-        psys_mat_hair_to_global(
-            ob, psmd_eval->mesh_final, psys->part->from, psys->particles + i, mat);
-      }
-
-      for (k = 0, key = point->keys; k < point->totkey; k++, key++) {
-        if (key->flag & PEK_USE_WCO) {
-          copy_v3_v3(key->world_co, key->co);
-          mul_m4_v3(mat, key->world_co);
-          td->loc = key->world_co;
-        }
-        else {
-          td->loc = key->co;
-        }
-
-        copy_v3_v3(td->iloc, td->loc);
-        copy_v3_v3(td->center, td->loc);
-
-        if (key->flag & PEK_SELECT) {
-          td->flag |= TD_SELECTED;
-        }
-        else if (!is_prop_edit) {
-          td->flag |= TD_SKIP;
-        }
-
-        unit_m3(td->mtx);
-        unit_m3(td->smtx);
-
-        /* don't allow moving roots */
-        if (k == 0 && pset->flag & PE_LOCK_FIRST && (!psys || !(psys->flag & PSYS_GLOBAL_HAIR))) {
-          td->protectflag |= OB_LOCK_LOC;
-        }
-
-        td->ob = ob;
-        td->ext = tx;
-        if (t->mode == TFM_BAKE_TIME) {
-          td->val = key->time;
-          td->ival = *(key->time);
-          /* abuse size and quat for min/max values */
-          td->flag |= TD_NO_EXT;
-          if (k == 0) {
-            tx->size = NULL;
-          }
-          else {
-            tx->size = (key - 1)->time;
-          }
-
-          if (k == point->totkey - 1) {
-            tx->quat = NULL;
-          }
-          else {
-            tx->quat = (key + 1)->time;
-          }
-        }
-
-        td++;
-        if (tx) {
-          tx++;
-        }
-        tail++;
-      }
-      if (is_prop_edit && head != tail) {
-        calc_distanceCurveVerts(head, tail - 1);
-      }
-    }
-  }
-}
 
 void flushTransParticles(TransInfo *t)
 {
diff --git a/source/blender/editors/transform/transform_conversions.h b/source/blender/editors/transform/transform_conversions.h
index add7d485f08..34acf3af6fe 100644
--- a/source/blender/editors/transform/transform_conversions.h
+++ b/source/blender/editors/transform/transform_conversions.h
@@ -89,4 +89,7 @@ void createTransMBallVerts(TransInfo *t);
 
 /* transform_conversions_mesh.c */
 void createTransEditVerts(TransInfo *t);
+
+/* transform_conversions_particle.c */
+void createTransParticleVerts(bContext *C, TransInfo *t);
 #endif
diff --git a/source/blender/editors/transform/transform_conversions_particle.c b/source/blender/editors/transform/transform_conversions_particle.c
new file mode 100644
index 00000000000..d5bdd2e5b07
--- /dev/null
+++ b/source/blender/editors/transform/transform_conversions_particle.c
@@ -0,0 +1,190 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup edtransform
+ */
+
+#include "DNA_particle_types.h"
+#include "DNA_modifier_types.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_math.h"
+
+#include "BKE_context.h"
+#include "BKE_report.h"
+#include "BKE_particle.h"
+#include "BKE_pointcache.h"
+
+#include "ED_particle.h"
+
+#include "transform.h"
+#include "transform_conversions.h"
+
+/* -------------------------------------------------------------------- */
+/** \name Particle Edit Transform Creation
+ *
+ * \{ */
+
+void createTransParticleVerts(bContext *C, TransInfo *t)
+{
+  FOREACH_TRANS_DATA_CONTAINER (t, tc) {
+
+    TransData *td = NULL;
+    TransDataExtension *tx;
+    Object *ob = CTX_data_active_object(C);
+    ParticleEditSettings *pset = PE_settings(t->scene);
+    PTCacheEdit *edit = PE_get_current(t->scene, ob);
+    ParticleSystem *psys = NULL;
+    PTCacheEditPoint *point;
+    PTCacheEditKey *key;
+    float mat[4][4];
+    int i, k, transformparticle;
+    int count = 0, hasselected = 0;
+    const bool is_prop_edit = (t->flag & T_PROP_EDIT) != 0;
+
+    if (edit == NULL || t->settings->particle.selectmode == SCE_SELECT_PATH) {
+      return;
+    }
+
+    psys = edit->psys;
+
+    for (i = 0, point = edit->points; i < edit->totpoint; i++, point++) {
+      point->flag &= ~PEP_TRANSFORM;
+      transformparticle = 0;
+
+      if ((point->flag & PEP_HIDE) == 0) {
+        for (k = 0, key = point->keys; k < point->totkey; k++, key++) {
+          if ((key->flag & PEK_HIDE) == 0) {
+            if (key->flag & PEK_SELECT) {
+              hasselected = 1;
+              transformparticle = 1;
+            }
+            else if (is_prop_edit) {
+              transformparticle = 1;
+            }
+          }
+        }
+      }
+
+      if (transformparticle) {
+        count += point->totkey;
+        point->flag |= PEP_TRANSFORM;
+      }
+    }
+
+    /* note: in prop mode we need at least 1 selected */
+    if (hasselected == 0) {
+      return;
+    }
+
+    tc->data_len = count;
+    td = tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransObData(Particle Mode)");
+
+    if (t->mode == TFM_BAKE_TIME) {
+      tx = tc->data_ext = MEM_callocN(tc->data_len * sizeof(TransDataExtension),
+                                      "Particle_TransExtension");
+    }
+    else {
+      tx = tc->data_ext = NULL;
+    }
+
+    unit_m4(mat);
+
+    invert_m4_m4(ob->imat, ob->obmat);
+
+    for (i = 0, point = edit->points; i < edit->totpoint; i++, point++) {
+      TransData *head, *tail;
+      head = tail = td;
+
+      if (!(point->flag & PEP_TRANSFORM)) {
+        continue;
+      }
+
+      if (psys && !(psys->flag & PSYS_GLOBAL_HAIR)) {
+        ParticleSystemModifierData *psmd_eval = edit->psmd_eval;
+        psys_mat_hair_to_global(
+            ob, psmd_eval->mesh_final, psys->part->from, psys->particles + i, mat);
+      }
+
+      for (k = 0, key = point->keys; k < point->totkey; k++, key++) {
+        if (key->flag & PEK_USE_WCO) {
+          copy_v3_v3(key->world_co, key->co);
+          mul_m4_v3(mat, key->world_co);
+          td->loc = key->world_co;
+        }
+        else {
+          td->loc = key->co;
+        }
+
+        copy_v3_v3(td->iloc, td->loc);
+        copy_v3_v3(td->center, td->loc);
+
+        if (key->flag & PEK_SELECT) {
+          td->flag |= TD_SELECTED;
+        }
+        else if (!is_prop_edit) {
+          td->flag |= TD_SKIP;
+        }
+
+        unit_m3(td->mtx);
+        unit_m3(td->smtx);
+
+        /* don't allow moving roots */
+        if (k == 0 && pset->flag & PE_LOCK_FIRST && (!psy

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list