[Bf-blender-cvs] [4aab63d23ea] temp-object-multi-mode: Move layer utility functions into own file

Campbell Barton noreply at git.blender.org
Wed Mar 14 08:27:13 CET 2018


Commit: 4aab63d23eaa9b23d66649bdfff7485e08c0c8fc
Author: Campbell Barton
Date:   Wed Mar 14 18:32:29 2018 +1100
Branches: temp-object-multi-mode
https://developer.blender.org/rB4aab63d23eaa9b23d66649bdfff7485e08c0c8fc

Move layer utility functions into own file

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

M	source/blender/blenkernel/BKE_layer.h
M	source/blender/blenkernel/CMakeLists.txt
M	source/blender/blenkernel/intern/layer.c
A	source/blender/blenkernel/intern/layer_utils.c

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

diff --git a/source/blender/blenkernel/BKE_layer.h b/source/blender/blenkernel/BKE_layer.h
index 69494bcf410..2c05ee0966d 100644
--- a/source/blender/blenkernel/BKE_layer.h
+++ b/source/blender/blenkernel/BKE_layer.h
@@ -346,17 +346,15 @@ struct ObjectsRenderableIteratorData {
 	ITER_END;                                                                 \
 } ((void)0)
 
-/* Array utilities. */
 
-typedef bool (*ObjectsFilterFn)(
-        struct Object *ob, void *user_data);
+/* layer_utils.c */
 
 struct ObjectsInModeParams {
 	int object_mode;
 	uint no_dupe_data : 1;
 
-	ObjectsFilterFn  filter_fn;
-	void            *filter_userdata;
+	bool (*filter_fn)(struct Object *ob, void *user_data);
+	void  *filter_userdata;
 };
 
 Base **BKE_view_layer_array_from_bases_in_mode_params(
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index 3f6bb5b9954..7c02b6d5ced 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -165,6 +165,7 @@ set(SRC
 	intern/pointcache.c
 	intern/property.c
 	intern/layer.c
+	intern/layer_utils.c
 	intern/lightprobe.c
 	intern/report.c
 	intern/rigidbody.c
diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c
index ea796f9f8f2..6d5ac08398c 100644
--- a/source/blender/blenkernel/intern/layer.c
+++ b/source/blender/blenkernel/intern/layer.c
@@ -34,7 +34,6 @@
 #include "BLT_translation.h"
 
 #include "BKE_collection.h"
-#include "BKE_editmesh.h"
 #include "BKE_freestyle.h"
 #include "BKE_global.h"
 #include "BKE_group.h"
@@ -51,7 +50,6 @@
 #include "DNA_ID.h"
 #include "DNA_layer_types.h"
 #include "DNA_object_types.h"
-#include "DNA_mesh_types.h"
 #include "DNA_node_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_windowmanager_types.h"
@@ -2411,76 +2409,6 @@ void BKE_layer_eval_layer_collection_post(const struct EvaluationContext *UNUSED
 	}
 }
 
-
-Base **BKE_view_layer_array_from_bases_in_mode_params(
-        ViewLayer *view_layer, uint *r_len,
-        const struct ObjectsInModeParams *params)
-{
-	if (params->no_dupe_data) {
-		FOREACH_BASE_IN_MODE_BEGIN(view_layer, params->object_mode, base_iter) {
-			ID *id = base_iter->object->data;
-			if (id) {
-				id->tag |= LIB_TAG_DOIT;
-			}
-		} FOREACH_BASE_IN_MODE_END;
-	}
-
-	Base **base_array = NULL;
-	BLI_array_declare(base_array);
-
-	FOREACH_BASE_IN_MODE_BEGIN(view_layer, params->object_mode, base_iter) {
-		if (params->filter_fn) {
-			if (!params->filter_fn(base_iter->object, params->filter_userdata)) {
-				continue;
-			}
-		}
-		if (params->no_dupe_data) {
-			ID *id = base_iter->object->data;
-			if (id) {
-				if (id->tag & LIB_TAG_DOIT) {
-					id->tag &= ~LIB_TAG_DOIT;
-				}
-				else {
-					continue;
-				}
-			}
-		}
-		BLI_array_append(base_array, base_iter);
-	} FOREACH_BASE_IN_MODE_END;
-
-	if (base_array != NULL) {
-		base_array = MEM_reallocN(base_array, sizeof(*base_array) * BLI_array_count(base_array));
-	}
-	*r_len = BLI_array_count(base_array);
-	return base_array;
-}
-
-Object **BKE_view_layer_array_from_objects_in_mode_params(
-        ViewLayer *view_layer, uint *r_len,
-        const struct ObjectsInModeParams *params)
-{
-	Base **base_array = BKE_view_layer_array_from_bases_in_mode_params(
-	        view_layer, r_len, params);
-	if (base_array != NULL) {
-		for (uint i = 0; i < *r_len; i++) {
-			((Object **)base_array)[i] = base_array[i]->object;
-		}
-	}
-	return (Object **)base_array;
-}
-
-bool BKE_view_layer_filter_edit_mesh_has_uvs(Object *ob, void *UNUSED(user_data))
-{
-	if (ob->type == OB_MESH) {
-		Mesh *me = ob->data;
-		BMEditMesh *em = me->edit_btmesh;
-		if (em != NULL) {
-			return CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV) != -1;
-		}
-	}
-	return false;
-}
-
 /**
  * Free any static allocated memory.
  */
