another compile fix
This commit is contained in:
@@ -3371,808 +3371,6 @@ short sharesFace(EditMesh *em, EditEdge* e1, EditEdge* e2)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
typedef struct SlideUv {
|
||||
float origuv[2];
|
||||
float *uv_up, *uv_down;
|
||||
//float *fuv[4];
|
||||
LinkNode *fuv_list;
|
||||
} SlideUv;
|
||||
|
||||
typedef struct SlideVert {
|
||||
EditEdge *up,*down;
|
||||
EditVert origvert;
|
||||
} SlideVert;
|
||||
|
||||
int EdgeSlide(EditMesh *em, wmOperator *op, short immediate, float imperc)
|
||||
{
|
||||
return 0;
|
||||
/* XXX REFACTOR - #if 0'd for now, otherwise can't make 64bit windows builds on 64bit machine */
|
||||
#if 0
|
||||
useless:
|
||||
goto useless // because it doesn't do anything right now
|
||||
|
||||
// NumInput num; XXX
|
||||
Mesh *me= NULL; // XXX
|
||||
EditFace *efa;
|
||||
EditEdge *eed,*first=NULL,*last=NULL, *temp = NULL;
|
||||
EditVert *ev, *nearest;
|
||||
LinkNode *edgelist = NULL, *vertlist=NULL, *look;
|
||||
GHash *vertgh;
|
||||
|
||||
SlideVert *tempsv;
|
||||
float perc = 0, percp = 0,vertdist; // XXX, projectMat[4][4];
|
||||
float shiftlabda= 0.0f,len = 0.0f;
|
||||
int i = 0,j, numsel, numadded=0, timesthrough = 0, vertsel=0, prop=1, cancel = 0,flip=0;
|
||||
int wasshift = 0;
|
||||
|
||||
/* UV correction vars */
|
||||
GHash **uvarray= NULL;
|
||||
int uvlay_tot= CustomData_number_of_layers(&em->fdata, CD_MTFACE);
|
||||
int uvlay_idx;
|
||||
SlideUv *slideuvs=NULL, *suv=NULL, *suv_last=NULL;
|
||||
float uv_tmp[2];
|
||||
LinkNode *fuv_link;
|
||||
|
||||
short event, draw=1;
|
||||
short mval[2], mvalo[2];
|
||||
char str[128];
|
||||
float labda = 0.0f;
|
||||
|
||||
// initNumInput(&num);
|
||||
|
||||
// view3d_get_object_project_mat(curarea, obedit, projectMat);
|
||||
|
||||
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;
|
||||
eed->f2 = 0;
|
||||
if(eed->f & SELECT) numsel++;
|
||||
}
|
||||
|
||||
for(ev=em->verts.first;ev;ev=ev->next) {
|
||||
ev->f1 = 0;
|
||||
}
|
||||
|
||||
//Make sure each edge only has 2 faces
|
||||
// make sure loop doesn't cross face
|
||||
for(efa=em->faces.first;efa;efa=efa->next) {
|
||||
int ct = 0;
|
||||
if(efa->e1->f & SELECT) {
|
||||
ct++;
|
||||
efa->e1->f1++;
|
||||
if(efa->e1->f1 > 2) {
|
||||
BKE_report(op->reports, RPT_ERROR, "3+ face edge");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if(efa->e2->f & SELECT) {
|
||||
ct++;
|
||||
efa->e2->f1++;
|
||||
if(efa->e2->f1 > 2) {
|
||||
BKE_report(op->reports, RPT_ERROR, "3+ face edge");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if(efa->e3->f & SELECT) {
|
||||
ct++;
|
||||
efa->e3->f1++;
|
||||
if(efa->e3->f1 > 2) {
|
||||
BKE_report(op->reports, RPT_ERROR, "3+ face edge");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if(efa->e4 && efa->e4->f & SELECT) {
|
||||
ct++;
|
||||
efa->e4->f1++;
|
||||
if(efa->e4->f1 > 2) {
|
||||
BKE_report(op->reports, RPT_ERROR, "3+ face edge");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
// Make sure loop is not 2 edges of same face
|
||||
if(ct > 1) {
|
||||
BKE_report(op->reports, RPT_ERROR, "Loop crosses itself");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
// Get # of selected verts
|
||||
for(ev=em->verts.first;ev;ev=ev->next) {
|
||||
if(ev->f & SELECT) vertsel++;
|
||||
}
|
||||
|
||||
// Test for multiple segments
|
||||
if(vertsel > numsel+1) {
|
||||
BKE_report(op->reports, RPT_ERROR, "Please choose a single edge loop");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Get the edgeloop in order - mark f1 with SELECT once added
|
||||
for(eed=em->edges.first;eed;eed=eed->next) {
|
||||
if((eed->f & SELECT) && !(eed->f1 & SELECT)) {
|
||||
// If this is the first edge added, just put it in
|
||||
if(!edgelist) {
|
||||
BLI_linklist_prepend(&edgelist,eed);
|
||||
numadded++;
|
||||
first = eed;
|
||||
last = eed;
|
||||
eed->f1 = SELECT;
|
||||
} else {
|
||||
if(editedge_getSharedVert(eed, last)) {
|
||||
BLI_linklist_append(&edgelist,eed);
|
||||
eed->f1 = SELECT;
|
||||
numadded++;
|
||||
last = eed;
|
||||
} else if(editedge_getSharedVert(eed, first)) {
|
||||
BLI_linklist_prepend(&edgelist,eed);
|
||||
eed->f1 = SELECT;
|
||||
numadded++;
|
||||
first = eed;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(eed->next == NULL && numadded != numsel) {
|
||||
eed=em->edges.first;
|
||||
timesthrough++;
|
||||
}
|
||||
|
||||
// It looks like there was an unexpected case - Hopefully should not happen
|
||||
if(timesthrough >= numsel*2) {
|
||||
BLI_linklist_free(edgelist,NULL);
|
||||
BKE_report(op->reports, RPT_ERROR, "Could not order loop");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Put the verts in order in a linklist
|
||||
look = edgelist;
|
||||
while(look) {
|
||||
eed = look->link;
|
||||
if(!vertlist) {
|
||||
if(look->next) {
|
||||
temp = look->next->link;
|
||||
|
||||
//This is the first entry takes care of extra vert
|
||||
if(eed->v1 != temp->v1 && eed->v1 != temp->v2) {
|
||||
BLI_linklist_append(&vertlist,eed->v1);
|
||||
eed->v1->f1 = 1;
|
||||
} else {
|
||||
BLI_linklist_append(&vertlist,eed->v2);
|
||||
eed->v2->f1 = 1;
|
||||
}
|
||||
} else {
|
||||
//This is the case that we only have 1 edge
|
||||
BLI_linklist_append(&vertlist,eed->v1);
|
||||
eed->v1->f1 = 1;
|
||||
}
|
||||
}
|
||||
// for all the entries
|
||||
if(eed->v1->f1 != 1) {
|
||||
BLI_linklist_append(&vertlist,eed->v1);
|
||||
eed->v1->f1 = 1;
|
||||
} else if(eed->v2->f1 != 1) {
|
||||
BLI_linklist_append(&vertlist,eed->v2);
|
||||
eed->v2->f1 = 1;
|
||||
}
|
||||
look = look->next;
|
||||
}
|
||||
|
||||
// populate the SlideVerts
|
||||
|
||||
vertgh = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp);
|
||||
look = vertlist;
|
||||
while(look) {
|
||||
i=0;
|
||||
j=0;
|
||||
ev = look->link;
|
||||
tempsv = (struct SlideVert*)MEM_mallocN(sizeof(struct SlideVert),"SlideVert");
|
||||
tempsv->up = NULL;
|
||||
tempsv->down = NULL;
|
||||
tempsv->origvert.co[0] = ev->co[0];
|
||||
tempsv->origvert.co[1] = ev->co[1];
|
||||
tempsv->origvert.co[2] = ev->co[2];
|
||||
tempsv->origvert.no[0] = ev->no[0];
|
||||
tempsv->origvert.no[1] = ev->no[1];
|
||||
tempsv->origvert.no[2] = ev->no[2];
|
||||
// i is total edges that vert is on
|
||||
// j is total selected edges that vert is on
|
||||
|
||||
for(eed=em->edges.first;eed;eed=eed->next) {
|
||||
if(eed->v1 == ev || eed->v2 == ev) {
|
||||
i++;
|
||||
if(eed->f & SELECT) {
|
||||
j++;
|
||||
}
|
||||
}
|
||||
}
|
||||
// If the vert is in the middle of an edge loop, it touches 2 selected edges and 2 unselected edges
|
||||
if(i == 4 && j == 2) {
|
||||
for(eed=em->edges.first;eed;eed=eed->next) {
|
||||
if(editedge_containsVert(eed, ev)) {
|
||||
if(!(eed->f & SELECT)) {
|
||||
if(!tempsv->up) {
|
||||
tempsv->up = eed;
|
||||
} else if (!(tempsv->down)) {
|
||||
tempsv->down = eed;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// If it is on the end of the loop, it touches 1 selected and as least 2 more unselected
|
||||
if(i >= 3 && j == 1) {
|
||||
for(eed=em->edges.first;eed;eed=eed->next) {
|
||||
if(editedge_containsVert(eed, ev) && eed->f & SELECT) {
|
||||
for(efa = em->faces.first;efa;efa=efa->next) {
|
||||
if(editface_containsEdge(efa, eed)) {
|
||||
if(editedge_containsVert(efa->e1, ev) && efa->e1 != eed) {
|
||||
if(!tempsv->up) {
|
||||
tempsv->up = efa->e1;
|
||||
} else if (!(tempsv->down)) {
|
||||
tempsv->down = efa->e1;
|
||||
}
|
||||
}
|
||||
if(editedge_containsVert(efa->e2, ev) && efa->e2 != eed) {
|
||||
if(!tempsv->up) {
|
||||
tempsv->up = efa->e2;
|
||||
} else if (!(tempsv->down)) {
|
||||
tempsv->down = efa->e2;
|
||||
}
|
||||
}
|
||||
if(editedge_containsVert(efa->e3, ev) && efa->e3 != eed) {
|
||||
if(!tempsv->up) {
|
||||
tempsv->up = efa->e3;
|
||||
} else if (!(tempsv->down)) {
|
||||
tempsv->down = efa->e3;
|
||||
}
|
||||
}
|
||||
if(efa->e4) {
|
||||
if(editedge_containsVert(efa->e4, ev) && efa->e4 != eed) {
|
||||
if(!tempsv->up) {
|
||||
tempsv->up = efa->e4;
|
||||
} else if (!(tempsv->down)) {
|
||||
tempsv->down = efa->e4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(i > 4 && j == 2) {
|
||||
BLI_ghash_free(vertgh, NULL, (GHashValFreeFP)MEM_freeN);
|
||||
BLI_linklist_free(vertlist,NULL);
|
||||
BLI_linklist_free(edgelist,NULL);
|
||||
return 0;
|
||||
}
|
||||
BLI_ghash_insert(vertgh,ev,tempsv);
|
||||
|
||||
look = look->next;
|
||||
}
|
||||
|
||||
// make sure the UPs nad DOWNs are 'faceloops'
|
||||
// Also find the nearest slidevert to the cursor
|
||||
// XXX getmouseco_areawin(mval);
|
||||
look = vertlist;
|
||||
nearest = NULL;
|
||||
vertdist = -1;
|
||||
while(look) {
|
||||
tempsv = BLI_ghash_lookup(vertgh,(EditVert*)look->link);
|
||||
|
||||
if(!tempsv->up || !tempsv->down) {
|
||||
BKE_report(op->reports, RPT_ERROR, "Missing rails");
|
||||
BLI_ghash_free(vertgh, NULL, (GHashValFreeFP)MEM_freeN);
|
||||
BLI_linklist_free(vertlist,NULL);
|
||||
BLI_linklist_free(edgelist,NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(me->drawflag & ME_DRAW_EDGELEN) {
|
||||
if(!(tempsv->up->f & SELECT)) {
|
||||
tempsv->up->f |= SELECT;
|
||||
tempsv->up->f2 |= 16;
|
||||
} else {
|
||||
tempsv->up->f2 |= ~16;
|
||||
}
|
||||
if(!(tempsv->down->f & SELECT)) {
|
||||
tempsv->down->f |= SELECT;
|
||||
tempsv->down->f2 |= 16;
|
||||
} else {
|
||||
tempsv->down->f2 |= ~16;
|
||||
}
|
||||
}
|
||||
|
||||
if(look->next != NULL) {
|
||||
SlideVert *sv;
|
||||
|
||||
sv = BLI_ghash_lookup(vertgh,(EditVert*)look->next->link);
|
||||
|
||||
if(sv) {
|
||||
float tempdist, co[2];
|
||||
|
||||
if(!sharesFace(em, tempsv->up,sv->up)) {
|
||||
EditEdge *swap;
|
||||
swap = sv->up;
|
||||
sv->up = sv->down;
|
||||
sv->down = swap;
|
||||
}
|
||||
|
||||
// view3d_project_float(curarea, tempsv->origvert.co, co, projectMat);
|
||||
|
||||
tempdist = sqrt(pow(co[0] - mval[0],2)+pow(co[1] - mval[1],2));
|
||||
|
||||
if(vertdist < 0) {
|
||||
vertdist = tempdist;
|
||||
nearest = (EditVert*)look->link;
|
||||
} else if ( tempdist < vertdist ) {
|
||||
vertdist = tempdist;
|
||||
nearest = (EditVert*)look->link;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
look = look->next;
|
||||
}
|
||||
|
||||
|
||||
if (uvlay_tot) { // XXX && (scene->toolsettings->uvcalc_flag & UVCALC_TRANSFORM_CORRECT)) {
|
||||
int maxnum = 0;
|
||||
uvarray = MEM_callocN( uvlay_tot * sizeof(GHash *), "SlideUVs Array");
|
||||
suv_last = slideuvs = MEM_callocN( uvlay_tot * (numadded+1) * sizeof(SlideUv), "SlideUVs"); /* uvLayers * verts */
|
||||
suv = NULL;
|
||||
|
||||
for (uvlay_idx=0; uvlay_idx<uvlay_tot; uvlay_idx++) {
|
||||
|
||||
uvarray[uvlay_idx] = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp);
|
||||
|
||||
for(ev=em->verts.first;ev;ev=ev->next) {
|
||||
ev->tmp.l = 0;
|
||||
}
|
||||
look = vertlist;
|
||||
while(look) {
|
||||
float *uv_new;
|
||||
tempsv = BLI_ghash_lookup(vertgh,(EditVert*)look->link);
|
||||
|
||||
ev = look->link;
|
||||
suv = NULL;
|
||||
for(efa = em->faces.first;efa;efa=efa->next) {
|
||||
if (ev->tmp.l != -1) { /* test for self, in this case its invalid */
|
||||
int k=-1; /* face corner */
|
||||
|
||||
/* Is this vert in the faces corner? */
|
||||
if (efa->v1==ev) k=0;
|
||||
else if (efa->v2==ev) k=1;
|
||||
else if (efa->v3==ev) k=2;
|
||||
else if (efa->v4 && efa->v4==ev) k=3;
|
||||
|
||||
if (k != -1) {
|
||||
MTFace *tf = CustomData_em_get_n(&em->fdata, efa->data, CD_MTFACE, uvlay_idx);
|
||||
EditVert *ev_up, *ev_down;
|
||||
|
||||
uv_new = tf->uv[k];
|
||||
|
||||
if (ev->tmp.l) {
|
||||
if (fabs(suv->origuv[0]-uv_new[0]) > 0.0001 || fabs(suv->origuv[1]-uv_new[1])) {
|
||||
ev->tmp.l = -1; /* Tag as invalid */
|
||||
BLI_linklist_free(suv->fuv_list,NULL);
|
||||
suv->fuv_list = NULL;
|
||||
BLI_ghash_remove(uvarray[uvlay_idx],ev, NULL, NULL);
|
||||
suv = NULL;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
ev->tmp.l = 1;
|
||||
suv = suv_last;
|
||||
|
||||
suv->fuv_list = NULL;
|
||||
suv->uv_up = suv->uv_down = NULL;
|
||||
suv->origuv[0] = uv_new[0];
|
||||
suv->origuv[1] = uv_new[1];
|
||||
|
||||
BLI_linklist_prepend(&suv->fuv_list, uv_new);
|
||||
BLI_ghash_insert(uvarray[uvlay_idx],ev,suv);
|
||||
|
||||
suv_last++; /* advance to next slide UV */
|
||||
maxnum++;
|
||||
}
|
||||
|
||||
/* Now get the uvs along the up or down edge if we can */
|
||||
if (suv) {
|
||||
if (!suv->uv_up) {
|
||||
ev_up = editedge_getOtherVert(tempsv->up,ev);
|
||||
if (efa->v1==ev_up) suv->uv_up = tf->uv[0];
|
||||
else if (efa->v2==ev_up) suv->uv_up = tf->uv[1];
|
||||
else if (efa->v3==ev_up) suv->uv_up = tf->uv[2];
|
||||
else if (efa->v4 && efa->v4==ev_up) suv->uv_up = tf->uv[3];
|
||||
}
|
||||
if (!suv->uv_down) { /* if the first face was apart of the up edge, it cant be apart of the down edge */
|
||||
ev_down = editedge_getOtherVert(tempsv->down,ev);
|
||||
if (efa->v1==ev_down) suv->uv_down = tf->uv[0];
|
||||
else if (efa->v2==ev_down) suv->uv_down = tf->uv[1];
|
||||
else if (efa->v3==ev_down) suv->uv_down = tf->uv[2];
|
||||
else if (efa->v4 && efa->v4==ev_down) suv->uv_down = tf->uv[3];
|
||||
}
|
||||
|
||||
/* Copy the pointers to the face UV's */
|
||||
BLI_linklist_prepend(&suv->fuv_list, uv_new);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
look = look->next;
|
||||
}
|
||||
} /* end uv layer loop */
|
||||
} /* end uvlay_tot */
|
||||
|
||||
|
||||
|
||||
// we should have enough info now to slide
|
||||
|
||||
len = 0.0f;
|
||||
|
||||
percp = -1;
|
||||
while(draw) {
|
||||
/* For the % calculation */
|
||||
short mval[2];
|
||||
float rc[2];
|
||||
float v2[2], v3[2];
|
||||
EditVert *centerVert, *upVert, *downVert;
|
||||
|
||||
// XXX getmouseco_areawin(mval);
|
||||
|
||||
if (!immediate && (mval[0] == mvalo[0] && mval[1] == mvalo[1])) {
|
||||
PIL_sleep_ms(10);
|
||||
} else {
|
||||
char *p = str;
|
||||
int ctrl= 0, shift= 0; // XXX
|
||||
|
||||
mvalo[0] = mval[0];
|
||||
mvalo[1] = mval[1];
|
||||
|
||||
|
||||
tempsv = BLI_ghash_lookup(vertgh,nearest);
|
||||
|
||||
centerVert = editedge_getSharedVert(tempsv->up, tempsv->down);
|
||||
upVert = editedge_getOtherVert(tempsv->up, centerVert);
|
||||
downVert = editedge_getOtherVert(tempsv->down, centerVert);
|
||||
|
||||
// view3d_project_float(curarea, upVert->co, v2, projectMat);
|
||||
// view3d_project_float(curarea, downVert->co, v3, projectMat);
|
||||
|
||||
/* Determine the % on which the loop should be cut */
|
||||
|
||||
rc[0]= v3[0]-v2[0];
|
||||
rc[1]= v3[1]-v2[1];
|
||||
len= rc[0]*rc[0]+ rc[1]*rc[1];
|
||||
if (len==0) {len = 0.0001;}
|
||||
|
||||
if (shift) {
|
||||
wasshift = 0;
|
||||
labda= ( rc[0]*((mval[0]-v2[0])) + rc[1]*((mval[1]-v2[1])) )/len;
|
||||
}
|
||||
else {
|
||||
if (wasshift==0) {
|
||||
wasshift = 1;
|
||||
shiftlabda = labda;
|
||||
}
|
||||
labda= ( rc[0]*((mval[0]-v2[0])) + rc[1]*((mval[1]-v2[1])) )/len / 10.0 + shiftlabda;
|
||||
}
|
||||
|
||||
|
||||
if(labda<=0.0) labda=0.0;
|
||||
else if(labda>=1.0)labda=1.0;
|
||||
|
||||
perc=((1-labda)*2)-1;
|
||||
|
||||
if(shift == 0 && ctrl==0) {
|
||||
perc *= 100;
|
||||
perc = floor(perc);
|
||||
perc /= 100;
|
||||
} else if (ctrl) {
|
||||
perc *= 10;
|
||||
perc = floor(perc);
|
||||
perc /= 10;
|
||||
}
|
||||
|
||||
if(prop == 0) {
|
||||
len = VecLenf(upVert->co,downVert->co)*((perc+1)/2);
|
||||
if(flip == 1) {
|
||||
len = VecLenf(upVert->co,downVert->co) - len;
|
||||
}
|
||||
}
|
||||
|
||||
if (0) // XXX hasNumInput(&num))
|
||||
{
|
||||
// XXX applyNumInput(&num, &perc);
|
||||
|
||||
if (prop)
|
||||
{
|
||||
perc = MIN2(perc, 1);
|
||||
perc = MAX2(perc, -1);
|
||||
}
|
||||
else
|
||||
{
|
||||
len = MIN2(perc, VecLenf(upVert->co,downVert->co));
|
||||
len = MAX2(len, 0);
|
||||
}
|
||||
}
|
||||
|
||||
//Adjust Edgeloop
|
||||
if(immediate) {
|
||||
perc = imperc;
|
||||
}
|
||||
percp = perc;
|
||||
if(prop) {
|
||||
look = vertlist;
|
||||
while(look) {
|
||||
EditVert *tempev;
|
||||
ev = look->link;
|
||||
tempsv = BLI_ghash_lookup(vertgh,ev);
|
||||
|
||||
tempev = editedge_getOtherVert((perc>=0)?tempsv->up:tempsv->down, ev);
|
||||
VecLerpf(ev->co, tempsv->origvert.co, tempev->co, fabs(perc));
|
||||
|
||||
if (0) { // XXX scene->toolsettings->uvcalc_flag & UVCALC_TRANSFORM_CORRECT) {
|
||||
for (uvlay_idx=0; uvlay_idx<uvlay_tot; uvlay_idx++) {
|
||||
suv = BLI_ghash_lookup( uvarray[uvlay_idx], ev );
|
||||
if (suv && suv->fuv_list && suv->uv_up && suv->uv_down) {
|
||||
Vec2Lerpf(uv_tmp, suv->origuv, (perc>=0)?suv->uv_up:suv->uv_down, fabs(perc));
|
||||
fuv_link = suv->fuv_list;
|
||||
while (fuv_link) {
|
||||
VECCOPY2D(((float *)fuv_link->link), uv_tmp);
|
||||
fuv_link = fuv_link->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
look = look->next;
|
||||
}
|
||||
}
|
||||
else {
|
||||
//Non prop code
|
||||
look = vertlist;
|
||||
while(look) {
|
||||
float newlen;
|
||||
ev = look->link;
|
||||
tempsv = BLI_ghash_lookup(vertgh,ev);
|
||||
newlen = (len / VecLenf(editedge_getOtherVert(tempsv->up,ev)->co,editedge_getOtherVert(tempsv->down,ev)->co));
|
||||
if(newlen > 1.0) {newlen = 1.0;}
|
||||
if(newlen < 0.0) {newlen = 0.0;}
|
||||
if(flip == 0) {
|
||||
VecLerpf(ev->co, editedge_getOtherVert(tempsv->down,ev)->co, editedge_getOtherVert(tempsv->up,ev)->co, fabs(newlen));
|
||||
if (0) { // XXX scene->toolsettings->uvcalc_flag & UVCALC_TRANSFORM_CORRECT) {
|
||||
/* dont do anything if no UVs */
|
||||
for (uvlay_idx=0; uvlay_idx<uvlay_tot; uvlay_idx++) {
|
||||
suv = BLI_ghash_lookup( uvarray[uvlay_idx], ev );
|
||||
if (suv && suv->fuv_list && suv->uv_up && suv->uv_down) {
|
||||
Vec2Lerpf(uv_tmp, suv->uv_down, suv->uv_up, fabs(newlen));
|
||||
fuv_link = suv->fuv_list;
|
||||
while (fuv_link) {
|
||||
VECCOPY2D(((float *)fuv_link->link), uv_tmp);
|
||||
fuv_link = fuv_link->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else{
|
||||
VecLerpf(ev->co, editedge_getOtherVert(tempsv->up,ev)->co, editedge_getOtherVert(tempsv->down,ev)->co, fabs(newlen));
|
||||
|
||||
if (0) { // XXX scene->toolsettings->uvcalc_flag & UVCALC_TRANSFORM_CORRECT) {
|
||||
/* dont do anything if no UVs */
|
||||
for (uvlay_idx=0; uvlay_idx<uvlay_tot; uvlay_idx++) {
|
||||
suv = BLI_ghash_lookup( uvarray[uvlay_idx], ev );
|
||||
if (suv && suv->fuv_list && suv->uv_up && suv->uv_down) {
|
||||
Vec2Lerpf(uv_tmp, suv->uv_up, suv->uv_down, fabs(newlen));
|
||||
fuv_link = suv->fuv_list;
|
||||
while (fuv_link) {
|
||||
VECCOPY2D(((float *)fuv_link->link), uv_tmp);
|
||||
fuv_link = fuv_link->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
look = look->next;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Highlight the Control Edges
|
||||
// scrarea_do_windraw(curarea);
|
||||
// persp(PERSP_VIEW);
|
||||
// glPushMatrix();
|
||||
// mymultmatrix(obedit->obmat);
|
||||
|
||||
glColor3ub(0, 255, 0);
|
||||
glBegin(GL_LINES);
|
||||
glVertex3fv(upVert->co);
|
||||
glVertex3fv(downVert->co);
|
||||
glEnd();
|
||||
|
||||
if(prop == 0) {
|
||||
// draw start edge for non-prop
|
||||
glPointSize(5);
|
||||
glBegin(GL_POINTS);
|
||||
glColor3ub(255,0,255);
|
||||
if(flip) {
|
||||
glVertex3fv(upVert->co);
|
||||
} else {
|
||||
glVertex3fv(downVert->co);
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
if(prop) {
|
||||
p += sprintf(str, "(P)ercentage: ");
|
||||
} else {
|
||||
p += sprintf(str, "Non (P)rop Length: ");
|
||||
}
|
||||
|
||||
if (0) // XXX hasNumInput(&num))
|
||||
{
|
||||
char num_str[20];
|
||||
|
||||
// XX outputNumInput(&num, num_str);
|
||||
p += sprintf(p, "%s", num_str);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (prop)
|
||||
{
|
||||
p += sprintf(p, "%f", perc);
|
||||
}
|
||||
else
|
||||
{
|
||||
p += sprintf(p, "%f", len);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (prop == 0) {
|
||||
p += sprintf(p, ", Press (F) to flip control side");
|
||||
}
|
||||
|
||||
// headerprint(str);
|
||||
// screen_swapbuffers();
|
||||
}
|
||||
if(!immediate) {
|
||||
while(qtest()) {
|
||||
short val=0;
|
||||
event= extern_qread(&val); // extern_qread stores important events for the mainloop to handle
|
||||
|
||||
/* val==0 on key-release event */
|
||||
if (val) {
|
||||
if(ELEM(event, ESCKEY, RIGHTMOUSE)) {
|
||||
prop = 1; // Go back to prop mode
|
||||
imperc = 0; // This is the % that gets set for immediate
|
||||
immediate = 1; //Run through eval code 1 more time
|
||||
cancel = 1; // Return -1
|
||||
mvalo[0] = -1;
|
||||
} else if(ELEM3(event, PADENTER, LEFTMOUSE, RETKEY)) {
|
||||
draw = 0; // End looping now
|
||||
} else if(event==MIDDLEMOUSE) {
|
||||
perc = 0;
|
||||
immediate = 1;
|
||||
} else if(event==PKEY) {
|
||||
// XXX initNumInput(&num); /* reset num input */
|
||||
if (prop) {
|
||||
prop = 0;
|
||||
// XXX num.flag |= NUM_NO_NEGATIVE;
|
||||
}
|
||||
else {
|
||||
prop = 1;
|
||||
}
|
||||
mvalo[0] = -1;
|
||||
} else if(event==FKEY) {
|
||||
(flip == 1) ? (flip = 0):(flip = 1);
|
||||
mvalo[0] = -1;
|
||||
} else if(ELEM(event, RIGHTARROWKEY, WHEELUPMOUSE)) { // Scroll through Control Edges
|
||||
look = vertlist;
|
||||
while(look) {
|
||||
if(nearest == (EditVert*)look->link) {
|
||||
if(look->next == NULL) {
|
||||
nearest = (EditVert*)vertlist->link;
|
||||
} else {
|
||||
nearest = (EditVert*)look->next->link;
|
||||
}
|
||||
mvalo[0] = -1;
|
||||
break;
|
||||
}
|
||||
look = look->next;
|
||||
}
|
||||
} else if(ELEM(event, LEFTARROWKEY, WHEELDOWNMOUSE)) { // Scroll through Control Edges
|
||||
look = vertlist;
|
||||
while(look) {
|
||||
if(look->next) {
|
||||
if(look->next->link == nearest) {
|
||||
nearest = (EditVert*)look->link;
|
||||
mvalo[0] = -1;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if((EditVert*)vertlist->link == nearest) {
|
||||
nearest = look->link;
|
||||
mvalo[0] = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
look = look->next;
|
||||
}
|
||||
}
|
||||
|
||||
// XXX if (handleNumInput(&num, event))
|
||||
{
|
||||
mvalo[0] = -1; /* NEED A BETTER WAY TO TRIGGER REDRAW */
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
draw = 0;
|
||||
}
|
||||
// DAG_id_flush_update(obedit->data, OB_RECALC_DATA);
|
||||
}
|
||||
|
||||
|
||||
if(me->drawflag & ME_DRAW_EDGELEN) {
|
||||
look = vertlist;
|
||||
while(look) {
|
||||
tempsv = BLI_ghash_lookup(vertgh,(EditVert*)look->link);
|
||||
if(tempsv != NULL) {
|
||||
tempsv->up->f &= !SELECT;
|
||||
tempsv->down->f &= !SELECT;
|
||||
}
|
||||
look = look->next;
|
||||
}
|
||||
}
|
||||
|
||||
// force_draw(0);
|
||||
|
||||
if(!immediate)
|
||||
EM_automerge(0);
|
||||
// DAG_id_flush_update(obedit->data, OB_RECALC_DATA);
|
||||
// scrarea_queue_winredraw(curarea);
|
||||
|
||||
//BLI_ghash_free(edgesgh, freeGHash, NULL);
|
||||
BLI_ghash_free(vertgh, NULL, (GHashValFreeFP)MEM_freeN);
|
||||
BLI_linklist_free(vertlist,NULL);
|
||||
BLI_linklist_free(edgelist,NULL);
|
||||
|
||||
if (uvlay_tot) { // XXX && (scene->toolsettings->uvcalc_flag & UVCALC_TRANSFORM_CORRECT)) {
|
||||
for (uvlay_idx=0; uvlay_idx<uvlay_tot; uvlay_idx++) {
|
||||
BLI_ghash_free(uvarray[uvlay_idx], NULL, NULL);
|
||||
}
|
||||
MEM_freeN(uvarray);
|
||||
MEM_freeN(slideuvs);
|
||||
|
||||
suv = suv_last-1;
|
||||
while (suv >= slideuvs) {
|
||||
if (suv->fuv_list) {
|
||||
BLI_linklist_free(suv->fuv_list,NULL);
|
||||
}
|
||||
suv--;
|
||||
}
|
||||
}
|
||||
|
||||
if(cancel == 1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 1;
|
||||
#endif // END OF XXX
|
||||
}
|
||||
|
||||
/* -------------------- More tools ------------------ */
|
||||
#if 0
|
||||
void mesh_set_face_flags(EditMesh *em, short mode)
|
||||
|
||||
Reference in New Issue
Block a user