cleanup of extend edge data and fixed minor errors

This commit is contained in:
Rohan Rathi 2018-07-04 00:04:03 +05:30
parent 1c699d75a0
commit b360c9d7f9
2 changed files with 10 additions and 71 deletions

View File

@ -1551,13 +1551,13 @@ static void check_edge_data_seam_sharp_edges(BevVert *bv, int flag, bool neg)
int flag_count = 0;
EdgeHalf *ne = e->next;
while ((!neg && !EDGE_DATA_CHECK(e, flag) || (neg && EDGE_DATA_CHECK(e, flag))) && ne != efirst) {
while ((!neg && !EDGE_DATA_CHECK(ne, flag) || (neg && EDGE_DATA_CHECK(ne, flag))) && ne != efirst) {
if (ne->is_bev)
flag_count++;
ne = ne->next;
}
if (ne == e || (ne == efirst && (!neg && !EDGE_DATA_CHECK(e, flag) ||
(neg && EDGE_DATA_CHECK(e, flag))))) {
if (ne == e || (ne == efirst && (!neg && !EDGE_DATA_CHECK(efirst, flag) ||
(neg && EDGE_DATA_CHECK(efirst, flag))))) {
break;
}
if (flag == BM_ELEM_SEAM)
@ -1657,6 +1657,8 @@ static void bevel_extend_edge_data(BevVert *bv)
static void bevel_harden_normals_mode(BMesh *bm, BevelParams *bp, BevVert *bv, BMOperator *op)
{
if (bp->hnmode == BEVEL_HN_NONE)
return;
int mode = 1;
VMesh *vm = bv->vmesh;
@ -1726,69 +1728,6 @@ static void bevel_harden_normals_mode(BMesh *bm, BevelParams *bp, BevVert *bv, B
} while (bcur != bstart);
}
static void bevel_fix_normal_shading_continuity(BevelParams *bp, BMesh *bm, BevVert *bv)
{
GHash *faceHash = bp->faceHash;
VMesh *vm = bv->vmesh;
BoundVert *bcur = bv->vmesh->boundstart, *start = bcur;
int ns = vm->seg;
int ns2 = ns / 2;
BMLoop *l;
BMIter liter;
int cd_clnors_offset = CustomData_get_offset(&bm->ldata, CD_CUSTOMLOOPNORMAL);
float ref = 20.0f;
do {
for (int i = 0; i <= ns; i++) {
BMVert *v1 = mesh_vert(vm, bcur->index, 0, i)->v;
BMEdge *e;
BMIter eiter;
BM_ITER_ELEM(e, &eiter, v1, BM_EDGES_OF_VERT) {
BMFace *f_a, *f_b;
BM_edge_face_pair(e, &f_a, &f_b);
bool _f_a = false, _f_b = false;
if (f_a)
_f_a = BLI_ghash_haskey(faceHash, f_a);
if (f_b)
_f_b = BLI_ghash_haskey(faceHash, f_b);
if (_f_a ^ _f_b) {
BM_ITER_ELEM(l, &liter, v1, BM_LOOPS_OF_VERT) {
if (l->f == f_a || l->f == f_b) {
const int l_index = BM_elem_index_get(l);
short *clnors = BM_ELEM_CD_GET_VOID_P(l, cd_clnors_offset);
float n_final[3], pow_a[3], pow_b[3];
zero_v3(n_final);
copy_v3_v3(pow_a, f_a->no);
copy_v3_v3(pow_b, f_b->no);
if (_f_a) {
mul_v3_fl(pow_a, ns / ref);
mul_v3_fl(pow_b, ref / ns);
}
else {
mul_v3_fl(pow_b, ns / ref);
mul_v3_fl(pow_a, ref / ns);
}
add_v3_v3(n_final, pow_a);
add_v3_v3(n_final, pow_b);
normalize_v3(n_final);
BKE_lnor_space_custom_normal_to_data(bm->lnor_spacearr->lspacearr[l_index], n_final, clnors);
}
}
}
}
}
bcur = bcur->next;
} while (bcur != start);
}
/* 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)
{
@ -3761,7 +3700,7 @@ static void bevel_build_rings(BevelParams *bp, BMesh *bm, BevVert *bv)
vm1 = adj_vmesh(bp, bv);
}
bool do_fix_shading_bv = ((bp->faceHash != NULL) && bv->fix_shading);
bool do_fix_shading_bv = bp->faceHash != NULL;
/* copy final vmesh into bv->vmesh, make BMVerts and BMFaces */
vm = bv->vmesh;

View File

@ -190,14 +190,14 @@ static void bevel_mod_harden_normals(BevelModifierData *bmd, BMesh *bm, float hn
mul_v3_v3fl(cur, lfan_pivot->f->no, BM_face_calc_area(lfan_pivot->f));
add_v3_v3(cn_wght, cur);
}
if (!BM_elem_flag_test(e_next, BM_ELEM_TAG) || (e_next == e_org)) {
break;
}
lfan_pivot = lfan_pivot_next;
if (!BLI_ghash_haskey(faceHash, f)) {
recon_face = f;
recon_face_count++;
}
if (!BM_elem_flag_test(e_next, BM_ELEM_TAG) || (e_next == e_org)) {
break;
}
lfan_pivot = lfan_pivot_next;
}
normalize_v3(cn_wght);