[Bf-blender-cvs] [f902bba] wiggly-widgets: Cleanup the file mess with facemaps, make correct BKE/ED files for all functions. Blenderplayer compiles again

Antony Riakiotakis noreply at git.blender.org
Mon Jan 5 12:17:00 CET 2015


Commit: f902bbad83727ba8c35328aeb75583449eb84e6f
Author: Antony Riakiotakis
Date:   Mon Jan 5 12:16:44 2015 +0100
Branches: wiggly-widgets
https://developer.blender.org/rBf902bbad83727ba8c35328aeb75583449eb84e6f

Cleanup the file mess with facemaps, make correct BKE/ED files for all
functions. Blenderplayer compiles again

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

A	source/blender/blenkernel/BKE_facemap.h
M	source/blender/blenkernel/BKE_object_deform.h
M	source/blender/blenkernel/CMakeLists.txt
A	source/blender/blenkernel/intern/facemap.c
M	source/blender/blenkernel/intern/object.c
M	source/blender/editors/include/ED_mesh.h
M	source/blender/editors/object/object_fmap.c
M	source/blender/makesrna/intern/rna_object.c
M	source/blenderplayer/bad_level_call_stubs/stubs.c

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

diff --git a/source/blender/blenkernel/BKE_facemap.h b/source/blender/blenkernel/BKE_facemap.h
new file mode 100644
index 0000000..1367ef5
--- /dev/null
+++ b/source/blender/blenkernel/BKE_facemap.h
@@ -0,0 +1,54 @@
+/*
+ * ***** 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.
+ *
+ * Contributor(s): Antony Riakiotakis
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef __BKE_FACEMAP_H__
+#define __BKE_FACEMAP_H__
+
+/** \file BKE_facemap.h
+ * \ingroup bke
+ * \brief Functions for dealing with objects and facemaps.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct bFaceMap;
+struct ListBase;
+struct Object;
+
+/* Face map operations */
+struct bFaceMap *BKE_object_facemap_add(struct Object *ob);
+struct bFaceMap *BKE_object_facemap_add_name(struct Object *ob, const char *name);
+void BKE_object_facemap_remove(struct Object *ob, struct bFaceMap *fmap);
+void BKE_object_fmap_remove_all(struct Object *ob);
+
+int fmap_name_index(struct Object *ob, const char *name);
+void fmap_unique_name(struct bFaceMap *fmap, struct Object *ob);
+struct bFaceMap *fmap_find_name(struct Object *ob, const char *name);
+void fmap_copy_list(struct ListBase *outbase, struct ListBase *inbase);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __BKE_FACEMAP_H__ */
diff --git a/source/blender/blenkernel/BKE_object_deform.h b/source/blender/blenkernel/BKE_object_deform.h
index e5d3087..6403aa0 100644
--- a/source/blender/blenkernel/BKE_object_deform.h
+++ b/source/blender/blenkernel/BKE_object_deform.h
@@ -55,20 +55,6 @@ bool BKE_object_defgroup_clear_all(struct Object *ob, const bool use_selection);
 void BKE_object_defgroup_remove(struct Object *ob, struct bDeformGroup *defgroup);
 void BKE_object_defgroup_remove_all(struct Object *ob);
 
