[Bf-blender-cvs] [4d33e80] mesh-transfer-data: HugeRefactor! Move most of remaining transferdata code into BKE.

Bastien Montagne noreply at git.blender.org
Tue Nov 4 22:00:21 CET 2014


Commit: 4d33e80c46907a247deaf7cf3c2467124c2b5022
Author: Bastien Montagne
Date:   Tue Nov 4 21:59:09 2014 +0100
Branches: mesh-transfer-data
https://developer.blender.org/rB4d33e80c46907a247deaf7cf3c2467124c2b5022

HugeRefactor! Move most of remaining transferdata code into BKE.

Note, we might have to adjust a bit more what goes where, but this should
allow us to make a modifier now!

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

A	source/blender/blenkernel/BKE_data_transfer.h
M	source/blender/blenkernel/BKE_object_deform.h
M	source/blender/blenkernel/CMakeLists.txt
A	source/blender/blenkernel/intern/data_transfer.c
A	source/blender/blenkernel/intern/data_transfer_intern.h
M	source/blender/blenkernel/intern/deform.c
M	source/blender/blenkernel/intern/object_deform.c
M	source/blender/editors/include/ED_object.h
M	source/blender/editors/object/CMakeLists.txt
A	source/blender/editors/object/object_data_transfer.c
M	source/blender/editors/object/object_intern.h
D	source/blender/editors/object/object_transfer_data.c
M	source/blender/editors/object/object_vgroup.c
M	source/blender/editors/space_view3d/view3d_buttons.c

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

diff --git a/source/blender/blenkernel/BKE_data_transfer.h b/source/blender/blenkernel/BKE_data_transfer.h
new file mode 100644
index 0000000..acc5c3d
--- /dev/null
+++ b/source/blender/blenkernel/BKE_data_transfer.h
@@ -0,0 +1,115 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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) 2014 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Bastien Montagne
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/blenkernel/BKE_data_transfer.h
+ *  \ingroup bke
+ */
+
+#ifndef __BKE_DATA_TRANSFER_H__
+#define __BKE_DATA_TRANSFER_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Warning, those def are stored in files (TransferData modifier), *DO NOT* modify those values. */
+enum {
+	DT_DATA_MDEFORMVERT                 = 1 << 0,
+	DT_DATA_SHAPEKEY                    = 1 << 1,
+	DT_DATA_SKIN                        = 1 << 2,
+	DT_DATA_BWEIGHT_VERT                = 1 << 3,
+
+	DT_DATA_SHARP_EDGE                  = 1 << 8,
+	DT_DATA_SEAM                        = 1 << 9,
+	DT_DATA_CREASE                      = 1 << 10,
+	DT_DATA_BWEIGHT_EDGE                = 1 << 11,
+	DT_DATA_FREESTYLE_EDGE              = 1 << 12,
+
+	DT_DATA_UV                          = 1 << 16,
+	DT_DATA_SHARP_FACE                  = 1 << 17,
+	DT_DATA_FREESTYLE_FACE              = 1 << 18,
+
+	DT_DATA_VCOL                        = 1 << 24,
+};
+
+int BKE_data_transfer_dttype_to_cdtype(const int dtdata_type);
+bool BKE_data_transfer_get_dttype_capacity(
+        const int dtdata_type, bool *r_advanced_mixing, bool *r_threshold);
+
+#define DT_DATATYPE_IS_VERT(_dt) ELEM(_dt, DT_DATA_MDEFORMVERT, DT_DATA_SHAPEKEY, DT_DATA_SKIN,  \
+                                           DT_DATA_BWEIGHT_VERT)
+#define DT_DATATYPE_IS_EDGE(_dt) ELEM(_dt, DT_DATA_CREASE, DT_DATA_SHARP_EDGE, DT_DATA_SEAM,  \
+                                           DT_DATA_BWEIGHT_EDGE, DT_DATA_FREESTYLE_EDGE)
+#define DT_DATATYPE_IS_POLY(_dt) ELEM(_dt, DT_DATA_UV, DT_DATA_SHARP_FACE, DT_DATA_FREESTYLE_FACE)
+#define DT_DATATYPE_IS_LOOP(_dt) ELEM(_dt, DT_DATA_UV, DT_DATA_VCOL)
+
+#define DT_DATATYPE_IS_MULTILAYERS(_dt) ELEM(_dt, DT_DATA_MDEFORMVERT, DT_DATA_SHAPEKEY, DT_DATA_UV, DT_DATA_VCOL)
+
+
+/* How to select data layers, for types supporting multi-layers.
+ * Here too, some options are highly dependent on type of transferred data! */
+enum {
+	DT_FROMLAYERS_ACTIVE                 = 0,
+	DT_FROMLAYERS_ALL                    = 1,
+	/* Datatype-specific. */
+	DT_FROMLAYERS_VGROUP                 = 1 << 8,
+	DT_FROMLAYERS_VGROUP_BONE_SELECTED   = DT_FROMLAYERS_VGROUP | 1,
+	DT_FROMLAYERS_VGROUP_BONE_DEFORM     = DT_FROMLAYERS_VGROUP | 2,
+	/* Other types-related modes... */
+};
+
+/* How to map a source layer to a destination layer, for types supporting multi-layers.
+ * Note: if no matching layer can be found, it will be created. */
+enum {
+	DT_TOLAYERS_ACTIVE                   = 0,  /* Only for DT_LAYERS_FROMSEL_ACTIVE. */
+	DT_TOLAYERS_NAME                     = 1,
+	DT_TOLAYERS_INDEX                    = 2,
+#if 0  /* TODO */
+	DT_TOLAYERS_CREATE                   = 3,  /* Never replace existing data in dst, always create new layers. */
+#endif
+};
+
+bool BKE_data_transfer_mesh(
+        struct Scene *scene, struct Object *ob_src, struct Object *ob_dst, const int data_types, const bool use_create,
+        const int map_vert_mode, const int map_edge_mode, const int map_poly_mode, const int map_loop_mode,
+        struct SpaceTransform *space_transform, const float max_distance, const float precision,
+        const int fromlayers_select, const int tolayers_select,
+        const int mix_mode, const float mix_factor, const char *vgroup_name);
+bool BKE_data_transfer_dm(
+        struct Scene *scene, struct Object *ob_src, struct Object *ob_dst, struct DerivedMesh *dm_dst,
+        const int data_types, const bool use_create,
+        const int map_vert_mode, const int map_edge_mode, const int map_poly_mode, const int map_loop_mode,
+        struct SpaceTransform *space_transform, const float max_distance, const float ray_radius,
+        const int fromlayers_select, const int tolayers_select,
+        const int mix_mode, const float mix_factor, const char *vgroup_name);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif  /* __BKE_DATA_TRANSFER_H__ */
+
diff --git a/source/blender/blenkernel/BKE_object_deform.h b/source/blender/blenkernel/BKE_object_deform.h
index 6de7ff9..10f7c5a 100644
--- a/source/blender/blenkernel/BKE_object_deform.h
+++ b/source/blender/blenkernel/BKE_object_deform.h
@@ -31,8 +31,17 @@
 
 struct Object;
 
