[Bf-blender-cvs] [5304180] mesh-transfer-data: rename mesh-island vars to clarify use

Campbell Barton noreply at git.blender.org
Mon Nov 17 16:17:28 CET 2014


Commit: 530418040a6f6778505802fe7365efa0541b74ac
Author: Campbell Barton
Date:   Mon Nov 17 15:18:38 2014 +0100
Branches: mesh-transfer-data
https://developer.blender.org/rB530418040a6f6778505802fe7365efa0541b74ac

rename mesh-island vars to clarify use

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

M	source/blender/blenkernel/BKE_mesh_mapping.h
M	source/blender/blenkernel/intern/mesh_mapping.c
M	source/blender/blenkernel/intern/mesh_remap.c

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

diff --git a/source/blender/blenkernel/BKE_mesh_mapping.h b/source/blender/blenkernel/BKE_mesh_mapping.h
index 41cb270..6a72047 100644
--- a/source/blender/blenkernel/BKE_mesh_mapping.h
+++ b/source/blender/blenkernel/BKE_mesh_mapping.h
@@ -138,27 +138,27 @@ enum {
 	MISLAND_TYPE_LOOP = 4,
 };
 
-typedef struct MeshIslands {
-	short item_type;  /* MISLAND_TYPE_... */
+typedef struct MeshIslandStore {
+	short item_type;    /* MISLAND_TYPE_... */
 	short island_type;  /* MISLAND_TYPE_... */
 
-	int nbr_items;
-	int *items_to_islands_idx;
+	int  items_to_islands_num;
+	int *items_to_islands;  /* map the item to the island index */
 
-	int nbr_islands;
+	int                  islands_num;
+	size_t               islands_num_alloc;
 	struct MeshElemMap **islands;  /* Array of pointers, one item per island. */
 
-	void *mem;  /* Memory handler, internal use only. */
-	size_t allocated_islands;
-} MeshIslands;
+	struct MemArena *mem;  /* Memory arena, internal use only. */
+} MeshIslandStore;
 
 void BKE_mesh_loop_islands_init(
-        MeshIslands *islands,
-        const short item_type, const int num_items, const short island_type);
-void BKE_mesh_loop_islands_clear(MeshIslands *islands);
-void BKE_mesh_loop_islands_free(MeshIslands *islands);
+        MeshIslandStore *island_store,
+        const short item_type, const int item_num, const short island_type);
+void BKE_mesh_loop_islands_clear(MeshIslandStore *island_store);
+void BKE_mesh_loop_islands_free(MeshIslandStore *island_store);
 void BKE_mesh_loop_islands_add(
-        MeshIslands *islands, const int num_items, int *item_indices,
+        MeshIslandStore *islands, const int item_num, int *item_indices,
         const int num_island_items, int *island_item_indices);
 
 typedef bool (*MeshRemapIslandsCalc)(
@@ -166,7 +166,7 @@ typedef bool (*MeshRemapIslandsCalc)(
         struct MEdge *edges, const int totedge,
         struct MPoly *polys, const int totpoly,
         struct MLoop *loops, const int totloop,
-        struct MeshIslands *r_islands);
+        struct MeshIslandStore *r_island_store);
 
 /* Above vert/UV mapping stuff does not do what we need here, but does things we do not need here.
  * So better keep them separated for now, I think.
@@ -176,7 +176,7 @@ bool BKE_mesh_calc_islands_loop_poly_uv(
         struct MEdge *edges, const int totedge,
         struct MPoly *polys, const int totpoly,
         struct MLoop *loops, const int totloop,
-        MeshIslands *r_islands);
+        MeshIslandStore *r_island_store);
 
 int *BKE_mesh_calc_smoothgroups(
         const struct MEdge *medge, const int totedge,
diff --git a/source/blender/blenkernel/intern/mesh_mapping.c b/source/blender/blenkernel/intern/mesh_mapping.c
index 618eb13..c41ef1d 100644
--- a/source/blender/blenkernel/intern/mesh_mapping.c
+++ b/source/blender/blenkernel/intern/mesh_mapping.c
@@ -571,10 +571,10 @@ int *BKE_mesh_calc_smoothgroups(const MEdge *medge, const int totedge,
 
 
 void BKE_mesh_loop_islands_init(
-        MeshIslands *islands,
-        const short item_type, const int num_items, const short island_type)
+        MeshIslandStore *island_store,
+        const short item_type, const int items_num, const short island_type)
 {
-	MemArena *mem = islands->mem;
+	MemArena *mem = island_store->mem;
 
 	if (mem == NULL) {
 		mem = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, __func__);
@@ -584,68 +584,68 @@ void BKE_mesh_loop_islands_init(
 	BLI_assert(ELEM(item_type, MISLAND_TYPE_VERT, MISLAND_TYPE_EDGE, MISLAND_TYPE_POLY, MISLAND_TYPE_LOOP));
 	BLI_assert(ELEM(island_type, MISLAND_TYPE_VERT, MISLAND_TYPE_EDGE, MISLAND_TYPE_POLY, MISLAND_TYPE_LOOP));
 
-	islands->item_type = item_type;
-	islands->nbr_items = num_items;
-	islands->items_to_islands_idx = BLI_memarena_alloc(mem, sizeof(*islands->items_to_islands_idx) * (size_t)num_items);
+	island_store->item_type = item_type;
+	island_store->items_to_islands_num = items_num;
+	island_store->items_to_islands = BLI_memarena_alloc(mem, sizeof(*island_store->items_to_islands) * (size_t)items_num);
 
-	islands->island_type = island_type;
-	islands->allocated_islands = 64;
-	islands->islands = BLI_memarena_alloc(mem, sizeof(*islands->islands) * islands->allocated_islands);
+	island_store->island_type = island_type;
+	island_store->islands_num_alloc = 64;
+	island_store->islands = BLI_memarena_alloc(mem, sizeof(*island_store->islands) * island_store->islands_num_alloc);
 
-	islands->mem = mem;
+	island_store->mem = mem;
 }
 
-void BKE_mesh_loop_islands_clear(MeshIslands *islands)
+void BKE_mesh_loop_islands_clear(MeshIslandStore *island_store)
 {
-	islands->item_type = 0;
-	islands->nbr_items = 0;
-	islands->items_to_islands_idx = NULL;
+	island_store->item_type = 0;
+	island_store->items_to_islands_num = 0;
+	island_store->items_to_islands = NULL;
 
-	islands->island_type = 0;
-	islands->nbr_islands = 0;
-	islands->islands = NULL;
+	island_store->island_type = 0;
+	island_store->islands_num = 0;
+	island_store->islands = NULL;
 
-	if (islands->mem) {
-		BLI_memarena_clear(islands->mem);
+	if (island_store->mem) {
+		BLI_memarena_clear(island_store->mem);
 	}
 
-	islands->allocated_islands = 0;
+	island_store->islands_num_alloc = 0;
 }
 
-void BKE_mesh_loop_islands_free(MeshIslands *islands)
+void BKE_mesh_loop_islands_free(MeshIslandStore *island_store)
 {
-	if (islands->mem) {
-		BLI_memarena_free(islands->mem);
-		islands->mem = NULL;
+	if (island_store->mem) {
+		BLI_memarena_free(island_store->mem);
+		island_store->mem = NULL;
 	}
 }
 
 void BKE_mesh_loop_islands_add(
-        MeshIslands *islands, const int num_items, int *items_indices,
+        MeshIslandStore *island_store, const int item_num, int *items_indices,
         const int num_island_items, int *island_item_indices)
 {
-	MemArena *mem = islands->mem;
+	MemArena *mem = island_store->mem;
 
 	MeshElemMap *isld;
-	const int curr_island_idx = islands->nbr_islands++;
-	const size_t curr_num_islands = (size_t)islands->nbr_islands;
-	int i = num_items;
+	const int curr_island_idx = island_store->islands_num++;
+	const size_t curr_num_islands = (size_t)island_store->islands_num;
+	int i = item_num;
 
-	islands->nbr_items = num_items;
+	island_store->items_to_islands_num = item_num;
 	while (i--) {
-		islands->items_to_islands_idx[items_indices[i]] = curr_island_idx;
+		island_store->items_to_islands[items_indices[i]] = curr_island_idx;
 	}
 
-	if (UNLIKELY(curr_num_islands > islands->allocated_islands)) {
+	if (UNLIKELY(curr_num_islands > island_store->islands_num_alloc)) {
 		MeshElemMap **islds;
 
-		islands->allocated_islands *= 2;
-		islds = BLI_memarena_alloc(mem, sizeof(*islds) * islands->allocated_islands);
-		memcpy(islds, islands->islands, sizeof(*islds) * (curr_num_islands - 1));
-		islands->islands = islds;
+		island_store->islands_num_alloc *= 2;
+		islds = BLI_memarena_alloc(mem, sizeof(*islds) * island_store->islands_num_alloc);
+		memcpy(islds, island_store->islands, sizeof(*islds) * (curr_num_islands - 1));
+		island_store->islands = islds;
 	}
 
-	islands->islands[curr_island_idx] = isld = BLI_memarena_alloc(mem, sizeof(*isld));
+	island_store->islands[curr_island_idx] = isld = BLI_memarena_alloc(mem, sizeof(*isld));
 
 	isld->count = num_island_items;
 	isld->indices = BLI_memarena_alloc(mem, sizeof(*isld->indices) * (size_t)num_island_items);
@@ -676,7 +676,7 @@ bool BKE_mesh_calc_islands_loop_poly_uv(
         MPoly *polys, const int totpoly,
         MLoop *loops, const int totloop,
 
-        MeshIslands *r_islands)
+        MeshIslandStore *r_island_store)
 {
 	int *poly_groups = NULL;
 	int num_poly_groups;
@@ -687,8 +687,8 @@ bool BKE_mesh_calc_islands_loop_poly_uv(
 
 	int grp_idx, p_idx, pl_idx, l_idx;
 
-	BKE_mesh_loop_islands_clear(r_islands);
-	BKE_mesh_loop_islands_init(r_islands, MISLAND_TYPE_LOOP, totloop, MISLAND_TYPE_POLY);
+	BKE_mesh_loop_islands_clear(r_island_store);
+	BKE_mesh_loop_islands_init(r_island_store, MISLAND_TYPE_LOOP, totloop, MISLAND_TYPE_POLY);
 
 	poly_loop_islands_calc(
 	        edges, totedge, polys, totpoly, loops, totloop, false,
@@ -717,7 +717,7 @@ bool BKE_mesh_calc_islands_loop_poly_uv(
 			}
 		}
 
-		BKE_mesh_loop_islands_add(r_islands, num_lidx, loop_indices, num_pidx, poly_indices);
+		BKE_mesh_loop_islands_add(r_island_store, num_lidx, loop_indices, num_pidx, poly_indices);
 	}
 
 	MEM_freeN(poly_indices);
diff --git a/source/blender/blenkernel/intern/mesh_remap.c b/source/blender/blenkernel/intern/mesh_remap.c
index 676a955..74d2b90 100644
--- a/source/blender/blenkernel/intern/mesh_remap.c
+++ b/source/blender/blenkernel/intern/mesh_remap.c
@@ -765,7 +765,7 @@ void BKE_dm2mesh_mapping_loops_compute(
 
 		const bool use_from_vert = (mode & M2MMAP_USE_VERT);
 
-		MeshIslands islands = {0};
+		MeshIslandStore island_store = {0};
 		bool use_islands = false;
 
 		float (*poly_nors_src)[3] = NULL;
@@ -885,15 +885,15 @@ void BKE_dm2mesh_mapping_loops_compute(
 			        edges_src, num_edges_src,
 			        polys_src, num_polys_src,
 			        loops_src, num_loops_src,
-			        &islands);
+			        &island_store);
 
-			num_trees = use_islands ? islands.nbr_islands : 1;
+			num_trees = use_islands ? island_store.islands_num : 1;
 			treedata = MEM_callocN(sizeof(*treedata) * (size_t)num_trees, __func__);
 
 			if (use_islands) {
 				/* We expect our islands to contain poly indices, and a mapping loops -> islands indices.
 				 * This implies all loops of a same poly are in the same island. */
-				BLI_assert((islands.item_type == MISLAND_TYPE_LOOP) && (islands.island_type == MISLAND_TYPE_POLY));
+				BLI_assert((island_store.item_type == MISLAND_TYPE_LOOP) && (island_store.island_type == MISLAND_TYPE_POLY));
 			}
 		}
 		else {
@@ -907,7 +907,7 @@ void BKE_dm2mesh_mapping_loops_compute(
 				BLI_bitmap *verts_active = BLI_BITMAP_NEW((size_t)num_verts_src, __func__);
 
 				for (tidx = 0; tidx < num_trees; tidx++) {
-					MeshElemMap *isld = islands.islands[tidx];
+					MeshElemMap *isld = island_store.islands[tidx];
 					int num_verts_active = 0;
 					BLI_BITMAP_SET_ALL(verts_active, false, (size_t)num_verts_src);
 					for (i = 0; i < isld->count; i++) {
@@ -956,7 +956,7 @@ void BKE_dm2mesh_mapping_loops_compute(
 					BLI_BITMAP_SET_A

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list