-/* Face map operations */
-struct bFaceMap *BKE_object_facemap_add(struct Object *ob);
-struct bFaceMap *BKE_object_facemap_add_name(struct Object *ob, const char *name);
-void BKE_object_facemap_remove(struct Object *ob, struct bFaceMap *fmap);
-void BKE_object_fmap_remove_all(struct Object *ob);
-
-void ED_fmap_face_add(struct Object *ob, struct bFaceMap *fmap, int facenum);
-void ED_fmap_face_remove(struct Object *ob, struct bFaceMap *fmap, int facenum);
-
-int fmap_name_index(struct Object *ob, const char *name);
-void fmap_unique_name(struct bFaceMap *fmap, struct Object *ob);
-struct bFaceMap *fmap_find_name(struct Object *ob, const char *name);
-void fmap_copy_list(struct ListBase *outbase, struct ListBase *inbase);
-
 /* Select helpers */
 enum eVGroupSelect;
 bool *BKE_object_defgroup_subset_from_select_type(
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index 5850b16..7912efb 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -93,6 +93,7 @@ set(SRC
 	intern/editmesh.c
 	intern/editmesh_bvh.c
 	intern/effect.c
+	intern/facemap.c
 	intern/fcurve.c
 	intern/fluidsim.c
 	intern/fmodifier.c
@@ -206,6 +207,7 @@ set(SRC
 	BKE_displist.h
 	BKE_dynamicpaint.h
 	BKE_effect.h
+	BKE_facemap.h
 	BKE_fcurve.h
 	BKE_fluidsim.h
 	BKE_font.h
diff --git a/source/blender/blenkernel/intern/facemap.c b/source/blender/blenkernel/intern/facemap.c
new file mode 100644
index 0000000..2dca535
--- /dev/null
+++ b/source/blender/blenkernel/intern/facemap.c
@@ -0,0 +1,259 @@
+
+/*
+ * ***** 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) 2008 Blender Foundation.
+ * All rights reserved.
+ *
+ * 
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+
+#include "DNA_object_types.h"
+#include "DNA_mesh_types.h"
+
+#include "WM_types.h"
+#include "WM_api.h"
+
+#include "BKE_context.h"
+#include "BKE_customdata.h"
+#include "BKE_facemap.h"
+#include "BKE_editmesh.h"
+#include "BKE_object.h"
+#include "BKE_object_deform.h"
+
+#include "BKE_depsgraph.h"
+
+#include "BLI_utildefines.h"
+#include "BLI_path_util.h"
+#include "BLI_string.h"
+#include "BLI_listbase.h"
+
+#include "BLF_translation.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "RNA_define.h"
+#include "RNA_access.h"
+
+#include <string.h>
+
+
+static bool fmap_unique_check(void *arg, const char *name)
+{
+	struct {Object *ob; void *fm; } *data = arg;
+	
+	bFaceMap *fmap;
+
+	for (fmap = data->ob->fmaps.first; fmap; fmap = fmap->next) {
+		if (data->fm != fmap) {
+			if (!strcmp(fmap->name, name)) {
+				return true;
+			}
+		}
+	}
+	
+	return false;
+}
+
+static bFaceMap *fmap_duplicate(bFaceMap *infmap)
+{
+	bFaceMap *outfmap;
+
+	if (!infmap)
+		return NULL;
+
+	outfmap = MEM_callocN(sizeof(bFaceMap), "copy facemap");
+
+	/* For now, just copy everything over. */
+	memcpy(outfmap, infmap, sizeof(bFaceMap));
+
+	outfmap->next = outfmap->prev = NULL;
+
+	return outfmap;
+}
+
+void fmap_copy_list(ListBase *outbase, ListBase *inbase)
+{
+	bFaceMap *fmap, *fmapn;
+
+	BLI_listbase_clear(outbase);
+
+	for (fmap = inbase->first; fmap; fmap = fmap->next) {
+		fmapn = fmap_duplicate(fmap);
+		BLI_addtail(outbase, fmapn);
+	}
+}
+
+void fmap_unique_name(bFaceMap *fmap, Object *ob)
+{
+	struct {Object *ob; void *fmap; } data;
+	data.ob = ob;
+	data.fmap = fmap;
+
+	BLI_uniquename_cb(fmap_unique_check, &data, DATA_("Group"), '.', fmap->name, sizeof(fmap->name));
+}
+
+bFaceMap *BKE_object_facemap_add_name(Object *ob, const char *name)
+{
+	bFaceMap *fmap;
+	
+	if (!ob || ob->type != OB_MESH)
+		return NULL;
+	
+	fmap = MEM_callocN(sizeof(bFaceMap), __func__);
+
+	BLI_strncpy(fmap->name, name, sizeof(fmap->name));
+
+	BLI_addtail(&ob->fmaps, fmap);
+	
+	ob->actfmap = BLI_listbase_count(&ob->fmaps);
+	
+	fmap_unique_name(fmap, ob);
+
+	return fmap;
+}
+
+bFaceMap *BKE_object_facemap_add(Object *ob)
+{
+	return BKE_object_facemap_add_name(ob, DATA_("FaceMap"));
+}
+
+
+static void object_fmap_remove_edit_mode(Object *ob, bFaceMap *fmap, bool do_selected, bool purge)
+{
+	const int fmap_nr = BLI_findindex(&ob->fmaps, fmap);
+	
+	if (ob->type == OB_MESH) {
+		Mesh *me = ob->data;
+		
+		if (me->edit_btmesh) {
+			BMEditMesh *em = me->edit_btmesh;
+			const int cd_fmap_offset = CustomData_get_offset(&em->bm->pdata, CD_FACEMAP);
+			
+			if (cd_fmap_offset != -1) {
+				BMFace *efa;
+				BMIter iter;
+				int *map;
+				
+				if (purge) {
+					BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
+						map = BM_ELEM_CD_GET_VOID_P(efa, cd_fmap_offset);
+						
+						if (map) { 
+							if (*map == fmap_nr)
+								*map = -1;
+							else if (*map > fmap_nr)
+								*map -= 1;
+						}
+					}
+				}
+				else {
+					BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
+						map = BM_ELEM_CD_GET_VOID_P(efa, cd_fmap_offset);
+						
+						if (map && *map == fmap_nr && (!do_selected || BM_elem_flag_test(efa, BM_ELEM_SELECT))) {
+							*map = -1;
+						}
+					}
+				}
+			}
+
+			if (ob->actfmap == BLI_listbase_count(&ob->fmaps))
+				ob->actfmap--;
+			
+			BLI_remlink(&ob->fmaps, fmap);
+			MEM_freeN(fmap);
+		}
+	}
+}
+
+static void object_fmap_remove_object_mode(Object *ob, bFaceMap *fmap, bool purge)
+{
+	const int fmap_nr = BLI_findindex(&ob->fmaps, fmap);
+	
+	if (ob->type == OB_MESH) {
+		Mesh *me = ob->data;
+		
+		if (CustomData_has_layer(&me->pdata, CD_FACEMAP)) {
+			int *map = CustomData_get_layer(&me->pdata, CD_FACEMAP);
+			int i;
+			
+			if (map) {
+				for (i = 0; i < me->totpoly; i++) {
+					if (map[i] == fmap_nr)
+						map[i] = -1;
+					else if (purge && map[i] > fmap_nr)
+						map[i]--;
+				}
+			}
+		}
+
+		if (ob->actfmap == BLI_listbase_count(&ob->fmaps))
+			ob->actfmap--;
+		
+		BLI_remlink(&ob->fmaps, fmap);
+		MEM_freeN(fmap);
+	}
+}
+
+void BKE_object_facemap_remove(Object *ob, bFaceMap *fmap)
+{
+	if (BKE_object_is_in_editmode(ob))
+		object_fmap_remove_edit_mode(ob, fmap, false, true);
+	else
+		object_fmap_remove_object_mode(ob, fmap, true);
+}
+
+void BKE_object_fmap_remove_all(Object *ob)
+{
+	bFaceMap *fmap = (bFaceMap *)ob->fmaps.first;
+
+	if (fmap) {
+		const bool edit_mode = BKE_object_is_in_editmode_vgroup(ob);
+
+		while (fmap) {
+			bFaceMap *next_fmap = fmap->next;
+
+			if (edit_mode)
+				object_fmap_remove_edit_mode(ob, fmap, false, false);
+			else
+				object_fmap_remove_object_mode(ob, fmap, false);
+
+			fmap = next_fmap;
+		}
+	}
+	/* remove all dverts */
+	if (ob->type == OB_MESH) {
+		Mesh *me = ob->data;
+		CustomData_free_layer(&me->pdata, CD_FACEMAP, me->totpoly, 0);
+	}
+	ob->actfmap = 0;
+}
+
+int fmap_name_index(Object *ob, const char *name)
+{
+	return (name) ? BLI_findstringindex(&ob->fmaps, name, offsetof(bFaceMap, name)) : -1;
+}
+
+bFaceMap *fmap_find_name(Object *ob, const char *name)
+{
+	return BLI_findstring(&ob->fmaps, name, offsetof(bFaceMap, name));
+}
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/int

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list