diff options
author | Nicholas Bishop <nicholasbishop@gmail.com> | 2006-12-10 08:05:48 +0300 |
---|---|---|
committer | Nicholas Bishop <nicholasbishop@gmail.com> | 2006-12-10 08:05:48 +0300 |
commit | c66b56b6e011a6d050aba036b2b2276a645f608f (patch) | |
tree | c2bc652db12b8e4730f5dff281100fc7c57ed0cc /source/blender/src/sculptmode.c | |
parent | ab150e85129ad6538f2335ba0c44df373c87c02f (diff) |
Fixed bug #5390, smooth brush ignores verts on outer edge
The fix is to allow smoothing for edge verts, but only use other edge verts in
the calculation.
Diffstat (limited to 'source/blender/src/sculptmode.c')
-rw-r--r-- | source/blender/src/sculptmode.c | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/source/blender/src/sculptmode.c b/source/blender/src/sculptmode.c index 08ca88af0d5..21d36f587fc 100644 --- a/source/blender/src/sculptmode.c +++ b/source/blender/src/sculptmode.c @@ -718,14 +718,23 @@ void do_draw_brush(EditData *e, const ListBase* active_verts) vec3f neighbor_average(const int vert) { - Mesh *me= get_mesh(G.scene->sculptdata.active_ob); + SculptData *sd= &G.scene->sculptdata; + Mesh *me= get_mesh(sd->active_ob); int i, skip= -1, total=0; - IndexNode *node= G.scene->sculptdata.vertex_users[vert].first; + IndexNode *node= sd->vertex_users[vert].first; vec3f avg= {0,0,0}; + char ncount= BLI_countlist(&sd->vertex_users[vert]); MFace *f; + + /* Don't modify corner vertices */ + if(ncount==1) { + VecCopyf(&avg.x, me->mvert[vert].co); + return avg; + } while(node){ f= &me->mface[node->Index]; + if(f->v4) { skip= (f->v1==vert?2: f->v2==vert?3: @@ -734,7 +743,7 @@ vec3f neighbor_average(const int vert) } for(i=0; i<(f->v4?4:3); ++i) { - if(i != skip) { + if(i != skip && (ncount!=2 || BLI_countlist(&sd->vertex_users[(&f->v1)[i]]) <= 2)) { VecAddf(&avg.x,&avg.x,me->mvert[(&f->v1)[i]].co); ++total; } @@ -743,9 +752,13 @@ vec3f neighbor_average(const int vert) node= node->next; } - avg.x/= total; - avg.y/= total; - avg.z/= total; + if(total>0) { + avg.x/= total; + avg.y/= total; + avg.z/= total; + } + else + VecCopyf(&avg.x, me->mvert[vert].co); return avg; } @@ -759,16 +772,12 @@ void do_smooth_brush(const ListBase* active_verts) while(node){ cur= node->Index; - - if(BLI_countlist(&G.scene->sculptdata.vertex_users[cur]) > 2) { - avg.x=avg.y=avg.z= 0; - avg= neighbor_average(cur); + avg= neighbor_average(cur); - me->mvert[cur].co[0]+= (avg.x - me->mvert[cur].co[0])*node->Fade; - me->mvert[cur].co[1]+= (avg.y - me->mvert[cur].co[1])*node->Fade; - me->mvert[cur].co[2]+= (avg.z - me->mvert[cur].co[2])*node->Fade; - } + me->mvert[cur].co[0]+= (avg.x - me->mvert[cur].co[0])*node->Fade; + me->mvert[cur].co[1]+= (avg.y - me->mvert[cur].co[1])*node->Fade; + me->mvert[cur].co[2]+= (avg.z - me->mvert[cur].co[2])*node->Fade; node= node->next; } |