diff --git a/source/blender/blenkernel/intern/layer_utils.c b/source/blender/blenkernel/intern/layer_utils.c
new file mode 100644
index 00000000000..c7accf151ca
--- /dev/null
+++ b/source/blender/blenkernel/intern/layer_utils.c
@@ -0,0 +1,109 @@
+/*
+ * ***** 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/blenkernel/intern/layer_utils.c
+ *  \ingroup bke
+ */
+
+#include <string.h>
+
+#include "BLI_array.h"
+#include "BLI_listbase.h"
+
+#include "BKE_collection.h"
+#include "BKE_editmesh.h"
+#include "BKE_layer.h"
+
+#include "DNA_ID.h"
+#include "DNA_layer_types.h"
+#include "DNA_object_types.h"
+#include "DNA_mesh_types.h"
+#include "DNA_scene_types.h"
+
+#include "MEM_guardedalloc.h"
+
+Base **BKE_view_layer_array_from_bases_in_mode_params(
+        ViewLayer *view_layer, uint *r_len,
+        const struct ObjectsInModeParams *params)
+{
+	if (params->no_dupe_data) {
+		FOREACH_BASE_IN_MODE_BEGIN(view_layer, params->object_mode, base_iter) {
+			ID *id = base_iter->object->data;
+			if (id) {
+				id->tag |= LIB_TAG_DOIT;
+			}
+		} FOREACH_BASE_IN_MODE_END;
+	}
+
+	Base **base_array = NULL;
+	BLI_array_declare(base_array);
+
+	FOREACH_BASE_IN_MODE_BEGIN(view_layer, params->object_mode, base_iter) {
+		if (params->filter_fn) {
+			if (!params->filter_fn(base_iter->object, params->filter_userdata)) {
+				continue;
+			}
+		}
+		if (params->no_dupe_data) {
+			ID *id = base_iter->object->data;
+			if (id) {
+				if (id->tag & LIB_TAG_DOIT) {
+					id->tag &= ~LIB_TAG_DOIT;
+				}
+				else {
+					continue;
+				}
+			}
+		}
+		BLI_array_append(base_array, base_iter);
+	} FOREACH_BASE_IN_MODE_END;
+
+	if (base_array != NULL) {
+		base_array = MEM_reallocN(base_array, sizeof(*base_array) * BLI_array_count(base_array));
+	}
+	*r_len = BLI_array_count(base_array);
+	return base_array;
+}
+
+Object **BKE_view_layer_array_from_objects_in_mode_params(
+        ViewLayer *view_layer, uint *r_len,
+        const struct ObjectsInModeParams *params)
+{
+	Base **base_array = BKE_view_layer_array_from_bases_in_mode_params(
+	        view_layer, r_len, params);
+	if (base_array != NULL) {
+		for (uint i = 0; i < *r_len; i++) {
+			((Object **)base_array)[i] = base_array[i]->object;
+		}
+	}
+	return (Object **)base_array;
+}
+
+bool BKE_view_layer_filter_edit_mesh_has_uvs(Object *ob, void *UNUSED(user_data))
+{
+	if (ob->type == OB_MESH) {
+		Mesh *me = ob->data;
+		BMEditMesh *em = me->edit_btmesh;
+		if (em != NULL) {
+			return CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV) != -1;
+		}
+	}
+	return false;
+}



More information about the Bf-blender-cvs mailing list