Fix: outliner crash on deleting bones in editmode

Further cleaned up editmesh code to be warning free and to have a little
nicer style :)
This commit is contained in:
2005-07-17 15:45:35 +00:00
parent d5ccd35f4c
commit 261bd94e7f
3 changed files with 876 additions and 898 deletions

View File

@@ -92,13 +92,15 @@ editmesh_loop: tools with own drawing subloops, select, knife, subdiv
/* New LoopCut */ /* New LoopCut */
static void edgering_sel(EditEdge *startedge, int select, int previewlines){ static void edgering_sel(EditEdge *startedge, int select, int previewlines)
{
EditMesh *em = G.editMesh; EditMesh *em = G.editMesh;
EditEdge *eed; EditEdge *eed;
EditFace *efa; EditFace *efa;
int looking= 1,i;
float co[2][3];
EditVert *v[2][2]; EditVert *v[2][2];
float co[2][3];
int looking= 1,i;
/* in eed->f1 we put the valence (amount of faces in edge) */ /* in eed->f1 we put the valence (amount of faces in edge) */
/* in eed->f2 we put tagged flag as correct loop */ /* in eed->f2 we put tagged flag as correct loop */
/* in efa->f1 we put tagged flag as correct to select */ /* in efa->f1 we put tagged flag as correct to select */
@@ -200,13 +202,15 @@ static void edgering_sel(EditEdge *startedge, int select, int previewlines){
} }
} }
} }
void CutEdgeloop(int numcuts){ void CutEdgeloop(int numcuts)
{
EditMesh *em = G.editMesh; EditMesh *em = G.editMesh;
int keys = 0,holdnum=0; EditEdge *nearest=NULL, *eed;
int keys = 0, holdnum=0;
short mvalo[2] = {0,0}, mval[2]; short mvalo[2] = {0,0}, mval[2];
EditEdge* nearest,*eed;
short event,val,choosing=1,cancel=0,dist,cuthalf = 0; short event,val,choosing=1,cancel=0,dist,cuthalf = 0;
char msg[128]; char msg[128];
while(choosing){ while(choosing){
getmouseco_areawin(mval); getmouseco_areawin(mval);
if (mval[0] != mvalo[0] || mval[1] != mvalo[1]) { if (mval[0] != mvalo[0] || mval[1] != mvalo[1]) {
@@ -368,8 +372,9 @@ void CutEdgeloop(int numcuts){
/* *************** LOOP SELECT ************* */ /* *************** LOOP SELECT ************* */
#if 0
static short edgeFaces(EditEdge *e){ static short edgeFaces(EditEdge *e)
{
EditMesh *em = G.editMesh; EditMesh *em = G.editMesh;
EditFace *search=NULL; EditFace *search=NULL;
short count = 0; short count = 0;
@@ -378,10 +383,11 @@ static short edgeFaces(EditEdge *e){
while(search){ while(search){
if((search->e1 == e || search->e2 == e) || (search->e3 == e || search->e4 == e)) if((search->e1 == e || search->e2 == e) || (search->e3 == e || search->e4 == e))
count++; count++;
search = search->next; search = search->next;
} }
return count; return count;
} }
#endif
/* this utility function checks to see if 2 edit edges share a face, /* this utility function checks to see if 2 edit edges share a face,
returns 1 if they do returns 1 if they do
@@ -391,6 +397,7 @@ short sharesFace(EditEdge* e1, EditEdge* e2)
{ {
EditMesh *em = G.editMesh; EditMesh *em = G.editMesh;
EditFace *search=NULL; EditFace *search=NULL;
search = em->faces.first; search = em->faces.first;
if (e1 == e2){ if (e1 == e2){
return 0 ; return 0 ;
@@ -428,12 +435,13 @@ typedef struct CutCurve {
short y; short y;
} CutCurve; } CutCurve;
static CutCurve *get_mouse_trail(int *len, char mode){ static CutCurve *get_mouse_trail(int *len, char mode)
{
CutCurve *curve,*temp; CutCurve *curve,*temp;
int i=0, j, blocks=1, lasti=0;
short event, val, ldown=0, restart=0, rubberband=0; short event, val, ldown=0, restart=0, rubberband=0;
short mval[2], lockaxis=0, lockx=0, locky=0, lastx=0, lasty=0; short mval[2], lockaxis=0, lockx=0, locky=0, lastx=0, lasty=0;
int i=0, j, blocks=1, lasti=0;
*len=0; *len=0;
curve=(CutCurve *)MEM_callocN(1024*sizeof(CutCurve), "MouseTrail"); curve=(CutCurve *)MEM_callocN(1024*sizeof(CutCurve), "MouseTrail");
@@ -572,11 +580,11 @@ short seg_intersect(struct EditEdge * e, CutCurve *c, int len);
void KnifeSubdivide(char mode) void KnifeSubdivide(char mode)
{ {
EditMesh *em = G.editMesh; EditMesh *em = G.editMesh;
int oldcursor, len=0;
short isect=0;
CutCurve *curve; CutCurve *curve;
EditEdge *eed; EditEdge *eed;
Window *win; Window *win;
int oldcursor, len=0;
short isect=0;
short numcuts=1; short numcuts=1;
if (G.obedit==0) return; if (G.obedit==0) return;
@@ -646,15 +654,16 @@ void KnifeSubdivide(char mode)
/* seg_intersect() Determines if and where a mouse trail intersects an EditEdge */ /* seg_intersect() Determines if and where a mouse trail intersects an EditEdge */
short seg_intersect(EditEdge *e, CutCurve *c, int len){ short seg_intersect(EditEdge *e, CutCurve *c, int len)
{
#define MAXSLOPE 100000 #define MAXSLOPE 100000
short isect=0;
float x11, y11, x12=0, y12=0, x2max, x2min, y2max; float x11, y11, x12=0, y12=0, x2max, x2min, y2max;
float y2min, dist, lastdist=0, xdiff2, xdiff1; float y2min, dist, lastdist=0, xdiff2, xdiff1;
float m1, b1, m2, b2, x21, x22, y21, y22, xi; float m1, b1, m2, b2, x21, x22, y21, y22, xi;
float yi, x1min, x1max, y1max, y1min, perc=0; float yi, x1min, x1max, y1max, y1min, perc=0;
float scr[2], co[4]; float scr[2], co[4];
int i; int i;
short isect=0;
/* Get screen coords of verts (v->xs and v->ys clip if off screen */ /* Get screen coords of verts (v->xs and v->ys clip if off screen */
VECCOPY(co, e->v1->co); VECCOPY(co, e->v1->co);
@@ -752,8 +761,8 @@ short seg_intersect(EditEdge *e, CutCurve *c, int len){
return(isect); return(isect);
} }
void LoopMenu(){ /* Called by KKey */ void LoopMenu() /* Called by KKey */
{
short ret; short ret;
ret=pupmenu("Loop/Cut Menu %t|Loop Cut (CTRL-R)%x2|" ret=pupmenu("Loop/Cut Menu %t|Loop Cut (CTRL-R)%x2|"

File diff suppressed because it is too large Load Diff

View File

@@ -364,10 +364,6 @@ static void outliner_sort(SpaceOops *soops, ListBase *lb)
} }
} }
/* Prototype, see function below */
static void outliner_add_bone(SpaceOops *soops, ListBase *lb,
ID *id, Bone *curBone, TreeElement *parent, int *a);
static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *idv, static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *idv,
TreeElement *parent, short type, short index) TreeElement *parent, short type, short index)
@@ -493,9 +489,10 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
ten= nten; ten= nten;
} }
/* restore prev pointers */ /* restore prev pointers */
for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { pchan= ob->pose->chanbase.first;
if(pchan) pchan->prev= NULL;
for(; pchan; pchan= pchan->next) {
if(pchan->next) pchan->next->prev= pchan; if(pchan->next) pchan->next->prev= pchan;
else if(pchan==ob->pose->chanbase.first) pchan->prev= NULL;
} }
} }
} }
@@ -662,12 +659,6 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
ten= nten; ten= nten;
} }
} }
else {
Bone *curBone;
for (curBone=arm->bonebase.first; curBone; curBone=curBone->next){
outliner_add_bone(soops, &te->subtree, id, curBone, te, &a);
}
}
} }
break; break;
} }
@@ -675,22 +666,6 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
return te; return te;
} }
/* special handling of hierarchical non-lib data */
static void outliner_add_bone(SpaceOops *soops, ListBase *lb, ID *id, Bone *curBone,
TreeElement *parent, int *a)
{
TreeElement *te= outliner_add_element(soops, lb, id, parent, TSE_BONE, *a);
(*a)++;
te->name= curBone->name;
te->directdata= curBone;
for(curBone= curBone->childbase.first; curBone; curBone=curBone->next) {
outliner_add_bone(soops, &te->subtree, id, curBone, te, a);
}
}
static void outliner_make_hierarchy(SpaceOops *soops, ListBase *lb) static void outliner_make_hierarchy(SpaceOops *soops, ListBase *lb)
{ {
TreeElement *te, *ten, *tep; TreeElement *te, *ten, *tep;
@@ -1364,8 +1339,6 @@ static int tree_element_type_active(SpaceOops *soops, TreeElement *te, TreeStore
return tree_element_active_nla_action(te, tselem, set); return tree_element_active_nla_action(te, tselem, set);
case TSE_DEFGROUP: case TSE_DEFGROUP:
return tree_element_active_defgroup(te, tselem, set); return tree_element_active_defgroup(te, tselem, set);
case TSE_BONE:
return tree_element_active_bone(te, tselem, set);
case TSE_EBONE: case TSE_EBONE:
return tree_element_active_ebone(te, tselem, set); return tree_element_active_ebone(te, tselem, set);
case TSE_HOOK: // actually object case TSE_HOOK: // actually object
@@ -1900,7 +1873,6 @@ static void tselem_draw_icon(TreeStoreElem *tselem)
BIF_draw_icon(ICON_ACTION); break; BIF_draw_icon(ICON_ACTION); break;
case TSE_DEFGROUP_BASE: case TSE_DEFGROUP_BASE:
BIF_draw_icon(ICON_VERTEXSEL); break; BIF_draw_icon(ICON_VERTEXSEL); break;
case TSE_BONE:
case TSE_EBONE: case TSE_EBONE:
BIF_draw_icon(ICON_WPAINT_DEHLT); break; BIF_draw_icon(ICON_WPAINT_DEHLT); break;
case TSE_CONSTRAINT_BASE: case TSE_CONSTRAINT_BASE:
@@ -2265,20 +2237,6 @@ static void namebutton_cb(void *soopsp, void *oldnamep)
allqueue(REDRAWVIEW3D, 1); allqueue(REDRAWVIEW3D, 1);
allqueue(REDRAWBUTSEDIT, 0); allqueue(REDRAWBUTSEDIT, 0);
break; break;
case TSE_BONE:
{
Bone *bone= te->directdata;
char newname[32];
/* restore bone name */
BLI_strncpy(newname, bone->name, 32);
BLI_strncpy(bone->name, oldnamep, 32);
armature_bone_rename((bArmature *)tselem->id, oldnamep, newname);
}
allqueue(REDRAWOOPS, 0);
allqueue(REDRAWVIEW3D, 1);
allqueue(REDRAWBUTSEDIT, 0);
break;
} }
} }
} }
@@ -2300,7 +2258,7 @@ static void outliner_buttons(uiBlock *block, SpaceOops *soops, ListBase *lb)
tselem= TREESTORE(te); tselem= TREESTORE(te);
if(tselem->flag & TSE_TEXTBUT) { if(tselem->flag & TSE_TEXTBUT) {
if(tselem->type==TSE_BONE) { if(tselem->type==TSE_EBONE) {
len= 32; len= 32;
} }
else len= 19; else len= 19;