[Bf-blender-cvs] [da43420] temp-array-modifier: Cleanup
Campbell Barton
noreply at git.blender.org
Tue Aug 12 02:51:17 CEST 2014
Commit: da434209c49a2d186510198ced7810991d2d3ed8
Author: Campbell Barton
Date: Tue Aug 12 10:48:15 2014 +1000
Branches: temp-array-modifier
https://developer.blender.org/rBda434209c49a2d186510198ced7810991d2d3ed8
Cleanup
===================================================================
M source/blender/blenkernel/intern/cdderivedmesh.c
M source/blender/modifiers/intern/MOD_array.c
===================================================================
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c
index 68fb01d..9ad9916 100644
--- a/source/blender/blenkernel/intern/cdderivedmesh.c
+++ b/source/blender/blenkernel/intern/cdderivedmesh.c
@@ -2597,8 +2597,9 @@ static int cddm_poly_compare(MLoop *mloop_array, MPoly *mpoly_source, MPoly *mpo
mloop_source = mloop_array + mpoly_source->loopstart;
vert_source = mloop_source->v;
- if (vtargetmap[vert_source] != -1)
+ if (vtargetmap[vert_source] != -1) {
vert_source = vtargetmap[vert_source];
+ }
else {
/* All source loop vertices should be mapped */
BLI_assert(false);
@@ -2607,8 +2608,9 @@ static int cddm_poly_compare(MLoop *mloop_array, MPoly *mpoly_source, MPoly *mpo
/* Find same vertex within mpoly_target's loops */
mloop_target = mloop_array + mpoly_target->loopstart;
for (i_loop_target = 0; i_loop_target < mpoly_target->totloop; i_loop_target++, mloop_target++) {
- if (mloop_target->v == vert_source)
+ if (mloop_target->v == vert_source) {
break;
+ }
}
/* If same vertex not found, then polys cannot be equal */
@@ -2663,8 +2665,9 @@ static int cddm_poly_compare(MLoop *mloop_array, MPoly *mpoly_source, MPoly *mpo
} while (vert_source == vert_target);
- if (compare_completed)
+ if (compare_completed) {
break;
+ }
/* Now advance i_loop_target as well */
i_loop_target_offset++;
@@ -2688,13 +2691,14 @@ static int cddm_poly_compare(MLoop *mloop_array, MPoly *mpoly_source, MPoly *mpo
/* Adjust i_loop_target for cycling around and for direct/reverse order defined by delta = +1 or -1 */
i_loop_target_adjusted = (i_loop_target_start + direct_reverse * i_loop_target_offset) % mpoly_target->totloop;
- if (i_loop_target_adjusted < 0)
+ if (i_loop_target_adjusted < 0) {
i_loop_target_adjusted += mpoly_target->totloop;
+ }
mloop_target = mloop_array + mpoly_target->loopstart + i_loop_target_adjusted;
vert_target = mloop_target->v;
if (vert_target != vert_source) {
- same_loops = false; /* Polys are different */
+ same_loops = false; /* Polys are different */
break;
}
}
@@ -2722,8 +2726,8 @@ static int poly_ghash_compare_fn(const void *k1, const void *k2)
PolyKey *pk1 = (PolyKey*)k1;
PolyKey *pk2 = (PolyKey*)k2;
if (pk1->hash_sum == pk2->hash_sum &&
- pk1->hash_xor == pk2->hash_xor &&
- pk1->totloops == pk2->totloops)
+ pk1->hash_xor == pk2->hash_xor &&
+ pk1->totloops == pk2->totloops)
{
/* Equality - note that this does not mean equality of polys */
return 0;
@@ -2953,23 +2957,25 @@ DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, const int *vtargetmap, const int
}
if ((pkey_found = BLI_ghash_lookup(poly_ghash, &pkey))) {
- /* There might be a poly that matches this one */
- /* We could just leave it there and say there is, and do a "continue". */
- /* ... but we are checking whether there is an exact poly match. */
- /* It's not so costly in terms of CPU since it's very rare, just a lot of complex code. */
+ /* There might be a poly that matches this one.
+ * We could just leave it there and say there is, and do a "continue".
+ * ... but we are checking whether there is an exact poly match.
+ * It's not so costly in terms of CPU since it's very rare, just a lot of complex code.
+ */
/* Consider current loop again */
ml = cddm->mloop + mp->loopstart;
/* Consider the target of the loop's first vert */
v_target = vtargetmap[ml->v];
/* Now see if v_target belongs to a poly that shares all vertices with source poly,
- * in same order, or reverse order */
+ * in same order, or reverse order */
for (i_poly = 0; i_poly < cddm->pmap[v_target].count; i_poly++) {
MPoly *target_poly = cddm->mpoly + *(cddm->pmap[v_target].indices + i_poly);
if (cddm_poly_compare(cddm->mloop, mp, target_poly, vtargetmap, +1) ||
- cddm_poly_compare(cddm->mloop, mp, target_poly, vtargetmap, -1)) {
+ cddm_poly_compare(cddm->mloop, mp, target_poly, vtargetmap, -1))
+ {
found = true;
break;
}
@@ -2985,10 +2991,10 @@ DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, const int *vtargetmap, const int
}
- /* Here either the poly's vertices were not all merged */
- /* or they were all merged, but targets do not make up an identical poly */
- /* The poly is retained */
-
+ /* Here either the poly's vertices were not all merged
+ * or they were all merged, but targets do not make up an identical poly,
+ * the poly is retained.
+ */
ml = cddm->mloop + mp->loopstart;
c = 0;
diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c
index adbaa3d..0a573d0 100644
--- a/source/blender/modifiers/intern/MOD_array.c
+++ b/source/blender/modifiers/intern/MOD_array.c
@@ -178,9 +178,9 @@ static int vergaverco(const void *e1, const void *e2)
const SortVertsElem *sv1 = (SortVertsElem *)e1;
const SortVertsElem *sv2 = (SortVertsElem *)e2;
- if (sv1->sum_co > sv2->sum_co) return 1;
+ if (sv1->sum_co > sv2->sum_co) return 1;
else if (sv1->sum_co < sv2->sum_co) return -1;
- else return 0;
+ else return 0;
}
static void svert_from_mvert(SortVertsElem *sv, MVert *mv, int i_begin, int i_end)
@@ -199,7 +199,7 @@ static void svert_from_mvert(SortVertsElem *sv, MVert *mv, int i_begin, int i_en
* The int doubles_map[num_verts_source] array must have been allocated by caller.
*/
static void map_doubles(
- int *doubles_map,
+ int *doubles_map,
MVert *mverts,
int target_start,
int target_num_verts,
@@ -208,7 +208,7 @@ static void map_doubles(
float dist,
bool with_follow)
{
- const float dist3 = 1.7321 * dist; /* Just above sqrt(3) */
+ const float dist3 = (M_SQRT3 + 0.00005f) * dist; /* Just above sqrt(3) */
int i_source, i_target, i_target_low_bound, target_end, source_end;
SortVertsElem *sorted_verts_target, *sorted_verts_source;
SortVertsElem *sve_source, *sve_target, *sve_target_low_bound;
@@ -291,7 +291,8 @@ static void map_doubles(
if (with_follow) { /* with_follow option: map to initial target */
target_vertex = doubles_map[target_vertex];
}
- else { /* not with_follow: if target is mapped, then we do not map source, and stop searching */
+ else {
+ /* not with_follow: if target is mapped, then we do not map source, and stop searching */
break;
}
}
@@ -302,7 +303,7 @@ static void map_doubles(
i_target++;
sve_target++;
}
- /* End of candidate scan : if none found then no doubles */
+ /* End of candidate scan: if none found then no doubles */
if (!double_found) {
doubles_map[sve_source->vertex_num] = -1;
}
@@ -497,7 +498,7 @@ static DerivedMesh *arrayModifier_doArray(
full_doubles_map[i] = -1;
}
- /*copy customdata to original geometry*/
+ /* copy customdata to original geometry */
DM_copy_vert_data(dm, result_dm, 0, 0, chunk_nverts);
DM_copy_edge_data(dm, result_dm, 0, 0, chunk_nedges);
DM_copy_loop_data(dm, result_dm, 0, 0, chunk_nloops);
@@ -548,8 +549,9 @@ static DerivedMesh *arrayModifier_doArray(
}
mp = CDDM_get_polys(result_dm) + c * chunk_npolys;
- for (i = 0; i < chunk_npolys; i++, mp++)
+ for (i = 0; i < chunk_npolys; i++, mp++) {
mp->loopstart += c * chunk_nloops;
+ }
/* adjust loop vertex and edge indices */
ml = CDDM_get_loops(result_dm) + c * chunk_nloops;
@@ -611,7 +613,7 @@ static DerivedMesh *arrayModifier_doArray(
false);
}
- /* start capping */
+ /* start capping */
if (start_cap_dm) {
float start_offset[4][4];
int start_cap_start = result_nverts - start_cap_nverts - end_cap_nverts;
More information about the Bf-blender-cvs
mailing list