From 413ff0ca2dd605c1fe646093622ba006bb0c01ee Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Fri, 12 Jan 2007 04:47:38 +0000 Subject: [PATCH] Changed the way sculptmode interacts with shape keys. Vertex coordinates are now copied into the active key at the end of each brush action. (This is in preperation for removing the function set_sculpt_object.) --- source/blender/blenkernel/intern/key.c | 5 --- source/blender/include/BDR_sculptmode.h | 4 -- source/blender/src/sculptmode.c | 52 ++++++++++--------------- 3 files changed, 21 insertions(+), 40 deletions(-) diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c index fcb03fcc6db..345bc522449 100644 --- a/source/blender/blenkernel/intern/key.c +++ b/source/blender/blenkernel/intern/key.c @@ -1305,11 +1305,6 @@ int do_ob_key(Object *ob) if(key==NULL) return 0; - /* Don't apply key for sculptmode */ - if(key==NULL || ((G.f & G_SCULPTMODE) && !G.obedit && ob==OBACT)) - return 0; - - if(ob->shapeflag & (OB_SHAPE_LOCK|OB_SHAPE_TEMPLOCK)) { KeyBlock *kb= BLI_findlink(&key->block, ob->shapenr-1); diff --git a/source/blender/include/BDR_sculptmode.h b/source/blender/include/BDR_sculptmode.h index 79df879e7ef..0956c22f255 100644 --- a/source/blender/include/BDR_sculptmode.h +++ b/source/blender/include/BDR_sculptmode.h @@ -65,8 +65,6 @@ typedef struct PropsetData { } PropsetData; typedef struct SculptSession { - struct Object *active_ob; - /* Cache of the OpenGL matrices */ double modelviewmat[16]; double projectionmat[16]; @@ -89,8 +87,6 @@ typedef struct SculptSession { /* For rotating around a pivot point */ vec3f pivot; - - struct KeyBlock *keyblock; } SculptSession; SculptSession *sculpt_session(); diff --git a/source/blender/src/sculptmode.c b/source/blender/src/sculptmode.c index b69ad030d44..528171062d1 100644 --- a/source/blender/src/sculptmode.c +++ b/source/blender/src/sculptmode.c @@ -615,37 +615,17 @@ void calc_vertex_users() /* its really time to add some comments in code... */ void set_sculpt_object(Object *ob) { - SculptSession *ss= sculpt_session(); - + SculptSession *ss; + /* return when no sculptmode, temporal for now because this call breaks switching shapes */ if(!(G.f & G_SCULPTMODE)) return; - if(ss) { - /* Copy any sculpted changes back into the old shape key. */ - if(ss->keyblock) { - Mesh *me= get_mesh(ss->active_ob); - if(me) { - mesh_to_key(me, ss->keyblock); - DAG_object_flush_update(G.scene, ss->active_ob, OB_RECALC_DATA); - } - } + ss= sculpt_session(); + + if(ss && ob) + calc_vertex_users(); - if(ob) { - Mesh *me= get_mesh(ob); - calc_vertex_users(); - - /* Copy current shape key (if any) to mesh. Sculptmode - sculpts only one shape key at a time. */ - ss->keyblock= ob_get_keyblock(ob); - if(ss->keyblock) - key_to_mesh(ss->keyblock, me); - - DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA); - } - - ss->active_ob= ob; - } } /* ===== INTERFACE ===== @@ -856,9 +836,11 @@ void do_draw_brush(const EditData *e, const ListBase* active_verts) while(node){ float *co= me->mvert[node->Index].co; + const float val[3]= {co[0]+area_normal.x*node->Fade, co[1]+area_normal.y*node->Fade, co[2]+area_normal.z*node->Fade}; + sculpt_clip(e, co, val); node= node->next; @@ -1207,6 +1189,7 @@ void do_brush_action(float *vertexcosnos, EditData e, float *vert; Mesh *me= get_mesh(OBACT); const float bstrength= brush_strength(&e); + KeyBlock *keyblock= ob_get_keyblock(OBACT); sculptmode_add_damaged_rect(&e,damaged_rects); @@ -1254,6 +1237,16 @@ void do_brush_action(float *vertexcosnos, EditData e, do_layer_brush(&e, &active_verts); break; } + + /* Copy the modified vertices from mesh to the active key */ + if(keyblock) { + float *co= keyblock->data; + if(co) { + for(adata= active_verts.first; adata; adata= adata->next) + if(adata->Index < keyblock->totelem) + VecCopyf(&co[adata->Index*3], me->mvert[adata->Index].co); + } + } if(vertexcosnos) BLI_freelistN(&active_verts); @@ -1837,9 +1830,6 @@ void sculptmode_correct_state() if(!sculpt_session()) sculpt_init_session(); - if(get_mesh(sculpt_session()->active_ob) != get_mesh(OBACT)) - set_sculpt_object(OBACT); - glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_NORMAL_ARRAY); @@ -1975,8 +1965,8 @@ void sculpt() do_symmetrical_brush_actions(vertexcosnos,&e,&damaged_verts,&damaged_rects); } - if(modifier_calculations) - DAG_object_flush_update(G.scene, OBACT, OB_RECALC_DATA); + if(modifier_calculations || ob_get_keyblock(ob)) + DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA); if(modifier_calculations || sd->brush_type == GRAB_BRUSH || !sd->draw_mode) { calc_damaged_verts(&damaged_verts,e.grabdata);