From b05651199b87f74bc3ce7bb9ee761c8ecfe3aab8 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Fri, 7 Feb 2020 13:32:02 -0500 Subject: Code Quality Day: Comment formatting in bmesh_bevel.c --- source/blender/bmesh/tools/bmesh_bevel.c | 933 ++++++++++++++++--------------- 1 file changed, 485 insertions(+), 448 deletions(-) (limited to 'source/blender/bmesh/tools') diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c index d3b3541a539..d8c2057bb56 100644 --- a/source/blender/bmesh/tools/bmesh_bevel.c +++ b/source/blender/bmesh/tools/bmesh_bevel.c @@ -66,7 +66,7 @@ /* for testing */ // #pragma GCC diagnostic error "-Wpadded" -/* Constructed vertex, sometimes later instantiated as BMVert */ +/* Constructed vertex, sometimes later instantiated as BMVert. */ typedef struct NewVert { BMVert *v; float co[3]; @@ -75,31 +75,31 @@ typedef struct NewVert { struct BoundVert; -/* Data for one end of an edge involved in a bevel */ +/* Data for one end of an edge involved in a bevel. */ typedef struct EdgeHalf { /** Other EdgeHalves connected to the same BevVert, in CCW order. */ struct EdgeHalf *next, *prev; - /** Original mesh edge */ + /** Original mesh edge. */ BMEdge *e; - /** Face between this edge and previous, if any */ + /** Face between this edge and previous, if any. */ BMFace *fprev; - /** Face between this edge and next, if any */ + /** Face between this edge and next, if any. */ BMFace *fnext; - /** Left boundary vert (looking along edge to end) */ + /** Left boundary vert (looking along edge to end). */ struct BoundVert *leftv; - /** Right boundary vert, if beveled */ + /** Right boundary vert, if beveled. */ struct BoundVert *rightv; - /** Offset into profile to attach non-beveled edge */ + /** Offset into profile to attach non-beveled edge. */ int profile_index; - /** How many segments for the bevel */ + /** How many segments for the bevel. */ int seg; - /** Offset for this edge, on left side */ + /** Offset for this edge, on left side. */ float offset_l; - /** Offset for this edge, on right side */ + /** Offset for this edge, on right side. */ float offset_r; - /** User specification for offset_l */ + /** User specification for offset_l. */ float offset_l_spec; - /** User specification for offset_r */ + /** User specification for offset_r. */ float offset_r_spec; /** Is this edge beveled? */ bool is_bev; @@ -107,44 +107,45 @@ typedef struct EdgeHalf { bool is_rev; /** Is e a seam for custom loopdata (e.g., UVs)? */ bool is_seam; - /** Used during the custom profile orientation pass */ + /** Used during the custom profile orientation pass. */ bool visited_rpo; char _pad[4]; } EdgeHalf; -/* Profile specification: +/** + * Profile specification: + * The profile is a path defined with start, middle, and end control points projected onto a + * plane (plane_no is normal, plane_co is a point on it) via lines in a given direction (proj_dir). + * * Many interesting profiles are in family of superellipses: * (abs(x/a))^r + abs(y/b))^r = 1 * r==2 => ellipse; r==1 => line; r < 1 => concave; r > 1 => bulging out. * Special cases: let r==0 mean straight-inward, and r==4 mean straight outward. - * The profile is a path defined with start, middle, and end control points - * projected onto a plane (plane_no is normal, plane_co is a point on it) - * via lines in a given direction (proj_dir). - * After the parameters are all set, the actual profile points are calculated - * and pointed to by prof_co. We also may need profile points for a higher resolution - * number of segments for the subdivision while making the ADJ vertex mesh pattern, - * and that goes in prof_co_2. + * + * After the parameters are all set, the actual profile points are calculated and pointed to + * by prof_co. We also may need profile points for a higher resolution number of segments + * for the subdivision while making the ADJ vertex mesh pattern, and that goes in prof_co_2. */ typedef struct Profile { - /** Superellipse r parameter */ + /** Superellipse r parameter. */ float super_r; - /** Height for profile cutoff face sides */ + /** Height for profile cutoff face sides. */ float height; - /** Start control point for profile */ + /** Start control point for profile. */ float start[3]; - /** Mid control point for profile */ + /** Mid control point for profile. */ float middle[3]; - /** End control point for profile */ + /** End control point for profile. */ float end[3]; - /** Normal of plane to project to */ + /** Normal of plane to project to. */ float plane_no[3]; - /** Coordinate on plane to project to */ + /** Coordinate on plane to project to. */ float plane_co[3]; - /** Direction of projection line */ + /** Direction of projection line. */ float proj_dir[3]; - /** seg+1 profile coordinates (triples of floats) */ + /** seg+1 profile coordinates (triples of floats). */ float *prof_co; - /** Like prof_co, but for seg power of 2 >= seg */ + /** Like prof_co, but for seg power of 2 >= seg. */ float *prof_co_2; /** Mark a special case so the these parameters aren't reset with others. */ bool special_params; @@ -155,27 +156,29 @@ typedef struct Profile { #define PRO_SQUARE_IN_R 0.0f /** - * The un-transformed 2D storage of profile vertex locations. Also for non-custom profiles + * The un-transformed 2D storage of profile vertex locations. Also, for non-custom profiles * this serves as a cache for the results of the expensive calculation of u parameter values to - * get even spacing on superellipse for current BevelParams seg - * and pro_super_r. + * get even spacing on superellipse for current BevelParams seg and pro_super_r. */ typedef struct ProfileSpacing { - /** The profile's seg+1 x values */ + /** The profile's seg+1 x values. */ double *xvals; - /** The profile's seg+1 y values */ + /** The profile's seg+1 y values. */ double *yvals; - /** The profile's seg_2+1 x values, (seg_2 = power of 2 >= seg) */ + /** The profile's seg_2+1 x values, (seg_2 = power of 2 >= seg). */ double *xvals_2; - /** The profile's seg_2+1 y values, (seg_2 = power of 2 >= seg) */ + /** The profile's seg_2+1 y values, (seg_2 = power of 2 >= seg). */ double *yvals_2; /** The power of two greater than or equal to the number of segments. */ int seg_2; - /** How far "out" the profile is, used at the start of subdivision */ + /** How far "out" the profile is, used at the start of subdivision. */ float fullness; } ProfileSpacing; -/** An element in a cyclic boundary of a Vertex Mesh (VMesh) */ +/** + * An element in a cyclic boundary of a Vertex Mesh (VMesh), placed on each side of beveled edges + * where each profile starts, or on each side of a miter. + */ typedef struct BoundVert { /** In CCW order. */ struct BoundVert *next, *prev; @@ -197,107 +200,107 @@ typedef struct BoundVert { Profile profile; /** Are any of the edges attached here seams? */ bool any_seam; - /** Used during delta adjust pass */ + /** Used during delta adjust pass. */ bool visited; - /** This boundvert begins an arc profile */ + /** This boundvert begins an arc profile. */ bool is_arc_start; - /** This boundvert begins a patch profile */ + /** This boundvert begins a patch profile. */ bool is_patch_start; - /** Is this boundvert the side of the custom profile's start */ + /** Is this boundvert the side of the custom profile's start. */ bool is_profile_start; char _pad[3]; - /** Length of seam starting from current boundvert to next boundvert with ccw ordering */ + /** Length of seam starting from current boundvert to next boundvert with ccw ordering. */ int seam_len; - /** Same as seam_len but defines length of sharp edges */ + /** Same as seam_len but defines length of sharp edges. */ int sharp_len; } BoundVert; -/** Mesh structure replacing a vertex */ +/** Data for the mesh structure replacing a vertex. */ typedef struct VMesh { - /** Allocated array - size and structure depends on kind */ + /** Allocated array - size and structure depends on kind. */ NewVert *mesh; - /** Start of boundary double-linked list */ + /** Start of boundary double-linked list. */ BoundVert *boundstart; - /** Number of vertices in the boundary */ + /** Number of vertices in the boundary. */ int count; - /** Common number of segments for segmented edges (same as bp->seg) */ + /** Common number of segments for segmented edges (same as bp->seg). */ int seg; - /** The kind of mesh to build at the corner vertex meshes */ + /** The kind of mesh to build at the corner vertex meshes. */ enum { - M_NONE, /* no polygon mesh needed */ - M_POLY, /* a simple polygon */ - M_ADJ, /* "adjacent edges" mesh pattern */ - M_TRI_FAN, /* a simple polygon - fan filled */ - M_CUTOFF, /* A triangulated face at the end of each profile */ + M_NONE, /* No polygon mesh needed. */ + M_POLY, /* A simple polygon. */ + M_ADJ, /* "Adjacent edges" mesh pattern. */ + M_TRI_FAN, /* A simple polygon - fan filled. */ + M_CUTOFF, /* A triangulated face at the end of each profile. */ } mesh_kind; int _pad; } VMesh; -/* Data for a vertex involved in a bevel */ +/* Data for a vertex involved in a bevel. */ typedef struct BevVert { - /** Original mesh vertex */ + /** Original mesh vertex. */ BMVert *v; - /** Total number of edges around the vertex (excluding wire edges if edge beveling) */ + /** Total number of edges around the vertex (excluding wire edges if edge beveling). */ int edgecount; - /** Number of selected edges around the vertex */ + /** Number of selected edges around the vertex. */ int selcount; - /** Count of wire edges */ + /** Count of wire edges. */ int wirecount; - /** Offset for this vertex, if vertex_only bevel */ + /** Offset for this vertex, if vertex_only bevel. */ float offset; /** Any seams on attached edges? */ bool any_seam; - /** Used in graph traversal */ + /** Used in graph traversal for adjusting offsets. */ bool visited; - /** Array of size edgecount; CCW order from vertex normal side */ + /** Array of size edgecount; CCW order from vertex normal side. */ char _pad[6]; EdgeHalf *edges; - /** Array of size wirecount of wire edges */ + /** Array of size wirecount of wire edges. */ BMEdge **wire_edges; - /** Mesh structure for replacing vertex */ + /** Mesh structure for replacing vertex. */ VMesh *vmesh; } BevVert; -/* Face classification. Note: depends on F_RECON > F_EDGE > F_VERT */ +/* Face classification. Note: depends on F_RECON > F_EDGE > F_VERT .*/ typedef enum { - /** Used when there is no face at all */ + /** Used when there is no face at all. */ F_NONE, - /** Original face, not touched */ + /** Original face, not touched. */ F_ORIG, - /** Face for construction around a vert */ + /** Face for construction around a vert. */ F_VERT, - /** Face for a beveled edge */ + /** Face for a beveled edge. */ F_EDGE, - /** Reconstructed original face with some new verts */ + /** Reconstructed original face with some new verts. */ F_RECON, } FKind; /** Helper for keeping track of angle kind. */ enum { - /** Angle less than 180 degrees */ + /** Angle less than 180 degrees. */ ANGLE_SMALLER = -1, - /** 180 degree angle */ + /** 180 degree angle. */ ANGLE_STRAIGHT = 0, - /** Angle greater than 180 degrees */ + /** Angle greater than 180 degrees. */ ANGLE_LARGER = 1, }; -/** Bevel parameters and state */ +/** Bevel parameters and state. */ typedef struct BevelParams { /** Records BevVerts made: key BMVert*, value BevVert* */ GHash *vert_hash; - /** Records new faces: key BMFace*, value one of {VERT/EDGE/RECON}_POLY */ + /** Records new faces: key BMFace*, value one of {VERT/EDGE/RECON}_POLY. */ GHash *face_hash; - /** Use for all allocs while bevel runs, if we need to free we can switch to mempool. */ + /** Use for all allocs while bevel runs. Note: If we need to free we can switch to mempool. */ MemArena *mem_arena; - /** Profile vertex location and spacings */ + /** Profile vertex location and spacings. */ ProfileSpacing pro_spacing; - /** Parameter values for evenly spaced profile points for the miter profiles */ + /** Parameter values for evenly spaced profile points for the miter profiles. */ ProfileSpacing pro_spacing_miter; /** Blender units to offset each side of a beveled edge. */ float offset; - /** How offset is measured; enum defined in bmesh_operators.h */ + /** How offset is measured; enum defined in bmesh_operators.h. */ int offset_type; /** Number of segments in beveled edge profile. */ int seg; @@ -324,7 +327,7 @@ typedef struct BevelParams { /** Should we use the custom profiles feature? */ bool use_custom_profile; char _pad[3]; - /** The struct used to store the custom profile input */ + /** The struct used to store the custom profile input. */ const struct CurveProfile *custom_profile; /** Vertex group array, maybe set if vertex_only. */ const struct MDeformVert *dvert; @@ -348,14 +351,14 @@ typedef struct BevelParams { // #pragma GCC diagnostic ignored "-Wpadded" -/* Only for debugging, shouldn't be in blender repo. */ +/* Only for debugging, this file shouldn't be in blender repo. */ // #include "bevdebug.c" -/* use the unused _BM_ELEM_TAG_ALT flag to flag the 'long' loops (parallel to beveled edge) +/* Use the unused _BM_ELEM_TAG_ALT flag to flag the 'long' loops (parallel to beveled edge) * of edge-polygons. */ #define BM_ELEM_LONG_TAG (1 << 6) -/* these flag values will get set on geom we want to return in 'out' slots for edges and verts */ +/* These flag values will get set on geom we want to return in 'out' slots for edges and verts. */ #define EDGE_OUT 4 #define VERT_OUT 8 @@ -404,7 +407,7 @@ static bool nearly_parallel(const float d1[3], const float d2[3]) return (fabsf(ang) < BEVEL_EPSILON_ANG) || (fabsf(ang - (float)M_PI) < BEVEL_EPSILON_ANG); } -/* Make a new BoundVert of the given kind, insert it at the end of the circular linked +/* Make a new BoundVert of the given kind, inserting it at the end of the circular linked * list with entry point bv->boundstart, and return it. */ static BoundVert *add_new_bound_vert(MemArena *mem_arena, VMesh *vm, const float co[3]) { @@ -445,7 +448,7 @@ BLI_INLINE void adjust_bound_vert(BoundVert *bv, const float co[3]) * i = boundvert index (0 <= i < nv) * j = ring index (0 <= j <= ns2) * k = segment index (0 <= k <= ns) - * Not all of these are used, and some will share BMVerts */ + * Not all of these are used, and some will share BMVerts. */ static NewVert *mesh_vert(VMesh *vm, int i, int j, int k) { int nj = (vm->seg / 2) + 1; @@ -472,7 +475,7 @@ static void copy_mesh_vert(VMesh *vm, int ito, int jto, int kto, int ifrom, int copy_v3_v3(nvto->co, nvfrom->co); } -/* find the EdgeHalf in bv's array that has edge bme */ +/* Find the EdgeHalf in bv's array that has edge bme. */ static EdgeHalf *find_edge_half(BevVert *bv, BMEdge *bme) { int i; @@ -485,15 +488,17 @@ static EdgeHalf *find_edge_half(BevVert *bv, BMEdge *bme) return NULL; } -/* find the BevVert corresponding to BMVert bmv */ +/* Find the BevVert corresponding to BMVert bmv. */ static BevVert *find_bevvert(BevelParams *bp, BMVert *bmv) { return BLI_ghash_lookup(bp->vert_hash, bmv); } -/* Find the EdgeHalf representing the other end of e->e. - * Return other end's BevVert in *bvother, if r_bvother is provided. - * That may not have been constructed yet, in which case return NULL. */ +/** + * Find the EdgeHalf representing the other end of e->e. + * \return Return other end's BevVert in *r_bvother, if r_bvother is provided. That may not have + * been constructed yet, in which case return NULL. + */ static EdgeHalf *find_other_end_edge_half(BevelParams *bp, EdgeHalf *e, BevVert **r_bvother) { BevVert *bvo; @@ -532,7 +537,7 @@ static EdgeHalf *next_bev(BevVert *bv, EdgeHalf *from_e) return NULL; } -/* return count of edges between e1 and e2 when going around bv CCW */ +/* Return the count of edges between e1 and e2 when going around bv CCW. */ static int count_ccw_edges_between(EdgeHalf *e1, EdgeHalf *e2) { int cnt = 0; @@ -564,11 +569,13 @@ static bool edges_face_connected_at_vert(BMEdge *bme1, BMEdge *bme2) return false; } -/* Return a good representative face (for materials, etc.) for faces +/** + * Return a good representative face (for materials, etc.) for faces * created around/near BoundVert v. * Sometimes care about a second choice, if there is one. * If r_fother parameter is non-NULL and there is another, different, - * possible frep, return the other one in that parameter. */ + * possible frep, return the other one in that parameter. + */ static BMFace *boundvert_rep_face(BoundVert *v, BMFace **r_fother) { BMFace *frep, *frep2; @@ -657,7 +664,7 @@ static BMFace *bev_create_ngon(BMesh *bm, i = 0; BM_ITER_ELEM (l, &iter, f, BM_LOOPS_OF_FACE) { if (face_arr) { - /* assume loops of created face are in same order as verts */ + /* Assume loops of created face are in same order as verts. */ BLI_assert(l->v == vert_arr[i]); interp_f = face_arr[i]; } @@ -683,8 +690,8 @@ static BMFace *bev_create_ngon(BMesh *bm, } } - /* not essential for bevels own internal logic, - * this is done so the operator can select newly created geometry */ + /* Not essential for bevels own internal logic, + * this is done so the operator can select newly created geometry. */ if (f) { BM_elem_flag_enable(f, BM_ELEM_TAG); BM_ITER_ELEM (bme, &iter, f, BM_EDGES_OF_FACE) { @@ -832,7 +839,7 @@ static void bev_merge_uvs(BMesh *bm, BMVert *v) } /* Merge (using average) the UV values for two specific loops of v: those for faces containing v, - * and part of faces that share edge bme */ + * and part of faces that share edge bme. */ static void bev_merge_edge_uvs(BMesh *bm, BMEdge *bme, BMVert *v) { BMIter iter; @@ -876,7 +883,7 @@ static void bev_merge_edge_uvs(BMesh *bm, BMEdge *bme, BMVert *v) } } -/* Calculate coordinates of a point a distance d from v on e->e and return it in slideco */ +/* Calculate coordinates of a point a distance d from v on e->e and return it in slideco. */ static void slide_dist(EdgeHalf *e, BMVert *v, float d, float r_slideco[3]) { float dir[3], len; @@ -890,7 +897,7 @@ static void slide_dist(EdgeHalf *e, BMVert *v, float d, float r_slideco[3]) madd_v3_v3fl(r_slideco, dir, -d); } -/* Is co not on the edge e? if not, return the closer end of e in ret_closer_v */ +/* Is co not on the edge e? If not, return the closer end of e in ret_closer_v. */ static bool is_outside_edge(EdgeHalf *e, const float co[3], BMVert **ret_closer_v) { float h[3], u[3], lambda, lenu, *l1 = e->e->v1->co; @@ -912,7 +919,7 @@ static bool is_outside_edge(EdgeHalf *e, const float co[3], BMVert **ret_closer_ } } -/* Return -1, 0, or 1 as angle from e1 to e2 is <. =, or > 180 degrees */ +/* Return whether the angle is less than, equal to, or larger than 180 degrees. */ static int edges_angle_kind(EdgeHalf *e1, EdgeHalf *e2, BMVert *v) { BMVert *v1, *v2; @@ -924,7 +931,7 @@ static int edges_angle_kind(EdgeHalf *e1, EdgeHalf *e2, BMVert *v) sub_v3_v3v3(dir2, v->co, v2->co); normalize_v3(dir1); normalize_v3(dir2); - /* angles are in [0,pi]. need to compare cross product with normal to see if they are reflex */ + /* Angles are in [0,pi]. Need to compare cross product with normal to see if they are reflex. */ cross_v3_v3v3(cross, dir1, dir2); normalize_v3(cross); if (e1->fnext) { @@ -948,9 +955,8 @@ static int edges_angle_kind(EdgeHalf *e1, EdgeHalf *e2, BMVert *v) } } -/* co should be approximately on the plane between e1 and e2, which share common vert v - * and common face f (which cannot be NULL). - * Is it between those edges, sweeping CCW? */ +/* co should be approximately on the plane between e1 and e2, which share common vert v and common + * face f (which cannot be NULL). Is it between those edges, sweeping CCW? */ static bool point_between_edges(float co[3], BMVert *v, BMFace *f, EdgeHalf *e1, EdgeHalf *e2) { BMVert *v1, *v2; @@ -967,7 +973,7 @@ static bool point_between_edges(float co[3], BMVert *v, BMFace *f, EdgeHalf *e1, normalize_v3(dirco); ang11 = angle_normalized_v3v3(dir1, dir2); ang1co = angle_normalized_v3v3(dir1, dirco); - /* angles are in [0,pi]. need to compare cross product with normal to see if they are reflex */ + /* Angles are in [0,pi]. Need to compare cross product with normal to see if they are reflex. */ cross_v3_v3v3(no, dir1, dir2); if (dot_v3v3(no, f->no) < 0.0f) { ang11 = (float)(M_PI * 2.0) - ang11; @@ -1039,7 +1045,7 @@ static void offset_meet(EdgeHalf *e1, * so use the average of the two, and the offset formula for angle bisector. * If offsets are different, we're out of luck: * Use the max of the two (so get consistent looking results if the same situation - * arises elsewhere in the object but with opposite roles for e1 and e2 */ + * arises elsewhere in the object but with opposite roles for e1 and e2. */ if (f) { copy_v3_v3(norm_v, f->no); } @@ -1066,8 +1072,8 @@ static void offset_meet(EdgeHalf *e1, * in case f is non-planar. * Except: sometimes locally there can be a small angle between dir1 and dir2 that leads * to a normal that is actually almost perpendicular to the face normal; - * in this case it looks wrong to use the local (cross-product) normal, - * so use the face normal if the angle between dir1 and dir2 is smallish. + * in this case it looks wrong to use the local (cross-product) normal, so use the face normal + * if the angle between dir1 and dir2 is smallish. * If e1-v-e2 is a reflex angle (viewed from vertex normal side), need to flip. * Use f->no to figure out which side to look at angle from, as even if f is non-planar, * will be more accurate than vertex normal. */ @@ -1121,7 +1127,7 @@ static void offset_meet(EdgeHalf *e1, } else { /* The lines intersect, but is it at a reasonable place? - * One problem to check: if one of the offsets is 0, then don't want an intersection + * One problem to check: if one of the offsets is 0, then we don't want an intersection * that is outside that edge itself. This can happen if angle between them is > 180 degrees, * or if the offset amount is > the edge length. */ if (e1->offset_r == 0.0f && is_outside_edge(e1, meetco, &closer_v)) { @@ -1163,11 +1169,13 @@ static void offset_meet(EdgeHalf *e1, /* Chosen so 1/sin(BEVEL_GOOD_ANGLE) is about 4, giving that expansion factor to bevel width. */ #define BEVEL_GOOD_ANGLE 0.25f -/* Calculate the meeting point between e1 and e2 (one of which should have zero offsets), +/** + * Calculate the meeting point between e1 and e2 (one of which should have zero offsets), * where e1 precedes e2 in CCW order around their common vertex v (viewed from normal side). * If r_angle is provided, return the angle between e and emeet in *r_angle. * If the angle is 0, or it is 180 degrees or larger, there will be no meeting point; - * return false in that case, else true. */ + * return false in that case, else true. + */ static bool offset_meet_edge( EdgeHalf *e1, EdgeHalf *e2, BMVert *v, float meetco[3], float *r_angle) { @@ -1214,8 +1222,10 @@ static bool offset_meet_edge( return true; } -/* Return true if it will look good to put the meeting point where offset_on_edge_between - * would put it. This means that neither side sees a reflex angle. */ +/** + * Return true if it will look good to put the meeting point where offset_on_edge_between + * would put it. This means that neither side sees a reflex angle. + */ static bool good_offset_on_edge_between(EdgeHalf *e1, EdgeHalf *e2, EdgeHalf *emid, BMVert *v) { float ang; @@ -1224,11 +1234,12 @@ static bool good_offset_on_edge_between(EdgeHalf *e1, EdgeHalf *e2, EdgeHalf *em return offset_meet_edge(e1, emid, v, meet, &ang) && offset_meet_edge(emid, e2, v, meet, &ang); } -/* Calculate the best place for a meeting point for the offsets from edges e1 and e2 - * on the in-between edge emid. Viewed from the vertex normal side, the CCW - * order of these edges is e1, emid, e2. - * Return true if we placed meetco as compromise between where two edges met. - * If we did, put ration of sines of angles in *r_sinratio too */ +/** + * Calculate the best place for a meeting point for the offsets from edges e1 and e2 on the + * in-between edge emid. Viewed from the vertex normal side, the CCW order of these edges is e1, + * emid, e2. Return true if we placed meetco as compromise between where two edges met. If we did, + * put the ratio of sines of angles in *r_sinratio too. + */ static bool offset_on_edge_between( EdgeHalf *e1, EdgeHalf *e2, EdgeHalf *emid, BMVert *v, float meetco[3], float *r_sinratio) { @@ -1264,9 +1275,9 @@ static bool offset_on_edge_between( return retval; } -/* Offset by e->offset in plane with normal plane_no, on left if left==true, - * else on right. If no is NULL, choose an arbitrary plane different from eh's direction. */ -static void offset_in_plane(EdgeHalf *e, const float plane_no[3], bool left, float r[3]) +/* Offset by e->offset in plane with normal plane_no, on left if left==true, else on right. + * If plane_no is NULL, choose an arbitrary plane different from eh's direction. */ +static void offset_in_plane(EdgeHalf *e, const float plane_no[3], bool left, float r_co[3]) { float dir[3], no[3], fdir[3]; BMVert *v; @@ -1294,8 +1305,8 @@ static void offset_in_plane(EdgeHalf *e, const float plane_no[3], bool left, flo cross_v3_v3v3(fdir, no, dir); } normalize_v3(fdir); - copy_v3_v3(r, v->co); - madd_v3_v3fl(r, fdir, left ? e->offset_l : e->offset_r); + copy_v3_v3(r_co, v->co); + madd_v3_v3fl(r_co, fdir, left ? e->offset_l : e->offset_r); } /* Calculate the point on e where line (co_a, co_b) comes closest to and return it in projco. */ @@ -1328,7 +1339,7 @@ static void set_profile_params(BevelParams *bp, BevVert *bv, BoundVert *bndv) if (e) { do_linear_interp = false; pro->super_r = bp->pro_super_r; - /* projection direction is direction of the edge. */ + /* Projection direction is direction of the edge. */ sub_v3_v3v3(pro->proj_dir, e->e->v1->co, e->e->v2->co); if (e->is_rev) { negate_v3(pro->proj_dir); @@ -1346,14 +1357,13 @@ static void set_profile_params(BevelParams *bp, BevVert *bv, BoundVert *bndv) normalize_v3(pro->plane_no); if (nearly_parallel(d1, d2)) { /* Start - middle - end are collinear. - * Should be case that beveled edge is coplanar with two boundary verts. + * It should be the case that beveled edge is coplanar with two boundary verts. * We want to move the profile to that common plane, if possible. * That makes the multi-segment bevels curve nicely in that plane, as users expect. * The new middle should be either v (when neighbor edges are unbeveled) * or the intersection of the offset lines (if they are). * If the profile is going to lead into unbeveled edges on each side - * (that is, both BoundVerts are "on-edge" points on non-beveled edges) - */ + * (that is, both BoundVerts are "on-edge" points on non-beveled edges). */ copy_v3_v3(pro->middle, bv->v->co); if (e->prev->is_bev && e->next->is_bev && bv->selcount >= 3) { /* Want mid at the meet point of next and prev offset edges. */ @@ -1434,17 +1444,19 @@ static void set_profile_params(BevelParams *bp, BevVert *bv, BoundVert *bndv) } } -/* Maybe move the profile plane for bndv->ebev to the plane its profile's start, and the +/** + * Maybe move the profile plane for bndv->ebev to the plane its profile's start, and the * original beveled vert, bmv. This will usually be the plane containing its adjacent * non-beveled edges, but sometimes the start and the end are not on those edges. * - * Currently just used in #build_boundary_terminal_edge */ + * Currently just used in #build_boundary_terminal_edge. + */ static void move_profile_plane(BoundVert *bndv, BMVert *bmvert) { float d1[3], d2[3], no[3], no2[3], no3[3], dot2, dot3; Profile *pro = &bndv->profile; - /* only do this if projecting, and start, end, and proj_dir are not coplanar */ + /* Only do this if projecting, and start, end, and proj_dir are not coplanar. */ if (is_zero_v3(pro->proj_dir)) { return; } @@ -1468,16 +1480,18 @@ static void move_profile_plane(BoundVert *bndv, BMVert *bmvert) pro->special_params = true; } -/* Move the profile plane for the two BoundVerts involved in a weld. +/** + * Move the profile plane for the two BoundVerts involved in a weld. * We want the plane that is most likely to have the intersections of the - * two edges' profile projections on it. bndv1 and bndv2 are by - * construction the intersection points of the outside parts of the profiles. - * The original vertex should form a third point of the desired plane. */ + * two edges' profile projections on it. bndv1 and bndv2 are by construction the + * intersection points of the outside parts of the profiles. + * The original vertex should form a third point of the desired plane. + */ static void move_weld_profile_planes(BevVert *bv, BoundVert *bndv1, BoundVert *bndv2) { float d1[3], d2[3], no[3], no2[3], no3[3], dot1, dot2, l1, l2, l3; - /* only do this if projecting, and d1, d2, and proj_dir are not coplanar */ + /* Only do this if projecting, and d1, d2, and proj_dir are not coplanar. */ if (is_zero_v3(bndv1->profile.proj_dir) || is_zero_v3(bndv2->profile.proj_dir)) { return; } @@ -1485,8 +1499,8 @@ static void move_weld_profile_planes(BevVert *bv, BoundVert *bndv1, BoundVert *b sub_v3_v3v3(d2, bv->v->co, bndv2->nv.co); cross_v3_v3v3(no, d1, d2); l1 = normalize_v3(no); - /* "no" is new normal projection plane, but don't move if - * it is coplanar with both of the projection dirs */ + /* "no" is new normal projection plane, but don't move if it is coplanar with both of the + * projection dirs. */ cross_v3_v3v3(no2, d1, bndv1->profile.proj_dir); l2 = normalize_v3(no2); cross_v3_v3v3(no3, d2, bndv2->profile.proj_dir); @@ -1507,8 +1521,8 @@ static void move_weld_profile_planes(BevVert *bv, BoundVert *bndv1, BoundVert *b bndv2->profile.special_params = true; } -/* return 1 if a and b are in CCW order on the normal side of f, - * and -1 if they are reversed, and 0 if there is no shared face f */ +/* Return 1 if a and b are in CCW order on the normal side of f, + * and -1 if they are reversed, and 0 if there is no shared face f. */ static int bev_ccw_test(BMEdge *a, BMEdge *b, BMFace *f) { BMLoop *la, *lb; @@ -1524,10 +1538,11 @@ static int bev_ccw_test(BMEdge *a, BMEdge *b, BMFace *f) return lb->next == la ? 1 : -1; } -/* Fill matrix r_mat so that a point in the sheared parallelogram with corners +/** + * Fill matrix r_mat so that a point in the sheared parallelogram with corners * va, vmid, vb (and the 4th that is implied by it being a parallelogram) * is the result of transforming the unit square by multiplication with r_mat. - * If it can't be done because the parallelogram is degenerate, return false + * If it can't be done because the parallelogram is degenerate, return false, * else return true. * Method: * Find vo, the origin of the parallelogram with other three points va, vmid, vb. @@ -1568,7 +1583,7 @@ static bool make_unit_square_map(const float va[3], add_v3_v3v3(vd, vo, vddir); /* The cols of m are: {vmid - va, vmid - vb, vmid + vd - va -vb, va + vb - vmid; - * blender transform matrices are stored such that m[i][*] is ith column; + * Blender transform matrices are stored such that m[i][*] is ith column; * the last elements of each col remain as they are in unity matrix. */ sub_v3_v3v3(&r_mat[0][0], vmid, va); r_mat[0][3] = 0.0f; @@ -1585,7 +1600,8 @@ static bool make_unit_square_map(const float va[3], return true; } -/* Like make_unit_square_map, but this one makes a matrix that transforms the +/** + * Like make_unit_square_map, but this one makes a matrix that transforms the * (1,1,1) corner of a unit cube into an arbitrary corner with corner vert d * and verts around it a, b, c (in ccw order, viewed from d normal dir). * The matrix mat is calculated to map: @@ -1629,10 +1645,12 @@ static void make_unit_cube_map( r_mat[3][3] = 1.0f; } -/* Get the coordinate on the superellipse (x^r + y^r = 1), - * at parameter value x (or, if !rbig, mirrored (y=x)-line). +/** + * Get the coordinate on the superellipse (x^r + y^r = 1), at parameter value x + * (or, if !rbig, mirrored (y=x)-line). * rbig should be true if r > 1.0 and false if <= 1.0. - * Assume r > 0.0 */ + * Assume r > 0.0. + */ static double superellipse_co(double x, float r, bool rbig) { BLI_assert(r > 0.0f); @@ -1647,13 +1665,15 @@ static double superellipse_co(double x, float r, bool rbig) } } -/* Find the point on given profile at parameter i which goes from 0 to n as - * the profile is moved from pro->start to pro->end. - * We assume that n is either the global seg number or a power of 2 less than +/** + * Find the point on given profile at parameter i which goes from 0 to nseg as + * the profile moves from pro->start to pro->end. + * We assume that nseg is either the global seg number or a power of 2 less than * or equal to the power of 2 >= seg. * In the latter case, we subsample the profile for seg_2, which will not necessarily * give equal spaced chords, but is in fact more what is desired by the cubic subdivision - * method used to make the vmesh pattern. */ + * method used to make the vmesh pattern. + */ static void get_profile_point(BevelParams *bp, const Profile *pro, int i, int nseg, float r_co[3]) { int subsample_spacing; @@ -1674,20 +1694,21 @@ static void get_profile_point(BevelParams *bp, const Profile *pro, int i, int ns } else { BLI_assert(is_power_of_2_i(nseg) && nseg <= bp->pro_spacing.seg_2); - /* Find spacing between subsamples in prof_co_2 */ + /* Find spacing between subsamples in prof_co_2. */ subsample_spacing = bp->pro_spacing.seg_2 / nseg; copy_v3_v3(r_co, pro->prof_co_2 + 3 * i * subsample_spacing); } } } -/* Calculate the actual coordinate values for bndv's profile. +/** + * Calculate the actual coordinate values for bndv's profile. * This is only needed if bp->seg > 1. * Allocate the space for them if that hasn't been done already. * If bp->seg is not a power of 2, also need to calculate - * the coordinate values for the power of 2 >= bp->seg, - * because the ADJ pattern needs power-of-2 boundaries - * during construction. */ + * the coordinate values for the power of 2 >= bp->seg, because the ADJ pattern needs power-of-2 + * boundaries during construction. + */ static void calculate_profile(BevelParams *bp, BoundVert *bndv, bool reversed, bool miter) { int i, k, ns; @@ -1735,7 +1756,7 @@ static void calculate_profile(BevelParams *bp, BoundVert *bndv, bool reversed, b pro->height = len_v3v3(bottom_corner, top_corner); } - /* The first iteration is the nseg case, the second is the seg_2 case (if it's needed) */ + /* The first iteration is the nseg case, the second is the seg_2 case (if it's needed) .*/ for (i = 0; i < 2; i++) { if (i == 0) { ns = bp->seg; @@ -1745,7 +1766,7 @@ static void calculate_profile(BevelParams *bp, BoundVert *bndv, bool reversed, b } else { if (!need_2) { - break; /* shares coords with pro->prof_co */ + break; /* Shares coords with pro->prof_co. */ } ns = bp->pro_spacing.seg_2; xvals = pro_spacing->xvals_2; @@ -1753,7 +1774,7 @@ static void calculate_profile(BevelParams *bp, BoundVert *bndv, bool reversed, b prof_co = pro->prof_co_2; } - /* Iterate over the vertices along the boundary arc */ + /* Iterate over the vertices along the boundary arc. */ for (k = 0; k <= ns; k++) { if (k == 0) { copy_v3_v3(co, pro->start); @@ -1772,20 +1793,20 @@ static void calculate_profile(BevelParams *bp, BoundVert *bndv, bool reversed, b p[1] = (float)yvals[k]; } p[2] = 0.0f; - /* Do the 2D->3D transformation of the profile coordinates */ + /* Do the 2D->3D transformation of the profile coordinates. */ mul_v3_m4v3(co, map, p); } else { interp_v3_v3v3(co, pro->start, pro->end, (float)k / (float)ns); } } - /* Finish the 2D->3D transformation by projecting onto the final profile plane */ - prof_co_k = prof_co + 3 * k; /* Each coord takes up 3 spaces */ + /* Finish the 2D->3D transformation by projecting onto the final profile plane. */ + prof_co_k = prof_co + 3 * k; /* Each coord takes up 3 spaces. */ if (!is_zero_v3(pro->proj_dir)) { add_v3_v3v3(co2, co, pro->proj_dir); - /* pro->plane_co and pro->plane_no are filled in "set_profile_params" */ + /* pro->plane_co and pro->plane_no are filled in "set_profile_params". */ if (!isect_line_plane_v3(prof_co_k, co, co2, pro->plane_co, pro->plane_no)) { - /* shouldn't happen */ + /* Shouldn't happen. */ copy_v3_v3(prof_co_k, co); } } @@ -1796,10 +1817,12 @@ static void calculate_profile(BevelParams *bp, BoundVert *bndv, bool reversed, b } } -/* Snap a direction co to a superellipsoid with parameter super_r. +/** + * Snap a direction co to a superellipsoid with parameter super_r. * For square profiles, midline says whether or not to snap to both planes. * - * Only currently used for the pipe and cube corner special cases */ + * Only currently used for the pipe and cube corner special cases. + */ static void snap_to_superellipsoid(float co[3], const float super_r, bool midline) { float a, b, c, x, y, z, r, rinv, dx, dy; @@ -1813,13 +1836,13 @@ static void snap_to_superellipsoid(float co[3], const float super_r, bool midlin y = b = max_ff(0.0f, co[1]); z = c = max_ff(0.0f, co[2]); if (r == PRO_SQUARE_R || r == PRO_SQUARE_IN_R) { - /* will only be called for 2d profile */ + /* Will only be called for 2d profile. */ BLI_assert(fabsf(z) < BEVEL_EPSILON); z = 0.0f; x = min_ff(1.0f, x); y = min_ff(1.0f, y); if (r == PRO_SQUARE_R) { - /* snap to closer of x==1 and y==1 lines, or maybe both */ + /* Snap to closer of x==1 and y==1 lines, or maybe both. */ dx = 1.0f - x; dy = 1.0f - y; if (dx < dy) { @@ -1832,7 +1855,7 @@ static void snap_to_superellipsoid(float co[3], const float super_r, bool midlin } } else { - /* snap to closer of x==0 and y==0 lines, or maybe both */ + /* Snap to closer of x==0 and y==0 lines, or maybe both. */ if (x < y) { x = 0.0f; y = midline ? 0.0f : y; @@ -1874,7 +1897,7 @@ static void check_edge_data_seam_sharp_edges(BevVert *bv, int flag, bool neg) { EdgeHalf *e = &bv->edges[0], *efirst = &bv->edges[0]; - /* First first edge with seam or sharp edge data */ + /* First first edge with seam or sharp edge data. */ while ((!neg && !BEV_EXTEND_EDGE_DATA_CHECK(e, flag)) || (neg && BEV_EXTEND_EDGE_DATA_CHECK(e, flag))) { e = e->next; @@ -1883,7 +1906,7 @@ static void check_edge_data_seam_sharp_edges(BevVert *bv, int flag, bool neg) } } - /* If no such edge found, return */ + /* If no such edge found, return. */ if ((!neg && !BEV_EXTEND_EDGE_DATA_CHECK(e, flag)) || (neg && BEV_EXTEND_EDGE_DATA_CHECK(e, flag))) { return; @@ -1908,7 +1931,7 @@ static void check_edge_data_seam_sharp_edges(BevVert *bv, int flag, bool neg) (neg && BEV_EXTEND_EDGE_DATA_CHECK(efirst, flag))))) { break; } - /* Set seam_len / sharp_len of starting edge */ + /* Set seam_len / sharp_len of starting edge. */ if (flag == BM_ELEM_SEAM) { e->rightv->seam_len = flag_count; } @@ -1930,15 +1953,15 @@ static void bevel_extend_edge_data(BevVert *bv) BoundVert *bcur = bv->vmesh->boundstart, *start = bcur; do { - /* If current boundvert has a seam length > 0 then it has a seam running along its edges */ + /* If current boundvert has a seam length > 0 then it has a seam running along its edges. */ if (bcur->seam_len) { if (!bv->vmesh->boundstart->seam_len && start == bv->vmesh->boundstart) { - start = bcur; /* set start to first boundvert with seam_len > 0 */ + start = bcur; /* Set start to first boundvert with seam_len > 0. */ } /* Now for all the mesh_verts starting at current index and ending at idxlen - * We go through outermost ring and through all its segments and add seams - * for those edges */ + * we go through outermost ring and through all its segments and add seams + * for those edges. */ int idxlen = bcur->index + bcur->seam_len; for (int i = bcur->index; i < idxlen; i++) { BMVert *v1 = mesh_vert(vm, i % vm->count, 0, 0)->v, *v2; @@ -1961,7 +1984,7 @@ static void bevel_extend_edge_data(BevVert *bv) v1 = v2; } BMVert *v3 = mesh_vert(vm, (i + 1) % vm->count, 0, 0)->v; - e = v1->e; // Do same as above for first and last vert + e = v1->e; /* Do same as above for first and last vert. */ while (e->v1 != v3 && e->v2 != v3) { if (e->v1 == v1) { e = e->v1_disk_link.next; @@ -2042,7 +2065,7 @@ static void bevel_edges_sharp_boundary(BMesh *bm, BevelParams *bp) continue; } BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) { - /* cases we care about will have exactly one adjacent face */ + /* Cases we care about will have exactly one adjacent face. */ lother = l->radial_next; fother = lother->f; if (lother != l && fother) { @@ -2056,8 +2079,9 @@ static void bevel_edges_sharp_boundary(BMesh *bm, BevelParams *bp) } /** - * Harden normals for bevel. - * The desired effect is that the newly created #F_EDGE and F_VERT faces appear smoothly shaded + * \brief Harden normals for bevel. + * + * The desired effect is that the newly created #F_EDGE and #F_VERT faces appear smoothly shaded * with the normals at the boundaries with #F_RECON faces matching those recon faces. * And at boundaries between #F_EDGE and #F_VERT faces, the normals should match the #F_EDGE ones. * Assumes custom loop normals are in use. @@ -2077,24 +2101,23 @@ static void bevel_harden_normals(BevelParams *bp, BMesh *bm) return; } - /* recalculate all face and vertex normals; side effect: ensures vertex, edge, face indices */ - /* I suspect this is not necessary: TODO: test that guess */ + /* Recalculate all face and vertex normals. Side effect: ensures vertex, edge, face indices. */ + /* I suspect this is not necessary. TODO: test that guess. */ BM_mesh_normals_update(bm); cd_clnors_offset = CustomData_get_offset(&bm->ldata, CD_CUSTOMLOOPNORMAL); /* If there is not already a custom split normal layer then making one (with BM_lnorspace_update) * will not respect the autosmooth angle between smooth faces. To get that to happen, we have - * to mark the sharpen the edges that are only sharp because - * of the angle test -- otherwise would be smooth. - */ + * to mark the sharpen the edges that are only sharp because of the angle test -- otherwise would + * be smooth. */ if (cd_clnors_offset == -1) { BM_edges_sharp_from_angle_set(bm, bp->smoothresh); bevel_edges_sharp_boundary(bm, bp); } - /* Ensure that bm->lnor_spacearr has properly stored loop normals; - * side effect: ensures loop indices. */ + /* Ensure that bm->lnor_spacearr has properly stored loop normals. + * Side effect: ensures loop indices. */ BM_lnorspace_update(bm); if (cd_clnors_offset == -1) { @@ -2107,9 +2130,9 @@ static void bevel_harden_normals(BevelParams *bp, BMesh *bm) continue; } BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) { - estep = l->prev->e; /* causes CW walk around l->v fan */ + estep = l->prev->e; /* Causes CW walk around l->v fan. */ lprev = BM_vert_step_fan_loop(l, &estep); - estep = l->e; /* causes CCW walk around l->v fan */ + estep = l->e; /* Causes CCW walk around l->v fan. */ lnext = BM_vert_step_fan_loop(l, &estep); fprevkind = lprev ? get_face_kind(bp, lprev->f) : F_NONE; fnextkind = lnext ? get_face_kind(bp, lnext->f) : F_NONE; @@ -2236,7 +2259,7 @@ static void bevel_set_weighted_normal_face_strength(BMesh *bm, BevelParams *bp) } } -/* Set the any_seam property for a BevVert and all its BoundVerts */ +/* Set the any_seam property for a BevVert and all its BoundVerts. */ static void set_bound_vert_seams(BevVert *bv, bool mark_seam, bool mark_sharp) { BoundVert *v; @@ -2294,7 +2317,12 @@ static bool eh_on_plane(EdgeHalf *e) return false; } -/* Calculate the profiles for all the BoundVerts of VMesh vm */ +/** + * Calculate the profiles for all the BoundVerts of VMesh vm. + * + * \note This should only be called once for each BevVert, after all changes have been made to the + * profile's parameters. + */ static void calculate_vm_profiles(BevelParams *bp, BevVert *bv, VMesh *vm) { BoundVert *bndv = vm->boundstart; @@ -2315,7 +2343,7 @@ static void calculate_vm_profiles(BevelParams *bp, BevVert *bv, VMesh *vm) } while ((bndv = bndv->next) != vm->boundstart); } -/* Implements build_boundary for vertex-only case */ +/* Implements build_boundary for the vertex-only case. */ static void build_boundary_vertex_only(BevelParams *bp, BevVert *bv, bool construct) { VMesh *vm = bv->vmesh; @@ -2372,7 +2400,7 @@ static void build_boundary_terminal_edge(BevelParams *bp, e = efirst; if (bv->edgecount == 2) { - /* only 2 edges in, so terminate the edge with an artificial vertex on the unbeveled edge */ + /* Only 2 edges in, so terminate the edge with an artificial vertex on the unbeveled edge. */ no = e->fprev ? e->fprev->no : (e->fnext ? e->fnext->no : NULL); offset_in_plane(e, no, true, co); if (construct) { @@ -2393,7 +2421,7 @@ static void build_boundary_terminal_edge(BevelParams *bp, else { adjust_bound_vert(e->rightv, co); } - /* make artificial extra point along unbeveled edge, and form triangle */ + /* Make artificial extra point along unbeveled edge, and form triangle. */ slide_dist(e->next, bv->v, e->offset_l, co); if (construct) { bndv = add_new_bound_vert(mem_arena, vm, co); @@ -2406,9 +2434,9 @@ static void build_boundary_terminal_edge(BevelParams *bp, } } else { - /* More than 2 edges in. Put on-edge verts on all the other edges - * and join with the beveled edge to make a poly or adj mesh, - * Because e->prev has offset 0, offset_meet will put co on that edge. */ + /* More than 2 edges in. Put on-edge verts on all the other edges and join with the beveled + * edge to make a poly or adj mesh, because e->prev has offset 0, offset_meet will put co on + * that edge. */ /* TODO: should do something else if angle between e and e->prev > 180 */ offset_meet(e->prev, e, bv->v, e->fprev, false, co, NULL); if (construct) { @@ -2468,11 +2496,11 @@ static void build_boundary_terminal_edge(BevelParams *bp, else if (vm->count == 3) { use_tri_fan = true; if (bp->use_custom_profile) { - /* Use M_POLY if the extra point is planar with the profile to prevent overhanging edges */ + /* Prevent overhanging edges: use M_POLY if the extra point is planar with the profile. */ bndv = efirst->leftv; float profile_plane[4]; plane_from_point_normal_v3(profile_plane, bndv->profile.plane_co, bndv->profile.plane_no); - bndv = efirst->rightv->next; /* The added boundvert placed along the non-adjacent edge */ + bndv = efirst->rightv->next; /* The added boundvert placed along the non-adjacent edge. */ if (dist_squared_to_plane_v3(bndv->nv.co, profile_plane) < BEVEL_EPSILON_BIG) { use_tri_fan = false; } @@ -2485,7 +2513,7 @@ static void build_boundary_terminal_edge(BevelParams *bp, } } -/* Helper for build_boundary to handle special miters */ +/* Helper for build_boundary to handle special miters. */ static void adjust_miter_coords(BevelParams *bp, BevVert *bv, EdgeHalf *emiter) { float co1[3], co2[3], co3[3], edge_dir[3], line_p[3]; @@ -2512,19 +2540,19 @@ static void adjust_miter_coords(BevelParams *bp, BevVert *bv, EdgeHalf *emiter) } /* co1 is intersection of line through co2 in dir of emiter->e - * and plane with normal the dir of emiter->e and through v1prev */ + * and plane with normal the dir of emiter->e and through v1prev. */ vother = BM_edge_other_vert(emiter->e, bv->v); sub_v3_v3v3(edge_dir, bv->v->co, vother->co); normalize_v3(edge_dir); - float d = bp->offset / (bp->seg / 2.0f); /* a fallback amount to move */ + float d = bp->offset / (bp->seg / 2.0f); /* A fallback amount to move. */ madd_v3_v3v3fl(line_p, co2, edge_dir, d); if (!isect_line_plane_v3(co1, co2, line_p, v1prev->nv.co, edge_dir)) { copy_v3_v3(co1, line_p); } adjust_bound_vert(v1, co1); - /* co3 is similar, but plane is through v3next and line is other side of miter edge */ - emiter_other = v3->elast; /*v3->efirst;*/ + /* co3 is similar, but plane is through v3next and line is other side of miter edge. */ + emiter_other = v3->elast; vother = BM_edge_other_vert(emiter_other->e, bv->v); sub_v3_v3v3(edge_dir, bv->v->co, vother->co); normalize_v3(edge_dir); @@ -2659,7 +2687,7 @@ static void build_boundary(BevelParams *bp, BevVert *bv, bool construct) } } else { - /* n_in_plane > 0 and n_not_in_plane == 0 */ + /* n_in_plane > 0 and n_not_in_plane == 0. */ if (bp->loop_slide && in_plane == 1 && good_offset_on_edge_between(e, e2, eip, bv->v)) { if (offset_on_edge_between(e, e2, eip, bv->v, co, &r)) { eon = eip; @@ -2687,7 +2715,6 @@ static void build_boundary(BevelParams *bp, BevVert *bv, bool construct) ang_kind = edges_angle_kind(e, e2, bv->v); /* Are we doing special mitering? - * ang_kind is -1, 0, 1 as angle is <, =, > 180 degrees. * There can only be one outer reflex angle, so only one outer miter, * and emiter will be set to the first edge of such an edge. * A miter kind of BEVEL_MITER_SHARP means no special miter */ @@ -2696,7 +2723,7 @@ static void build_boundary(BevelParams *bp, BevVert *bv, bool construct) if (ang_kind == ANGLE_LARGER) { emiter = e; } - /* make one or two more boundverts; for now all will have same co */ + /* Make one or two more boundverts; for now all will have same co. */ v1 = v; v1->ebev = NULL; if (ang_kind == ANGLE_LARGER && miter_outer == BEVEL_MITER_PATCH) { @@ -2743,7 +2770,7 @@ static void build_boundary(BevelParams *bp, BevVert *bv, bool construct) bool betodd = (between % 2) == 1; int i = 0; /* Put first half of in-between edges at index 0, second half at index bp->seg. - * If between is odd, put middle one at midindex */ + * If between is odd, put middle one at midindex. */ for (e3 = e->next; e3 != e2; e3 = e3->next) { v1->elast = e3; if (i < bet2) { @@ -2761,7 +2788,7 @@ static void build_boundary(BevelParams *bp, BevVert *bv, bool construct) } } } - else { /* construct == false */ + else { /* construct == false. */ ang_kind = edges_angle_kind(e, e2, bv->v); if ((miter_outer != BEVEL_MITER_SHARP && !emiter && ang_kind == ANGLE_LARGER) || (miter_inner != BEVEL_MITER_SHARP && ang_kind == ANGLE_SMALLER)) { @@ -2960,7 +2987,7 @@ static bool adjust_the_cycle_or_chain_fast(BoundVert *vstart, int np, bool iscyc if (iscycle) { gprod *= g[0]; if (fabs(gprod - 1.0f) > BEVEL_EPSILON) { - /* fast cycle calc only works if total product is 1 */ + /* Fast cycle calc only works if total product is 1. */ MEM_freeN(g); MEM_freeN(g_prod); return false; @@ -2973,7 +3000,7 @@ static bool adjust_the_cycle_or_chain_fast(BoundVert *vstart, int np, bool iscyc } p = spec_sum / gprod_sum; - /* apply the new offsets */ + /* Apply the new offsets. */ v = vstart; i = 0; do { @@ -2986,7 +3013,7 @@ static bool adjust_the_cycle_or_chain_fast(BoundVert *vstart, int np, bool iscyc } } else { - /* not a cycle, and last of chain */ + /* Not a cycle, and last of chain. */ eleft = v->elast; eleft->offset_l = p; } @@ -3067,7 +3094,7 @@ static EdgeHalf *next_edgehalf_bev(BevelParams *bp, } normalize_v3(dir_new_edge); - /* Use this edge if it is the most parallel to the orignial so far */ + /* Use this edge if it is the most parallel to the orignial so far. */ new_dot = dot_v3v3(dir_new_edge, dir_start_edge); if (new_dot > best_dot) { second_best_dot = best_dot; /* For remembering if the choice was too close. */ @@ -3149,7 +3176,8 @@ static void regularize_profile_orientation(BevelParams *bp, BMEdge *bme) } } -/* Adjust the offsets for a single cycle or chain. +/** + * Adjust the offsets for a single cycle or chain. * For chains and some cycles, a fast solution exists. * Otherwise, we set up and solve a linear least squares problem * that tries to minimize the squared differences of lengths @@ -3194,9 +3222,9 @@ static void adjust_the_cycle_or_chain(BoundVert *vstart, bool iscycle) v = vstart; i = 0; - weight = BEVEL_MATCH_SPEC_WEIGHT; /* sqrt of factor to weight down importance of spec match */ + weight = BEVEL_MATCH_SPEC_WEIGHT; /* Sqrt of factor to weight down importance of spec match. */ do { - /* except at end of chain, v's indep variable is offset_r of v->efirst */ + /* Except at end of chain, v's indep variable is offset_r of v->efirst. */ if (iscycle || i < np - 1) { eright = v->efirst; eleft = v->elast; @@ -3211,7 +3239,7 @@ static void adjust_the_cycle_or_chain(BoundVert *vstart, bool iscycle) } #endif - /* residue i: width difference between eright and eleft of next */ + /* Residue i: width difference between eright and eleft of next. */ EIG_linear_solver_matrix_add(solver, i, i, 1.0); EIG_linear_solver_right_hand_side_add(solver, 0, i, 0.0); if (iscycle) { @@ -3223,8 +3251,8 @@ static void adjust_the_cycle_or_chain(BoundVert *vstart, bool iscycle) } } - /* residue np + 2*i (if cycle) else np - 1 + 2*i: - * right offset for parm i matches its spec; weighted */ + /* Residue np + 2*i (if cycle) else np - 1 + 2*i: + * right offset for parm i matches its spec; weighted. */ row = iscycle ? np + 2 * i : np - 1 + 2 * i; EIG_linear_solver_matrix_add(solver, row, i, weight); EIG_linear_solver_right_hand_side_add(solver, 0, row, weight * eright->offset_r); @@ -3236,8 +3264,8 @@ static void adjust_the_cycle_or_chain(BoundVert *vstart, bool iscycle) BM_elem_index_get(eright->e)); #endif - /* residue np + 2*i + 1 (if cycle) else np - 1 + 2*i + 1: - * left offset for parm i matches its spec; weighted */ + /* Residue np + 2*i + 1 (if cycle) else np - 1 + 2*i + 1: + * left offset for parm i matches its spec; weighted. */ row = row + 1; EIG_linear_solver_matrix_add( solver, row, (i == np - 1) ? 0 : i + 1, weight * v->adjchain->sinratio); @@ -3251,12 +3279,12 @@ static void adjust_the_cycle_or_chain(BoundVert *vstart, bool iscycle) #endif } else { - /* not a cycle, and last of chain */ + /* Not a cycle, and last of chain. */ eleft = v->elast; #ifdef DEBUG_ADJUST printf("p%d: e%d->offset_l = %f\n", i, BM_elem_index_get(eleft->e), eleft->offset_l); #endif - /* second part of residue i for last i */ + /* Second part of residue i for last i. */ EIG_linear_solver_matrix_add(solver, i - 1, i, -1.0); } i++; @@ -3264,7 +3292,7 @@ static void adjust_the_cycle_or_chain(BoundVert *vstart, bool iscycle) } while (v && v != vstart); EIG_linear_solver_solve(solver); #ifdef DEBUG_ADJUST - /* Note: this print only works after solve, but by that time b has been cleared */ + /* Note: this print only works after solve, but by that time b has been cleared. */ EIG_linear_solver_print_matrix(solver); printf("\nSolution:\n"); for (i = 0; i < np; i++) { @@ -3272,7 +3300,7 @@ static void adjust_the_cycle_or_chain(BoundVert *vstart, bool iscycle) } #endif - /* Use the solution to set new widths */ + /* Use the solution to set new widths. */ v = vstart; i = 0; do { @@ -3292,7 +3320,7 @@ static void adjust_the_cycle_or_chain(BoundVert *vstart, bool iscycle) } } else { - /* not a cycle, and last of chain */ + /* Not a cycle, and last of chain. */ eleft = v->elast; eleft->offset_l = (float)val; #ifdef DEBUG_ADJUST @@ -3311,7 +3339,8 @@ static void adjust_the_cycle_or_chain(BoundVert *vstart, bool iscycle) EIG_linear_solver_delete(solver); } -/* Adjust the offsets to try to make them, as much as possible, +/** + * Adjust the offsets to try to make them, as much as possible, * have even-width bevels with offsets that match their specs. * The problem that we can try to ameliorate is that when loop slide * is active, the meet point will probably not be the one that makes @@ -3331,8 +3360,8 @@ static void adjust_offsets(BevelParams *bp, BMesh *bm) bool iscycle; int chainlen; - /* find and process chains and cycles of unvisited BoundVerts that have eon set */ - /* note: for repeatability, iterate over all verts of mesh rather than over ghash'ed BMVerts */ + /* Find and process chains and cycles of unvisited BoundVerts that have eon set. */ + /* Note: for repeatability, iterate over all verts of mesh rather than over ghash'ed BMVerts. */ BM_ITER_MESH (bmv, &iter, bm, BM_VERTS_OF_MESH) { if (!BM_elem_flag_test(bmv, BM_ELEM_TAG)) { continue; @@ -3357,7 +3386,7 @@ static void adjust_offsets(BevelParams *bp, BMesh *bm) * them in left->right direction, meaning that the left side of one edge * pairs with the right side of the next edge in the cycle or chain. */ - /* first follow paired edges in left->right direction */ + /* First follow paired edges in left->right direction. */ v = vchainstart = vchainend = vanchor; iscycle = false; chainlen = 1; @@ -3385,7 +3414,7 @@ static void adjust_offsets(BevelParams *bp, BMesh *bm) v = vnext; } if (!iscycle) { - /* right->left direction, changing vchainstart at each step */ + /* right->left direction, changing vchainstart at each step. */ v->adjchain = NULL; v = vchainstart; bvcur = bv; @@ -3411,7 +3440,7 @@ static void adjust_offsets(BevelParams *bp, BMesh *bm) } while ((vanchor = vanchor->next) != bv->vmesh->boundstart); } - /* Rebuild boundaries with new width specs */ + /* Rebuild boundaries with new width specs. */ BM_ITER_MESH (bmv, &iter, bm, BM_VERTS_OF_MESH) { if (BM_elem_flag_test(bmv, BM_ELEM_TAG)) { bv = find_bevvert(bp, bmv); @@ -3422,13 +3451,15 @@ static void adjust_offsets(BevelParams *bp, BMesh *bm) } } -/* Do the edges at bv form a "pipe"? +/** + * Do the edges at bv form a "pipe"? * Current definition: 3 or 4 beveled edges, 2 in line with each other, * with other edges on opposite sides of the pipe if there are 4. * Also, the vertex boundary should have 3 or 4 vertices in it, * and all of the faces involved should be parallel to the pipe edges. * Return the boundary vert whose ebev is one of the pipe edges, and - * whose next boundary vert has a beveled, non-pipe edge. */ + * whose next boundary vert has a beveled, non-pipe edge. + */ static BoundVert *pipe_test(BevVert *bv) { EdgeHalf *e, *epipe; @@ -3441,7 +3472,7 @@ static BoundVert *pipe_test(BevVert *bv) return NULL; } - /* find v1, v2, v3 all with beveled edges, where v1 and v3 have collinear edges */ + /* Find v1, v2, v3 all with beveled edges, where v1 and v3 have collinear edges. */ epipe = NULL; v1 = vm->boundstart; do { @@ -3463,7 +3494,7 @@ static BoundVert *pipe_test(BevVert *bv) return NULL; } - /* check face planes: all should have normals perpendicular to epipe */ + /* Check face planes: all should have normals perpendicular to epipe. */ for (e = &bv->edges[0]; e != &bv->edges[bv->edgecount]; e++) { if (e->fnext) { if (fabsf(dot_v3v3(dir1, e->fnext->no)) > BEVEL_EPSILON_BIG) { @@ -3488,14 +3519,16 @@ static VMesh *new_adj_vmesh(MemArena *mem_arena, int count, int seg, BoundVert * return vm; } -/* VMesh verts for vertex i have data for (i, 0 <= j <= ns2, 0 <= k <= ns), +/** + * VMesh verts for vertex i have data for (i, 0 <= j <= ns2, 0 <= k <= ns), * where ns2 = floor(nseg / 2). * But these overlap data from previous and next i: there are some forced equivalences. * Let's call these indices the canonical ones: we will just calculate data for these * 0 <= j <= ns2, 0 <= k < ns2 (for odd ns2) * 0 <= j < ns2, 0 <= k <= ns2 (for even ns2) - * also (j=ns2, k=ns2) at i=0 (for even ns2) - * This function returns the canonical one for any i, j, k in [0,n],[0,ns],[0,ns] */ + * also (j=ns2, k=ns2) at i=0 (for even ns2) + * This function returns the canonical one for any i, j, k in [0,n],[0,ns],[0,ns]. + */ static NewVert *mesh_vert_canon(VMesh *vm, int i, int j, int k) { int n, ns, ns2, odd; @@ -3525,15 +3558,15 @@ static NewVert *mesh_vert_canon(VMesh *vm, int i, int j, int k) static bool is_canon(VMesh *vm, int i, int j, int k) { int ns2 = vm->seg / 2; - if (vm->seg % 2 == 1) { /* odd */ + if (vm->seg % 2 == 1) { /* Odd. */ return (j <= ns2 && k <= ns2); } - else { /* even */ + else { /* Even. */ return ((j < ns2 && k <= ns2) || (j == ns2 && k == ns2 && i == 0)); } } -/* Copy the vertex data to all of vm verts from canonical ones */ +/* Copy the vertex data to all of vm verts from canonical ones. */ static void vmesh_copy_equiv_verts(VMesh *vm) { int n, ns, ns2, i, j, k; @@ -3557,7 +3590,7 @@ static void vmesh_copy_equiv_verts(VMesh *vm) } } -/* Calculate and return in r_cent the centroid of the center poly */ +/* Calculate and return in r_cent the centroid of the center poly. */ static void vmesh_center(VMesh *vm, float r_cent[3]) { int n, ns2, i; @@ -3585,12 +3618,12 @@ static void avg4( mul_v3_fl(co, 0.25f); } -/* gamma needed for smooth Catmull-Clark, Sabin modification */ +/* Gamma needed for smooth Catmull-Clark, Sabin modification. */ static float sabin_gamma(int n) { double ans, k, k2, k4, k6, x, y; - /* precalculated for common cases of n */ + /* pPrecalculated for common cases of n. */ if (n < 3) { return 0.0f; } @@ -3608,8 +3641,8 @@ static float sabin_gamma(int n) } else { k = cos(M_PI / (double)n); - /* need x, real root of x^3 + (4k^2 - 3)x - 2k = 0. - * answer calculated via Wolfram Alpha */ + /* Need x, real root of x^3 + (4k^2 - 3)x - 2k = 0. + * Answer calculated via Wolfram Alpha. */ k2 = k * k; k4 = k2 * k2; k6 = k4 * k2; @@ -3620,7 +3653,8 @@ static float sabin_gamma(int n) return (float)ans; } -/* Fill frac with fractions of way along ring 0 for vertex i, for use with interp_range function */ +/* Fill frac with fractions of the way along ring 0 for vertex i, for use with interp_range + * function. */ static void fill_vmesh_fracs(VMesh *vm, float *frac, int i) { int k, ns; @@ -3642,7 +3676,7 @@ static void fill_vmesh_fracs(VMesh *vm, float *frac, int i) } } -/* Like fill_vmesh_fracs but want fractions for profile points of bndv, with ns segments */ +/* Like fill_vmesh_fracs but want fractions for profile points of bndv, with ns segments. */ static void fill_profile_fracs(BevelParams *bp, BoundVert *bndv, float *frac, int ns) { int k; @@ -3668,13 +3702,13 @@ static void fill_profile_fracs(BevelParams *bp, BoundVert *bndv, float *frac, in } /* Return i such that frac[i] <= f <= frac[i + 1], where frac[n] == 1.0 - * and put fraction of rest of way between frac[i] and frac[i + 1] into r_rest */ + * and put fraction of rest of way between frac[i] and frac[i + 1] into r_rest. */ static int interp_range(const float *frac, int n, const float f, float *r_rest) { int i; float rest; - /* could binary search in frac, but expect n to be reasonably small */ + /* Could binary search in frac, but expect n to be reasonably small. */ for (i = 0; i < n; i++) { if (f <= frac[i + 1]) { rest = f - frac[i]; @@ -3695,10 +3729,10 @@ static int interp_range(const float *frac, int n, const float f, float *r_rest) return n; } -/* Interpolate given vmesh to make one with target nseg border vertices on the profiles */ -/* HANS-TODO: This puts the center mesh vert at a slightly off location sometimes, which seems to +/* Interpolate given vmesh to make one with target nseg border vertices on the profiles. + * TODO(Hans): This puts the center mesh vert at a slightly off location sometimes, which seems to * be associated with the rest of that ring being shifted or connected slightly incorrectly to its - * neighbors */ + * neighbors. */ static VMesh *interp_vmesh(BevelParams *bp, VMesh *vm_in, int nseg) { int n_bndv, ns_in, nseg2, odd, i, j, k, j_in, k_in, k_in_prev, j0inc, k0inc; @@ -3727,7 +3761,7 @@ static VMesh *interp_vmesh(BevelParams *bp, VMesh *vm_in, int nseg) fill_profile_fracs(bp, bndv, new_frac, nseg); for (j = 0; j <= nseg2 - 1 + odd; j++) { for (k = 0; k <= nseg2; k++) { - /* Finding the locations where "fraction" fits into previous and current "frac" */ + /* Finding the locations where "fraction" fits into previous and current "frac". */ fraction = new_frac[k]; k_in = interp_range(frac, ns_in, fraction, &restk); fraction = prev_new_frac[nseg - j]; @@ -3741,7 +3775,7 @@ static VMesh *interp_vmesh(BevelParams *bp, VMesh *vm_in, int nseg) j_in = j_in - 1; restj = 1.0f + restj; } - /* Use bilinear interpolation within the source quad; could be smarter here */ + /* Use bilinear interpolation within the source quad; could be smarter here. */ if (restj < BEVEL_EPSILON && restk < BEVEL_EPSILON) { copy_v3_v3(co, mesh_vert_canon(vm_in, i, j_in, k_in)->co); } @@ -3840,13 +3874,13 @@ static VMesh *cubic_subdiv(BevelParams *bp, VMesh *vm_in) vmesh_copy_equiv_verts(vm_in); /* Now we do the internal vertices, using standard Catmull-Clark - * and assuming all boundary vertices have valence 4 */ + * and assuming all boundary vertices have valence 4. */ - /* The new face vertices */ + /* The new face vertices. */ for (i = 0; i < n_boundary; i++) { for (j = 0; j < ns_in2; j++) { for (k = 0; k < ns_in2; k++) { - /* face up and right from (j, k) */ + /* Face up and right from (j, k). */ avg4(co, mesh_vert(vm_in, i, j, k), mesh_vert(vm_in, i, j, k + 1), @@ -3857,11 +3891,11 @@ static VMesh *cubic_subdiv(BevelParams *bp, VMesh *vm_in) } } - /* The new vertical edge vertices */ + /* The new vertical edge vertices. */ for (i = 0; i < n_boundary; i++) { for (j = 0; j < ns_in2; j++) { for (k = 1; k <= ns_in2; k++) { - /* vertical edge between (j, k) and (j+1, k) */ + /* Vertical edge between (j, k) and (j+1, k). */ avg4(co, mesh_vert(vm_in, i, j, k), mesh_vert(vm_in, i, j + 1, k), @@ -3872,11 +3906,11 @@ static VMesh *cubic_subdiv(BevelParams *bp, VMesh *vm_in) } } - /* The new horizontal edge vertices */ + /* The new horizontal edge vertices. */ for (i = 0; i < n_boundary; i++) { for (j = 1; j < ns_in2; j++) { for (k = 0; k < ns_in2; k++) { - /* horizontal edge between (j, k) and (j, k+1) */ + /* Horizontal edge between (j, k) and (j, k+1). */ avg4(co, mesh_vert(vm_in, i, j, k), mesh_vert(vm_in, i, j, k + 1), @@ -3887,26 +3921,26 @@ static VMesh *cubic_subdiv(BevelParams *bp, VMesh *vm_in) } } - /* The new vertices, not on border */ + /* The new vertices, not on border. */ gamma = 0.25f; beta = -gamma; for (i = 0; i < n_boundary; i++) { for (j = 1; j < ns_in2; j++) { for (k = 1; k <= ns_in2; k++) { - /* co1 = centroid of adjacent new edge verts */ + /* co1 = centroid of adjacent new edge verts. */ avg4(co1, mesh_vert_canon(vm_out, i, 2 * j, 2 * k - 1), mesh_vert_canon(vm_out, i, 2 * j, 2 * k + 1), mesh_vert_canon(vm_out, i, 2 * j - 1, 2 * k), mesh_vert_canon(vm_out, i, 2 * j + 1, 2 * k)); - /* co2 = centroid of adjacent new face verts */ + /* co2 = centroid of adjacent new face verts. */ avg4(co2, mesh_vert_canon(vm_out, i, 2 * j - 1, 2 * k - 1), mesh_vert_canon(vm_out, i, 2 * j + 1, 2 * k - 1), mesh_vert_canon(vm_out, i, 2 * j - 1, 2 * k + 1), mesh_vert_canon(vm_out, i, 2 * j + 1, 2 * k + 1)); - /* combine with original vert with alpha, beta, gamma factors */ - copy_v3_v3(co, co1); /* alpha = 1.0 */ + /* Combine with original vert with alpha, beta, gamma factors. */ + copy_v3_v3(co, co1); /* Alpha = 1.0. */ madd_v3_v3fl(co, co2, beta); madd_v3_v3fl(co, mesh_vert(vm_in, i, j, k)->co, gamma); copy_v3_v3(mesh_vert(vm_out, i, 2 * j, 2 * k)->co, co); @@ -3916,10 +3950,10 @@ static VMesh *cubic_subdiv(BevelParams *bp, VMesh *vm_in) vmesh_copy_equiv_verts(vm_out); - /* The center vertex is special */ + /* The center vertex is special. */ gamma = sabin_gamma(n_boundary); beta = -gamma; - /* accumulate edge verts in co1, face verts in co2 */ + /* Accumulate edge verts in co1, face verts in co2. */ zero_v3(co1); zero_v3(co2); for (i = 0; i < n_boundary; i++) { @@ -3935,7 +3969,7 @@ static VMesh *cubic_subdiv(BevelParams *bp, VMesh *vm_in) copy_v3_v3(mesh_vert(vm_out, i, ns_in, ns_in)->co, co); } - /* Final step: Copy the profile vertices to the VMesh's boundary */ + /* Final step: Copy the profile vertices to the VMesh's boundary. */ bndv = vm_out->boundstart; for (i = 0; i < n_boundary; i++) { inext = (i + 1) % n_boundary; @@ -3952,7 +3986,7 @@ static VMesh *cubic_subdiv(BevelParams *bp, VMesh *vm_in) return vm_out; } -/* Special case for cube corner, when r is PRO_SQUARE_R, meaning straight sides */ +/* Special case for cube corner, when r is PRO_SQUARE_R, meaning straight sides. */ static VMesh *make_cube_corner_square(MemArena *mem_arena, int nseg) { VMesh *vm; @@ -3984,10 +4018,12 @@ static VMesh *make_cube_corner_square(MemArena *mem_arena, int nseg) return vm; } -/* Special case for cube corner, when r is PRO_SQUARE_IN_R, meaning inward +/** + * Special case for cube corner, when r is PRO_SQUARE_IN_R, meaning inward * straight sides. * We mostly don't want a VMesh at all for this case -- just a three-way weld - * with a triangle in the middle for odd nseg */ + * with a triangle in the middle for odd nseg. + */ static VMesh *make_cube_corner_square_in(MemArena *mem_arena, int nseg) { VMesh *vm; @@ -3998,7 +4034,7 @@ static VMesh *make_cube_corner_square_in(MemArena *mem_arena, int nseg) ns2 = nseg / 2; odd = nseg % 2; vm = new_adj_vmesh(mem_arena, 3, nseg, NULL); - vm->count = 0; // reset, so following loop will end up with correct count + vm->count = 0; /* Reset, so following loop will end up with correct count. */ for (i = 0; i < 3; i++) { zero_v3(co); co[i] = 1.0f; @@ -4025,7 +4061,8 @@ static VMesh *make_cube_corner_square_in(MemArena *mem_arena, int nseg) return vm; } -/* Make a VMesh with nseg segments that covers the unit radius sphere octant +/** + * Make a VMesh with nseg segments that covers the unit radius sphere octant * with center at (0,0,0). * This has BoundVerts at (1,0,0), (0,1,0) and (0,0,1), with quarter circle arcs * on the faces for the orthogonal planes through the origin. @@ -4049,7 +4086,7 @@ static VMesh *make_cube_corner_adj_vmesh(BevelParams *bp) } } - /* Initial mesh has 3 sides and 2 segments on each side */ + /* Initial mesh has 3 sides and 2 segments on each side. */ vm0 = new_adj_vmesh(mem_arena, 3, 2, NULL); vm0->count = 0; /* Reset, so the following loop will end up with correct count. */ for (i = 0; i < 3; i++) { @@ -4059,7 +4096,7 @@ static VMesh *make_cube_corner_adj_vmesh(BevelParams *bp) } bndv = vm0->boundstart; for (i = 0; i < 3; i++) { - /* Get point, 1/2 of the way around profile, on arc between this and next */ + /* Get point, 1/2 of the way around profile, on arc between this and next. */ coc[i] = 1.0f; coc[(i + 1) % 3] = 1.0f; coc[(i + 2) % 3] = 0.0f; @@ -4074,12 +4111,12 @@ static VMesh *make_cube_corner_adj_vmesh(BevelParams *bp) /* Calculate profiles again because we started over with new boundverts. */ calculate_profile(bp, bndv, false, false); /* No custom profiles in this case. */ - /* Just building the boundaries here, so sample the profile halfway through */ + /* Just building the boundaries here, so sample the profile halfway through. */ get_profile_point(bp, &bndv->profile, 1, 2, mesh_vert(vm0, i, 0, 1)->co); bndv = bndv->next; } - /* center vertex */ + /* Center vertex. */ copy_v3_fl(co, (float)M_SQRT1_3); if (nseg > 2) { @@ -4102,7 +4139,7 @@ static VMesh *make_cube_corner_adj_vmesh(BevelParams *bp) vm1 = interp_vmesh(bp, vm1, nseg); } - /* Now snap each vertex to the superellipsoid */ + /* Now snap each vertex to the superellipsoid. */ ns2 = nseg / 2; for (i = 0; i < 3; i++) { for (j = 0; j <= ns2; j++) { @@ -4165,7 +4202,6 @@ static VMesh *tri_corner_adj_vmesh(BevelParams *bp, BevVert *bv) VMesh *vm; BoundVert *bndv; - /*BLI_assert(bv->edgecount == 3 && bv->selcount == 3); Add support for in plane edges */ bndv = bv->vmesh->boundstart; copy_v3_v3(co0, bndv->nv.co); bndv = bndv->next; @@ -4190,7 +4226,7 @@ static VMesh *tri_corner_adj_vmesh(BevelParams *bp, BevVert *bv) return vm; } -/* Makes the mesh that replaces the original vertex, bounded by the profiles on the sides */ +/* Makes the mesh that replaces the original vertex, bounded by the profiles on the sides. */ static VMesh *adj_vmesh(BevelParams *bp, BevVert *bv) { int n_bndv, nseg, i; @@ -4202,7 +4238,7 @@ static VMesh *adj_vmesh(BevelParams *bp, BevVert *bv) n_bndv = bv->vmesh->count; - /* Same bevel as that of 3 edges of vert in a cube */ + /* Same bevel as that of 3 edges of vert in a cube. */ if (n_bndv == 3 && tri_corner_test(bp, bv) != -1 && bp->pro_super_r != PRO_SQUARE_IN_R) { return tri_corner_adj_vmesh(bp, bv); } @@ -4231,7 +4267,7 @@ static VMesh *adj_vmesh(BevelParams *bp, BevVert *bv) sub_v3_v3v3(negative_fullest, boundverts_center, original_vertex); add_v3_v3(negative_fullest, boundverts_center); - /* Find the vertex mesh's start center with the profile's fullness */ + /* Find the vertex mesh's start center with the profile's fullness. */ fullness = bp->pro_spacing.fullness; sub_v3_v3v3(center_direction, original_vertex, boundverts_center); if (len_squared_v3(center_direction) > BEVEL_EPSILON_SQ) { @@ -4259,10 +4295,12 @@ static VMesh *adj_vmesh(BevelParams *bp, BevVert *bv) return vm1; } -/* Snap co to the closest point on the profile for vpipe projected onto the plane +/** + * Snap co to the closest point on the profile for vpipe projected onto the plane * containing co with normal in the direction of edge vpipe->ebev. * For the square profiles, need to decide whether to snap to just one plane - * or to the midpoint of the profile; do so if midline is true. */ + * or to the midpoint of the profile; do so if midline is true. + */ static void snap_to_pipe_profile(BoundVert *vpipe, bool midline, float co[3]) { float va[3], vb[3], edir[3], va0[3], vb0[3], vmid0[3]; @@ -4277,7 +4315,7 @@ static void snap_to_pipe_profile(BoundVert *vpipe, bool midline, float co[3]) return; } - /* Get a plane with the normal pointing along the beveled edge */ + /* Get a plane with the normal pointing along the beveled edge. */ sub_v3_v3v3(edir, e->e->v1->co, e->e->v2->co); plane_from_point_normal_v3(plane, co, edir); @@ -4285,7 +4323,7 @@ static void snap_to_pipe_profile(BoundVert *vpipe, bool midline, float co[3]) closest_to_plane_v3(vb0, plane, vb); closest_to_plane_v3(vmid0, plane, pro->middle); if (make_unit_square_map(va0, vmid0, vb0, m) && invert_m4_m4(minv, m)) { - /* Transform co and project it onto superellipse */ + /* Transform co and project it onto superellipse. */ mul_v3_m4v3(p, minv, co); snap_to_superellipsoid(p, pro->super_r, midline); @@ -4293,7 +4331,7 @@ static void snap_to_pipe_profile(BoundVert *vpipe, bool midline, float co[3]) copy_v3_v3(co, snap); } else { - /* planar case: just snap to line va0--vb0 */ + /* Planar case: just snap to line va0--vb0. */ closest_to_line_segment_v3(p, co, va0, vb0); copy_v3_v3(co, p); } @@ -4328,6 +4366,7 @@ static VMesh *pipe_adj_vmesh(BevelParams *bp, BevVert *bv, BoundVert *vpipe) if (!is_canon(vm, i, j, k)) { continue; } + /* With a custom profile just copy the shape of the profile at each ring. */ if (bp->use_custom_profile) { /* Find both profile vertices that correspond to this point. */ if (i == ipipe1 || i == ipipe2) { @@ -4479,7 +4518,7 @@ static void build_center_ngon(BevelParams *bp, BMesh *bm, BevVert *bv, int mat_n /* Special case of bevel_build_rings when tri-corner and profile is 0. * There is no corner mesh except, if nseg odd, for a center poly. * Boundary verts merge with previous ones according to pattern: - * (i, 0, k) merged with (i+1, 0, ns-k) for k <= ns/2 */ + * (i, 0, k) merged with (i+1, 0, ns-k) for k <= ns/2. */ static void build_square_in_vmesh(BevelParams *bp, BMesh *bm, BevVert *bv, VMesh *vm1) { int n, ns, ns2, odd, i, k; @@ -4513,7 +4552,7 @@ static void build_square_in_vmesh(BevelParams *bp, BMesh *bm, BevVert *bv, VMesh } } -/* copy whichever of a and b is closer to v into r */ +/* Copy whichever of a and b is closer to v into r. */ static void closer_v3_v3v3v3(float r[3], float a[3], float b[3], float v[3]) { if (len_squared_v3v3(a, v) <= len_squared_v3v3(b, v)) { @@ -4524,7 +4563,8 @@ static void closer_v3_v3v3v3(float r[3], float a[3], float b[3], float v[3]) } } -/* Special case of VMesh when profile == 1 and there are 3 or more beveled edges. +/** + * Special case of VMesh when profile == 1 and there are 3 or more beveled edges. * We want the effect of parallel offset lines (n/2 of them) * on each side of the center, for even n. * Wherever they intersect with each other between two successive beveled edges, @@ -4532,8 +4572,8 @@ static void closer_v3_v3v3v3(float r[3], float a[3], float b[3], float v[3]) * We have to move the boundary edges too -- the usual method is to make one profile plane between * successive BoundVerts, but for the effect we want here, there will be two planes, * one on each side of the original edge. - * At the moment, this is not called for odd number of segments, - * though code does something if it is. + * At the moment, this is not called for odd number of segments, though code does something if it + * is. */ static VMesh *square_out_adj_vmesh(BevelParams *bp, BevVert *bv) { @@ -4557,8 +4597,8 @@ static VMesh *square_out_adj_vmesh(BevelParams *bp, BevVert *bv) centerline = MEM_mallocN((size_t)(clstride * n_bndv) * sizeof(float), "bevel"); cset = MEM_callocN((size_t)n_bndv * sizeof(bool), "bevel"); - /* find on_edge, place on bndv[i]'s elast where offset line would meet, - * taking min-distance-to bv->v with position where next sector's offset line would meet */ + /* Find on_edge, place on bndv[i]'s elast where offset line would meet, + * taking min-distance-to bv->v with position where next sector's offset line would meet. */ bndv = vm->boundstart; for (i = 0; i < n_bndv; i++) { copy_v3_v3(bndco, bndv->nv.co); @@ -4577,7 +4617,7 @@ static VMesh *square_out_adj_vmesh(BevelParams *bp, BevVert *bv) cset[i] = true; bndv = bndv->next; i++; - /* leave cset[i] where it was - probably false, unless i == n - 1 */ + /* Leave cset[i] where it was - probably false, unless i == n - 1. */ } else if (bndv->is_arc_start) { e1 = bndv->efirst; @@ -4586,24 +4626,24 @@ static VMesh *square_out_adj_vmesh(BevelParams *bp, BevVert *bv) bndv = bndv->next; cset[i] = true; i++; - /* leave cset[i] where it was - probably false, unless i == n - 1 */ + /* Leave cset[i] where it was - probably false, unless i == n - 1. */ } else if (ang_kind == ANGLE_SMALLER) { sub_v3_v3v3(dir1, e1->e->v1->co, e1->e->v2->co); sub_v3_v3v3(dir2, e2->e->v1->co, e2->e->v2->co); add_v3_v3v3(co1, bndco, dir1); add_v3_v3v3(co2, bndco, dir2); - /* intersect e1 with line through bndv parallel to e2 to get v1co */ + /* Intersect e1 with line through bndv parallel to e2 to get v1co. */ ikind = isect_line_line_v3(e1->e->v1->co, e1->e->v2->co, bndco, co2, meet1, meet2); if (ikind == 0) { v1set = false; } else { - /* if the lines are skew (ikind == 2), want meet1 which is on e1 */ + /* If the lines are skew (ikind == 2), want meet1 which is on e1. */ copy_v3_v3(v1co, meet1); v1set = true; } - /* intersect e2 with line through bndv parallel to e1 to get v2co */ + /* Intersect e2 with line through bndv parallel to e1 to get v2co. */ ikind = isect_line_line_v3(e2->e->v1->co, e2->e->v2->co, bndco, co1, meet1, meet2); if (ikind == 0) { v2set = false; @@ -4613,7 +4653,7 @@ static VMesh *square_out_adj_vmesh(BevelParams *bp, BevVert *bv) copy_v3_v3(v2co, meet1); } - /* want on_edge[i] to be min dist to bv->v of v2co and the v1co of next iteration */ + /* We want on_edge[i] to be min dist to bv->v of v2co and the v1co of next iteration. */ on_edge_cur = centerline + clstride * i; iprev = (i == 0) ? n_bndv - 1 : i - 1; on_edge_prev = centerline + clstride * iprev; @@ -4638,7 +4678,7 @@ static VMesh *square_out_adj_vmesh(BevelParams *bp, BevVert *bv) } bndv = bndv->next; } - /* Maybe not everything was set by the previous loop */ + /* Maybe not everything was set by the previous loop. */ bndv = vm->boundstart; for (i = 0; i < n_bndv; i++) { if (!cset[i]) { @@ -4672,14 +4712,14 @@ static VMesh *square_out_adj_vmesh(BevelParams *bp, BevVert *bv) bndv = bndv->next; } - /* fill in rest of centerlines by interpolation */ + /* Fill in rest of centerlines by interpolation. */ copy_v3_v3(co2, bv->v->co); bndv = vm->boundstart; for (i = 0; i < n_bndv; i++) { if (odd) { ang = 0.5f * angle_v3v3v3(bndv->nv.co, co1, bndv->next->nv.co); if (ang > BEVEL_SMALL_ANG) { - /* finalfrac is length along arms of isosceles triangle with top angle 2*ang + /* finalfrac is the length along arms of isosceles triangle with top angle 2*ang * such that the base of the triangle is 1. * This is used in interpolation along center-line in odd case. * To avoid too big a drop from bv, cap finalfrac a 0.8 arbitrarily */ @@ -4704,7 +4744,7 @@ static VMesh *square_out_adj_vmesh(BevelParams *bp, BevVert *bv) bndv = bndv->next; } - /* coords of edges and mid or near-mid line */ + /* Coords of edges and mid or near-mid line. */ bndv = vm->boundstart; for (i = 0; i < n_bndv; i++) { copy_v3_v3(co1, bndv->nv.co); @@ -4723,7 +4763,7 @@ static VMesh *square_out_adj_vmesh(BevelParams *bp, BevVert *bv) } vmesh_copy_equiv_verts(vm); - /* fill in interior points by interpolation from edges to centerlines */ + /* Fill in interior points by interpolation from edges to centerlines. */ bndv = vm->boundstart; for (i = 0; i < n_bndv; i++) { im1 = (i == 0) ? n_bndv - 1 : i - 1; @@ -4736,7 +4776,7 @@ static VMesh *square_out_adj_vmesh(BevelParams *bp, BevVert *bv) meet1, meet2); if (ikind == 0) { - /* how can this happen? fall back on interpolation in one direction if it does */ + /* How can this happen? fall back on interpolation in one direction if it does. */ interp_v3_v3v3(mesh_vert(vm, i, j, k)->co, mesh_vert(vm, i, 0, k)->co, centerline + clstride * im1 + 3 * k, @@ -4790,8 +4830,8 @@ static void bevel_build_rings(BevelParams *bp, BMesh *bm, BevVert *bv, BoundVert } else if (tri_corner_test(bp, bv) == 1) { vm1 = tri_corner_adj_vmesh(bp, bv); - /* the PRO_SQUARE_IN_R profile has boundary edges that merge - * and no internal ring polys except possibly center ngon */ + /* The PRO_SQUARE_IN_R profile has boundary edges that merge + * and no internal ring polys except possibly center ngon. */ if (bp->pro_super_r == PRO_SQUARE_IN_R && !bp->use_custom_profile) { build_square_in_vmesh(bp, bm, bv, vm1); return; @@ -4801,13 +4841,13 @@ static void bevel_build_rings(BevelParams *bp, BMesh *bm, BevVert *bv, BoundVert vm1 = adj_vmesh(bp, bv); } - /* copy final vmesh into bv->vmesh, make BMVerts and BMFaces */ + /* Copy final vmesh into bv->vmesh, make BMVerts and BMFaces. */ vm = bv->vmesh; for (i = 0; i < n_bndv; i++) { for (j = 0; j <= ns2; j++) { for (k = 0; k <= ns; k++) { if (j == 0 && (k == 0 || k == ns)) { - continue; /* boundary corners already made */ + continue; /* Boundary corners already made. */ } if (!is_canon(vm, i, j, k)) { continue; @@ -4818,7 +4858,7 @@ static void bevel_build_rings(BevelParams *bp, BMesh *bm, BevVert *bv, BoundVert } } vmesh_copy_equiv_verts(vm); - /* make the polygons */ + /* Make the polygons. */ bndv = vm->boundstart; do { i = bndv->index; @@ -4834,7 +4874,7 @@ static void bevel_build_rings(BevelParams *bp, BMesh *bm, BevVert *bv, BoundVert /* For odd ns, make polys with lower left corner at (i,j,k) for * j in [0, ns2-1], k in [0, ns2]. And then the center ngon. * For even ns, - * j in [0, ns2-1], k in [0, ns2-1] */ + * j in [0, ns2-1], k in [0, ns2-1]. */ for (j = 0; j < ns2; j++) { for (k = 0; k < ns2 + odd; k++) { bmv1 = mesh_vert(vm, i, j, k)->v; @@ -4868,7 +4908,7 @@ static void bevel_build_rings(BevelParams *bp, BMesh *bm, BevVert *bv, BoundVert r_f = bev_create_quad(bm, bmv1, bmv2, bmv3, bmv4, f2, f2, f2, f2, mat_nr); } else { /* j == k */ - /* only one edge attached to v, since vertex_only */ + /* Only one edge attached to v, since vertex_only. */ if (e->is_seam) { r_f = bev_create_quad_ex( bm, bmv1, bmv2, bmv3, bmv4, f2, f2, f2, f2, bme, NULL, bme, NULL, mat_nr); @@ -4879,7 +4919,7 @@ static void bevel_build_rings(BevelParams *bp, BMesh *bm, BevVert *bv, BoundVert } } } - else { /* edge bevel */ + else { /* Edge bevel. */ if (odd) { if (k == ns2) { if (e && e->is_seam) { @@ -4910,7 +4950,7 @@ static void bevel_build_rings(BevelParams *bp, BMesh *bm, BevVert *bv, BoundVert } } while ((bndv = bndv->next) != vm->boundstart); - /* Fix UVs along center lines if even number of segments */ + /* Fix UVs along center lines if even number of segments. */ if (!odd) { bndv = vm->boundstart; do { @@ -4930,7 +4970,7 @@ static void bevel_build_rings(BevelParams *bp, BMesh *bm, BevVert *bv, BoundVert } } - /* center ngon */ + /* Center ngon. */ if (odd) { build_center_ngon(bp, bm, bv, mat_nr); } @@ -5040,7 +5080,7 @@ static void bevel_build_cutoff(BevelParams *bp, BMesh *bm, BevVert *bv) BLI_array_staticdeclare(bmedges, BM_DEFAULT_NGON_STACK_SIZE); BLI_array_staticdeclare(bmfaces, BM_DEFAULT_NGON_STACK_SIZE); - /* Add the first corner vertex under this boundvert */ + /* Add the first corner vertex under this boundvert. */ face_bmverts[0] = mesh_vert(bv->vmesh, i, 1, 0)->v; #ifdef DEBUG_CUSTOM_PROFILE_CUTOFF @@ -5100,12 +5140,14 @@ static void bevel_build_cutoff(BevelParams *bp, BMesh *bm, BevVert *bv) } } -/* If we make a poly out of verts around bv, snapping to rep frep, will uv poly have zero area? +/** + * If we make a poly out of verts around bv, snapping to rep frep, will uv poly have zero area? * The uv poly is made by snapping all outside-of-frep vertices to the closest edge in frep. * Assume that this function is called when the only inside-of-frep vertex is vm->boundstart. * The poly will have zero area if the distance of that first vertex to some edge e is zero, * and all the other vertices snap to e or snap to an edge - * at a point that is essentially on e too. */ + * at a point that is essentially on e too. + */ static bool is_bad_uv_poly(BevVert *bv, BMFace *frep) { BoundVert *v; @@ -5160,8 +5202,8 @@ static BMFace *bevel_build_poly(BevelParams *bp, BMesh *bm, BevVert *bv) bndv = vm->boundstart; n = 0; do { - /* accumulate vertices for vertex ngon */ - /* also accumulate faces in which uv interpolation is to happen for each */ + /* Accumulate vertices for vertex ngon. */ + /* Also accumulate faces in which uv interpolation is to happen for each. */ BLI_array_append(bmverts, bndv->nv.v); if (repface) { BLI_array_append(bmfaces, repface); @@ -5211,7 +5253,7 @@ static void bevel_build_trifan(BevelParams *bp, BMesh *bm, BevVert *bv) f = bevel_build_poly(bp, bm, bv); if (f) { - /* we have a polygon which we know starts at the previous vertex, make it into a fan */ + /* We have a polygon which we know starts at the previous vertex, make it into a fan. */ BMLoop *l_fan = BM_FACE_FIRST_LOOP(f)->prev; BMVert *v_fan = l_fan->v; @@ -5238,7 +5280,7 @@ static void bevel_build_trifan(BevelParams *bp, BMesh *bm, BevVert *bv) } } else { - if (l_fan->v == v_fan) { /* l_fan = l_fan; */ + if (l_fan->v == v_fan) { /* l_fan = l_fan. */ } else if (l_fan->next->v == v_fan) { l_fan = l_fan->next; @@ -5373,7 +5415,7 @@ static void build_vmesh(BevelParams *bp, BMesh *bm, BevVert *bv) for (k = 1; k < ns; k++) { if (bndv->ebev) { get_profile_point(bp, &bndv->profile, k, ns, co); - copy_v3_v3(mesh_vert(vm, i, 0, k)->co, co); /* Get NewVert location from profile coord */ + copy_v3_v3(mesh_vert(vm, i, 0, k)->co, co); if (!weld) { /* This is done later with (possibly) better positions for the weld case. */ create_mesh_bmvert(bm, vm, i, 0, k, bv->v); @@ -5454,7 +5496,7 @@ static void build_vmesh(BevelParams *bp, BMesh *bm, BevVert *bv) static float edge_face_angle(EdgeHalf *e) { if (e->fprev && e->fnext) { - /* angle between faces is supplement of angle between face normals */ + /* Angle between faces is supplement of angle between face normals. */ return (float)M_PI - angle_normalized_v3v3(e->fprev->no, e->fnext->no); } else { @@ -5462,18 +5504,20 @@ static float edge_face_angle(EdgeHalf *e) } } -/* take care, this flag isn't cleared before use, it just so happens that its not set */ +/* Take care, this flag isn't cleared before use, it just so happens that its not set. */ #define BM_BEVEL_EDGE_TAG_ENABLE(bme) BM_ELEM_API_FLAG_ENABLE((bme), _FLAG_OVERLAP) #define BM_BEVEL_EDGE_TAG_DISABLE(bme) BM_ELEM_API_FLAG_DISABLE((bme), _FLAG_OVERLAP) #define BM_BEVEL_EDGE_TAG_TEST(bme) BM_ELEM_API_FLAG_TEST((bme), _FLAG_OVERLAP) -/* Try to extend the bv->edges[] array beyond i by finding more successor edges. +/** + * Try to extend the bv->edges[] array beyond i by finding more successor edges. * This is a possibly exponential-time search, but it is only exponential in the number * of "internal faces" at a vertex -- i.e., faces that bridge between the edges that naturally * form a manifold cap around bv. It is rare to have more than one of these, so unlikely * that the exponential time case will be hit in practice. * Returns the new index i' where bv->edges[i'] ends the best path found. - * The path will have the tags of all of its edges set. */ + * The path will have the tags of all of its edges set. + */ static int bevel_edge_order_extend(BMesh *bm, BevVert *bv, int i) { BMEdge *bme, *bme2, *nextbme; @@ -5482,11 +5526,11 @@ static int bevel_edge_order_extend(BMesh *bm, BevVert *bv, int i) int j, tryj, bestj, nsucs, sucindex, k; BMEdge **sucs = NULL; BMEdge **save_path = NULL; - BLI_array_staticdeclare(sucs, 4); /* likely very few faces attached to same edge */ + BLI_array_staticdeclare(sucs, 4); /* Likely very few faces attached to same edge. */ BLI_array_staticdeclare(save_path, BM_DEFAULT_NGON_STACK_SIZE); bme = bv->edges[i].e; - /* fill sucs with all unmarked edges of bmes */ + /* Fill sucs with all unmarked edges of bmesh. */ BM_ITER_ELEM (l, &iter, bme, BM_LOOPS_OF_EDGE) { bme2 = (l->v == bv->v) ? l->prev->e : l->next->e; if (!BM_BEVEL_EDGE_TAG_TEST(bme2)) { @@ -5512,16 +5556,16 @@ static int bevel_edge_order_extend(BMesh *bm, BevVert *bv, int i) BLI_array_append(save_path, bv->edges[k].e); } } - /* now reset to path only-going-to-j state */ + /* Now reset to path only-going-to-j state. */ for (k = j + 1; k <= tryj; k++) { BM_BEVEL_EDGE_TAG_DISABLE(bv->edges[k].e); bv->edges[k].e = NULL; } } - /* at this point we should be back at invariant on entrance: path up to j */ + /* At this point we should be back at invariant on entrance: path up to j. */ if (bestj > j) { - /* save_path should have from j + 1 to bestj inclusive - * edges to add to edges[] before returning. */ + /* Save_path should have from j + 1 to bestj inclusive. + * Edges to add to edges[] before returning. */ for (k = j + 1; k <= bestj; k++) { BLI_assert(save_path[k - (j + 1)] != NULL); bv->edges[k].e = save_path[k - (j + 1)]; @@ -5590,17 +5634,17 @@ static bool fast_bevel_edge_order(BevVert *bv) ntot = bv->edgecount; - /* add edges to bv->edges in order that keeps adjacent edges sharing - * a unique face, if possible */ + /* Add edges to bv->edges in order that keeps adjacent edges sharing + * a unique face, if possible. */ e = &bv->edges[0]; bme = e->e; if (!bme->l) { return false; } for (i = 1; i < ntot; i++) { - /* find an unflagged edge bme2 that shares a face f with previous bme */ + /* Find an unflagged edge bme2 that shares a face f with previous bme. */ num_shared_face = 0; - first_suc = NULL; /* keep track of first successor to match legacy behavior */ + first_suc = NULL; /* Keep track of first successor to match legacy behavior. */ BM_ITER_ELEM (bme2, &iter, bv->v, BM_EDGES_OF_VERT) { if (BM_BEVEL_EDGE_TAG_TEST(bme2)) { continue; @@ -5635,9 +5679,8 @@ static bool fast_bevel_edge_order(BevVert *bv) #endif /* Fill in bv->edges with a good ordering of non-wire edges around bv->v. - * Use only edges where BM_BEVEL_EDGE_TAG is disabled so far - * (if edge beveling, others are wire). - * first_bme is a good edge to start with.*/ + * Use only edges where BM_BEVEL_EDGE_TAG is disabled so far (if edge beveling, others are wire). + * first_bme is a good edge to start with. */ static void find_bevel_edge_order(BMesh *bm, BevVert *bv, BMEdge *first_bme) { BMEdge *bme, *bme2; @@ -5662,7 +5705,7 @@ static void find_bevel_edge_order(BMesh *bm, BevVert *bv, BMEdge *first_bme) if (i >= bv->edgecount) { break; } - /* Not done yet: find a new first_bme */ + /* Not done yet: find a new first_bme. */ first_bme = NULL; BM_ITER_ELEM (bme, &iter, bv->v, BM_EDGES_OF_VERT) { if (BM_BEVEL_EDGE_TAG_TEST(bme)) { @@ -5677,7 +5720,7 @@ static void find_bevel_edge_order(BMesh *bm, BevVert *bv, BMEdge *first_bme) } } } - /* now fill in the faces ... */ + /* Now fill in the faces. */ for (i = 0; i < ntot; i++) { e = &bv->edges[i]; e2 = (i == bv->edgecount - 1) ? &bv->edges[0] : &bv->edges[i + 1]; @@ -5705,7 +5748,7 @@ static void find_bevel_edge_order(BMesh *bm, BevVert *bv, BMEdge *first_bme) } } -/* Construction around the vertex */ +/* Construction around the vertex. */ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v) { BMEdge *bme; @@ -5728,8 +5771,7 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v) * There may be one or more chains of shared faces broken by * gaps where there are no faces. * Want to ignore wire edges completely for edge beveling. - * TODO: make following work when more than one gap. - */ + * TODO: make following work when more than one gap. */ first_bme = NULL; BM_ITER_ELEM (bme, &iter, v, BM_EDGES_OF_VERT) { @@ -5743,7 +5785,7 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v) } } if (fcnt == 1) { - /* good to start face chain from this edge */ + /* Good to start face chain from this edge. */ first_bme = bme; } if (fcnt > 0 || bp->vertex_only) { @@ -5763,7 +5805,7 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v) } if ((nsel == 0 && !bp->vertex_only) || (ntot < 2 && bp->vertex_only)) { - /* signal this vert isn't being beveled */ + /* Signal this vert isn't being beveled. */ BM_elem_flag_disable(v, BM_ELEM_TAG); return NULL; } @@ -5788,7 +5830,7 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v) find_bevel_edge_order(bm, bv, first_bme); - /* fill in other attributes of EdgeHalfs */ + /* Fill in other attributes of EdgeHalfs. */ for (i = 0; i < ntot; i++) { e = &bv->edges[i]; bme = e->e; @@ -5805,13 +5847,13 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v) e->profile_index = 0; } - /* now done with tag flag */ + /* Now done with tag flag. */ BM_ITER_ELEM (bme, &iter, v, BM_EDGES_OF_VERT) { BM_BEVEL_EDGE_TAG_DISABLE(bme); } - /* if edge array doesn't go CCW around vertex from average normal side, - * reverse the array, being careful to reverse face pointers too */ + /* If edge array doesn't go CCW around vertex from average normal side, + * reverse the array, being careful to reverse face pointers too. */ if (ntot > 1) { ccw_test_sum = 0; for (i = 0; i < ntot; i++) { @@ -5832,7 +5874,7 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v) } if (bp->vertex_only) { - /* if weighted, modify offset by weight */ + /* If weighted, modify offset by weight. */ if (bp->dvert != NULL && bp->vertex_group != -1) { weight = defvert_find_weight(bp->dvert + BM_elem_index_get(v), bp->vertex_group); bv->offset *= weight; @@ -5857,7 +5899,7 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v) e->next = &bv->edges[(i + 1) % ntot]; e->prev = &bv->edges[(i + ntot - 1) % ntot]; - /* set offsets */ + /* Set offsets. */ if (e->is_bev) { /* Convert distance as specified by user into offsets along * faces on left side and right side of this edgehalf. @@ -5870,7 +5912,7 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v) case BEVEL_AMT_WIDTH: z = fabsf(2.0f * sinf(edge_face_angle(e) / 2.0f)); if (z < BEVEL_EPSILON) { - e->offset_l_spec = 0.01f * bp->offset; /* undefined behavior, so tiny bevel */ + e->offset_l_spec = 0.01f * bp->offset; /* Undefined behavior, so tiny bevel. */ } else { e->offset_l_spec = bp->offset / z; @@ -5879,14 +5921,15 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v) case BEVEL_AMT_DEPTH: z = fabsf(cosf(edge_face_angle(e) / 2.0f)); if (z < BEVEL_EPSILON) { - e->offset_l_spec = 0.01f * bp->offset; /* undefined behavior, so tiny bevel */ + e->offset_l_spec = 0.01f * bp->offset; /* Undefined behavior, so tiny bevel. */ } else { e->offset_l_spec = bp->offset / z; } break; case BEVEL_AMT_PERCENT: - /* offset needs to be such that it meets adjacent edges at percentage of their lengths */ + /* Offset needs to be such that it meets adjacent edges at percentage of their lengths. + */ v1 = BM_edge_other_vert(e->prev->e, v); v2 = BM_edge_other_vert(e->e, v); z = sinf(angle_v3v3v3(v1->co, v->co, v2->co)); @@ -5924,7 +5967,7 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v) sub_v3_v3v3(edge_dir, bv->v->co, v2->co); z = fabsf(2.0f * sinf(angle_v3v3(vert_axis, edge_dir))); if (z < BEVEL_EPSILON) { - e->offset_l_spec = 0.01f * bp->offset; /* undefined behavior, so tiny bevel. */ + e->offset_l_spec = 0.01f * bp->offset; /* Undefined behavior, so tiny bevel. */ } else { e->offset_l_spec = bp->offset / z; @@ -5936,7 +5979,7 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v) sub_v3_v3v3(edge_dir, bv->v->co, v2->co); z = fabsf(cosf(angle_v3v3(vert_axis, edge_dir))); if (z < BEVEL_EPSILON) { - e->offset_l_spec = 0.01f * bp->offset; /* undefined behavior, so tiny bevel. */ + e->offset_l_spec = 0.01f * bp->offset; /* Undefined behavior, so tiny bevel. */ } else { e->offset_l_spec = bp->offset / z; @@ -5978,7 +6021,7 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v) return bv; } -/* Face f has at least one beveled vertex. Rebuild f */ +/* Face f has at least one beveled vertex. Rebuild f. */ static bool bev_rebuild_polygon(BMesh *bm, BevelParams *bp, BMFace *f) { BMIter liter, eiter, fiter; @@ -6011,28 +6054,28 @@ static bool bev_rebuild_polygon(BMesh *bm, BevelParams *bp, BMFace *f) eprev = find_edge_half(bv, lprev->e); BLI_assert(eprev != NULL); - /* which direction around our vertex do we travel to match orientation of f? */ + /* Which direction around our vertex do we travel to match orientation of f? */ if (e->prev == eprev) { if (eprev->prev == e) { - /* valence 2 vertex: use f is one of e->fnext or e->fprev to break tie */ + /* Valence 2 vertex: use f is one of e->fnext or e->fprev to break tie. */ go_ccw = (e->fnext != f); } else { - go_ccw = true; /* going ccw around bv to trace this corner */ + go_ccw = true; /* Going ccw around bv to trace this corner. */ } } else if (eprev->prev == e) { - go_ccw = false; /* going cw around bv to trace this corner */ + go_ccw = false; /* Going cw around bv to trace this corner. */ } else { - /* edges in face are non-contiguous in our ordering around bv. + /* Edges in face are non-contiguous in our ordering around bv. * Which way should we go when going from eprev to e? */ if (count_ccw_edges_between(eprev, e) < count_ccw_edges_between(e, eprev)) { - /* go counterclockewise from eprev to e */ + /* Go counterclockewise from eprev to e. */ go_ccw = true; } else { - /* go clockwise from eprev to e */ + /* Go clockwise from eprev to e. */ go_ccw = false; } } @@ -6060,7 +6103,7 @@ static bool bev_rebuild_polygon(BMesh *bm, BevelParams *bp, BMFace *f) BLI_array_append(ee, bme); } while (v != vend) { - /* check for special case: multisegment 3rd face opposite a beveled edge with no vmesh */ + /* Check for special case: multisegment 3rd face opposite a beveled edge with no vmesh. */ corner3special = (vm->mesh_kind == M_NONE && v->ebev != e && v->ebev != eprev); if (go_ccw) { i = v->index; @@ -6081,7 +6124,7 @@ static bool bev_rebuild_polygon(BMesh *bm, BevelParams *bp, BMFace *f) bmv = mesh_vert(vm, i, 0, k)->v; if (bmv) { BLI_array_append(vv, bmv); - BLI_array_append(ee, bme); /* TODO: maybe better edge here */ + BLI_array_append(ee, bme); /* TODO: Maybe better edge here. */ if (corner3special && v->ebev && !v->ebev->is_seam && k != vm->seg) { BLI_array_append(vv_fix, bmv); } @@ -6090,7 +6133,7 @@ static bool bev_rebuild_polygon(BMesh *bm, BevelParams *bp, BMFace *f) v = v->next; } else { - /* going cw */ + /* Going cw. */ i = v->prev->index; if (on_profile_start) { kstart = eprev->profile_index; @@ -6133,7 +6176,7 @@ static bool bev_rebuild_polygon(BMesh *bm, BevelParams *bp, BMFace *f) bev_merge_uvs(bm, vv_fix[k]); } - /* copy attributes from old edges */ + /* Copy attributes from old edges. */ BLI_assert(n == BLI_array_len(ee)); bme_prev = ee[n - 1]; for (k = 0; k < n; k++) { @@ -6141,14 +6184,14 @@ static bool bev_rebuild_polygon(BMesh *bm, BevelParams *bp, BMFace *f) BLI_assert(ee[k] && bme_new); if (ee[k] != bme_new) { BM_elem_attrs_copy(bm, bm, ee[k], bme_new); - /* want to undo seam and smooth for corner segments - * if those attrs aren't contiguous around face */ + /* Want to undo seam and smooth for corner segments + * if those attrs aren't contiguous around face. */ if (k < n - 1 && ee[k] == ee[k + 1]) { if (BM_elem_flag_test(ee[k], BM_ELEM_SEAM) && !BM_elem_flag_test(bme_prev, BM_ELEM_SEAM)) { BM_elem_flag_disable(bme_new, BM_ELEM_SEAM); } - /* actually want "sharp" to be contiguous, so reverse the test */ + /* Actually want "sharp" to be contiguous, so reverse the test. */ if (!BM_elem_flag_test(ee[k], BM_ELEM_SMOOTH) && BM_elem_flag_test(bme_prev, BM_ELEM_SMOOTH)) { BM_elem_flag_enable(bme_new, BM_ELEM_SMOOTH); @@ -6160,11 +6203,11 @@ static bool bev_rebuild_polygon(BMesh *bm, BevelParams *bp, BMFace *f) } } - /* don't select newly or return created boundary faces... */ + /* Don't select newly or return created boundary faces. */ if (f_new) { record_face_kind(bp, f_new, F_RECON); BM_elem_flag_disable(f_new, BM_ELEM_TAG); - /* Also don't want new edges that aren't part of a new bevel face */ + /* Also don't want new edges that aren't part of a new bevel face. */ BM_ITER_ELEM (bme, &eiter, f_new, BM_EDGES_OF_FACE) { keep = false; BM_ITER_ELEM (f_other, &fiter, bme, BM_FACES_OF_EDGE) { @@ -6186,7 +6229,7 @@ static bool bev_rebuild_polygon(BMesh *bm, BevelParams *bp, BMFace *f) return do_rebuild; } -/* All polygons touching v need rebuilding because beveling v has made new vertices */ +/* All polygons touching v need rebuilding because beveling v has made new vertices. */ static void bevel_rebuild_existing_polygons(BMesh *bm, BevelParams *bp, BMVert *v) { void *faces_stack[BM_DEFAULT_ITER_STACK_SIZE]; @@ -6208,7 +6251,7 @@ static void bevel_rebuild_existing_polygons(BMesh *bm, BevelParams *bp, BMVert * } } -/* If there were any wire edges, they need to be reattached somewhere */ +/* If there were any wire edges, they need to be reattached somewhere. */ static void bevel_reattach_wires(BMesh *bm, BevelParams *bp, BMVert *v) { BMEdge *e; @@ -6225,7 +6268,7 @@ static void bevel_reattach_wires(BMesh *bm, BevelParams *bp, BMVert *v) for (i = 0; i < bv->wirecount; i++) { e = bv->wire_edges[i]; - /* look for the new vertex closest to the other end of e */ + /* Look for the new vertex closest to the other end of e. */ vclosest = NULL; dclosest = FLT_MAX; votherclosest = NULL; @@ -6234,7 +6277,7 @@ static void bevel_reattach_wires(BMesh *bm, BevelParams *bp, BMVert *v) if (BM_elem_flag_test(vother, BM_ELEM_TAG)) { bvother = find_bevvert(bp, vother); if (!bvother || !bvother->vmesh) { - return; /* shouldn't happen */ + return; /* Shouldn't happen. */ } } bndv = bv->vmesh->boundstart; @@ -6288,7 +6331,7 @@ static bool bevvert_is_weld_cross(BevVert *bv) (bv->edges[1].is_bev && bv->edges[3].is_bev))); } -/* +/** * Copy edge attribute data across the non-beveled crossing edges of a cross weld. * * Situation looks like this: @@ -6305,7 +6348,7 @@ static bool bevvert_is_weld_cross(BevVert *bv) * where e is the EdgeHalf of one of the beveled edges, * e->next and e->prev are EdgeHalfs for the unbeveled edges of the cross * and their attributes are to be copied to the edges 01, 12, 23. - * The vert i is mesh_vert(vm, vmindex, 0, i)->v + * The vert i is mesh_vert(vm, vmindex, 0, i)->v. */ static void weld_cross_attrs_copy(BMesh *bm, BevVert *bv, VMesh *vm, int vmindex, EdgeHalf *e) { @@ -6415,18 +6458,18 @@ static void bevel_build_edge_polygons(BMesh *bm, BevelParams *bp, BMEdge *bme) verts[2] = mesh_vert(vm2, i2, 0, nseg - k)->v; if (odd && k == mid + 1) { if (e1->is_seam) { - /* straddles a seam: choose to interpolate in f1 and snap right edge to bme */ + /* Straddles a seam: choose to interpolate in f1 and snap right edge to bme. */ edges[0] = edges[1] = NULL; edges[2] = edges[3] = bme; r_f = bev_create_ngon(bm, verts, 4, NULL, f1, edges, mat_nr, true); } else { - /* straddles but not a seam: interpolate left half in f1, right half in f2 */ + /* Straddles but not a seam: interpolate left half in f1, right half in f2. */ r_f = bev_create_ngon(bm, verts, 4, faces, NULL, NULL, mat_nr, true); } } else if (!odd && k == mid) { - /* left poly that touches an even center line on right */ + /* Left poly that touches an even center line on right. */ edges[0] = edges[1] = NULL; edges[2] = edges[3] = bme; r_f = bev_create_ngon(bm, verts, 4, NULL, f1, edges, mat_nr, true); @@ -6434,18 +6477,18 @@ static void bevel_build_edge_polygons(BMesh *bm, BevelParams *bp, BMEdge *bme) BLI_assert(center_bme != NULL); } else if (!odd && k == mid + 1) { - /* right poly that touches an even center line on left */ + /* Right poly that touches an even center line on left. */ edges[0] = edges[1] = bme; edges[2] = edges[3] = NULL; r_f = bev_create_ngon(bm, verts, 4, NULL, f2, edges, mat_nr, true); } else { - /* doesn't cross or touch the center line, so interpolate in appropriate f1 or f2 */ + /* Doesn't cross or touch the center line, so interpolate in appropriate f1 or f2. */ f = (k <= mid) ? f1 : f2; r_f = bev_create_ngon(bm, verts, 4, NULL, f, NULL, mat_nr, true); } record_face_kind(bp, r_f, F_EDGE); - /* tag the long edges: those out of verts[0] and verts[2] */ + /* Tag the long edges: those out of verts[0] and verts[2]. */ BM_ITER_ELEM (l, &iter, r_f, BM_LOOPS_OF_FACE) { if (l->v == verts[0] || l->v == verts[2]) { BM_elem_flag_enable(l, BM_ELEM_LONG_TAG); @@ -6463,8 +6506,8 @@ static void bevel_build_edge_polygons(BMesh *bm, BevelParams *bp, BMEdge *bme) } } - /* Fix UVs along end edge joints. A nop unless other side built already. */ - /* TODO: if some seam, may want to do selective merge */ + /* Fix UVs along end edge joints. A nop unless other side built already. */ + /* TODO: If some seam, may want to do selective merge. */ if (!bv1->any_seam && bv1->vmesh->mesh_kind == M_NONE) { bev_merge_end_uvs(bm, bv1, e1); } @@ -6472,14 +6515,14 @@ static void bevel_build_edge_polygons(BMesh *bm, BevelParams *bp, BMEdge *bme) bev_merge_end_uvs(bm, bv2, e2); } - /* Copy edge data to first and last edge */ + /* Copy edge data to first and last edge. */ bme1 = BM_edge_exists(bmv1, bmv2); bme2 = BM_edge_exists(bmv3, bmv4); BLI_assert(bme1 && bme2); BM_elem_attrs_copy(bm, bm, bme, bme1); BM_elem_attrs_copy(bm, bm, bme, bme2); - /* If either end is a "weld cross", want continuity of edge attributes across end edge(s) */ + /* If either end is a "weld cross", want continuity of edge attributes across end edge(s). */ if (bevvert_is_weld_cross(bv1)) { weld_cross_attrs_copy(bm, bv1, vm1, i1, e1); } @@ -6491,18 +6534,16 @@ static void bevel_build_edge_polygons(BMesh *bm, BevelParams *bp, BMEdge *bme) /* Find xnew > x0 so that distance((x0,y0), (xnew, ynew)) = dtarget. * False position Illinois method used because the function is somewhat linear * -> linear interpolation converges fast. - * Assumes that the gradient is always between 1 and -1 for - * x in [x0, x0+dtarget] */ + * Assumes that the gradient is always between 1 and -1 for x in [x0, x0+dtarget]. */ static double find_superellipse_chord_endpoint(double x0, double dtarget, float r, bool rbig) { double xmin, xmax, ymin, ymax, dmaxerr, dminerr, dnewerr, xnew, ynew; double y0 = superellipse_co(x0, r, rbig); - const double tol = 1e-13; // accumulates for many segments so use low value + const double tol = 1e-13; /* accumulates for many segments so use low value. */ const int maxiter = 10; bool lastupdated_upper; - /* For gradient between -1 and 1, xnew can only be in - * [x0 + sqrt(2)/2*dtarget, x0 + dtarget]. */ + /* For gradient between -1 and 1, xnew can only be in [x0 + sqrt(2)/2*dtarget, x0 + dtarget]. */ xmin = x0 + M_SQRT2 / 2.0 * dtarget; if (xmin > 1.0) { xmin = 1.0; @@ -6569,7 +6610,7 @@ static void find_even_superellipse_chords_general(int seg, float r, double *xval const int smoothitermax = 10; const double error_tol = 1e-7; int i; - int imax = (seg + 1) / 2 - 1; /* ceiling division - 1 */ + int imax = (seg + 1) / 2 - 1; /* Ceiling division - 1. */ double d, dmin, dmax; double davg; @@ -6597,7 +6638,7 @@ static void find_even_superellipse_chords_general(int seg, float r, double *xval } yvals[0] = 1; - /* Smooth distance loop */ + /* Smooth distance loop. */ for (int iter = 0; iter < smoothitermax; iter++) { sum = 0.0; dmin = 2.0; @@ -6666,8 +6707,8 @@ static void find_even_superellipse_chords_general(int seg, float r, double *xval * function in the first quadrant. For special profiles (linear, arc, * rectangle) the point can be calculated easily, for any other profile a more * expensive search procedure must be used because there is no known closed - * form for equidistant parametrization - * xvals and yvals should be size n+1 + * form for equidistant parametrization. + * xvals and yvals should be size n+1. */ static void find_even_superellipse_chords(int n, float r, double *xvals, double *yvals) { @@ -6679,7 +6720,7 @@ static void find_even_superellipse_chords(int n, float r, double *xvals, double /* Special cases. */ if (r == PRO_LINE_R) { - /* Linear spacing */ + /* Linear spacing. */ for (i = 0; i <= n; i++) { xvals[i] = (double)i / n; yvals[i] = 1.0 - (double)i / n; @@ -6807,7 +6848,8 @@ static float find_profile_fullness(BevelParams *bp) * Use doubles because otherwise we cannot come close to float precision for final results. * * \param pro_spacing: The struct to fill. Changes depending on whether there needs - * to be a separate miter profile. */ + * to be a separate miter profile. + */ static void set_profile_spacing(BevelParams *bp, ProfileSpacing *pro_spacing, bool custom) { int seg, seg_2; @@ -6866,7 +6908,7 @@ static void set_profile_spacing(BevelParams *bp, ProfileSpacing *pro_spacing, bo } } } - else { /* Only 1 segment, we don't need any profile information */ + else { /* Only 1 segment, we don't need any profile information. */ pro_spacing->xvals = NULL; pro_spacing->yvals = NULL; pro_spacing->xvals_2 = NULL; @@ -6875,7 +6917,7 @@ static void set_profile_spacing(BevelParams *bp, ProfileSpacing *pro_spacing, bo } } -/* +/** * Assume we have a situation like: * * a d @@ -6885,8 +6927,7 @@ static void set_profile_spacing(BevelParams *bp, ProfileSpacing *pro_spacing, bo * b---------c * B * - * where edges are A, B, and C, - * following a face around vertices a, b, c, d; + * where edges are A, B, and C, following a face around vertices a, b, c, d. * th1 is angle abc and th2 is angle bcd; * and the argument EdgeHalf eb is B, going from b to c. * In general case, edge offset specs for A, B, C have @@ -6911,7 +6952,7 @@ static float geometry_collide_offset(BevelParams *bp, EdgeHalf *eb) return no_collide_offset; } kb = eb->offset_l_spec; - ea = eb->next; /* note: this is in direction b --> a */ + ea = eb->next; /* Note: this is in direction b --> a. */ ka = ea->offset_r_spec; if (eb->is_rev) { vc = eb->e->v1; @@ -6925,16 +6966,16 @@ static float geometry_collide_offset(BevelParams *bp, EdgeHalf *eb) bvc = NULL; ebother = find_other_end_edge_half(bp, eb, &bvc); if (ebother != NULL) { - ec = ebother->prev; /* note: this is in direction c --> d*/ + ec = ebother->prev; /* Note: this is in direction c --> d. */ vc = bvc->v; kc = ec->offset_l_spec; vd = ec->is_rev ? ec->e->v1 : ec->e->v2; } else { - /* No bevvert for w, so C can't be beveled */ + /* No bevvert for w, so C can't be beveled. */ kc = 0.0f; ec = NULL; - /* Find an edge from c that has same face */ + /* Find an edge from c that has same face. */ lb = BM_face_edge_share_loop(eb->fnext, eb->e); if (!lb) { return no_collide_offset; @@ -6960,7 +7001,7 @@ static float geometry_collide_offset(BevelParams *bp, EdgeHalf *eb) /* First calculate offset at which edge B collapses, which happens * when advancing clones of A, B, C all meet at a point. - * This only happens if at least two of those three edges have non-zero k's */ + * This only happens if at least two of those three edges have non-zero k's. */ sin1 = sinf(th1); sin2 = sinf(th2); if ((ka > 0.0f) + (kb > 0.0f) + (kc > 0.0f) >= 2) { @@ -6978,8 +7019,8 @@ static float geometry_collide_offset(BevelParams *bp, EdgeHalf *eb) } } - /* Now check edge slide cases */ - if (kb > 0.0f && ka == 0.0f /*&& bvb->selcount == 1 && bvb->edgecount > 2*/) { + /* Now check edge slide cases. */ + if (kb > 0.0f && ka == 0.0f /*&& bvb->selcount == 1 && bvb->edgecount > 2 */) { t = BM_edge_calc_length(ea->e); t *= sin1 / kb; if (t >= 0.0f && t < limit) { @@ -6996,11 +7037,9 @@ static float geometry_collide_offset(BevelParams *bp, EdgeHalf *eb) return limit; } -/* - * We have an edge A between vertices a and b, - * where EdgeHalf ea is the half of A that starts at a. - * For vertex-only bevels, the new vertices slide from a at a rate ka*t - * and from b at a rate kb*t. +/** + * We have an edge A between vertices a and b, where EdgeHalf ea is the half of A that starts at a. + * For vertex-only bevels, the new vertices slide from a at a rate ka*t and from b at a rate kb*t. * We want to calculate the t at which the two meet. */ static float vertex_collide_offset(BevelParams *bp, EdgeHalf *ea) @@ -7024,13 +7063,10 @@ static float vertex_collide_offset(BevelParams *bp, EdgeHalf *ea) return limit; } -/* - * Calculate an offset that is the lesser of the current - * bp.offset and the maximum possible offset before geometry - * collisions happen. - * If the offset changes as a result of this, adjust the - * current edge offset specs to reflect this clamping, - * and store the new offset in bp.offset. +/** + * Calculate an offset that is the lesser of the current bp.offset and the maximum possible offset + * before geometry collisions happen. If the offset changes as a result of this, adjust the current + * edge offset specs to reflect this clamping, and store the new offset in bp.offset. */ static void bevel_limit_offset(BevelParams *bp, BMesh *bm) { @@ -7142,7 +7178,7 @@ void BM_mesh_bevel(BMesh *bm, bp.offset_type = offset_type; bp.seg = (int)segments; bp.profile = profile; - bp.pro_super_r = -logf(2.0) / logf(sqrtf(profile)); /* convert to superellipse exponent */ + bp.pro_super_r = -logf(2.0) / logf(sqrtf(profile)); /* Convert to superellipse exponent. */ bp.vertex_only = vertex_only; bp.use_weights = use_weights; bp.loop_slide = loop_slide; @@ -7164,7 +7200,8 @@ void BM_mesh_bevel(BMesh *bm, bp.custom_profile = custom_profile; bp.vmesh_method = vmesh_method; - /* Disable the miters with the cutoff vertex mesh method, this combination isn't useful anyway */ + /* Disable the miters with the cutoff vertex mesh method, this combination isn't useful anyway. + */ if (bp.vmesh_method == BEVEL_VMESH_CUTOFF) { bp.miter_outer = BEVEL_MITER_SHARP; bp.miter_inner = BEVEL_MITER_SHARP; @@ -7184,18 +7221,18 @@ void BM_mesh_bevel(BMesh *bm, } if (bp.offset > 0) { - /* primary alloc */ + /* Primary alloc. */ bp.vert_hash = BLI_ghash_ptr_new(__func__); bp.mem_arena = BLI_memarena_new(MEM_SIZE_OPTIMAL(1 << 16), __func__); BLI_memarena_use_calloc(bp.mem_arena); - /* Get the 2D profile point locations from either the superellipse or the custom profile */ + /* Get the 2D profile point locations from either the superellipse or the custom profile. */ set_profile_spacing(&bp, &bp.pro_spacing, bp.use_custom_profile); if (bp.seg > 1) { bp.pro_spacing.fullness = find_profile_fullness(&bp); } - /* Get separate non-custom profile samples for the miter profiles if they are needed */ + /* Get separate non-custom profile samples for the miter profiles if they are needed. */ if (bp.use_custom_profile && (bp.miter_inner != BEVEL_MITER_SHARP || bp.miter_outer != BEVEL_MITER_SHARP)) { set_profile_spacing(&bp, &bp.pro_spacing_miter, false); @@ -7204,7 +7241,7 @@ void BM_mesh_bevel(BMesh *bm, bp.face_hash = BLI_ghash_ptr_new(__func__); BLI_ghash_flag_set(bp.face_hash, GHASH_FLAG_ALLOW_DUPES); - /* Analyze input vertices, sorting edges and assigning initial new vertex positions */ + /* Analyze input vertices, sorting edges and assigning initial new vertex positions. */ BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { if (BM_elem_flag_test(v, BM_ELEM_TAG)) { bv = bevel_vert_construct(bm, &bp, v); @@ -7214,11 +7251,11 @@ void BM_mesh_bevel(BMesh *bm, } } - /* Perhaps clamp offset to avoid geometry colliisions */ + /* Perhaps clamp offset to avoid geometry colliisions. */ if (limit_offset) { bevel_limit_offset(&bp, bm); - /* Assign initial new vertex positions */ + /* Assign initial new vertex positions. */ BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { if (BM_elem_flag_test(v, BM_ELEM_TAG)) { bv = find_bevvert(&bp, v); @@ -7229,7 +7266,7 @@ void BM_mesh_bevel(BMesh *bm, } } - /* Perhaps do a pass to try to even out widths */ + /* Perhaps do a pass to try to even out widths. */ if (!bp.vertex_only && bp.offset_adjust && bp.offset_type != BEVEL_AMT_PERCENT) { adjust_offsets(&bp, bm); } @@ -7243,7 +7280,7 @@ void BM_mesh_bevel(BMesh *bm, } } - /* Build the meshes around vertices, now that positions are final */ + /* Build the meshes around vertices, now that positions are final. */ BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { if (BM_elem_flag_test(v, BM_ELEM_TAG)) { bv = find_bevvert(&bp, v); @@ -7253,7 +7290,7 @@ void BM_mesh_bevel(BMesh *bm, } } - /* Build polygons for edges */ + /* Build polygons for edges. */ if (!bp.vertex_only) { BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) { if (BM_elem_flag_test(e, BM_ELEM_TAG)) { @@ -7262,7 +7299,7 @@ void BM_mesh_bevel(BMesh *bm, } } - /* Extend edge data like sharp edges and precompute normals for harden */ + /* Extend edge data like sharp edges and precompute normals for harden. */ BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { if (BM_elem_flag_test(v, BM_ELEM_TAG)) { bv = find_bevvert(&bp, v); @@ -7272,7 +7309,7 @@ void BM_mesh_bevel(BMesh *bm, } } - /* Rebuild face polygons around affected vertices */ + /* Rebuild face polygons around affected vertices. */ BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { if (BM_elem_flag_test(v, BM_ELEM_TAG)) { bevel_rebuild_existing_polygons(bm, &bp, v); @@ -7295,7 +7332,7 @@ void BM_mesh_bevel(BMesh *bm, } /* When called from operator (as opposed to modifier), bm->use_toolflags - * will be set, and we need to transfer the oflags to BM_ELEM_TAGs */ + * will be set, and we need to transfer the oflags to BM_ELEM_TAGs. */ if (bm->use_toolflags) { BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { if (BMO_vert_flag_test(bm, v, VERT_OUT)) { @@ -7309,7 +7346,7 @@ void BM_mesh_bevel(BMesh *bm, } } - /* clear the BM_ELEM_LONG_TAG tags, which were only set on some edges in F_EDGE faces */ + /* Clear the BM_ELEM_LONG_TAG tags, which were only set on some edges in F_EDGE faces. */ BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) { if (get_face_kind(&bp, f) != F_EDGE) { continue; @@ -7319,7 +7356,7 @@ void BM_mesh_bevel(BMesh *bm, } } - /* primary free */ + /* Primary free. */ BLI_ghash_free(bp.vert_hash, NULL, NULL); BLI_ghash_free(bp.face_hash, NULL, NULL); BLI_memarena_free(bp.mem_arena); -- cgit v1.2.3