+enum eVGroupSelect;
+
 bool *BKE_objdef_lock_flags_get(struct Object *ob, const int defbase_tot);
 bool *BKE_objdef_validmap_get(struct Object *ob, const int defbase_tot);
 bool *BKE_objdef_selected_get(struct Object *ob, int defbase_tot, int *r_dg_flags_sel_tot);
 
+/* Select helpers */
+bool *BKE_objdef_vgroup_subset_from_select_type(
+        struct Object *ob, enum eVGroupSelect subset_type, int *r_vgroup_tot, int *r_subset_count);
+void BKE_objdef_vgroup_subset_to_index_array(
+        const bool *vgroup_validmap, const int vgroup_tot, int *r_vgroup_subset_map);
+
+
 #endif  /* __BKE_OBJECT_DEFORM_H__ */
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index 6550882..f487c90 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -83,6 +83,7 @@ set(SRC
 	intern/curve.c
 	intern/customdata.c
 	intern/customdata_file.c
+	intern/data_transfer.c
 	intern/deform.c
 	intern/depsgraph.c
 	intern/displist.c
@@ -198,6 +199,7 @@ set(SRC
 	BKE_curve.h
 	BKE_customdata.h
 	BKE_customdata_file.h
+	BKE_data_transfer.h
 	BKE_deform.h
 	BKE_depsgraph.h
 	BKE_displist.h
@@ -272,6 +274,7 @@ set(SRC
 	tracking_private.h
 	intern/CCGSubSurf.h
 	intern/pbvh_intern.h
+	intern/data_transfer_intern.h
 )
 
 add_definitions(${GL_DEFINITIONS})
diff --git a/source/blender/editors/object/object_transfer_data.c b/source/blender/blenkernel/intern/data_transfer.c
similarity index 58%
rename from source/blender/editors/object/object_transfer_data.c
rename to source/blender/blenkernel/intern/data_transfer.c
index 3ff84cc..5525046 100644
--- a/source/blender/editors/object/object_transfer_data.c
+++ b/source/blender/blenkernel/intern/data_transfer.c
@@ -15,18 +15,18 @@
  * 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.
+ * The Original Code is Copyright (C) 2014 by Blender Foundation.
  * All rights reserved.
  *
  * The Original Code is: all of this file.
  *
- * Contributor(s): Ove M Henriksen.
+ * Contributor(s): Bastien Montagne.
  *
  * ***** END GPL LICENSE BLOCK *****
  */
 
-/** \file blender/editors/object/object_transfer_data.c
- *  \ingroup edobj
+/** \file blender/blenkernel/intern/data_transfer.c
+ *  \ingroup bke
  */
 
 #include "MEM_guardedalloc.h"
@@ -43,65 +43,47 @@
 
 #include "BKE_context.h"
 #include "BKE_customdata.h"
+#include "BKE_data_transfer.h"
 #include "BKE_deform.h"
-#include "BKE_mesh_mapping.h"
 #include "BKE_DerivedMesh.h"
+#include "BKE_mesh_mapping.h"
 #include "BKE_object.h"
+#include "BKE_object_deform.h"
 
-#include "RNA_access.h"
-#include "RNA_define.h"
-
-#include "WM_api.h"
-#include "WM_types.h"
-
-#include "ED_object.h"
-
-#include "UI_interface.h"
-#include "UI_resources.h"
-
-#include "object_intern.h"
-
+#include "data_transfer_intern.h"
 
-#define MDT_DATATYPE_IS_VERT(_dt) ELEM(_dt, MDT_DATA_MDEFORMVERT, MDT_DATA_SHAPEKEY, MDT_DATA_SKIN,  \
-                                            MDT_DATA_BWEIGHT_VERT)
-#define MDT_DATATYPE_IS_EDGE(_dt) ELEM(_dt, MDT_DATA_CREASE, MDT_DATA_SHARP_EDGE, MDT_DATA_SEAM,  \
-                                            MDT_DATA_BWEIGHT_EDGE, MDT_DATA_FREESTYLE_EDGE)
-#define MDT_DATATYPE_IS_POLY(_dt) ELEM(_dt, MDT_DATA_UV, MDT_DATA_SHARP_FACE, MDT_DATA_FREESTYLE_FACE)
-#define MDT_DATATYPE_IS_LOOP(_dt) ELEM(_dt, MDT_DATA_UV, MDT_DATA_VCOL)
 
