Example #1
0
void lattice_foreachScreenVert(
        ViewContext *vc,
        void (*func)(void *userData, BPoint *bp, const float screen_co[2]),
        void *userData, const eV3DProjTest clip_flag)
{
	Object *obedit = vc->obedit;
	Lattice *lt = obedit->data;
	BPoint *bp = lt->editlatt->latt->def;
	DispList *dl = BKE_displist_find(&obedit->disp, DL_VERTS);
	float *co = dl ? dl->verts : NULL;
	int i, N = lt->editlatt->latt->pntsu * lt->editlatt->latt->pntsv * lt->editlatt->latt->pntsw;

	ED_view3d_check_mats_rv3d(vc->rv3d);

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

	for (i = 0; i < N; i++, bp++, co += 3) {
		if (bp->hide == 0) {
			float screen_co[2];
			if (ED_view3d_project_float_object(vc->ar, dl ? co : bp->vec, screen_co, clip_flag) == V3D_PROJ_RET_OK) {
				func(userData, bp, screen_co);
			}
		}
	}
}
Example #2
0
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 */
	}

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

	dm->release(dm);
}
void meshobject_foreachScreenVert(
        ViewContext *vc,
        void (*func)(void *userData, MVert *eve, const float screen_co[2], int index),
        void *userData, eV3DProjTest clip_flag)
{
	foreachScreenObjectVert_userData data;
	DerivedMesh *dm = mesh_get_derived_deform(vc->scene, vc->obact, CD_MASK_BAREMESH);

	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 */
	}

	dm->foreachMappedVert(dm, meshobject_foreachScreenVert__mapFunc, &data);

	dm->release(dm);
}
Example #4
0
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 */
	}

	EDBM_index_arrays_ensure(vc->em, BM_VERT);
	dm->foreachMappedVert(dm, mesh_foreachScreenVert__mapFunc, &data);

	dm->release(dm);
}
Example #5
0
void nurbs_foreachScreenVert(
        ViewContext *vc,
        void (*func)(void *userData, Nurb *nu, BPoint *bp, BezTriple *bezt, int beztindex, const float screen_co_b[2]),
        void *userData, const eV3DProjTest clip_flag)
{
	Curve *cu = vc->obedit->data;
	Nurb *nu;
	int i;
	ListBase *nurbs = BKE_curve_editNurbs_get(cu);

	ED_view3d_check_mats_rv3d(vc->rv3d);

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

	for (nu = nurbs->first; nu; nu = nu->next) {
		if (nu->type == CU_BEZIER) {
			for (i = 0; i < nu->pntsu; i++) {
				BezTriple *bezt = &nu->bezt[i];

				if (bezt->hide == 0) {
					float screen_co[2];

					if (cu->drawflag & CU_HIDE_HANDLES) {
						if (ED_view3d_project_float_object(vc->ar, bezt->vec[1], screen_co,
						                                   V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN) == V3D_PROJ_RET_OK)
						{
							func(userData, nu, NULL, bezt, 1, screen_co);
						}
					}
					else {
						if (ED_view3d_project_float_object(vc->ar, bezt->vec[0], screen_co,
						                                   V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN) == V3D_PROJ_RET_OK)
						{
							func(userData, nu, NULL, bezt, 0, screen_co);
						}
						if (ED_view3d_project_float_object(vc->ar, bezt->vec[1], screen_co,
						                                   V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN) == V3D_PROJ_RET_OK)
						{
							func(userData, nu, NULL, bezt, 1, screen_co);
						}
						if (ED_view3d_project_float_object(vc->ar, bezt->vec[2], screen_co,
						                                   V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN) == V3D_PROJ_RET_OK)
						{
							func(userData, nu, NULL, bezt, 2, screen_co);
						}
					}
				}
			}
		}
		else {
			for (i = 0; i < nu->pntsu * nu->pntsv; i++) {
				BPoint *bp = &nu->bp[i];

				if (bp->hide == 0) {
					float screen_co[2];
					if (ED_view3d_project_float_object(vc->ar, bp->vec, screen_co,
					                                   V3D_PROJ_RET_CLIP_BB | V3D_PROJ_RET_CLIP_WIN) == V3D_PROJ_RET_OK)
					{
						func(userData, nu, bp, NULL, -1, screen_co);
					}
				}
			}
		}
	}
}