void mesh_foreachScreenEdge(
        ViewContext *vc,
        void (*func)(void *userData, BMEdge *eed, const float screen_co_a[2], const float screen_co_b[2], int index),
        void *userData, eV3DProjTest clip_flag)
{
	foreachScreenEdge_userData data;
	DerivedMesh *dm = editbmesh_get_derived_cage(vc->scene, vc->obedit, vc->em, CD_MASK_BAREMESH);

	ED_view3d_check_mats_rv3d(vc->rv3d);

	data.vc = *vc;

	data.win_rect.xmin = 0;
	data.win_rect.ymin = 0;
	data.win_rect.xmax = vc->ar->winx;
	data.win_rect.ymax = vc->ar->winy;

	data.func = func;
	data.userData = userData;
	data.clip_flag = clip_flag;

	if (clip_flag & V3D_PROJ_TEST_CLIP_BB) {
		ED_view3d_clipping_local(vc->rv3d, vc->obedit->obmat);  /* for local clipping lookups */
	}

	BM_mesh_elem_table_ensure(vc->em->bm, BM_EDGE);
	dm->foreachMappedEdge(dm, mesh_foreachScreenEdge__mapFunc, &data);

	dm->release(dm);
}
void mesh_foreachScreenFace(
        ViewContext *vc,
        void (*func)(void *userData, BMFace *efa, const float screen_co_b[2], int index),
        void *userData, const eV3DProjTest clip_flag)
{
	foreachScreenFace_userData data;
	DerivedMesh *dm = editbmesh_get_derived_cage(vc->scene, vc->obedit, vc->em, CD_MASK_BAREMESH);

	ED_view3d_check_mats_rv3d(vc->rv3d);

	data.vc = *vc;
	data.func = func;
	data.userData = userData;
	data.clip_flag = clip_flag;

	BM_mesh_elem_table_ensure(vc->em->bm, BM_FACE);
	dm->foreachMappedFaceCenter(dm, mesh_foreachScreenFace__mapFunc, &data, DM_FOREACH_NOP);

	dm->release(dm);
}
Exemple #3
0
void bmo_recalc_face_normals_exec(BMesh *bm, BMOperator *op)
{
	int *groups_array = MEM_mallocN(sizeof(*groups_array) * bm->totface, __func__);
	BMFace **faces_grp = MEM_mallocN(sizeof(*faces_grp) * bm->totface, __func__);

	int (*group_index)[2];
	const int group_tot = BM_mesh_calc_face_groups(
	        bm, groups_array, &group_index,
	        bmo_recalc_normal_loop_filter_cb, NULL,
	        0, BM_EDGE);
	int i;

	BMO_slot_buffer_flag_enable(bm, op->slots_in, "faces", BM_FACE, FACE_FLAG);

	BM_mesh_elem_table_ensure(bm, BM_FACE);

	for (i = 0; i < group_tot; i++) {
		const int fg_sta = group_index[i][0];
		const int fg_len = group_index[i][1];
		int j;
		bool is_calc = false;

		for (j = 0; j < fg_len; j++) {
			faces_grp[j] = BM_face_at_index(bm, groups_array[fg_sta + j]);

			if (is_calc == false) {
				is_calc = BMO_face_flag_test_bool(bm, faces_grp[j], FACE_FLAG);
			}
		}

		if (is_calc) {
			bmo_recalc_face_normals_array(bm, faces_grp, fg_len, FACE_FLAG);
		}
	}

	MEM_freeN(faces_grp);

	MEM_freeN(groups_array);
	MEM_freeN(group_index);
}
void mesh_foreachScreenVert(
        ViewContext *vc,
        void (*func)(void *userData, BMVert *eve, const float screen_co[2], int index),
        void *userData, eV3DProjTest clip_flag)
{
	foreachScreenVert_userData data;
	DerivedMesh *dm = editbmesh_get_derived_cage(vc->scene, vc->obedit, vc->em, CD_MASK_BAREMESH);

	ED_view3d_check_mats_rv3d(vc->rv3d);

	data.vc = *vc;
	data.func = func;
	data.userData = userData;
	data.clip_flag = clip_flag;

	if (clip_flag & V3D_PROJ_TEST_CLIP_BB) {
		ED_view3d_clipping_local(vc->rv3d, vc->obedit->obmat);  /* for local clipping lookups */
	}

	BM_mesh_elem_table_ensure(vc->em->bm, BM_VERT);
	dm->foreachMappedVert(dm, mesh_foreachScreenVert__mapFunc, &data, DM_FOREACH_NOP);

	dm->release(dm);
}