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:
@@ -92,13 +92,15 @@ editmesh_loop: tools with own drawing subloops, select, knife, subdiv
|
||||
|
||||
|
||||
/* 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;
|
||||
EditEdge *eed;
|
||||
EditFace *efa;
|
||||
int looking= 1,i;
|
||||
float co[2][3];
|
||||
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->f2 we put tagged flag as correct loop */
|
||||
/* 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;
|
||||
int keys = 0,holdnum=0;
|
||||
EditEdge *nearest=NULL, *eed;
|
||||
int keys = 0, holdnum=0;
|
||||
short mvalo[2] = {0,0}, mval[2];
|
||||
EditEdge* nearest,*eed;
|
||||
short event,val,choosing=1,cancel=0,dist,cuthalf = 0;
|
||||
char msg[128];
|
||||
|
||||
while(choosing){
|
||||
getmouseco_areawin(mval);
|
||||
if (mval[0] != mvalo[0] || mval[1] != mvalo[1]) {
|
||||
@@ -368,8 +372,9 @@ void CutEdgeloop(int numcuts){
|
||||
|
||||
|
||||
/* *************** LOOP SELECT ************* */
|
||||
|
||||
static short edgeFaces(EditEdge *e){
|
||||
#if 0
|
||||
static short edgeFaces(EditEdge *e)
|
||||
{
|
||||
EditMesh *em = G.editMesh;
|
||||
EditFace *search=NULL;
|
||||
short count = 0;
|
||||
@@ -382,6 +387,7 @@ static short edgeFaces(EditEdge *e){
|
||||
}
|
||||
return count;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* this utility function checks to see if 2 edit edges share a face,
|
||||
returns 1 if they do
|
||||
@@ -391,6 +397,7 @@ short sharesFace(EditEdge* e1, EditEdge* e2)
|
||||
{
|
||||
EditMesh *em = G.editMesh;
|
||||
EditFace *search=NULL;
|
||||
|
||||
search = em->faces.first;
|
||||
if (e1 == e2){
|
||||
return 0 ;
|
||||
@@ -428,12 +435,13 @@ typedef struct CutCurve {
|
||||
short y;
|
||||
} CutCurve;
|
||||
|
||||
static CutCurve *get_mouse_trail(int *len, char mode){
|
||||
static CutCurve *get_mouse_trail(int *len, char mode)
|
||||
{
|
||||
|
||||
CutCurve *curve,*temp;
|
||||
int i=0, j, blocks=1, lasti=0;
|
||||
short event, val, ldown=0, restart=0, rubberband=0;
|
||||
short mval[2], lockaxis=0, lockx=0, locky=0, lastx=0, lasty=0;
|
||||
int i=0, j, blocks=1, lasti=0;
|
||||
|
||||
*len=0;
|
||||
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)
|
||||
{
|
||||
EditMesh *em = G.editMesh;
|
||||
int oldcursor, len=0;
|
||||
short isect=0;
|
||||
CutCurve *curve;
|
||||
EditEdge *eed;
|
||||
Window *win;
|
||||
int oldcursor, len=0;
|
||||
short isect=0;
|
||||
short numcuts=1;
|
||||
|
||||
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 */
|
||||
|
||||
short seg_intersect(EditEdge *e, CutCurve *c, int len){
|
||||
short seg_intersect(EditEdge *e, CutCurve *c, int len)
|
||||
{
|
||||
#define MAXSLOPE 100000
|
||||
short isect=0;
|
||||
float x11, y11, x12=0, y12=0, x2max, x2min, y2max;
|
||||
float y2min, dist, lastdist=0, xdiff2, xdiff1;
|
||||
float m1, b1, m2, b2, x21, x22, y21, y22, xi;
|
||||
float yi, x1min, x1max, y1max, y1min, perc=0;
|
||||
float scr[2], co[4];
|
||||
int i;
|
||||
short isect=0;
|
||||
|
||||
/* Get screen coords of verts (v->xs and v->ys clip if off screen */
|
||||
VECCOPY(co, e->v1->co);
|
||||
@@ -752,8 +761,8 @@ short seg_intersect(EditEdge *e, CutCurve *c, int len){
|
||||
return(isect);
|
||||
}
|
||||
|
||||
void LoopMenu(){ /* Called by KKey */
|
||||
|
||||
void LoopMenu() /* Called by KKey */
|
||||
{
|
||||
short ret;
|
||||
|
||||
ret=pupmenu("Loop/Cut Menu %t|Loop Cut (CTRL-R)%x2|"
|
||||
|
||||
@@ -1107,7 +1107,8 @@ void fill_mesh(void)
|
||||
#define EDGENEW 2
|
||||
#define EDGEINNER 4
|
||||
|
||||
static void alter_co(float* co,EditEdge *edge,float rad,int beauty){
|
||||
static void alter_co(float* co,EditEdge *edge,float rad,int beauty)
|
||||
{
|
||||
float vec1[3],vec2[3],fac,vec3[3],vec4[4],len,ang;
|
||||
|
||||
if(rad > 0.0) { /* subdivide sphere */
|
||||
@@ -1179,7 +1180,8 @@ static void alter_co(float* co,EditEdge *edge,float rad,int beauty){
|
||||
}
|
||||
}
|
||||
|
||||
static void flipvertarray(EditVert** arr, short size){
|
||||
static void flipvertarray(EditVert** arr, short size)
|
||||
{
|
||||
EditVert *hold;
|
||||
int i;
|
||||
|
||||
@@ -1279,7 +1281,8 @@ static void set_uv_vcol(EditFace *efa, float *co, float *uv, char *col)
|
||||
}
|
||||
}
|
||||
|
||||
static void facecopy(EditFace *source,EditFace *target){
|
||||
static void facecopy(EditFace *source,EditFace *target)
|
||||
{
|
||||
|
||||
set_uv_vcol(source,target->v1->co,target->tf.uv[0],(char*)&target->tf.col[0]);
|
||||
set_uv_vcol(source,target->v2->co,target->tf.uv[1],(char*)&target->tf.col[1]);
|
||||
@@ -1299,11 +1302,12 @@ static void facecopy(EditFace *source,EditFace *target){
|
||||
|
||||
}
|
||||
|
||||
static void fill_quad_single(EditFace *efa, struct GHash *gh, int numcuts){
|
||||
EditEdge *cedge;
|
||||
static void fill_quad_single(EditFace *efa, struct GHash *gh, int numcuts)
|
||||
{
|
||||
EditEdge *cedge=NULL;
|
||||
EditVert *v[4], **verts;
|
||||
EditFace *hold;
|
||||
short start, end, left, right, vertsize,i;
|
||||
short start=0, end, left, right, vertsize,i;
|
||||
|
||||
v[0] = efa->v1;
|
||||
v[1] = efa->v2;
|
||||
@@ -1370,11 +1374,12 @@ static void fill_quad_single(EditFace *efa, struct GHash *gh, int numcuts){
|
||||
}
|
||||
}
|
||||
|
||||
static void fill_tri_single(EditFace *efa, struct GHash *gh, int numcuts){
|
||||
EditEdge *cedge;
|
||||
static void fill_tri_single(EditFace *efa, struct GHash *gh, int numcuts)
|
||||
{
|
||||
EditEdge *cedge=NULL;
|
||||
EditVert *v[3], **verts;
|
||||
EditFace *hold;
|
||||
short start, end, op, vertsize,i;
|
||||
short start=0, end, op, vertsize,i;
|
||||
|
||||
v[0] = efa->v1;
|
||||
v[1] = efa->v2;
|
||||
@@ -1434,11 +1439,12 @@ static void fill_tri_single(EditFace *efa, struct GHash *gh, int numcuts){
|
||||
}
|
||||
}
|
||||
|
||||
static void fill_quad_double_op(EditFace *efa, struct GHash *gh, int numcuts){
|
||||
EditEdge *cedge[2];
|
||||
static void fill_quad_double_op(EditFace *efa, struct GHash *gh, int numcuts)
|
||||
{
|
||||
EditEdge *cedge[2]={NULL, NULL};
|
||||
EditVert *v[4], **verts[2];
|
||||
EditFace *hold;
|
||||
short start, end, left, right, vertsize,i;
|
||||
short start=0, end, left, right, vertsize,i;
|
||||
|
||||
v[0] = efa->v1;
|
||||
v[1] = efa->v2;
|
||||
@@ -1496,11 +1502,12 @@ static void fill_quad_double_op(EditFace *efa, struct GHash *gh, int numcuts){
|
||||
}
|
||||
|
||||
|
||||
static void fill_quad_double_adj(EditFace *efa, struct GHash *gh, int numcuts){
|
||||
EditEdge *cedge[2];
|
||||
static void fill_quad_double_adj(EditFace *efa, struct GHash *gh, int numcuts)
|
||||
{
|
||||
EditEdge *cedge[2]={NULL, NULL};
|
||||
EditVert *v[4], **verts[2];
|
||||
EditFace *hold;
|
||||
short start, start2, vertsize,i;
|
||||
short start=0, start2=0, vertsize,i;
|
||||
|
||||
v[0] = efa->v1;
|
||||
v[1] = efa->v2;
|
||||
@@ -1560,11 +1567,12 @@ static void fill_quad_double_adj(EditFace *efa, struct GHash *gh, int numcuts){
|
||||
}
|
||||
}
|
||||
|
||||
static void fill_tri_double(EditFace *efa, struct GHash *gh, int numcuts){
|
||||
EditEdge *cedge[2];
|
||||
static void fill_tri_double(EditFace *efa, struct GHash *gh, int numcuts)
|
||||
{
|
||||
EditEdge *cedge[2]={NULL, NULL};
|
||||
EditVert *v[3], **verts[2];
|
||||
EditFace *hold;
|
||||
short start, start2, vertsize,i;
|
||||
short start=0, start2=0, vertsize,i;
|
||||
|
||||
v[0] = efa->v1;
|
||||
v[1] = efa->v2;
|
||||
@@ -1620,11 +1628,12 @@ static void fill_tri_double(EditFace *efa, struct GHash *gh, int numcuts){
|
||||
}
|
||||
}
|
||||
|
||||
static void fill_quad_triple(EditFace *efa, struct GHash *gh, int numcuts){
|
||||
static void fill_quad_triple(EditFace *efa, struct GHash *gh, int numcuts)
|
||||
{
|
||||
EditEdge *cedge[3];
|
||||
EditVert *v[4], **verts[3];
|
||||
EditFace *hold;
|
||||
short start, start2, start3, vertsize, i, repeats;
|
||||
short start=0, start2=0, start3=0, vertsize, i, repeats;
|
||||
|
||||
v[0] = efa->v1;
|
||||
v[1] = efa->v2;
|
||||
@@ -1777,7 +1786,8 @@ static void fill_quad_triple(EditFace *efa, struct GHash *gh, int numcuts){
|
||||
}
|
||||
}
|
||||
|
||||
static void fill_quad_quadruple(EditFace *efa, struct GHash *gh, int numcuts,float rad,int beauty){
|
||||
static void fill_quad_quadruple(EditFace *efa, struct GHash *gh, int numcuts,float rad,int beauty)
|
||||
{
|
||||
EditVert **verts[4], ***innerverts;
|
||||
short vertsize, i, j;
|
||||
float co[3];
|
||||
@@ -1874,7 +1884,8 @@ static void fill_quad_quadruple(EditFace *efa, struct GHash *gh, int numcuts,flo
|
||||
MEM_freeN(innerverts);
|
||||
}
|
||||
|
||||
static void fill_tri_triple(EditFace *efa, struct GHash *gh, int numcuts,float rad,int beauty){
|
||||
static void fill_tri_triple(EditFace *efa, struct GHash *gh, int numcuts,float rad,int beauty)
|
||||
{
|
||||
EditVert **verts[3], ***innerverts;
|
||||
short vertsize, i, j;
|
||||
float co[3];
|
||||
@@ -1987,7 +1998,8 @@ static void fill_tri_triple(EditFace *efa, struct GHash *gh, int numcuts,float r
|
||||
// This function takes an example edge, the current point to create and
|
||||
// the total # of points to create, then creates the point and return the
|
||||
// editvert pointer to it.
|
||||
static EditVert *subdivideedgenum(EditEdge *edge,int curpoint,int totpoint,float rad,int beauty){
|
||||
static EditVert *subdivideedgenum(EditEdge *edge,int curpoint,int totpoint,float rad,int beauty)
|
||||
{
|
||||
float co[3];
|
||||
float percent;
|
||||
EditVert *ev;
|
||||
@@ -2018,7 +2030,6 @@ void esubdivideflag(int flag, float rad, int beauty, int numcuts, int seltype)
|
||||
EditVert **templist;
|
||||
struct GHash *gh;
|
||||
int i,edgecount,facetype;
|
||||
short cuttype=0;
|
||||
|
||||
//Set faces f1 to 0 cause we need it later
|
||||
|
||||
@@ -2156,7 +2167,7 @@ void esubdivideflag(int flag, float rad, int beauty, int numcuts, int seltype)
|
||||
}
|
||||
// Free the ghash and call MEM_freeN on all the value entries to return
|
||||
// that memory
|
||||
BLI_ghash_free(gh, NULL, MEM_freeN);
|
||||
BLI_ghash_free(gh, NULL, (GHashValFreeFP)MEM_freeN);
|
||||
|
||||
recalc_editnormals();
|
||||
countall();
|
||||
@@ -2188,9 +2199,9 @@ typedef EVPtr EVPTuple[2];
|
||||
|
||||
static int collect_quadedges(EVPTuple *efaa, EditEdge *eed, EditFace *efa)
|
||||
{
|
||||
int i = 0;
|
||||
EditEdge *e1, *e2, *e3;
|
||||
EVPtr *evp;
|
||||
int i = 0;
|
||||
|
||||
/* run through edges, if selected, set pointer edge-> facearray */
|
||||
while(eed) {
|
||||
@@ -4069,31 +4080,31 @@ typedef struct SlideVert {
|
||||
} SlideVert;
|
||||
|
||||
// This passes a ghash to the ghash free function so we can use it pseudo-recursively later
|
||||
void freeGHash(GHash *g){
|
||||
BLI_ghash_free(g,NULL,NULL);
|
||||
void freeGHash(GHash *g)
|
||||
{
|
||||
BLI_ghash_free(g, NULL, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
void EdgeSlide(short immediate, float imperc){
|
||||
void EdgeSlide(short immediate, float imperc)
|
||||
{
|
||||
EditMesh *em = G.editMesh;
|
||||
EditFace *efa;
|
||||
EditEdge *eed,*first=NULL,*last=NULL, *temp = NULL;
|
||||
EditVert *ev;
|
||||
LinkNode *edgelist = NULL, *vertlist=NULL, *look;
|
||||
int i = 0,j;
|
||||
char str[128];
|
||||
int numsel,numadded=0,timesthrough = 0,vertsel=0,prop=1,side=1;
|
||||
short event,draw=1;
|
||||
GHash *vertgh;
|
||||
SlideVert *tempsv;
|
||||
float perc = 0, percp = 0;
|
||||
short mval[2],mvalo[2];
|
||||
int i = 0,j;
|
||||
int numsel, numadded=0, timesthrough = 0, vertsel=0, prop=1;
|
||||
short event, draw=1;
|
||||
short mval[2], mvalo[2];
|
||||
char str[128];
|
||||
|
||||
mvalo[0] = -1;mvalo[1] = -1;
|
||||
mvalo[0] = -1; mvalo[1] = -1;
|
||||
numsel =0;
|
||||
|
||||
|
||||
|
||||
// Get number of selected edges and clear some flags
|
||||
for(eed=em->edges.first;eed;eed=eed->next){
|
||||
eed->f1 = 0;
|
||||
@@ -4315,7 +4326,7 @@ void EdgeSlide(short immediate, float imperc){
|
||||
}
|
||||
}
|
||||
if(i > 4 && j == 2){
|
||||
BLI_ghash_free(vertgh,NULL,MEM_freeN);
|
||||
BLI_ghash_free(vertgh, NULL, (GHashValFreeFP)MEM_freeN);
|
||||
BLI_linklist_free(vertlist,NULL);
|
||||
BLI_linklist_free(edgelist,NULL);
|
||||
return;
|
||||
@@ -4459,7 +4470,7 @@ void EdgeSlide(short immediate, float imperc){
|
||||
}
|
||||
|
||||
//BLI_ghash_free(edgesgh, freeGHash, NULL);
|
||||
BLI_ghash_free(vertgh,NULL,MEM_freeN);
|
||||
BLI_ghash_free(vertgh, NULL, (GHashValFreeFP)MEM_freeN);
|
||||
BLI_linklist_free(vertlist,NULL);
|
||||
BLI_linklist_free(edgelist,NULL);
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
TreeElement *parent, short type, short index)
|
||||
@@ -493,9 +489,10 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
|
||||
ten= nten;
|
||||
}
|
||||
/* 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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
else {
|
||||
Bone *curBone;
|
||||
for (curBone=arm->bonebase.first; curBone; curBone=curBone->next){
|
||||
outliner_add_bone(soops, &te->subtree, id, curBone, te, &a);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -675,22 +666,6 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
|
||||
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)
|
||||
{
|
||||
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);
|
||||
case TSE_DEFGROUP:
|
||||
return tree_element_active_defgroup(te, tselem, set);
|
||||
case TSE_BONE:
|
||||
return tree_element_active_bone(te, tselem, set);
|
||||
case TSE_EBONE:
|
||||
return tree_element_active_ebone(te, tselem, set);
|
||||
case TSE_HOOK: // actually object
|
||||
@@ -1900,7 +1873,6 @@ static void tselem_draw_icon(TreeStoreElem *tselem)
|
||||
BIF_draw_icon(ICON_ACTION); break;
|
||||
case TSE_DEFGROUP_BASE:
|
||||
BIF_draw_icon(ICON_VERTEXSEL); break;
|
||||
case TSE_BONE:
|
||||
case TSE_EBONE:
|
||||
BIF_draw_icon(ICON_WPAINT_DEHLT); break;
|
||||
case TSE_CONSTRAINT_BASE:
|
||||
@@ -2265,20 +2237,6 @@ static void namebutton_cb(void *soopsp, void *oldnamep)
|
||||
allqueue(REDRAWVIEW3D, 1);
|
||||
allqueue(REDRAWBUTSEDIT, 0);
|
||||
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);
|
||||
if(tselem->flag & TSE_TEXTBUT) {
|
||||
|
||||
if(tselem->type==TSE_BONE) {
|
||||
if(tselem->type==TSE_EBONE) {
|
||||
len= 32;
|
||||
}
|
||||
else len= 19;
|
||||
|
||||
Reference in New Issue
Block a user