-#define MDT_DATATYPE_IS_MULTILAYERS(_dt) ELEM(_dt, MDT_DATA_MDEFORMVERT, MDT_DATA_SHAPEKEY, MDT_DATA_UV, MDT_DATA_VCOL)
-
-int ED_data_transfer_mdtdata_to_cdtype(const int mdtdata)
+int BKE_data_transfer_dttype_to_cdtype(const int dtdata_type)
 {
-	switch (mdtdata) {
-		case MDT_DATA_MDEFORMVERT:
+	switch (dtdata_type) {
+		case DT_DATA_MDEFORMVERT:
 			return CD_FAKE_MDEFORMVERT;
-		case MDT_DATA_SHAPEKEY:
+		case DT_DATA_SHAPEKEY:
 			return CD_FAKE_SHAPEKEY;
-		case MDT_DATA_SKIN:
+		case DT_DATA_SKIN:
 			return CD_MVERT_SKIN;
-		case MDT_DATA_BWEIGHT_VERT:
+		case DT_DATA_BWEIGHT_VERT:
 			return CD_FAKE_BWEIGHT;
 
-		case MDT_DATA_SHARP_EDGE:
+		case DT_DATA_SHARP_EDGE:
 			return CD_FAKE_SHARP;
-		case MDT_DATA_SEAM:
+		case DT_DATA_SEAM:
 			return CD_FAKE_SEAM;
-		case MDT_DATA_CREASE:
+		case DT_DATA_CREASE:
 			return CD_FAKE_CREASE;
-		case MDT_DATA_BWEIGHT_EDGE:
+		case DT_DATA_BWEIGHT_EDGE:
 			return CD_FAKE_BWEIGHT;
-		case MDT_DATA_FREESTYLE_EDGE:
+		case DT_DATA_FREESTYLE_EDGE:
 			return CD_FREESTYLE_EDGE;
 
-		case MDT_DATA_UV:
+		case DT_DATA_UV:
 			return CD_FAKE_UV;
-		case MDT_DATA_SHARP_FACE:
+		case DT_DATA_SHARP_FACE:
 			return CD_FAKE_SHARP;
-		case MDT_DATA_FREESTYLE_FACE:
+		case DT_DATA_FREESTYLE_FACE:
 			return CD_FREESTYLE_FACE;
 
-		case MDT_DATA_VCOL:
+		case DT_DATA_VCOL

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list