示例#1
0
static void clip_planes_from_rect(bContext *C,
                                  float clip_planes[4][4],
                                  const rcti *rect)
{
	ViewContext vc;
	BoundBox bb;
	bglMats mats = {{0}};
	
	view3d_operator_needs_opengl(C);
	view3d_set_viewcontext(C, &vc);
	view3d_get_transformation(vc.ar, vc.rv3d, vc.obact, &mats);
	ED_view3d_calc_clipping(&bb, clip_planes, &mats, rect);
	mul_m4_fl(clip_planes, -1.0f);
}
示例#2
0
/* Get four planes in object-space that describe the projection of
 * screen_rect from screen into object-space (essentially converting a
 * 2D screens-space bounding box into four 3D planes) */
void paint_calc_redraw_planes(float planes[4][4],
                              const ARegion *ar,
                              RegionView3D *rv3d,
                              Object *ob,
                              const rcti *screen_rect)
{
	BoundBox bb;
	bglMats mats;
	rcti rect;

	memset(&bb, 0, sizeof(BoundBox));
	view3d_get_transformation(ar, rv3d, ob, &mats);

	/* use some extra space just in case */
	rect = *screen_rect;
	rect.xmin -= 2;
	rect.xmax += 2;
	rect.ymin -= 2;
	rect.ymax += 2;

	ED_view3d_clipping_calc(&bb, planes, &mats, &rect);
	negate_m4(planes);
}