Removed set_sculpt_object. Tested with sculpt undo, sculpt+multires, sculpt+partial visibility, and sculpt+shapekeys, seems stable.

This commit is contained in:
2007-01-12 05:13:36 +00:00
parent 413ff0ca2d
commit 25361281a1
6 changed files with 18 additions and 68 deletions

View File

@@ -125,7 +125,6 @@ float *get_tex_angle();
void sculptmode_update_tex(); void sculptmode_update_tex();
char sculpt_modifiers_active(struct Object *ob); char sculpt_modifiers_active(struct Object *ob);
void sculpt(); void sculpt();
void set_sculpt_object(struct Object *ob);
void set_sculptmode(); void set_sculptmode();
/* Partial Mesh Visibility */ /* Partial Mesh Visibility */

View File

@@ -605,12 +605,10 @@ void do_common_editbuts(unsigned short event) // old name, is a mix of object an
error("Cannot create shape keys on a multires mesh."); error("Cannot create shape keys on a multires mesh.");
} else { } else {
insert_shapekey(ob); insert_shapekey(ob);
set_sculpt_object(ob);
} }
break; break;
case B_SETKEY: case B_SETKEY:
ob->shapeflag |= OB_SHAPE_TEMPLOCK; ob->shapeflag |= OB_SHAPE_TEMPLOCK;
set_sculpt_object(ob);
DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA); DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
allqueue(REDRAWVIEW3D, 0); allqueue(REDRAWVIEW3D, 0);
allqueue(REDRAWIPO, 0); allqueue(REDRAWIPO, 0);
@@ -618,7 +616,6 @@ void do_common_editbuts(unsigned short event) // old name, is a mix of object an
break; break;
case B_LOCKKEY: case B_LOCKKEY:
ob->shapeflag &= ~OB_SHAPE_TEMPLOCK; ob->shapeflag &= ~OB_SHAPE_TEMPLOCK;
set_sculpt_object(ob);
DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA); DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
allqueue(REDRAWVIEW3D, 0); allqueue(REDRAWVIEW3D, 0);
allqueue(REDRAWIPO, 0); allqueue(REDRAWIPO, 0);
@@ -630,7 +627,6 @@ void do_common_editbuts(unsigned short event) // old name, is a mix of object an
if(ob->shapenr == BLI_countlist(&key->block)) if(ob->shapenr == BLI_countlist(&key->block))
ob->shapenr= 1; ob->shapenr= 1;
else ob->shapenr++; else ob->shapenr++;
set_sculpt_object(ob);
do_common_editbuts(B_SETKEY); do_common_editbuts(B_SETKEY);
break; break;
} }
@@ -640,7 +636,6 @@ void do_common_editbuts(unsigned short event) // old name, is a mix of object an
if(ob->shapenr <= 1) if(ob->shapenr <= 1)
ob->shapenr= BLI_countlist(&key->block); ob->shapenr= BLI_countlist(&key->block);
else ob->shapenr--; else ob->shapenr--;
set_sculpt_object(ob);
do_common_editbuts(B_SETKEY); do_common_editbuts(B_SETKEY);
break; break;
} }
@@ -649,9 +644,7 @@ void do_common_editbuts(unsigned short event) // old name, is a mix of object an
allqueue (REDRAWIPO, 0); allqueue (REDRAWIPO, 0);
break; break;
case B_DELKEY: case B_DELKEY:
set_sculpt_object(NULL);
delete_key(OBACT); delete_key(OBACT);
set_sculpt_object(ob);
allqueue(REDRAWACTION, 0); allqueue(REDRAWACTION, 0);
break; break;
@@ -1241,9 +1234,6 @@ static void modifiers_applyModifier(void *obv, void *mdv)
else else
BIF_undo_push("Apply modifier"); BIF_undo_push("Apply modifier");
} }
if (G.f & G_SCULPTMODE)
set_sculpt_object(OBACT);
} }
static void modifiers_copyModifier(void *ob_v, void *md_v) static void modifiers_copyModifier(void *ob_v, void *md_v)

View File

