Ejemplo n.º 1
0
static DerivedMesh *triangulate_dm(DerivedMesh *dm, const int quad_method, const int ngon_method)
{
	DerivedMesh *result;
	BMesh *bm;
	int total_edges, i;
	MEdge *me;

	bm = DM_to_bmesh(dm, true);

	BM_mesh_triangulate(bm, quad_method, ngon_method, false, NULL, NULL);

	result = CDDM_from_bmesh(bm, false);
	BM_mesh_free(bm);

	total_edges = result->getNumEdges(result);
	me = CDDM_get_edges(result);

	/* force drawing of all edges (seems to be omitted in CDDM_from_bmesh) */
	for (i = 0; i < total_edges; i++, me++)
		me->flag |= ME_EDGEDRAW | ME_EDGERENDER;

	result->dirty |= DM_DIRTY_NORMALS;

	return result;
}
Ejemplo n.º 2
0
void bc_triangulate_mesh(Mesh *me) {
	bool use_beauty = false;
	bool tag_only   = false;
	 
	BMesh *bm = BM_mesh_create(&bm_mesh_allocsize_default);
	BM_mesh_bm_from_me(bm, me, FALSE, 0);
	BM_mesh_triangulate(bm, use_beauty, tag_only, NULL, NULL);
	BM_mesh_bm_to_me(bm, me, FALSE);
	BM_mesh_free(bm);
}
Ejemplo n.º 3
0
void bc_triangulate_mesh(Mesh *me)
{
	bool use_beauty  = false;
	bool tag_only    = false;
	int  quad_method = MOD_TRIANGULATE_QUAD_SHORTEDGE; /* XXX: The triangulation method selection could be offered in the UI */
	 
	BMesh *bm = BM_mesh_create(&bm_mesh_allocsize_default);
	BM_mesh_bm_from_me(bm, me, true, false, 0);
	BM_mesh_triangulate(bm, quad_method, use_beauty, tag_only, NULL, NULL);

	BM_mesh_bm_to_me(bm, me, false);
	BM_mesh_free(bm);
}
Ejemplo n.º 4
0
void bmo_triangulate_exec(BMesh *bm, BMOperator *op)
{
	const int quad_method = BMO_slot_int_get(op->slots_in, "quad_method");
	const int ngon_method = BMO_slot_int_get(op->slots_in, "ngon_method");

	BMOpSlot *slot_facemap_out = BMO_slot_get(op->slots_out, "face_map.out");

	BM_mesh_elem_hflag_disable_all(bm, BM_FACE | BM_EDGE, BM_ELEM_TAG, false);
	BMO_slot_buffer_hflag_enable(bm, op->slots_in, "faces", BM_FACE, BM_ELEM_TAG, false);

	BM_mesh_triangulate(bm, quad_method, ngon_method, true, op, slot_facemap_out);

	BMO_slot_buffer_from_enabled_hflag(bm, op, op->slots_out, "edges.out", BM_EDGE, BM_ELEM_TAG);
	BMO_slot_buffer_from_enabled_hflag(bm, op, op->slots_out, "faces.out", BM_FACE, BM_ELEM_TAG);
}
Ejemplo n.º 5
0
void bc_triangulate_mesh(Mesh *me)
{
	bool use_beauty  = false;
	bool tag_only    = false;
	int  quad_method = MOD_TRIANGULATE_QUAD_SHORTEDGE; /* XXX: The triangulation method selection could be offered in the UI */

	const struct BMeshCreateParams bm_create_params = {0};
	BMesh *bm = BM_mesh_create(
	        &bm_mesh_allocsize_default,
	        &bm_create_params);
	BMeshFromMeshParams bm_from_me_params = {0};
	bm_from_me_params.calc_face_normal = true;
	BM_mesh_bm_from_me(bm, me, &bm_from_me_params);
	BM_mesh_triangulate(bm, quad_method, use_beauty, tag_only, NULL, NULL, NULL);

	BMeshToMeshParams bm_to_me_params = {0};
	BM_mesh_bm_to_me(bm, me, &bm_to_me_params);
	BM_mesh_free(bm);
}