diff options
Diffstat (limited to 'source/blender/bmesh/intern')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_construct.c | 3 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_core.c | 18 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_edgeloop.c | 4 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_iterators_inline.h | 3 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_marking.c | 3 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_mesh.c | 157 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_mesh_conv.c | 54 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_mesh_validate.c | 3 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_mods.c | 21 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_polygon.c | 11 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_polygon_edgenet.c | 12 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_query.c | 20 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_walkers_impl.c | 5 |
13 files changed, 193 insertions, 121 deletions
diff --git a/source/blender/bmesh/intern/bmesh_construct.c b/source/blender/bmesh/intern/bmesh_construct.c index 4a4ea1e17a7..224f6ad1e5c 100644 --- a/source/blender/bmesh/intern/bmesh_construct.c +++ b/source/blender/bmesh/intern/bmesh_construct.c @@ -124,7 +124,8 @@ BMFace *BM_face_create_quad_tri(BMesh *bm, /** * \brief copies face loop data from shared adjacent faces. * - * \param filter_fn: A function that filters the source loops before copying (don't always want to copy all) + * \param filter_fn: A function that filters the source loops before copying + * (don't always want to copy all). * * \note when a matching edge is found, both loops of that edge are copied * this is done since the face may not be completely surrounded by faces, diff --git a/source/blender/bmesh/intern/bmesh_core.c b/source/blender/bmesh/intern/bmesh_core.c index 36abb1dc5c4..dfea4cbf7c0 100644 --- a/source/blender/bmesh/intern/bmesh_core.c +++ b/source/blender/bmesh/intern/bmesh_core.c @@ -140,7 +140,8 @@ BMVert *BM_vert_create(BMesh *bm, * \brief Main function for creating a new edge. * * \note Duplicate edges are supported by the API however users should _never_ see them. - * so unless you need a unique edge or know the edge won't exist, you should call with \a no_double = true + * so unless you need a unique edge or know the edge won't exist, + * you should call with \a no_double = true. */ BMEdge *BM_edge_create( BMesh *bm, BMVert *v1, BMVert *v2, const BMEdge *e_example, const eBMCreateFlag create_flag) @@ -1417,8 +1418,9 @@ static BMFace *bm_face_create__sfme(BMesh *bm, BMFace *f_example) * * \warning this is a low level function, most likely you want to use #BM_face_split() * - * Takes as input two vertices in a single face. An edge is created which divides the original face - * into two distinct regions. One of the regions is assigned to the original face and it is closed off. + * Takes as input two vertices in a single face. + * An edge is created which divides the original face into two distinct regions. + * One of the regions is assigned to the original face and it is closed off. * The second region has a new face assigned to it. * * \par Examples: @@ -1944,7 +1946,8 @@ BMEdge *bmesh_kernel_join_edge_kill_vert(BMesh *bm, * * Collapse an edge, merging surrounding data. * - * Unlike #BM_vert_collapse_edge & #bmesh_kernel_join_edge_kill_vert which only handle 2 valence verts, + * Unlike #BM_vert_collapse_edge & #bmesh_kernel_join_edge_kill_vert + * which only handle 2 valence verts, * this can handle any number of connected edges/faces. * * <pre> @@ -2065,8 +2068,8 @@ BMVert *bmesh_kernel_join_vert_kill_edge(BMesh *bm, * before attempting to fuse \a f1 and \a f2. * * \note The order of arguments decides whether or not certain per-face attributes are present - * in the resultant face. For instance vertex winding, material index, smooth flags, etc are inherited - * from \a f1, not \a f2. + * in the resultant face. For instance vertex winding, material index, smooth flags, + * etc are inherited from \a f1, not \a f2. * * \return A BMFace pointer */ @@ -2413,7 +2416,8 @@ void bmesh_kernel_vert_separate( * * Takes a list of edges, which have been split from their original. * - * Any edges which failed to split off in #bmesh_kernel_vert_separate will be merged back into the original edge. + * Any edges which failed to split off in #bmesh_kernel_vert_separate + * will be merged back into the original edge. * * \param edges_separate: * A list-of-lists, each list is from a single original edge (the first edge is the original), diff --git a/source/blender/bmesh/intern/bmesh_edgeloop.c b/source/blender/bmesh/intern/bmesh_edgeloop.c index f97ae0ace1e..2ca9c7e6340 100644 --- a/source/blender/bmesh/intern/bmesh_edgeloop.c +++ b/source/blender/bmesh/intern/bmesh_edgeloop.c @@ -264,7 +264,9 @@ static bool bm_loop_path_build_step(BLI_mempool *vs_pool, BLI_mempool_free(vs_pool, vs); } - /* bm->elem_index_dirty |= BM_VERT; */ /* Commented because used in a loop, and this flag has already been set. */ + + /* Commented because used in a loop, and this flag has already been set. */ + /* bm->elem_index_dirty |= BM_VERT; */ /* lb is now full of free'd items, overwrite */ *lb = lb_tmp; diff --git a/source/blender/bmesh/intern/bmesh_iterators_inline.h b/source/blender/bmesh/intern/bmesh_iterators_inline.h index ed3a9a5be09..4b9fbf52630 100644 --- a/source/blender/bmesh/intern/bmesh_iterators_inline.h +++ b/source/blender/bmesh/intern/bmesh_iterators_inline.h @@ -174,7 +174,8 @@ ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) BLI_INLINE } /** - * \brief Parallel (threaded) iterator, only available for most basic itertypes (verts/edges/faces of mesh). + * \brief Parallel (threaded) iterator, + * only available for most basic itertypes (verts/edges/faces of mesh). * * Uses BLI_task_parallel_mempool to iterate over all items of underlying matching mempool. * diff --git a/source/blender/bmesh/intern/bmesh_marking.c b/source/blender/bmesh/intern/bmesh_marking.c index f8ec69b6fe9..579fbbdc05e 100644 --- a/source/blender/bmesh/intern/bmesh_marking.c +++ b/source/blender/bmesh/intern/bmesh_marking.c @@ -1231,7 +1231,8 @@ void BM_mesh_elem_hflag_enable_test(BMesh *bm, /* note, better not attempt a fast path for selection as done with de-select * because hidden geometry and different selection modes can give different results, - * we could of course check for no hidden faces and then use quicker method but its not worth it. */ + * we could of course check for no hidden faces and then use + * quicker method but its not worth it. */ for (i = 0; i < 3; i++) { if (htype & flag_types[i]) { diff --git a/source/blender/bmesh/intern/bmesh_mesh.c b/source/blender/bmesh/intern/bmesh_mesh.c index 7a42ee35440..aad33d8c9c1 100644 --- a/source/blender/bmesh/intern/bmesh_mesh.c +++ b/source/blender/bmesh/intern/bmesh_mesh.c @@ -321,7 +321,8 @@ void BM_mesh_free(BMesh *bm) * Helpers for #BM_mesh_normals_update and #BM_verts_calc_normal_vcos */ -/* We use that existing internal API flag, assuming no other tool using it would run concurrently to clnors editing. */ +/* We use that existing internal API flag, + * assuming no other tool using it would run concurrently to clnors editing. */ #define BM_LNORSPACE_UPDATE _FLAG_MF typedef struct BMEdgesCalcVectorsData { @@ -433,7 +434,8 @@ static void mesh_verts_calc_normals_accum_cb(void *userdata, MempoolIterData *mp virtual_lock += f_no[0] * fac; v_no[1] += f_no[1] * fac; v_no[2] += f_no[2] * fac; - /* Second atomic operation to 'release' our lock on that vector and set its first scalar value. */ + /* Second atomic operation to 'release' + * our lock on that vector and set its first scalar value. */ /* Note that we do not need to loop here, since we 'locked' v_no[0], * nobody should have changed it in the mean time. */ virtual_lock = atomic_cas_float(&v_no[0], FLT_MAX, virtual_lock); @@ -529,7 +531,8 @@ void BM_mesh_normals_update(BMesh *bm) /** * \brief BMesh Compute Normals from/to external data. * - * Computes the vertex normals of a mesh into vnos, using given vertex coordinates (vcos) and polygon normals (fnos). + * Computes the vertex normals of a mesh into vnos, + * using given vertex coordinates (vcos) and polygon normals (fnos). */ void BM_verts_calc_normal_vcos(BMesh *bm, const float (*fnos)[3], @@ -573,9 +576,8 @@ static void bm_mesh_edges_sharp_tag(BMesh *bm, BM_mesh_elem_index_ensure(bm, htype); } - /* This first loop checks which edges are actually smooth, and pre-populate lnos with vnos (as if they were - * all smooth). - */ + /* This first loop checks which edges are actually smooth, + * and pre-populate lnos with vnos (as if they were all smooth). */ BM_ITER_MESH_INDEX (e, &eiter, bm, BM_EDGES_OF_MESH, i) { BMLoop *l_a, *l_b; @@ -613,7 +615,8 @@ static void bm_mesh_edges_sharp_tag(BMesh *bm, } } else if (do_sharp_edges_tag) { - /* Note that we do not care about the other sharp-edge cases (sharp poly, non-manifold edge, etc.), + /* Note that we do not care about the other sharp-edge cases + * (sharp poly, non-manifold edge, etc.), * only tag edge as sharp when it is due to angle threashold. */ BM_elem_flag_disable(e, BM_ELEM_SMOOTH); } @@ -626,7 +629,8 @@ static void bm_mesh_edges_sharp_tag(BMesh *bm, /** * Check whether given loop is part of an unknown-so-far cyclic smooth fan, or not. - * Needed because cyclic smooth fans have no obvious 'entry point', and yet we need to walk them once, and only once. + * Needed because cyclic smooth fans have no obvious 'entry point', + * and yet we need to walk them once, and only once. */ bool BM_loop_check_cyclic_smooth_fan(BMLoop *l_curr) { @@ -647,8 +651,9 @@ bool BM_loop_check_cyclic_smooth_fan(BMLoop *l_curr) /* Smooth loop/edge... */ else if (BM_elem_flag_test(lfan_pivot_next, BM_ELEM_TAG)) { if (lfan_pivot_next == l_curr) { - /* We walked around a whole cyclic smooth fan without finding any already-processed loop, means we can - * use initial l_curr/l_prev edge as start for this smooth fan. */ + /* We walked around a whole cyclic smooth fan + * without finding any already-processed loop, + * means we can use initial l_curr/l_prev edge as start for this smooth fan. */ return true; } /* ... already checked in some previous looping, we can abort. */ @@ -661,8 +666,11 @@ bool BM_loop_check_cyclic_smooth_fan(BMLoop *l_curr) } } -/* BMesh version of BKE_mesh_normals_loop_split() in mesh_evaluate.c - * Will use first clnors_data array, and fallback to cd_loop_clnors_offset (use NULL and -1 to not use clnors). */ +/** + * BMesh version of BKE_mesh_normals_loop_split() in mesh_evaluate.c + * Will use first clnors_data array, and fallback to cd_loop_clnors_offset + * (use NULL and -1 to not use clnors). + */ static void bm_mesh_loops_calc_normals(BMesh *bm, const float (*vcos)[3], const float (*fnos)[3], @@ -718,7 +726,8 @@ static void bm_mesh_loops_calc_normals(BMesh *bm, } bm->elem_index_dirty &= ~(BM_FACE | BM_LOOP); - /* We now know edges that can be smoothed (they are tagged), and edges that will be hard (they aren't). + /* We now know edges that can be smoothed (they are tagged), + * and edges that will be hard (they aren't). * Now, time to generate the normals. */ BM_ITER_MESH (f_curr, &fiter, bm, BM_FACES_OF_MESH) { @@ -731,12 +740,15 @@ static void bm_mesh_loops_calc_normals(BMesh *bm, continue; } /* A smooth edge, we have to check for cyclic smooth fan case. - * If we find a new, never-processed cyclic smooth fan, we can do it now using that loop/edge as - * 'entry point', otherwise we can skip it. */ - /* Note: In theory, we could make bm_mesh_loop_check_cyclic_smooth_fan() store mlfan_pivot's in a stack, - * to avoid having to fan again around the vert during actual computation of clnor & clnorspace. - * However, this would complicate the code, add more memory usage, and BM_vert_step_fan_loop() - * is quite cheap in term of CPU cycles, so really think it's not worth it. */ + * If we find a new, never-processed cyclic smooth fan, we can do it now using that loop/edge + * as 'entry point', otherwise we can skip it. */ + + /* Note: In theory, we could make bm_mesh_loop_check_cyclic_smooth_fan() store + * mlfan_pivot's in a stack, to avoid having to fan again around + * the vert during actual computation of clnor & clnorspace. However, this would complicate + * the code, add more memory usage, and + * BM_vert_step_fan_loop() is quite cheap in term of CPU cycles, + * so really think it's not worth it. */ if (BM_elem_flag_test(l_curr->e, BM_ELEM_TAG) && (BM_elem_flag_test(l_curr, BM_ELEM_TAG) || !BM_loop_check_cyclic_smooth_fan(l_curr))) { } @@ -769,7 +781,8 @@ static void bm_mesh_loops_calc_normals(BMesh *bm, } BKE_lnor_space_define(lnor_space, r_lnos[l_curr_index], vec_curr, vec_prev, NULL); - /* We know there is only one loop in this space, no need to create a linklist in this case... */ + /* We know there is only one loop in this space, + * no need to create a linklist in this case... */ BKE_lnor_space_add_loop(r_lnors_spacearr, lnor_space, l_curr_index, l_curr, true); if (has_clnors) { @@ -780,20 +793,22 @@ static void bm_mesh_loops_calc_normals(BMesh *bm, } } /* We *do not need* to check/tag loops as already computed! - * Due to the fact a loop only links to one of its two edges, a same fan *will never be walked more than - * once!* - * Since we consider edges having neighbor faces with inverted (flipped) normals as sharp, we are sure that - * no fan will be skipped, even only considering the case (sharp curr_edge, smooth prev_edge), and not the - * alternative (smooth curr_edge, sharp prev_edge). + * Due to the fact a loop only links to one of its two edges, + * a same fan *will never be walked more than once!* + * Since we consider edges having neighbor faces with inverted (flipped) normals as sharp, + * we are sure that no fan will be skipped, even only considering the case + * (sharp curr_edge, smooth prev_edge), and not the alternative + * (smooth curr_edge, sharp prev_edge). * All this due/thanks to link between normals and loop ordering. */ else { /* We have to fan around current vertex, until we find the other non-smooth edge, * and accumulate face normals into the vertex! - * Note in case this vertex has only one sharp edge, this is a waste because the normal is the same as - * the vertex normal, but I do not see any easy way to detect that (would need to count number - * of sharp edges per vertex, I doubt the additional memory usage would be worth it, especially as - * it should not be a common case in real-life meshes anyway). + * Note in case this vertex has only one sharp edge, + * this is a waste because the normal is the same as the vertex normal, + * but I do not see any easy way to detect that (would need to count number of sharp edges + * per vertex, I doubt the additional memory usage would be worth it, especially as it + * should not be a common case in real-life meshes anyway). */ BMVert *v_pivot = l_curr->v; BMEdge *e_next; @@ -820,7 +835,8 @@ static void bm_mesh_loops_calc_normals(BMesh *bm, lfan_pivot_index = BM_elem_index_get(lfan_pivot); e_next = lfan_pivot->e; /* Current edge here, actually! */ - /* Only need to compute previous edge's vector once, then we can just reuse old current one! */ + /* Only need to compute previous edge's vector once, + * then we can just reuse old current one! */ { const BMVert *v_2 = BM_edge_other_vert(e_next, v_pivot); const float *co_2 = vcos ? vcos[BM_elem_index_get(v_2)] : v_2->co; @@ -846,9 +862,10 @@ static void bm_mesh_loops_calc_normals(BMesh *bm, } /* Compute edge vector. - * NOTE: We could pre-compute those into an array, in the first iteration, instead of computing them - * twice (or more) here. However, time gained is not worth memory and time lost, - * given the fact that this code should not be called that much in real-life meshes... + * NOTE: We could pre-compute those into an array, in the first iteration, + * instead of computing them twice (or more) here. + * However, time gained is not worth memory and time lost, + * given the fact that this code should not be called that much in real-life meshes. */ { const BMVert *v_2 = BM_edge_other_vert(e_next, v_pivot); @@ -970,7 +987,8 @@ static void bm_mesh_loops_calc_normals(BMesh *bm, } } - /* Tag related vertex as sharp, to avoid fanning around it again (in case it was a smooth one). */ + /* Tag related vertex as sharp, to avoid fanning around it again + * (in case it was a smooth one). */ if (r_lnors_spacearr) { BM_elem_flag_enable(l_curr->v, BM_ELEM_TAG); } @@ -1023,8 +1041,8 @@ static void bm_mesh_loops_calc_normals_no_autosmooth(BMesh *bm, /** * \brief BMesh Compute Loop Normals * - * Updates the loop normals of a mesh. Assumes vertex and face normals are valid (else call BM_mesh_normals_update() - * first)! + * Updates the loop normals of a mesh. + * Assumes vertex and face normals are valid (else call BM_mesh_normals_update() first)! */ void BM_mesh_loop_normals_update(BMesh *bm, const bool use_split_normals, @@ -1041,7 +1059,8 @@ void BM_mesh_loop_normals_update(BMesh *bm, * When using custom loop normals, disable the angle feature! */ bm_mesh_edges_sharp_tag(bm, NULL, NULL, has_clnors ? (float)M_PI : split_angle, r_lnos); - /* Finish computing lnos by accumulating face normals in each fan of faces defined by sharp edges. */ + /* Finish computing lnos by accumulating face normals + * in each fan of faces defined by sharp edges. */ bm_mesh_loops_calc_normals( bm, NULL, NULL, r_lnos, r_lnors_spacearr, clnors_data, cd_loop_clnors_offset); } @@ -1056,7 +1075,8 @@ void BM_mesh_loop_normals_update(BMesh *bm, * \brief BMesh Compute Loop Normals from/to external data. * * Compute split normals, i.e. vertex normals associated with each poly (hence 'loop normals'). - * Useful to materialize sharp edges (or non-smooth faces) without actually modifying the geometry (splitting edges). + * Useful to materialize sharp edges (or non-smooth faces) without actually modifying the geometry + * (splitting edges). */ void BM_loops_calc_normal_vcos(BMesh *bm, const float (*vcos)[3], @@ -1077,7 +1097,8 @@ void BM_loops_calc_normal_vcos(BMesh *bm, * When using custom loop normals, disable the angle feature! */ bm_mesh_edges_sharp_tag(bm, vnos, fnos, r_lnos, has_clnors ? (float)M_PI : split_angle, false); - /* Finish computing lnos by accumulating face normals in each fan of faces defined by sharp edges. */ + /* Finish computing lnos by accumulating face normals + * in each fan of faces defined by sharp edges. */ bm_mesh_loops_calc_normals( bm, vcos, fnos, r_lnos, r_lnors_spacearr, clnors_data, cd_loop_clnors_offset, do_rebuild); } @@ -1089,7 +1110,8 @@ void BM_loops_calc_normal_vcos(BMesh *bm, /** Define sharp edges as needed to mimic 'autosmooth' from angle threshold. * - * Used when defining an empty custom loop normals data layer, to keep same shading as with autosmooth! + * Used when defining an empty custom loop normals data layer, + * to keep same shading as with autosmooth! */ void BM_edges_sharp_from_angle_set(BMesh *bm, const float split_angle) { @@ -1144,7 +1166,8 @@ void BM_lnorspace_invalidate(BMesh *bm, const bool do_invalidate_all) BMVert *v; BMLoop *l; BMIter viter, liter; - /* Note: we could use temp tag of BMItem for that, but probably better not use it in such a low-level func? + /* Note: we could use temp tag of BMItem for that, + * but probably better not use it in such a low-level func? * --mont29 */ BLI_bitmap *done_verts = BLI_BITMAP_NEW(bm->totvert, __func__); @@ -1414,13 +1437,15 @@ static int bm_loop_normal_mark_indiv(BMesh *bm, BLI_bitmap *loops) if (use_sel_face_history) { /* Using face history allows to select a single loop from a single face... - * Note that this is On² piece of code, but it is not designed to be used with huge selection sets, + * Note that this is On² piece of code, + * but it is not designed to be used with huge selection sets, * rather with only a few items selected at most.*/ printf("using face history selection\n"); /* Goes from last selected to the first selected element. */ for (ese = bm->selected.last; ese; ese = ese->prev) { if (ese->htype == BM_FACE) { - /* If current face is selected, then any verts to be edited must have been selected before it. */ + /* If current face is selected, + * then any verts to be edited must have been selected before it. */ for (ese_prev = ese->prev; ese_prev; ese_prev = ese_prev->prev) { if (ese_prev->htype == BM_VERT) { bm_loop_normal_mark_indiv_do_loop( @@ -2078,11 +2103,13 @@ int BM_mesh_elem_count(BMesh *bm, const char htype) * * A NULL array means no changes. * - * Note: - Does not mess with indices, just sets elem_index_dirty flag. - * - For verts/edges/faces only (as loops must remain "ordered" and "aligned" - * on a per-face basis...). + * \note + * - Does not mess with indices, just sets elem_index_dirty flag. + * - For verts/edges/faces only (as loops must remain "ordered" and "aligned" + * on a per-face basis...). * - * WARNING: Be careful if you keep pointers to affected BM elements, or arrays, when using this func! + * \warning Be careful if you keep pointers to affected BM elements, + * or arrays, when using this func! */ void BM_mesh_remap(BMesh *bm, const uint *vert_idx, const uint *edge_idx, const uint *face_idx) { @@ -2134,7 +2161,10 @@ void BM_mesh_remap(BMesh *bm, const uint *vert_idx, const uint *edge_idx, const for (i = totvert; i--; new_idx--, ve--, vep--) { BMVert *new_vep = verts_pool[*new_idx]; *new_vep = *ve; - /* printf("mapping vert from %d to %d (%p/%p to %p)\n", i, *new_idx, *vep, verts_pool[i], new_vep);*/ +#if 0 + printf( + "mapping vert from %d to %d (%p/%p to %p)\n", i, *new_idx, *vep, verts_pool[i], new_vep); +#endif BLI_ghash_insert(vptr_map, *vep, new_vep); if (cd_vert_pyptr != -1) { void **pyptr = BM_ELEM_CD_GET_VOID_P(((BMElem *)new_vep), cd_vert_pyptr); @@ -2183,7 +2213,10 @@ void BM_mesh_remap(BMesh *bm, const uint *vert_idx, const uint *edge_idx, const BMEdge *new_edp = edges_pool[*new_idx]; *new_edp = *ed; BLI_ghash_insert(eptr_map, *edp, new_edp); - /* printf("mapping edge from %d to %d (%p/%p to %p)\n", i, *new_idx, *edp, edges_pool[i], new_edp);*/ +#if 0 + printf( + "mapping edge from %d to %d (%p/%p to %p)\n", i, *new_idx, *edp, edges_pool[i], new_edp); +#endif if (cd_edge_pyptr != -1) { void **pyptr = BM_ELEM_CD_GET_VOID_P(((BMElem *)new_edp), cd_edge_pyptr); *pyptr = pyptrs[*new_idx]; @@ -2258,27 +2291,28 @@ void BM_mesh_remap(BMesh *bm, const uint *vert_idx, const uint *edge_idx, const } } - /* Edges' pointers, only vert pointers (as we don't mess with loops!), and - ack! - edge pointers, + /* Edges' pointers, only vert pointers (as we don't mess with loops!), + * and - ack! - edge pointers, * as we have to handle disklinks... */ if (vptr_map || eptr_map) { BM_ITER_MESH (ed, &iter, bm, BM_EDGES_OF_MESH) { if (vptr_map) { - /* printf("Edge v1: %p -> %p\n", ed->v1, BLI_ghash_lookup(vptr_map, ed->v1));*/ - /* printf("Edge v2: %p -> %p\n", ed->v2, BLI_ghash_lookup(vptr_map, ed->v2));*/ + /* printf("Edge v1: %p -> %p\n", ed->v1, BLI_ghash_lookup(vptr_map, ed->v1));*/ + /* printf("Edge v2: %p -> %p\n", ed->v2, BLI_ghash_lookup(vptr_map, ed->v2));*/ ed->v1 = BLI_ghash_lookup(vptr_map, ed->v1); ed->v2 = BLI_ghash_lookup(vptr_map, ed->v2); BLI_assert(ed->v1); BLI_assert(ed->v2); } if (eptr_map) { - /* printf("Edge v1_disk_link prev: %p -> %p\n", ed->v1_disk_link.prev,*/ - /* BLI_ghash_lookup(eptr_map, ed->v1_disk_link.prev));*/ - /* printf("Edge v1_disk_link next: %p -> %p\n", ed->v1_disk_link.next,*/ - /* BLI_ghash_lookup(eptr_map, ed->v1_disk_link.next));*/ - /* printf("Edge v2_disk_link prev: %p -> %p\n", ed->v2_disk_link.prev,*/ - /* BLI_ghash_lookup(eptr_map, ed->v2_disk_link.prev));*/ - /* printf("Edge v2_disk_link next: %p -> %p\n", ed->v2_disk_link.next,*/ - /* BLI_ghash_lookup(eptr_map, ed->v2_disk_link.next));*/ + /* printf("Edge v1_disk_link prev: %p -> %p\n", ed->v1_disk_link.prev,*/ + /* BLI_ghash_lookup(eptr_map, ed->v1_disk_link.prev));*/ + /* printf("Edge v1_disk_link next: %p -> %p\n", ed->v1_disk_link.next,*/ + /* BLI_ghash_lookup(eptr_map, ed->v1_disk_link.next));*/ + /* printf("Edge v2_disk_link prev: %p -> %p\n", ed->v2_disk_link.prev,*/ + /* BLI_ghash_lookup(eptr_map, ed->v2_disk_link.prev));*/ + /* printf("Edge v2_disk_link next: %p -> %p\n", ed->v2_disk_link.next,*/ + /* BLI_ghash_lookup(eptr_map, ed->v2_disk_link.next));*/ ed->v1_disk_link.prev = BLI_ghash_lookup(eptr_map, ed->v1_disk_link.prev); ed->v1_disk_link.next = BLI_ghash_lookup(eptr_map, ed->v1_disk_link.next); ed->v2_disk_link.prev = BLI_ghash_lookup(eptr_map, ed->v2_disk_link.prev); @@ -2571,7 +2605,8 @@ void BM_mesh_rebuild(BMesh *bm, #undef REMAP_EDGE /* Cleanup, re-use local tables if the current mesh had tables allocated. - * could use irrespective but it may use more memory then the caller wants (and not be needed). */ + * could use irrespective but it may use more memory then the caller wants + * (and not be needed). */ if (remap & BM_VERT) { if (bm->vtable) { SWAP(BMVert **, vtable_dst, bm->vtable); diff --git a/source/blender/bmesh/intern/bmesh_mesh_conv.c b/source/blender/bmesh/intern/bmesh_mesh_conv.c index f2db451888a..0ea33049458 100644 --- a/source/blender/bmesh/intern/bmesh_mesh_conv.c +++ b/source/blender/bmesh/intern/bmesh_mesh_conv.c @@ -33,33 +33,41 @@ * * - Editmode operations when a shape key-block is active edits only that key-block. * - The first Basis key-block always matches the Mesh verts. - * - Changing vertex locations of _any_ Basis will apply offsets to those shape keys using this as their Basis. + * - Changing vertex locations of _any_ Basis + * will apply offsets to those shape keys using this as their Basis. + * * \subsection enter_editmode Entering EditMode - #BM_mesh_bm_from_me * - * - the active key-block is used for BMesh vertex locations on entering edit-mode. - * So obviously the meshes vertex locations remain unchanged and the shape key its self is not being edited directly. - * Simply the #BMVert.co is a initialized from active shape key (when its set). - * - all key-blocks are added as CustomData layers (read code for details). + * - The active key-block is used for BMesh vertex locations on entering edit-mode. + * So obviously the meshes vertex locations remain unchanged and the shape key + * its self is not being edited directly. + * Simply the #BMVert.co is a initialized from active shape key (when its set). + * - All key-blocks are added as CustomData layers (read code for details). + * * \subsection exit_editmode Exiting EditMode - #BM_mesh_bm_to_me * - * This is where the most confusing code is! Won't attempt to document the details here, for that read the code. + * This is where the most confusing code is! Won't attempt to document the details here, + * for that read the code. * But basics are as follows. * - * - Vertex locations (possibly modified from initial active key-block) are copied directly into #MVert.co - * (special confusing note that these may be restored later, when editing the 'Basis', read on). - * - if the 'Key' is relative, and the active key-block is the basis for ANY other key-blocks - get an array of offsets - * between the new vertex locations and the original shape key (before entering edit-mode), - * these offsets get applied later on to inactive key-blocks using the active one (which we are editing) as their Basis. + * - Vertex locations (possibly modified from initial active key-block) + * are copied directly into #MVert.co + * (special confusing note that these may be restored later, when editing the 'Basis', read on). + * - if the 'Key' is relative, and the active key-block is the basis for ANY other key-blocks - + * get an array of offsets between the new vertex locations and the original shape key + * (before entering edit-mode), these offsets get applied later on to inactive key-blocks + * using the active one (which we are editing) as their Basis. * * Copying the locations back to the shape keys is quite confusing... * One main area of confusion is that when editing a 'Basis' key-block 'me->key->refkey' - * The coords are written into the mesh, from the users perspective the Basis coords are written into the mesh - * when exiting edit-mode. + * The coords are written into the mesh, from the users perspective the Basis coords are written + * into the mesh when exiting edit-mode. * - * When _not_ editing the 'Basis', the original vertex locations (stored in the mesh and unchanged during edit-mode), - * are copied back into the mesh. + * When _not_ editing the 'Basis', the original vertex locations + * (stored in the mesh and unchanged during edit-mode), are copied back into the mesh. * - * This has the effect from the users POV of leaving the mesh un-touched, and only editing the active shape key-block. + * This has the effect from the users POV of leaving the mesh un-touched, + * and only editing the active shape key-block. */ #include "DNA_mesh_types.h" @@ -490,7 +498,8 @@ static BMVert **bm_to_mesh_vertex_map(BMesh *bm, int ototvert) const int keyi = BM_ELEM_CD_GET_INT(eve, cd_shape_keyindex_offset); if ((keyi != ORIGINDEX_NONE) && (keyi < ototvert) && /* not fool-proof, but chances are if we have many verts with the same index, - * we will want to use the first one, since the second is more likely to be a duplicate. */ + * we will want to use the first one, + * since the second is more likely to be a duplicate. */ (vertMap[keyi] == NULL)) { vertMap[keyi] = eve; } @@ -944,8 +953,9 @@ void BM_mesh_bm_to_me(Main *bmain, BMesh *bm, Mesh *me, const struct BMeshToMesh if (apply_offset) { add_v3_v3(fp, *ofs_pt++); /* Apply back new coordinates of offsetted shapekeys into BMesh. - * Otherwise, in case we call again BM_mesh_bm_to_me on same BMesh, we'll apply diff from previous - * call to BM_mesh_bm_to_me, to shapekey values from *original creation of the BMesh*. See T50524. */ + * Otherwise, in case we call again BM_mesh_bm_to_me on same BMesh, + * we'll apply diff from previous call to BM_mesh_bm_to_me, + * to shapekey values from *original creation of the BMesh*. See T50524. */ copy_v3_v3(BM_ELEM_CD_GET_VOID_P(eve, cd_shape_offset), fp); } @@ -977,8 +987,10 @@ void BM_mesh_bm_to_me(Main *bmain, BMesh *bm, Mesh *me, const struct BMeshToMesh } /** - * A version of #BM_mesh_bm_to_me intended for getting the mesh to pass to the modifier stack for evaluation, - * instad of mode switching (where we make sure all data is kept and do expensive lookups to maintain shape keys). + * A version of #BM_mesh_bm_to_me intended for getting the mesh + * to pass to the modifier stack for evaluation, + * instad of mode switching (where we make sure all data is kept + * and do expensive lookups to maintain shape keys). * * Key differences: * diff --git a/source/blender/bmesh/intern/bmesh_mesh_validate.c b/source/blender/bmesh/intern/bmesh_mesh_validate.c index 3b6f63df089..83ab29940f3 100644 --- a/source/blender/bmesh/intern/bmesh_mesh_validate.c +++ b/source/blender/bmesh/intern/bmesh_mesh_validate.c @@ -51,7 +51,8 @@ # endif /** - * Check of this BMesh is valid, this function can be slow since its intended to help with debugging. + * Check of this BMesh is valid, + * this function can be slow since its intended to help with debugging. * * \return true when the mesh is valid. */ diff --git a/source/blender/bmesh/intern/bmesh_mods.c b/source/blender/bmesh/intern/bmesh_mods.c index 8728186ef33..888393de47a 100644 --- a/source/blender/bmesh/intern/bmesh_mods.c +++ b/source/blender/bmesh/intern/bmesh_mods.c @@ -322,13 +322,14 @@ BMFace *BM_face_split(BMesh *bm, * * Like BM_face_split, but with an edge split by \a n intermediate points with given coordinates. * - * \param bm: The bmesh - * \param f: the original face - * \param l_a, l_b: Vertices which define the split edge, must be different - * \param cos: Array of coordinates for intermediate points - * \param n: Length of \a cos (must be > 0) - * \param r_l: pointer which will receive the BMLoop for the first split edge (from \a l_a) in the new face - * \param example: Edge used for attributes of splitting edge, if non-NULL + * \param bm: The bmesh. + * \param f: the original face. + * \param l_a, l_b: Vertices which define the split edge, must be different. + * \param cos: Array of coordinates for intermediate points. + * \param n: Length of \a cos (must be > 0). + * \param r_l: pointer which will receive the BMLoop. + * for the first split edge (from \a l_a) in the new face. + * \param example: Edge used for attributes of splitting edge, if non-NULL. * * \return Pointer to the newly created face representing one side of the split * if the split is successful (and the original original face will be the @@ -370,7 +371,8 @@ BMFace *BM_face_split_n(BMesh *bm, #else f_new = bmesh_kernel_split_face_make_edge(bm, f, l_a, l_b, &l_new, example, false); #endif - /* bmesh_kernel_split_face_make_edge returns in 'l_new' a Loop for f_new going from 'v_a' to 'v_b'. + /* bmesh_kernel_split_face_make_edge returns in 'l_new' + * a Loop for f_new going from 'v_a' to 'v_b'. * The radial_next is for 'f' and goes from 'v_b' to 'v_a' */ if (f_new) { @@ -378,7 +380,8 @@ BMFace *BM_face_split_n(BMesh *bm, for (i = 0; i < n; i++) { v_new = bmesh_kernel_split_edge_make_vert(bm, v_b, e, &e_new); BLI_assert(v_new != NULL); - /* bmesh_kernel_split_edge_make_vert returns in 'e_new' the edge going from 'v_new' to 'v_b' */ + /* bmesh_kernel_split_edge_make_vert returns in 'e_new' + * the edge going from 'v_new' to 'v_b'. */ copy_v3_v3(v_new->co, cos[i]); /* interpolate the loop data for the loops with (v == v_new), using orig face */ diff --git a/source/blender/bmesh/intern/bmesh_polygon.c b/source/blender/bmesh/intern/bmesh_polygon.c index 1a0e167b93d..42e8d58567a 100644 --- a/source/blender/bmesh/intern/bmesh_polygon.c +++ b/source/blender/bmesh/intern/bmesh_polygon.c @@ -121,7 +121,8 @@ static void bm_face_calc_poly_center_median_vertex_cos(const BMFace *f, /** * For tools that insist on using triangles, ideally we would cache this data. * - * \param use_fixed_quad: When true, always split quad along (0 -> 2) regardless of concave corners, + * \param use_fixed_quad: When true, + * always split quad along (0 -> 2) regardless of concave corners, * (as done in #BM_mesh_calc_tessellation). * \param r_loops: Store face loop pointers, (f->len) * \param r_index: Store triangle triples, indices into \a r_loops, `((f->len - 2) * 3)` @@ -963,8 +964,8 @@ bool BM_face_point_inside_test(const BMFace *f, const float co[3]) * with a length equal to (f->len - 3). It will be filled with the new * triangles (not including the original triangle). * - * \param r_faces_double: When newly created faces are duplicates of existing faces, they're added to this list. - * Caller must handle de-duplication. + * \param r_faces_double: When newly created faces are duplicates of existing faces, + * they're added to this list. Caller must handle de-duplication. * This is done because its possible _all_ faces exist already, * and in that case we would have to remove all faces including the one passed, * which causes complications adding/removing faces while looking over them. @@ -1156,8 +1157,8 @@ void BM_face_triangulate(BMesh *bm, l_iter = l_first = l_new; do { BMEdge *e = l_iter->e; - /* confusing! if its not a boundary now, we know it will be later - * since this will be an edge of one of the new faces which we're in the middle of creating */ + /* Confusing! if its not a boundary now, we know it will be later since this will be an + * edge of one of the new faces which we're in the middle of creating. */ bool is_new_edge = (l_iter == l_iter->radial_next); if (is_new_edge) { diff --git a/source/blender/bmesh/intern/bmesh_polygon_edgenet.c b/source/blender/bmesh/intern/bmesh_polygon_edgenet.c index e2b117536f3..14b73693b03 100644 --- a/source/blender/bmesh/intern/bmesh_polygon_edgenet.c +++ b/source/blender/bmesh/intern/bmesh_polygon_edgenet.c @@ -987,8 +987,10 @@ static int bm_face_split_edgenet_find_connection(const struct EdgeGroup_FindConn * Method for finding connection is as follows: * * - Cast a ray along either the positive or negative directions. - * - Take the hit-edge, and cast rays to their vertices checking those rays don't intersect a closer edge. - * - Keep taking the hit-edge and testing its verts until a vertex is found which isn't blocked by an edge. + * - Take the hit-edge, and cast rays to their vertices + * checking those rays don't intersect a closer edge. + * - Keep taking the hit-edge and testing its verts + * until a vertex is found which isn't blocked by an edge. * * \note It's possible none of the verts can be accessed (with self-intersecting lines). * In that case theres no right answer (without subdividing edges), @@ -1146,7 +1148,8 @@ static BMVert *bm_face_split_edgenet_partial_connect(BMesh *bm, BMVert *v_delimi } } - /* Detect if this is a delimiter by checking if we didn't walk any of edges connected to 'v_delimit' */ + /* Detect if this is a delimiter + * by checking if we didn't walk any of edges connected to 'v_delimit'. */ bool is_delimit = false; FOREACH_VERT_EDGE(v_delimit, e_iter, { BMVert *v_step = BM_edge_other_vert(e_iter, v_delimit); @@ -1500,7 +1503,8 @@ bool BM_face_split_edgenet_connect_islands(BMesh *bm, /* Now create bvh tree * - * Note that a large epsilon is used because meshes with dimensions of around 100+ need it. see T52329. */ + * Note that a large epsilon is used because meshes with dimensions of around 100+ need it. + * see T52329. */ BVHTree *bvhtree = BLI_bvhtree_new(edge_arr_len, 1e-4f, 8, 8); for (uint i = 0; i < edge_arr_len; i++) { const float e_cos[2][3] = { diff --git a/source/blender/bmesh/intern/bmesh_query.c b/source/blender/bmesh/intern/bmesh_query.c index d7266121874..a2f95a013a2 100644 --- a/source/blender/bmesh/intern/bmesh_query.c +++ b/source/blender/bmesh/intern/bmesh_query.c @@ -311,9 +311,11 @@ float BM_loop_point_side_of_edge_test(const BMLoop *l, const float co[3]) } /** - * Given 2 verts, find a face they share that has the lowest angle across these verts and give back both loops. + * Given 2 verts, + * find a face they share that has the lowest angle across these verts and give back both loops. * - * This can be better then #BM_vert_pair_share_face_by_len because concave splits are ranked lowest. + * This can be better then #BM_vert_pair_share_face_by_len + * because concave splits are ranked lowest. */ BMFace *BM_vert_pair_share_face_by_angle( BMVert *v_a, BMVert *v_b, BMLoop **r_l_a, BMLoop **r_l_b, const bool allow_adjacent) @@ -1410,7 +1412,8 @@ BMLoop *BM_face_edge_share_loop(BMFace *f, BMEdge *e) * BM_face_create_ngon() on an arbitrary array of verts, * though be sure to pick an edge which has a face. * - * \note This is in fact quite a simple check, mainly include this function so the intent is more obvious. + * \note This is in fact quite a simple check, + * mainly include this function so the intent is more obvious. * We know these 2 verts will _always_ make up the loops edge */ void BM_edge_ordered_verts_ex(const BMEdge *edge, @@ -1507,10 +1510,13 @@ float BM_loop_calc_face_angle(const BMLoop *l) */ float BM_loop_calc_face_normal_safe_ex(const BMLoop *l, const float epsilon_sq, float r_normal[3]) { - /* Note: we cannot use result of normal_tri_v3 here to detect colinear vectors (vertex on a straight line) - * from zero value, because it does not normalize both vectors before making crossproduct. - * Instead of adding two costly normalize computations, just check ourselves for colinear case. */ - /* Note: FEPSILON might need some finer tweaking at some point? Seems to be working OK for now though. */ + /* Note: we cannot use result of normal_tri_v3 here to detect colinear vectors + * (vertex on a straight line) from zero value, + * because it does not normalize both vectors before making crossproduct. + * Instead of adding two costly normalize computations, + * just check ourselves for colinear case. */ + /* Note: FEPSILON might need some finer tweaking at some point? + * Seems to be working OK for now though. */ float v1[3], v2[3], v_tmp[3]; sub_v3_v3v3(v1, l->prev->v->co, l->v->co); sub_v3_v3v3(v2, l->next->v->co, l->v->co); diff --git a/source/blender/bmesh/intern/bmesh_walkers_impl.c b/source/blender/bmesh/intern/bmesh_walkers_impl.c index 0097e0a3056..5790f7fe69c 100644 --- a/source/blender/bmesh/intern/bmesh_walkers_impl.c +++ b/source/blender/bmesh/intern/bmesh_walkers_impl.c @@ -989,8 +989,9 @@ static void *bmw_EdgeLoopWalker_step(BMWalker *walker) vert_edge_tot = BM_vert_edge_count_nonwire(v); - /* typical loopiong over edges in the middle of a mesh */ - /* however, why use 2 here at all? I guess for internal ngon loops it can be useful. Antony R. */ + /* Typical loopiong over edges in the middle of a mesh */ + /* However, why use 2 here at all? + * I guess for internal ngon loops it can be useful. Antony R. */ if (vert_edge_tot == 4 || vert_edge_tot == 2) { int i_opposite = vert_edge_tot / 2; int i = 0; |