ported triangles to quads.
This commit is contained in:
parent
20fac2eca7
commit
08351bf3d6
|
@ -340,6 +340,27 @@ BMOpDefine def_makevert = {
|
|||
0,
|
||||
};
|
||||
|
||||
/*
|
||||
Join Triangles
|
||||
|
||||
Tries to intelligently join triangles according
|
||||
to various settings and stuff.
|
||||
|
||||
*/
|
||||
BMOpDefine def_join_triangles= {
|
||||
"join_triangles",
|
||||
{{BMOP_OPSLOT_ELEMENT_BUF, "faces"}, //input geometry.
|
||||
{BMOP_OPSLOT_ELEMENT_BUF, "faceout"}, //joined faces
|
||||
{BMOP_OPSLOT_INT, "compare_sharp"},
|
||||
{BMOP_OPSLOT_INT, "compare_uvs"},
|
||||
{BMOP_OPSLOT_INT, "compare_vcols"},
|
||||
{BMOP_OPSLOT_INT, "compare_materials"},
|
||||
{BMOP_OPSLOT_FLT, "limit"},
|
||||
{0, /*null-terminating sentinel*/}},
|
||||
bmesh_jointriangles_exec,
|
||||
0,
|
||||
};
|
||||
|
||||
/*
|
||||
Contextual Create
|
||||
|
||||
|
@ -685,9 +706,9 @@ BMOpDefine def_splitop = {
|
|||
};
|
||||
|
||||
/*
|
||||
Similar faces select
|
||||
Similar faces search
|
||||
|
||||
Select similar faces (area/material/perimeter....).
|
||||
Find similar faces (area/material/perimeter....).
|
||||
*/
|
||||
BMOpDefine def_similarfaces = {
|
||||
"similarfaces",
|
||||
|
@ -701,9 +722,9 @@ BMOpDefine def_similarfaces = {
|
|||
};
|
||||
|
||||
/*
|
||||
Similar edges select
|
||||
Similar edges search
|
||||
|
||||
Select similar edges (length, direction, edge, seam,....).
|
||||
Find similar edges (length, direction, edge, seam,....).
|
||||
*/
|
||||
BMOpDefine def_similaredges = {
|
||||
"similaredges",
|
||||
|
@ -717,9 +738,9 @@ BMOpDefine def_similaredges = {
|
|||
};
|
||||
|
||||
/*
|
||||
Similar vertices select
|
||||
Similar vertices search
|
||||
|
||||
Select similar vertices (normal, face, vertex group,....).
|
||||
Find similar vertices (normal, face, vertex group,....).
|
||||
*/
|
||||
BMOpDefine def_similarverts = {
|
||||
"similarverts",
|
||||
|
@ -783,9 +804,9 @@ BMOpDefine def_meshreversecolors = {
|
|||
};
|
||||
|
||||
/*
|
||||
Similar vertices select
|
||||
Similar vertices search
|
||||
|
||||
Select similar vertices (normal, face, vertex group,....).
|
||||
Find similar vertices (normal, face, vertex group,....).
|
||||
*/
|
||||
BMOpDefine def_vertexshortestpath = {
|
||||
"vertexshortestpath",
|
||||
|
@ -892,7 +913,7 @@ BMOpDefine def_create_cone = {
|
|||
{BMOP_OPSLOT_FLT, "depth"}, //distance between ends
|
||||
{BMOP_OPSLOT_MAT, "mat"}, //matrix to multiply the new geometry with--
|
||||
{0, /*null-terminating sentinel*/}},
|
||||
bmesh_create_monkey_exec,
|
||||
bmesh_create_cone_exec,
|
||||
0,
|
||||
};
|
||||
|
||||
|
@ -969,6 +990,7 @@ BMOpDefine *opdefines[] = {
|
|||
&def_create_monkey,
|
||||
&def_create_cone,
|
||||
&def_create_cube,
|
||||
&def_join_triangles,
|
||||
};
|
||||
|
||||
int bmesh_total_ops = (sizeof(opdefines) / sizeof(void*));
|
||||
|
|
|
@ -67,5 +67,6 @@ void bmesh_create_icosphere_exec(BMesh *bm, BMOperator *op);
|
|||
void bmesh_create_uvsphere_exec(BMesh *bm, BMOperator *op);
|
||||
void bmesh_create_grid_exec(BMesh *bm, BMOperator *op);
|
||||
void bmesh_create_cube_exec(BMesh *bm, BMOperator *op);
|
||||
void bmesh_jointriangles_exec(BMesh *bm, BMOperator *op);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#if 0
|
||||
#if 1
|
||||
#include "MEM_guardedalloc.h"
|
||||
#include "BKE_customdata.h"
|
||||
#include "DNA_listBase.h"
|
||||
|
@ -35,13 +35,18 @@
|
|||
*
|
||||
*/
|
||||
|
||||
/*Bitflags for edges.*/
|
||||
#define T2QDELETE 1
|
||||
#define T2QCOMPLEX 2
|
||||
#define T2QJOIN 4
|
||||
|
||||
/*assumes edges are validated before reaching this point*/
|
||||
static float measure_facepair(BMesh *bm, BMVert *v1, BMVert *v2,
|
||||
BMVert *v3, BMVert *v4, float limit)
|
||||
{
|
||||
/*gives a 'weight' to a pair of triangles that join an edge to decide how good a join they would make*/
|
||||
/*Note: this is more complicated than it needs to be and should be cleaned up...*/
|
||||
float no1[3], no2[3], measure = 0.0f, angle1, angle2, diff;
|
||||
float n1[3], n2[3], measure = 0.0f, angle1, angle2, diff;
|
||||
float edgeVec1[3], edgeVec2[3], edgeVec3[3], edgeVec4[3];
|
||||
float minarea, maxarea, areaA, areaB;
|
||||
|
||||
|
@ -49,16 +54,16 @@ static float measure_facepair(BMesh *bm, BMVert *v1, BMVert *v2,
|
|||
normal_tri_v3(n1, v1->co, v2->co, v3->co);
|
||||
normal_tri_v3(n2, v1->co, v3->co, v4->co);
|
||||
|
||||
if(no1[0] == no2[0] && no1[1] == no2[1] && no1[2] == no2[2]) angle1 = 0.0f;
|
||||
else angle1 = angle_v2v2(no1, no2);
|
||||
if(n1[0] == n2[0] && n1[1] == n2[1] && n1[2] == n2[2]) angle1 = 0.0f;
|
||||
else angle1 = angle_v3v3(n1, n2);
|
||||
|
||||
normal_tri_v3(n1, v2->co, v3->co, v4->co);
|
||||
normal_tri_v3(n2, v4->co, v1->co, v2->co);
|
||||
|
||||
if(no1[0] == no2[0] && no1[1] == no2[1] && no1[2] == no2[2]) angle2 = 0.0f;
|
||||
else angle2 = angle_v2v2(no1, no2);
|
||||
if(n1[0] == n2[0] && n1[1] == n2[1] && n1[2] == n2[2]) angle2 = 0.0f;
|
||||
else angle2 = angle_v3v3(n1, n2);
|
||||
|
||||
measure += (angle1/360.0f) + (angle2/360.0f);
|
||||
measure += angle1 + angle2;
|
||||
if(measure > limit) return measure;
|
||||
|
||||
/*Second test: Colinearity*/
|
||||
|
@ -70,10 +75,10 @@ static float measure_facepair(BMesh *bm, BMVert *v1, BMVert *v2,
|
|||
diff = 0.0;
|
||||
|
||||
diff = (
|
||||
fabs(angle_v2v2(edgeVec1, edgeVec2) - 90) +
|
||||
fabs(angle_v2v2(edgeVec2, edgeVec3) - 90) +
|
||||
fabs(angle_v2v2(edgeVec3, edgeVec4) - 90) +
|
||||
fabs(angle_v2v2(edgeVec4, edgeVec1) - 90)) / 360.0f;
|
||||
fabs(angle_v3v3(edgeVec1, edgeVec2) - M_PI/2) +
|
||||
fabs(angle_v3v3(edgeVec2, edgeVec3) - M_PI/2) +
|
||||
fabs(angle_v3v3(edgeVec3, edgeVec4) - M_PI/2) +
|
||||
fabs(angle_v3v3(edgeVec4, edgeVec1) - M_PI/2));
|
||||
if(!diff) return 0.0;
|
||||
|
||||
measure += diff;
|
||||
|
@ -98,22 +103,256 @@ static float measure_facepair(BMesh *bm, BMVert *v1, BMVert *v2,
|
|||
#define T2QUV_LIMIT 0.005
|
||||
#define T2QCOL_LIMIT 3
|
||||
|
||||
static int compareFaceAttribs(BMesh *bm, BMEdge *e)
|
||||
static int compareFaceAttribs(BMesh *bm, BMEdge *e, int douvs, int dovcols)
|
||||
{
|
||||
MTexPoly *tp1, *tp2;
|
||||
MLoopCol *lcol1, *lcol2, *lcol3, *lcol4;
|
||||
MLoopUV *luv1, *luv2, *luv3, *luv4;
|
||||
BMLoop *l1, *l2;
|
||||
BMLoop *l1, *l2, *l3, *l4;
|
||||
int mergeok_uvs=!douvs, mergeok_vcols=!dovcols;
|
||||
|
||||
l1 = e->loop
|
||||
l2 = (BMLoop*)e->loop->radial.next->data;
|
||||
l1 = e->loop;
|
||||
l3 = (BMLoop*)e->loop->radial.next->data;
|
||||
|
||||
/*match up loops on each side of an edge corrusponding to each vert*/
|
||||
if (l1->v == l3->v) {
|
||||
l2 = (BMLoop*)l1->head.next;
|
||||
l4 = (BMLoop*)l2->head.next;
|
||||
} else {
|
||||
l2 = (BMLoop*)l1->head.next;
|
||||
|
||||
l4 = l3;
|
||||
l3 = (BMLoop*)l4->head.next;
|
||||
}
|
||||
|
||||
lcol1 = CustomData_bmesh_get(&bm->ldata, l1->head.data, CD_MLOOPCOL);
|
||||
lcol2 = CustomData_bmesh_get(&bm->ldata, l1->head.data, CD_MLOOPCOL);
|
||||
lcol3 = CustomData_bmesh_get(&bm->ldata, l1->head.data, CD_MLOOPCOL);
|
||||
lcol4 = CustomData_bmesh_get(&bm->ldata, l1->head.data, CD_MLOOPCOL);
|
||||
|
||||
luv1 = CustomData_bmesh_get(&bm->ldata, l1->head.data, CD_MLOOPUV);
|
||||
luv2 = CustomData_bmesh_get(&bm->ldata, l1->head.data, CD_MLOOPUV);
|
||||
luv3 = CustomData_bmesh_get(&bm->ldata, l1->head.data, CD_MLOOPUV);
|
||||
luv4 = CustomData_bmesh_get(&bm->ldata, l1->head.data, CD_MLOOPUV);
|
||||
|
||||
tp1 = CustomData_bmesh_get(&bm->pdata, l1->f->head.data, CD_MTEXPOLY);
|
||||
tp2 = CustomData_bmesh_get(&bm->pdata, l2->f->head.data, CD_MTEXPOLY);
|
||||
|
||||
if (!lcol1)
|
||||
mergeok_vcols = 1;
|
||||
|
||||
if (!luv1)
|
||||
mergeok_uvs = 1;
|
||||
|
||||
/*compare faceedges for each face attribute. Additional per face attributes can be added later*/
|
||||
|
||||
/*do VCOLs*/
|
||||
if(lcol1 && dovcols){
|
||||
char *cols[4] = {(char*)lcol1, (char*)lcol2, (char*)lcol3, (char*)lcol4};
|
||||
int i;
|
||||
|
||||
for (i=0; i<3; i++) {
|
||||
if (cols[0][i] + T2QCOL_LIMIT < cols[3][i] - T2QCOL_LIMIT)
|
||||
break;
|
||||
if (cols[1][i] + T2QCOL_LIMIT < cols[4][i] - T2QCOL_LIMIT)
|
||||
break;
|
||||
}
|
||||
|
||||
if (i == 3)
|
||||
mergeok_vcols = 1;
|
||||
}
|
||||
|
||||
/*do UVs*/
|
||||
if (luv1 && douvs) {
|
||||
if(tp1->tpage != tp2->tpage); /*do nothing*/
|
||||
else {
|
||||
int i;
|
||||
|
||||
for(i = 0; i < 2; i++) {
|
||||
if(luv1->uv[0] + T2QUV_LIMIT > luv3->uv[0] && luv1->uv[0] - T2QUV_LIMIT < luv3->uv[0] &&
|
||||
luv1->uv[1] + T2QUV_LIMIT > luv3->uv[1] && luv1->uv[1] - T2QUV_LIMIT < luv3->uv[1])
|
||||
{
|
||||
if(luv2->uv[0] + T2QUV_LIMIT > luv4->uv[0] && luv2->uv[0] - T2QUV_LIMIT < luv4->uv[0] &&
|
||||
luv2->uv[1] + T2QUV_LIMIT > luv4->uv[1] && luv2->uv[1] - T2QUV_LIMIT < luv4->uv[1])
|
||||
{
|
||||
mergeok_uvs = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (douvs == mergeok_uvs && dovcols == mergeok_vcols)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
typedef struct JoinEdge {
|
||||
float weight;
|
||||
BMEdge *e;
|
||||
} JoinEdge;
|
||||
|
||||
#define EDGE_MARK 1
|
||||
#define EDGE_CHOSEN 2
|
||||
|
||||
#define FACE_MARK 1
|
||||
#define FACE_INPUT 2
|
||||
|
||||
static int fplcmp(const void *v1, const void *v2)
|
||||
{
|
||||
const JoinEdge *e1= ((JoinEdge*)v1), *e2=((JoinEdge*)v2);
|
||||
|
||||
if( e1->weight > e2->weight) return 1;
|
||||
else if( e1->weight < e2->weight) return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void bmesh_jointriangles_exec(BMesh *bm, BMOperator *op)
|
||||
{
|
||||
BMIter iter, liter;
|
||||
BMOIter siter;
|
||||
BMFace *f1, *f2;
|
||||
BMLoop *l;
|
||||
BMEdge *e;
|
||||
BLI_array_declare(jedges);
|
||||
JoinEdge *jedges = NULL;
|
||||
int dosharp = BMO_Get_Int(op, "compare_sharp"), douvs=BMO_Get_Int(op, "compare_uvs");
|
||||
int dovcols = BMO_Get_Int(op, "compare_vcols"), domat=BMO_Get_Int(op, "compare_materials");
|
||||
float limit = BMO_Get_Float(op, "limit")/180.0f*M_PI;
|
||||
int i, totedge;
|
||||
|
||||
/*flag all edges of all input faces*/
|
||||
BMO_ITER(f1, &siter, bm, op, "faces", BM_FACE) {
|
||||
BMO_SetFlag(bm, f1, FACE_INPUT);
|
||||
BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, f1) {
|
||||
BMO_SetFlag(bm, l->e, EDGE_MARK);
|
||||
}
|
||||
}
|
||||
|
||||
/*unflag edges that are invalid; e.g. aren't surrounded by triangles*/
|
||||
BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) {
|
||||
if (!BMO_TestFlag(bm, e, EDGE_MARK))
|
||||
continue;
|
||||
|
||||
if (BM_Edge_FaceCount(e) < 2) {
|
||||
BMO_ClearFlag(bm, e, EDGE_MARK);
|
||||
continue;
|
||||
}
|
||||
|
||||
f1 = e->loop->f;
|
||||
f2 = ((BMLoop*)e->loop->radial.next->data)->f;
|
||||
|
||||
if (f1->len != 3 || f2->len != 3) {
|
||||
BMO_ClearFlag(bm, e, EDGE_MARK);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!BMO_TestFlag(bm, f1, FACE_INPUT) || !BMO_TestFlag(bm, f2, FACE_INPUT)) {
|
||||
BMO_ClearFlag(bm, e, EDGE_MARK);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
i = 0;
|
||||
BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) {
|
||||
BMVert *v1, *v2, *v3, *v4;
|
||||
BMFace *f1, *f2;
|
||||
float measure;
|
||||
|
||||
if (!BMO_TestFlag(bm, e, EDGE_MARK))
|
||||
continue;
|
||||
|
||||
f1 = e->loop->f;
|
||||
f2 = ((BMLoop*)e->loop->radial.next->data)->f;
|
||||
|
||||
v1 = e->loop->v;
|
||||
v2 = ((BMLoop*)e->loop->head.prev)->v;
|
||||
v3 = ((BMLoop*)e->loop->head.next)->v;
|
||||
v4 = ((BMLoop*)((BMLoop*)e->loop->radial.next->data)->head.prev)->v;
|
||||
|
||||
if (dosharp && BM_TestHFlag(e, BM_SHARP))
|
||||
continue;
|
||||
|
||||
if ((douvs || dovcols) && compareFaceAttribs(bm, e, douvs, dovcols))
|
||||
continue;
|
||||
|
||||
if (domat && f1->mat_nr != f2->mat_nr)
|
||||
continue;
|
||||
|
||||
measure = measure_facepair(bm, v1, v2, v3, v4, limit);
|
||||
if(measure < limit) {
|
||||
BLI_array_growone(jedges);
|
||||
|
||||
jedges[i].e = e;
|
||||
jedges[i].weight = measure;
|
||||
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!jedges)
|
||||
return;
|
||||
|
||||
qsort(jedges, BLI_array_count(jedges), sizeof(JoinEdge), fplcmp);
|
||||
|
||||
totedge = BLI_array_count(jedges);
|
||||
for (i=0; i<totedge; i++) {
|
||||
BMFace *f1, *f2;
|
||||
|
||||
e = jedges[i].e;
|
||||
f1 = e->loop->f;
|
||||
f2 = ((BMLoop*)e->loop->radial.next->data)->f;
|
||||
|
||||
if (BMO_TestFlag(bm, f1, FACE_MARK) || BMO_TestFlag(bm, f2, FACE_MARK))
|
||||
continue;
|
||||
|
||||
BMO_SetFlag(bm, f1, FACE_MARK);
|
||||
BMO_SetFlag(bm, f2, FACE_MARK);
|
||||
BMO_SetFlag(bm, e, EDGE_CHOSEN);
|
||||
}
|
||||
|
||||
BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) {
|
||||
if (!BMO_TestFlag(bm, e, EDGE_CHOSEN))
|
||||
continue;
|
||||
|
||||
f1 = e->loop->f;
|
||||
f2 = ((BMLoop*)e->loop->radial.next->data)->f;
|
||||
|
||||
BM_Join_Faces(bm, f1, f2, e);
|
||||
}
|
||||
|
||||
BM_ITER(e, &iter, bm, BM_EDGES_OF_MESH, NULL) {
|
||||
if (BMO_TestFlag(bm, e, EDGE_MARK)) {
|
||||
/*ok, this edge wasn't merged, check if it's
|
||||
in a 2-tri-pair island, and if so merge*/
|
||||
|
||||
f1 = e->loop->f;
|
||||
f2 = ((BMLoop*)e->loop->radial.next->data)->f;
|
||||
|
||||
if (f1->len != 3 || f2->len != 3)
|
||||
continue;
|
||||
|
||||
for (i=0; i<2; i++) {
|
||||
BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, i ? f2 : f1) {
|
||||
if (l->e != e && BMO_TestFlag(bm, l->e, EDGE_MARK))
|
||||
break;
|
||||
}
|
||||
|
||||
/*if l isn't NULL, we broke out of the loop*/
|
||||
if (l)
|
||||
break;
|
||||
}
|
||||
|
||||
/*if i isn't 2, we broke out of that loop*/
|
||||
if (i != 2)
|
||||
continue;
|
||||
|
||||
BM_Join_Faces(bm, f1, f2, e);
|
||||
}
|
||||
}
|
||||
|
||||
BLI_array_free(jedges);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "MEM_guardedalloc.h"
|
||||
#include "MEM_guardedalloc.h"-
|
||||
|
||||
#include "DNA_meshdata_types.h"
|
||||
#include "DNA_mesh_types.h"
|
||||
|
@ -12,6 +12,8 @@
|
|||
#include "BLI_blenlib.h"
|
||||
#include "BLI_array.h"
|
||||
|
||||
#include "ED_mesh.h"
|
||||
|
||||
#include "bmesh.h"
|
||||
#include "mesh_intern.h"
|
||||
#include "bmesh_private.h"
|
||||
|
@ -350,6 +352,8 @@ void bmesh_create_uvsphere_exec(BMesh *bm, BMOperator *op)
|
|||
void bmesh_create_icosphere_exec(BMesh *bm, BMOperator *op)
|
||||
{
|
||||
BMVert *eva[12];
|
||||
BMIter liter;
|
||||
BMLoop *l;
|
||||
float vec[3], mat[4][4], phi, phid;
|
||||
float dia = BMO_Get_Float(op, "diameter");
|
||||
int a, subdiv = BMO_Get_Int(op, "subdivisions");
|
||||
|
@ -371,15 +375,20 @@ void bmesh_create_icosphere_exec(BMesh *bm, BMOperator *op)
|
|||
}
|
||||
|
||||
for(a=0;a<20;a++) {
|
||||
BMFace *evtemp;
|
||||
BMFace *eftemp;
|
||||
BMVert *v1, *v2, *v3;
|
||||
|
||||
v1= eva[ icoface[a][0] ];
|
||||
v2= eva[ icoface[a][1] ];
|
||||
v3= eva[ icoface[a][2] ];
|
||||
|
||||
evtemp = BM_Make_QuadTri(bm, v1, v2, v3, NULL, NULL, 0);
|
||||
BMO_SetFlag(bm, evtemp, FACE_MARK);
|
||||
eftemp = BM_Make_QuadTri(bm, v1, v2, v3, NULL, NULL, 0);
|
||||
|
||||
BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, eftemp) {
|
||||
BMO_SetFlag(bm, l->e, EDGE_MARK);
|
||||
}
|
||||
|
||||
BMO_SetFlag(bm, eftemp, FACE_MARK);
|
||||
}
|
||||
|
||||
dia*=200;
|
||||
|
@ -387,9 +396,12 @@ void bmesh_create_icosphere_exec(BMesh *bm, BMOperator *op)
|
|||
for(a=1; a<subdiv; a++) {
|
||||
BMOperator bmop;
|
||||
|
||||
BMO_InitOpf(bm, &bmop, "esubd edges=%he smooth=%f numcuts=%i gridfill=%i", EDGE_MARK, dia, 1, 1);
|
||||
BMO_InitOpf(bm, &bmop,
|
||||
"esubd edges=%fe smooth=%f numcuts=%i gridfill=%i beauty=%i",
|
||||
EDGE_MARK, dia, 1, 1, B_SPHERE);
|
||||
BMO_Exec_Op(bm, &bmop);
|
||||
BMO_Flag_Buffer(bm, &bmop, "geomout", VERT_MARK, BM_VERT);
|
||||
BMO_Flag_Buffer(bm, &bmop, "geomout", EDGE_MARK, BM_EDGE);
|
||||
BMO_Finish_Op(bm, &bmop);
|
||||
}
|
||||
|
||||
|
@ -459,7 +471,7 @@ void bmesh_create_cone_exec(BMesh *bm, BMOperator *op)
|
|||
BMO_SetFlag(bm, cent2, VERT_MARK);
|
||||
}
|
||||
|
||||
for (a=0; a<segs; a++) {
|
||||
for (a=0; a<segs; a++, phi+=phid) {
|
||||
vec[0]= dia1*sin(phi);
|
||||
vec[1]= dia1*cos(phi);
|
||||
vec[2]= -depth;
|
||||
|
|
|
@ -235,9 +235,11 @@ static void bm_subdivide_multicut(BMesh *bm, BMEdge *edge, subdparams *params,
|
|||
&newe, vsta, vend);
|
||||
BMO_SetFlag(bm, v, SUBD_SPLIT);
|
||||
BMO_SetFlag(bm, eed, SUBD_SPLIT);
|
||||
BMO_SetFlag(bm, newe, SUBD_SPLIT);
|
||||
|
||||
BMO_SetFlag(bm, v, ELE_SPLIT);
|
||||
BMO_SetFlag(bm, eed, ELE_SPLIT);
|
||||
BMO_SetFlag(bm, newe, SUBD_SPLIT);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -848,7 +850,7 @@ void esubdivide_exec(BMesh *bmesh, BMOperator *op)
|
|||
/*go through and split edges*/
|
||||
for (i=0; i<einput->len; i++) {
|
||||
edge = ((BMEdge**)einput->data.p)[i];
|
||||
bm_subdivide_multicut(bmesh, edge,¶ms, edge->v1, edge->v2);
|
||||
bm_subdivide_multicut(bmesh, edge, ¶ms, edge->v1, edge->v2);
|
||||
//BM_Split_Edge_Multi(bmesh, edge, numcuts);
|
||||
}
|
||||
|
||||
|
@ -966,7 +968,7 @@ void esubdivide_exec(BMesh *bmesh, BMOperator *op)
|
|||
ELE_SPLIT, BM_ALL);
|
||||
|
||||
BMO_Flag_To_Slot(bmesh, op, "geomout",
|
||||
ELE_INNER|ELE_SPLIT, BM_ALL);
|
||||
ELE_INNER|ELE_SPLIT|SUBD_SPLIT, BM_ALL);
|
||||
}
|
||||
|
||||
/*editmesh-emulating function*/
|
||||
|
|
|
@ -3878,7 +3878,7 @@ static int knife_cut_exec(bContext *C, wmOperator *op)
|
|||
return OPERATOR_CANCELLED;
|
||||
|
||||
if (bm->totvertsel < 2) {
|
||||
error("No edges are selected to operate on");
|
||||
//error("No edges are selected to operate on");
|
||||
return OPERATOR_CANCELLED;;
|
||||
}
|
||||
|
||||
|
@ -4086,17 +4086,15 @@ void MESH_OT_beauty_fill(wmOperatorType *ot)
|
|||
|
||||
static int quads_convert_to_tris_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
#if 0
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
BMEditMesh *em= ((Mesh *)obedit->data)->edit_btmesh;
|
||||
|
||||
//convert_to_triface(em,0);
|
||||
if (!EDBM_CallOpf(em, op, "triangulate faces=%hf", BM_SELECT))
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
DAG_id_flush_update(obedit->data, OB_RECALC_DATA);
|
||||
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
|
||||
#endif
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
|
@ -4116,17 +4114,27 @@ void MESH_OT_quads_convert_to_tris(wmOperatorType *ot)
|
|||
|
||||
static int tris_convert_to_quads_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
#if 0
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
EditMesh *em= BKE_mesh_get_editmesh((Mesh *)obedit->data);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
BMEditMesh *em= ((Mesh *)obedit->data)->edit_btmesh;
|
||||
int dosharp, douvs, dovcols, domaterials;
|
||||
float limit = RNA_float_get(op->ptr, "limit");
|
||||
|
||||
join_triangles(em);
|
||||
dosharp = RNA_boolean_get(op->ptr, "sharp");
|
||||
douvs = RNA_boolean_get(op->ptr, "uvs");
|
||||
dovcols = RNA_boolean_get(op->ptr, "vcols");
|
||||
domaterials = RNA_boolean_get(op->ptr, "materials");
|
||||
|
||||
if (!EDBM_CallOpf(em, op,
|
||||
"join_triangles faces=%hf limit=%f compare_sharp=%i compare_uvs=%i compare_vcols=%i compare_materials=%i",
|
||||
BM_SELECT, limit, dosharp, douvs, dovcols, domaterials))
|
||||
{
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
DAG_id_flush_update(obedit->data, OB_RECALC_DATA);
|
||||
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
|
||||
|
||||
BKE_mesh_end_editmesh(obedit->data, em);
|
||||
#endif
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
|
@ -4142,6 +4150,14 @@ void MESH_OT_tris_convert_to_quads(wmOperatorType *ot)
|
|||
|
||||
/* flags */
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
|
||||
RNA_def_float(ot->srna, "limit", 40.0f, -180.0f, 180.0f, "Max Angle", "Angle Limit in Degrees", -180, 180.0f);
|
||||
|
||||
RNA_def_boolean(ot->srna, "uvs", 0, "Compare UVs", "");
|
||||
RNA_def_boolean(ot->srna, "vcols", 0, "Compare VCols", "");
|
||||
RNA_def_boolean(ot->srna, "sharp", 0, "Compare Sharp", "");
|
||||
RNA_def_boolean(ot->srna, "materials", 0, "Compare Materials", "");
|
||||
|
||||
}
|
||||
|
||||
static int edge_flip_exec(bContext *C, wmOperator *op)
|
||||
|
|
|
@ -285,20 +285,27 @@ void MESH_OT_primitive_circle_add(wmOperatorType *ot)
|
|||
|
||||
static int add_primitive_tube_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
#if 0
|
||||
Object *obedit;
|
||||
Mesh *me;
|
||||
BMEditMesh *em;
|
||||
float loc[3], rot[3], mat[4][4], dia;
|
||||
int enter_editmode;
|
||||
float loc[3], rot[3];
|
||||
int state;
|
||||
|
||||
ED_object_add_generic_get_opts(op, loc, rot, &enter_editmode);
|
||||
make_prim_init(C, &dia, mat, &state, loc, rot);
|
||||
|
||||
make_prim_ext(C, loc, rot, enter_editmode,
|
||||
PRIM_CYLINDER, RNA_int_get(op->ptr, "vertices"), 0, 0,
|
||||
RNA_float_get(op->ptr, "radius"),
|
||||
RNA_float_get(op->ptr, "depth"), 1,
|
||||
RNA_boolean_get(op->ptr, "cap_ends"));
|
||||
#endif
|
||||
obedit = CTX_data_edit_object(C);
|
||||
me = obedit->data;
|
||||
em = me->edit_btmesh;
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
if (!EDBM_CallAndSelectOpf(em, op, "vertout",
|
||||
"create_cone segments=%i diameter1=%f diameter2=%f cap_ends=%i depth=%f mat=%m4",
|
||||
RNA_int_get(op->ptr, "vertices"), RNA_float_get(op->ptr, "radius"),
|
||||
RNA_float_get(op->ptr, "radius"), (int)RNA_boolean_get(op->ptr, "cap_end"), RNA_float_get(op->ptr, "depth"), mat))
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
make_prim_finish(C, &state, enter_editmode);
|
||||
}
|
||||
|
||||
void MESH_OT_primitive_tube_add(wmOperatorType *ot)
|
||||
|
@ -327,19 +334,29 @@ void MESH_OT_primitive_tube_add(wmOperatorType *ot)
|
|||
|
||||
static int add_primitive_cone_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
#if 0
|
||||
Object *obedit;
|
||||
Mesh *me;
|
||||
BMEditMesh *em;
|
||||
float loc[3], rot[3], mat[4][4], dia;
|
||||
int enter_editmode;
|
||||
float loc[3], rot[3];
|
||||
int state;
|
||||
|
||||
ED_object_add_generic_get_opts(op, loc, rot, &enter_editmode);
|
||||
make_prim_init(C, &dia, mat, &state, loc, rot);
|
||||
|
||||
make_prim_ext(C, loc, rot, enter_editmode,
|
||||
PRIM_CONE, RNA_int_get(op->ptr, "vertices"), 0, 0,
|
||||
RNA_float_get(op->ptr,"radius"), RNA_float_get(op->ptr, "depth"),
|
||||
0, RNA_boolean_get(op->ptr, "cap_end"));
|
||||
#endif
|
||||
obedit = CTX_data_edit_object(C);
|
||||
me = obedit->data;
|
||||
em = me->edit_btmesh;
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
if (!EDBM_CallAndSelectOpf(em, op, "vertout",
|
||||
"create_cone segments=%i diameter1=%f diameter2=%f cap_ends=%i depth=%f mat=%m4",
|
||||
RNA_int_get(op->ptr, "vertices"), RNA_float_get(op->ptr, "radius"),
|
||||
0.0f, (int)RNA_boolean_get(op->ptr, "cap_end"), RNA_float_get(op->ptr, "depth"), mat))
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
make_prim_finish(C, &state, enter_editmode);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void MESH_OT_primitive_cone_add(wmOperatorType *ot)
|
||||
|
@ -368,18 +385,30 @@ void MESH_OT_primitive_cone_add(wmOperatorType *ot)
|
|||
|
||||
static int add_primitive_grid_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
#if 0
|
||||
Object *obedit;
|
||||
Mesh *me;
|
||||
BMEditMesh *em;
|
||||
float loc[3], rot[3], mat[4][4], dia;
|
||||
int enter_editmode;
|
||||
float loc[3], rot[3];
|
||||
int state;
|
||||
|
||||
ED_object_add_generic_get_opts(op, loc, rot, &enter_editmode);
|
||||
make_prim_init(C, &dia, mat, &state, loc, rot);
|
||||
|
||||
make_prim_ext(C, loc, rot, enter_editmode,
|
||||
PRIM_GRID, RNA_int_get(op->ptr, "x_subdivisions"),
|
||||
RNA_int_get(op->ptr, "y_subdivisions"), 0,
|
||||
RNA_float_get(op->ptr,"size"), 0.0f, 0, 1);
|
||||
#endif
|
||||
obedit = CTX_data_edit_object(C);
|
||||
me = obedit->data;
|
||||
em = me->edit_btmesh;
|
||||
|
||||
if (!EDBM_CallAndSelectOpf(em, op, "vertout",
|
||||
"create_grid xsegments=%i ysegments=%i size=%f mat=%m4",
|
||||
RNA_int_get(op->ptr, "x_subdivisions"),
|
||||
RNA_int_get(op->ptr, "y_subdivisions"),
|
||||
RNA_float_get(op->ptr, "size"), mat))
|
||||
{
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
make_prim_finish(C, &state, enter_editmode);
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
|
@ -408,16 +437,25 @@ void MESH_OT_primitive_grid_add(wmOperatorType *ot)
|
|||
|
||||
static int add_primitive_monkey_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
#if 0
|
||||
Object *obedit;
|
||||
Mesh *me;
|
||||
BMEditMesh *em;
|
||||
float loc[3], rot[3], mat[4][4], dia;
|
||||
int enter_editmode;
|
||||
float loc[3], rot[3];
|
||||
int state;
|
||||
|
||||
ED_object_add_generic_get_opts(op, loc, rot, &enter_editmode);
|
||||
make_prim_init(C, &dia, mat, &state, loc, rot);
|
||||
|
||||
make_prim_ext(C, loc, rot, enter_editmode,
|
||||
PRIM_MONKEY, 0, 0, 2, 0.0f, 0.0f, 0, 0);
|
||||
#endif
|
||||
obedit = CTX_data_edit_object(C);
|
||||
me = obedit->data;
|
||||
em = me->edit_btmesh;
|
||||
|
||||
if (!EDBM_CallAndSelectOpf(em, op, "vertout", "create_monkey mat=%m4", mat)) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
make_prim_finish(C, &state, enter_editmode);
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
|
@ -492,16 +530,28 @@ void MESH_OT_primitive_uv_sphere_add(wmOperatorType *ot)
|
|||
|
||||
static int add_primitive_icosphere_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
#if 0
|
||||
Object *obedit;
|
||||
Mesh *me;
|
||||
BMEditMesh *em;
|
||||
float loc[3], rot[3], mat[4][4], dia;
|
||||
int enter_editmode;
|
||||
float loc[3], rot[3];
|
||||
int state;
|
||||
|
||||
ED_object_add_generic_get_opts(op, loc, rot, &enter_editmode);
|
||||
make_prim_init(C, &dia, mat, &state, loc, rot);
|
||||
|
||||
make_prim_ext(C, loc, rot, enter_editmode,
|
||||
PRIM_ICOSPHERE, 0, 0, RNA_int_get(op->ptr, "subdivisions"),
|
||||
RNA_float_get(op->ptr,"size"), 0.0f, 0, 0);
|
||||
#endif
|
||||
obedit = CTX_data_edit_object(C);
|
||||
me = obedit->data;
|
||||
em = me->edit_btmesh;
|
||||
|
||||
if (!EDBM_CallAndSelectOpf(em, op, "vertout",
|
||||
"create_icosphere subdivisions=%i diameter=%f mat=%m4",
|
||||
RNA_int_get(op->ptr, "subdivisions"),
|
||||
RNA_float_get(op->ptr, "size"), mat)) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
make_prim_finish(C, &state, enter_editmode);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue