First step towards restoring / improving subdivide 'beauty'.
Beauty button now is Beauty and Short. Works as follows Beauty on: If a face is selected, only subdivide the longest 2 sides Beauty & Short on: If a face is selected, only subdivide the shortest 2 sides 1 problem atm is when more than 2 sides are equal. Must add code to check for this and disable beauty on that face. Use with caution! :) Also restoring selection needs to be tweaked here. Side Note: for most accurate subdividing, use edge mode and select only the edges you wish to cut rather than relying on beauty.
This commit is contained in:
parent
8d2d045079
commit
b344db3670
|
@ -383,6 +383,7 @@
|
|||
#define B_KEEPORIG 2
|
||||
#define B_BEAUTY 4
|
||||
#define B_SMOOTH 8
|
||||
#define B_BEAUTY_SHORT 16
|
||||
#define B_KNIFE 0x80
|
||||
#define B_PERCENTSUBD 0x40
|
||||
|
||||
|
|
|
@ -2167,7 +2167,9 @@ static void editing_panel_mesh_tools(Object *ob, Mesh *me)
|
|||
if(uiNewPanel(curarea, block, "Mesh Tools", "Editing", 640, 0, 318, 204)==0) return;
|
||||
|
||||
uiBlockBeginAlign(block);
|
||||
uiDefButS(block, TOG|BIT|2, 0, "Beauty", 10,195,80,19, &editbutflag, 0, 0, 0, 0, "Causes 'Subdivide' to split faces in halves instead of quarters");
|
||||
uiDefButS(block, TOG|BIT|2, 0, "Beauty", 10,195,40,19, &editbutflag, 0, 0, 0, 0, "Causes 'Subdivide' to split faces in halves instead of quarters using Long Edges Unless short is selected");
|
||||
uiDefButS(block, TOG|BIT|4, 0, "Short", 50,195,40,19, &editbutflag, 0, 0, 0, 0, "Causes 'Subdivide' to split faces in halves instead of quarters using Short Edges");
|
||||
|
||||
uiDefBut(block, BUT,B_SUBDIV,"Subdivide", 90,195,80,19, 0, 0, 0, 0, 0, "Splits selected faces into halves or quarters");
|
||||
uiDefBut(block, BUT,B_FRACSUBDIV, "Fract Subd", 170,195,85,19, 0, 0, 0, 0, 0, "Subdivides selected faces with a random factor");
|
||||
|
||||
|
|
|
@ -1105,6 +1105,7 @@ void fill_mesh(void)
|
|||
|
||||
/*--------------Edge Based Subdivide------------------*/
|
||||
#define EDGENEW 2
|
||||
#define FACENEW 2
|
||||
#define EDGEINNER 4
|
||||
|
||||
static void alter_co(float* co,EditEdge *edge,float rad,int beauty)
|
||||
|
@ -2026,10 +2027,11 @@ void esubdivideflag(int flag, float rad, int beauty, int numcuts, int seltype)
|
|||
{
|
||||
EditMesh *em = G.editMesh;
|
||||
EditFace *ef;
|
||||
EditEdge *eed, *cedge;
|
||||
EditEdge *eed, *cedge, *sort[4];
|
||||
EditVert **templist;
|
||||
struct GHash *gh;
|
||||
int i,edgecount,facetype;
|
||||
int i,j,edgecount,facetype,hold;
|
||||
float length[4];
|
||||
|
||||
//Set faces f1 to 0 cause we need it later
|
||||
|
||||
|
@ -2046,6 +2048,71 @@ void esubdivideflag(int flag, float rad, int beauty, int numcuts, int seltype)
|
|||
// We store an array of verts for each edge that is subdivided,
|
||||
// we put this array as a value in a ghash which is keyed by the EditEdge*
|
||||
|
||||
// Now for beauty subdivide deselect edges based on length
|
||||
if(beauty & B_BEAUTY){
|
||||
for(ef = em->faces.first;ef;ef = ef->next){
|
||||
if(!ef->v4){
|
||||
continue;
|
||||
}
|
||||
if(ef->f & SELECT){
|
||||
length[0] = VecLenf(ef->e1->v1->co,ef->e1->v2->co);
|
||||
length[1] = VecLenf(ef->e2->v1->co,ef->e2->v2->co);
|
||||
length[2] = VecLenf(ef->e3->v1->co,ef->e3->v2->co);
|
||||
length[3] = VecLenf(ef->e4->v1->co,ef->e4->v2->co);
|
||||
sort[0] = ef->e1;
|
||||
sort[1] = ef->e2;
|
||||
sort[2] = ef->e3;
|
||||
sort[3] = ef->e4;
|
||||
|
||||
|
||||
// Beauty Short Edges
|
||||
if(beauty & B_BEAUTY_SHORT){
|
||||
for(j=0;j<2;j++){
|
||||
hold = -1;
|
||||
for(i=0;i<4;i++){
|
||||
if(length[i] < 0){
|
||||
continue;
|
||||
} else if(hold == -1){
|
||||
hold = i;
|
||||
} else {
|
||||
if(length[hold] < length[i]){
|
||||
hold = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
sort[hold]->f &= ~SELECT;
|
||||
sort[hold]->f2 |= EDGENEW;
|
||||
length[hold] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
// Beauty Long Edges
|
||||
else {
|
||||
for(j=0;j<2;j++){
|
||||
hold = -1;
|
||||
for(i=0;i<4;i++){
|
||||
if(length[i] < 0){
|
||||
continue;
|
||||
} else if(hold == -1){
|
||||
hold = i;
|
||||
} else {
|
||||
if(length[hold] > length[i]){
|
||||
hold = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
sort[hold]->f &= ~SELECT;
|
||||
sort[hold]->f2 |= EDGENEW;
|
||||
length[hold] = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
gh = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp);
|
||||
|
||||
// If we are knifing, We only need the selected edges that were cut, so deselect if it was not cut
|
||||
|
@ -2080,6 +2147,10 @@ void esubdivideflag(int flag, float rad, int beauty, int numcuts, int seltype)
|
|||
}
|
||||
}
|
||||
vertexnormals(0);
|
||||
|
||||
|
||||
|
||||
|
||||
// Now for each face in the mesh we need to figure out How many edges were cut
|
||||
// and which filling method to use for that face
|
||||
for(ef = em->faces.first;ef;ef = ef->next){
|
||||
|
|
Loading…
Reference in New Issue