[Bf-blender-cvs] [63ef1451483] soc-2019-bevel-profiles: Cleanup: Comments, formatting, TODOs
Hans Goudey
noreply at git.blender.org
Thu Aug 15 17:39:24 CEST 2019
Commit: 63ef145148328c13d726bf1e54c25459c206c740
Author: Hans Goudey
Date: Wed Aug 14 18:33:34 2019 -0400
Branches: soc-2019-bevel-profiles
https://developer.blender.org/rB63ef145148328c13d726bf1e54c25459c206c740
Cleanup: Comments, formatting, TODOs
===================================================================
M source/blender/bmesh/tools/bmesh_bevel.c
===================================================================
diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c
index 7d2bcb26231..428aedcbadc 100644
--- a/source/blender/bmesh/tools/bmesh_bevel.c
+++ b/source/blender/bmesh/tools/bmesh_bevel.c
@@ -59,12 +59,7 @@
#define BEVEL_MAX_AUTO_ADJUST_PCT 300.0f
#define BEVEL_MATCH_SPEC_WEIGHT 0.2
-#define DEBUG_CUSTOM_PROFILE_SAMPLE 0
-#define DEBUG_CUSTOM_PROFILE_WELD 0
-#define DEBUG_CUSTOM_PROFILE_ADJ 0
-#define DEBUG_CUSTOM_PROFILE_ORIENTATION 1
-#define DEBUG_PROFILE_ORIENTATION_DRAW
-#define DEBUG_CUSTOM_PROFILE_CUTOFF 0
+#define DEBUG_CUSTOM_PROFILE_CUTOFF
#if defined(DEBUG_PROFILE_ORIENTATION_DRAW) || defined(DEBUG_CUSTOM_PROFILE_PIPE)
static float debug_color_red[4] = {1.0f, 0.0f, 0.0f, 1.0f};
@@ -1810,9 +1805,6 @@ static void calculate_profile(BevelParams *bp, BoundVert *bndv, bool reversed, b
* 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)
{
-#if DEBUG_CUSTOM_PROFILE_ADJ
- printf("SNAP TO SUPERELLIPSOID\n");
-#endif
float a, b, c, x, y, z, r, rinv, dx, dy;
r = super_r;
if (r == PRO_CIRCLE_R) {
@@ -2037,7 +2029,7 @@ static void bevel_extend_edge_data(BevVert *bv)
} while (bcur != start);
}
-/* Mark edges as sharp if they are between a smooth recon face and a new face. */
+/* Mark edges as sharp if they are between a smooth reconstructed face and a new face. */
static void bevel_edges_sharp_boundary(BMesh *bm, BevelParams *bp)
{
BMIter fiter, liter;
@@ -2075,129 +2067,129 @@ static void bevel_edges_sharp_boundary(BMesh *bm, BevelParams *bp)
*/
static void bevel_harden_normals(BevelParams *bp, BMesh *bm)
{
- BMIter liter, fiter;
- BMFace *f;
- BMLoop *l, *lnext, *lprev, *lprevprev, *lnextnext;
- BMEdge *estep;
- FKind fkind, fprevkind, fnextkind, fprevprevkind, fnextnextkind;
- int cd_clnors_offset, l_index;
- short *clnors;
- float *pnorm, norm[3];
+ BMIter liter, fiter;
+ BMFace *f;
+ BMLoop *l, *lnext, *lprev, *lprevprev, *lnextnext;
+ BMEdge *estep;
+ FKind fkind, fprevkind, fnextkind, fprevprevkind, fnextnextkind;
+ int cd_clnors_offset, l_index;
+ short *clnors;
+ float *pnorm, norm[3];
+
+ if (bp->offset == 0.0 || !bp->harden_normals) {
+ return;
+ }
- if (bp->offset == 0.0 || !bp->harden_normals) {
- return;
- }
+ /* 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);
- /* 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);
- 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.
+ */
+ if (cd_clnors_offset == -1) {
+ BM_edges_sharp_from_angle_set(bm, bp->smoothresh);
+ bevel_edges_sharp_boundary(bm, bp);
+ }
- /* 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.
- */
- 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. */
+ BM_lnorspace_update(bm);
- /* Ensure that bm->lnor_spacearr has properly stored loop normals;
- * side effect: ensures loop indices. */
- BM_lnorspace_update(bm);
+ if (cd_clnors_offset == -1) {
+ cd_clnors_offset = CustomData_get_offset(&bm->ldata, CD_CUSTOMLOOPNORMAL);
+ }
- if (cd_clnors_offset == -1) {
- cd_clnors_offset = CustomData_get_offset(&bm->ldata, CD_CUSTOMLOOPNORMAL);
+ BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) {
+ fkind = get_face_kind(bp, f);
+ if (fkind == F_ORIG || fkind == F_RECON) {
+ continue;
+ }
+ BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
+ 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 */
+ 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;
+ pnorm = NULL;
+ if (fkind == F_EDGE) {
+ if (fprevkind == F_EDGE && BM_elem_flag_test(l, BM_ELEM_LONG_TAG)) {
+ add_v3_v3v3(norm, f->no, lprev->f->no);
+ pnorm = norm;
+ }
+ else if (fnextkind == F_EDGE && BM_elem_flag_test(lnext, BM_ELEM_LONG_TAG)) {
+ add_v3_v3v3(norm, f->no, lnext->f->no);
+ pnorm = norm;
+ }
+ else if (fprevkind == F_RECON && BM_elem_flag_test(l, BM_ELEM_LONG_TAG)) {
+ pnorm = lprev->f->no;
+ }
+ else if (fnextkind == F_RECON && BM_elem_flag_test(l->prev, BM_ELEM_LONG_TAG)) {
+ pnorm = lnext->f->no;
+ }
+ else {
+ /* printf("unexpected harden case (edge)\n"); */
+ }
}
-
- BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) {
- fkind = get_face_kind(bp, f);
- if (fkind == F_ORIG || fkind == F_RECON) {
- continue;
+ else if (fkind == F_VERT) {
+ if (fprevkind == F_VERT && fnextkind == F_VERT) {
+ pnorm = l->v->no;
}
- BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
- 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 */
- 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;
- pnorm = NULL;
- if (fkind == F_EDGE) {
- if (fprevkind == F_EDGE && BM_elem_flag_test(l, BM_ELEM_LONG_TAG)) {
- add_v3_v3v3(norm, f->no, lprev->f->no);
- pnorm = norm;
- }
- else if (fnextkind == F_EDGE && BM_elem_flag_test(lnext, BM_ELEM_LONG_TAG)) {
- add_v3_v3v3(norm, f->no, lnext->f->no);
- pnorm = norm;
- }
- else if (fprevkind == F_RECON && BM_elem_flag_test(l, BM_ELEM_LONG_TAG)) {
- pnorm = lprev->f->no;
- }
- else if (fnextkind == F_RECON && BM_elem_flag_test(l->prev, BM_ELEM_LONG_TAG)) {
- pnorm = lnext->f->no;
- }
- else {
- /* printf("unexpected harden case (edge)\n"); */
- }
+ else if (fprevkind == F_RECON) {
+ pnorm = lprev->f->no;
+ }
+ else if (fnextkind == F_RECON) {
+ pnorm = lnext->f->no;
+ }
+ else {
+ if (lprev) {
+ estep = lprev->prev->e;
+ lprevprev = BM_vert_step_fan_loop(lprev, &estep);
}
- else if (fkind == F_VERT) {
- if (fprevkind == F_VERT && fnextkind == F_VERT) {
- pnorm = l->v->no;
- }
- else if (fprevkind == F_RECON) {
- pnorm = lprev->f->no;
- }
- else if (fnextkind == F_RECON) {
- pnorm = lnext->f->no;
- }
- else {
- if (lprev) {
- estep = lprev->prev->e;
- lprevprev = BM_vert_step_fan_loop(lprev, &estep);
- }
- else {
- lprevprev = NULL;
- }
- if (lnext) {
- estep = lnext->e;
- lnextnext = BM_vert_step_fan_loop(lnext, &estep);
- }
- else {
- lnextnext = NULL;
- }
- fprevprevkind = lprevprev ? get_face_kind(bp, lprevprev->f) : F_NONE;
- fnextnextkind = lnextnext ? get_face_kind(bp, lnextnext->f) : F_NONE;
- if (fprevkind == F_EDGE && fprevprevkind == F_RECON) {
- pnorm = lprevprev->f->no;
- }
- else if (fprevkind == F_EDGE && fnextkind == F_VERT && fprevprevkind == F_EDGE) {
- add_v3_v3v3(norm, lprev->f->no, lprevprev->f->no);
- pnorm = norm;
- }
- else if (fnextkind == F_EDGE && fprevkind == F_VERT && fnextnextkind == F_EDGE) {
- add_v3_v3v3(norm, lnext->f->no, lnextnext->f->no);
- pnorm = norm;
- }
- else {
- /* printf("unexpected harden case (vert)\n"); */
- }
- }
+ else {
+ lprevprev = NULL;
}
- if (pnorm) {
- if (pnorm == norm) {
- normalize_v3(norm);
- }
- l_index = BM_elem_index_get(l);
- clnors = BM_ELEM_CD_GET_VOID_P(l, cd_clnors_offset);
- BKE_lnor_space_custom_normal_to_data(bm->lnor_spacearr->lspacearr[l_index], pnorm, clnors);
+ if (lnext) {
+ estep = lnext->e;
+ lnextnext = BM_vert_step_fan_loop(lnext, &estep);
+ }
+ else {
+ lnextnext = NULL;
+ }
+ fprevprevkind = lprevprev ? get_face_kind(bp, lprevprev->f) : F_NONE;
+ fnextnextkind = lnextnext ? get_face_kind(bp, lnextnext->f) : F_NONE;
+ if (fprevkind == F_EDGE && fprevprevkind == F_RECON) {
+ pnorm = lprevprev->f->no;
}
+ else if (fprevkind == F_EDGE && fnextkind == F_VERT && fprevpre
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list