@@ -1602,8 +1602,6 @@ void enter_editmode(int wc)
if(wc) waitcursor(1); if(wc) waitcursor(1);
if(ob->type==OB_MESH) { if(ob->type==OB_MESH) {
if(G.f & G_SCULPTMODE) set_sculpt_object(NULL);
me= get_mesh(ob); me= get_mesh(ob);
if( me==0 ) return; if( me==0 ) return;
if(me->id.lib) { if(me->id.lib) {
@@ -1741,9 +1739,6 @@ void exit_editmode(int flag) /* freedata==0 at render, 1= freedata, 2= do undo b
/* also flush ob recalc, doesn't take much overhead, but used for particles */ /* also flush ob recalc, doesn't take much overhead, but used for particles */
DAG_object_flush_update(G.scene, ob, OB_RECALC_OB|OB_RECALC_DATA); DAG_object_flush_update(G.scene, ob, OB_RECALC_OB|OB_RECALC_DATA);
if(G.f & G_SCULPTMODE)
set_sculpt_object(ob);
if(freedata) { if(freedata) {
setcursor_space(SPACE_VIEW3D, CURSOR_STD); setcursor_space(SPACE_VIEW3D, CURSOR_STD);
} }

View File

@@ -1097,10 +1097,6 @@ void set_active_base(Base *base)
DAG_object_flush_update(G.scene, tbase->object, OB_RECALC_DATA); DAG_object_flush_update(G.scene, tbase->object, OB_RECALC_DATA);
} }
} }
if(base->object->type==OB_MESH && G.f & G_SCULPTMODE) {
set_sculpt_object(base->object);
}
} }
} }

View File

@@ -1133,8 +1133,6 @@ void multires_level_to_mesh(Object *ob, Mesh *me)
multires_edge_level_update(ob,me); multires_edge_level_update(ob,me);
DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA); DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
mesh_calc_normals(me->mvert, me->totvert, me->mface, me->totface, NULL); mesh_calc_normals(me->mvert, me->totvert, me->mface, me->totface, NULL);
if(G.f & G_SCULPTMODE)
set_sculpt_object(ob);
} }
mesh_update_customdata_pointers(me); mesh_update_customdata_pointers(me);

View File

@@ -157,7 +157,9 @@ typedef struct ProjVert {
containing the brush. */ containing the brush. */
char inside; char inside;
} ProjVert; } ProjVert;
static ProjVert *projverts= NULL; static ProjVert *projverts= NULL;
static Object *active_ob= NULL;
SculptData *sculpt_data() SculptData *sculpt_data()
{ {
@@ -421,7 +423,7 @@ void sculptmode_undo_update(SculptUndoStep *newcur)
for(sus= oldcur; sus && sus != newcur; sus= sus->next); for(sus= oldcur; sus && sus != newcur; sus= sus->next);
if(sus == newcur) forward= 1; if(sus == newcur) forward= 1;
set_sculpt_object(NULL); active_ob= NULL;
/* Verts */ /* Verts */
if(newcur->verts) { if(newcur->verts) {
@@ -495,8 +497,6 @@ void sculptmode_undo_update(SculptUndoStep *newcur)
ss->undo->cur= newcur; ss->undo->cur= newcur;
set_sculpt_object(ob);
if(!sculpt_data()->draw_mode || sculpt_modifiers_active(ob)) if(!sculpt_data()->draw_mode || sculpt_modifiers_active(ob))
DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA); DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
@@ -611,23 +611,6 @@ void calc_vertex_users()
} }
} }
/* bad function... what is this supposed to do, and why is it called all over? (ton) */
/* its really time to add some comments in code... */
void set_sculpt_object(Object *ob)
{
SculptSession *ss;
/* return when no sculptmode, temporal for now because this call breaks switching shapes */
if(!(G.f & G_SCULPTMODE))
return;
ss= sculpt_session();
if(ss && ob)
calc_vertex_users();
}
/* ===== INTERFACE ===== /* ===== INTERFACE =====
*/ */
@@ -1864,29 +1847,26 @@ void sculpt()
RectNode *rn= NULL; RectNode *rn= NULL;
short spacing= 32000; short spacing= 32000;
if((G.f & G_SCULPTMODE)==0) return; if(!(G.f & G_SCULPTMODE) || G.obedit || !ob || !ob->id.lib || !get_mesh(OBACT) || get_mesh(OBACT)->totface == 0)
if(G.obedit) return; return;
if(!(ob->lay & G.vd->lay))
ob= OBACT; error("Active object is not in this layer");
if(ob->id.lib) return;
if(!ss) { if(!ss) {
sculpt_init_session(); sculpt_init_session();
ss= sd->session; ss= sd->session;
} }
/* Make sure that the active mesh is set correctly */ /* Check that vertex users are up-to-date */
if(get_mesh(OBACT) != get_mesh(ob)) if(ob != active_ob || ss->vertex_users_size != get_mesh(ob)->totvert) {
set_sculpt_object(ob); sculptmode_free_vertexusers(ss);
calc_vertex_users();
active_ob= ob;
}
glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY); glEnableClientState(GL_NORMAL_ARRAY);
if(!OBACT || !get_mesh(OBACT) ||
get_mesh(OBACT)->totface==0) return;
if(ob->lay & G.vd->lay); else error("Active object is not in this layer");
persp(PERSP_VIEW); persp(PERSP_VIEW);
getmouseco_areawin(mvalo); getmouseco_areawin(mvalo);
@@ -2068,8 +2048,6 @@ void set_sculptmode()
if(G.f & G_SCULPTMODE) { if(G.f & G_SCULPTMODE) {
G.f &= ~G_SCULPTMODE; G.f &= ~G_SCULPTMODE;
set_sculpt_object(NULL);
sculptmode_free_session(G.scene); sculptmode_free_session(G.scene);
} else { } else {
G.f |= G_SCULPTMODE; G.f |= G_SCULPTMODE;
@@ -2077,14 +2055,13 @@ void set_sculptmode()
if(!sculptmode_brush()) if(!sculptmode_brush())
sculptmode_init(G.scene); sculptmode_init(G.scene);
if(G.vd->twflag) G.vd->twflag= 0;
sculpt_init_session(); sculpt_init_session();
set_sculpt_object(OBACT);
glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY); glEnableClientState(GL_NORMAL_ARRAY);
} }
active_ob= NULL;
allqueue(REDRAWVIEW3D, 1); allqueue(REDRAWVIEW3D, 1);
allqueue(REDRAWBUTSEDIT, 0); allqueue(REDRAWBUTSEDIT, 0);
@@ -2116,9 +2093,8 @@ void sculptmode_revert_pmv(Mesh *me)
unsigned i; unsigned i;
MVert *nve, *old_verts; MVert *nve, *old_verts;
Object *ob= OBACT; Object *ob= OBACT;
/* Temporarily exit sculptmode */ active_ob= NULL;
set_sculpt_object(NULL);
/* Reorder vertices */ /* Reorder vertices */
nve= me->mvert; nve= me->mvert;
@@ -2148,8 +2124,6 @@ void sculptmode_revert_pmv(Mesh *me)
me->pv->edge_map= NULL; me->pv->edge_map= NULL;
MEM_freeN(me->pv->vert_map); MEM_freeN(me->pv->vert_map);
me->pv->vert_map= NULL; me->pv->vert_map= NULL;
set_sculpt_object(ob);
DAG_object_flush_update(G.scene, OBACT, OB_RECALC_DATA); DAG_object_flush_update(G.scene, OBACT, OB_RECALC_DATA);
} }
@@ -2210,7 +2184,7 @@ void sculptmode_do_pmv(Object *ob, rcti *hb_2d, int mode)
} }
/* Kill sculpt data */ /* Kill sculpt data */
set_sculpt_object(NULL); active_ob= NULL;
/* Initalize map with which verts are to be hidden */ /* Initalize map with which verts are to be hidden */
me->pv->vert_map= MEM_mallocN(sizeof(unsigned)*me->totvert, "PMV vertmap"); me->pv->vert_map= MEM_mallocN(sizeof(unsigned)*me->totvert, "PMV vertmap");
@@ -2319,8 +2293,6 @@ void sculptmode_do_pmv(Object *ob, rcti *hb_2d, int mode)
} }
me->totedge= edge_cnt_show; me->totedge= edge_cnt_show;
CustomData_set_layer(&me->edata, CD_MEDGE, me->medge); CustomData_set_layer(&me->edata, CD_MEDGE, me->medge);
set_sculpt_object(ob);
DAG_object_flush_update(G.scene, OBACT, OB_RECALC_DATA); DAG_object_flush_update(G.scene, OBACT, OB_RECALC_DATA);
} }