[Bf-blender-cvs] [f8f6f8f26ea] blender2.8: Merge branch 'master' into blender2.8

Campbell Barton noreply at git.blender.org
Fri Aug 25 12:46:24 CEST 2017


Commit: f8f6f8f26eaad3b6d89a57df70114cd4fa40dc79
Author: Campbell Barton
Date:   Fri Aug 25 20:45:16 2017 +1000
Branches: blender2.8
https://developer.blender.org/rBf8f6f8f26eaad3b6d89a57df70114cd4fa40dc79

Merge branch 'master' into blender2.8

===================================================================



===================================================================

diff --cc source/blender/editors/space_view3d/view3d_draw.c
index c85cf689068,56508ea989a..688bee4760b
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@@ -628,420 -1275,1264 +628,427 @@@ static void drawviewborder(Scene *scene
  			float sizey = scene->r.ysch * scene->r.yasp;
  			int sensor_fit = BKE_camera_sensor_fit(ca->sensor_fit, sizex, sizey);
  			float sensor_x = ca->sensor_x;
 -			float sensor_y = (ca->sensor_fit == CAMERA_SENSOR_FIT_AUTO) ? ca->sensor_x : ca->sensor_y;
 -
 -			/* determine sensor plane */
 -			rctf rect;
 -
 -			if (sensor_fit == CAMERA_SENSOR_FIT_HOR) {
 -				float sensor_scale = (x2i - x1i) / sensor_x;
 -				float sensor_height = sensor_scale * sensor_y;
 -
 -				rect.xmin = x1i;
 -				rect.xmax = x2i;
 -				rect.ymin = (y1i + y2i) * 0.5f - sensor_height * 0.5f;
 -				rect.ymax = rect.ymin + sensor_height;
 -			}
 -			else {
 -				float sensor_scale = (y2i - y1i) / sensor_y;
 -				float sensor_width = sensor_scale * sensor_x;
 -
 -				rect.xmin = (x1i + x2i) * 0.5f - sensor_width * 0.5f;
 -				rect.xmax = rect.xmin + sensor_width;
 -				rect.ymin = y1i;
 -				rect.ymax = y2i;
 -			}
 -
 -			/* draw */
 -			UI_ThemeColorShade(TH_VIEW_OVERLAY, 100);
 -			UI_draw_roundbox_gl_mode(GL_LINE_LOOP, rect.xmin, rect.ymin, rect.xmax, rect.ymax, 2.0f);
 -		}
 -	}
 -
 -	setlinestyle(0);
 -
 -	/* camera name - draw in highlighted text color */
 -	if (ca && (ca->flag & CAM_SHOWNAME)) {
 -		UI_ThemeColor(TH_TEXT_HI);
 -		BLF_draw_default(
 -		        x1i, y1i - (0.7f * U.widget_unit), 0.0f,
 -		        v3d->camera->id.name + 2, sizeof(v3d->camera->id.name) - 2);
 -	}
 -}
 -
 -/* *********************** backdraw for selection *************** */
 -
 -static void backdrawview3d(Scene *scene, wmWindow *win, ARegion *ar, View3D *v3d)
 -{
 -	RegionView3D *rv3d = ar->regiondata;
 -	struct Base *base = scene->basact;
 -	int multisample_enabled;
 -
 -	BLI_assert(ar->regiontype == RGN_TYPE_WINDOW);
 -
 -	if (base && (base->object->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT) ||
 -	             BKE_paint_select_face_test(base->object)))
 -	{
 -		/* do nothing */
 -	}
 -	/* texture paint mode sampling */
 -	else if (base && (base->object->mode & OB_MODE_TEXTURE_PAINT) &&
 -	         (v3d->drawtype > OB_WIRE))
 -	{
 -		/* do nothing */
 -	}
 -	else if ((base && (base->object->mode & OB_MODE_PARTICLE_EDIT)) &&
 -	         V3D_IS_ZBUF(v3d))
 -	{
 -		/* do nothing */
 -	}
 -	else if (scene->obedit &&
 -	         V3D_IS_ZBUF(v3d))
 -	{
 -		/* do nothing */
 -	}
 -	else {
 -		v3d->flag &= ~V3D_INVALID_BACKBUF;
 -		return;
 -	}
 -
 -	if (!(v3d->flag & V3D_INVALID_BACKBUF))
 -		return;
 -
 -#if 0
 -	if (test) {
 -		if (qtest()) {
 -			addafterqueue(ar->win, BACKBUFDRAW, 1);
 -			return;
 -		}
 -	}
 -#endif
 -
 -	if (v3d->drawtype > OB_WIRE) v3d->zbuf = true;
 -	
 -	/* dithering and AA break color coding, so disable */
 -	glDisable(GL_DITHER);
 -
 -	multisample_enabled = glIsEnabled(GL_MULTISAMPLE);
 -	if (multisample_enabled)
 -		glDisable(GL_MULTISAMPLE);
 -
 -	if (win->multisamples != USER_MULTISAMPLE_NONE) {
 -		/* for multisample we use an offscreen FBO. multisample drawing can fail
 -		 * with color coded selection drawing, and reading back depths from such
 -		 * a buffer can also cause a few seconds freeze on OS X / NVidia. */
 -		int w = BLI_rcti_size_x(&ar->winrct);
 -		int h = BLI_rcti_size_y(&ar->winrct);
 -		char error[256];
 -
 -		if (rv3d->gpuoffscreen) {
 -			if (GPU_offscreen_width(rv3d->gpuoffscreen)  != w ||
 -			    GPU_offscreen_height(rv3d->gpuoffscreen) != h)
 -			{
 -				GPU_offscreen_free(rv3d->gpuoffscreen);
 -				rv3d->gpuoffscreen = NULL;
 -			}
 -		}
 -
 -		if (!rv3d->gpuoffscreen) {
 -			rv3d->gpuoffscreen = GPU_offscreen_create(w, h, 0, error);
 -
 -			if (!rv3d->gpuoffscreen)
 -				fprintf(stderr, "Failed to create offscreen selection buffer for multisample: %s\n", error);
 -		}
 -	}
 -
 -	if (rv3d->gpuoffscreen)
 -		GPU_offscreen_bind(rv3d->gpuoffscreen, true);
 -	else
 -		glScissor(ar->winrct.xmin, ar->winrct.ymin, BLI_rcti_size_x(&ar->winrct), BLI_rcti_size_y(&ar->winrct));
 -
 -	glClearColor(0.0, 0.0, 0.0, 0.0);
 -	if (v3d->zbuf) {
 -		glEnable(GL_DEPTH_TEST);
 -		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 -	}
 -	else {
 -		glClear(GL_COLOR_BUFFER_BIT);
 -		glDisable(GL_DEPTH_TEST);
 -	}
 -	
 -	if (rv3d->rflag & RV3D_CLIPPING)
 -		ED_view3d_clipping_set(rv3d);
 -	
 -	G.f |= G_BACKBUFSEL;
 -	
 -	if (base && (base->lay & v3d->lay))
 -		draw_object_backbufsel(scene, v3d, rv3d, base->object);
 -	
 -	if (rv3d->gpuoffscreen)
 -		GPU_offscreen_unbind(rv3d->gpuoffscreen, true);
 -	else
 -		ar->swap = 0; /* mark invalid backbuf for wm draw */
 -
 -	v3d->flag &= ~V3D_INVALID_BACKBUF;
 -
 -	G.f &= ~G_BACKBUFSEL;
 -	v3d->zbuf = false;
 -	glDisable(GL_DEPTH_TEST);
 -	glEnable(GL_DITHER);
 -	if (multisample_enabled)
 -		glEnable(GL_MULTISAMPLE);
 -
 -	if (rv3d->rflag & RV3D_CLIPPING)
 -		ED_view3d_clipping_disable();
 -}
 -
 -void view3d_opengl_read_pixels(ARegion *ar, int x, int y, int w, int h, int format, int type, void *data)
 -{
 -	RegionView3D *rv3d = ar->regiondata;
 -
 -	if (rv3d->gpuoffscreen) {
 -		GPU_offscreen_bind(rv3d->gpuoffscreen, true);
 -		glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
 -		glReadPixels(x, y, w, h, format, type, data);
 -		GPU_offscreen_unbind(rv3d->gpuoffscreen, true);
 -	}
 -	else {
 -		glReadPixels(ar->winrct.xmin + x, ar->winrct.ymin + y, w, h, format, type, data);
 -	}
 -}
 -
 -/* XXX depth reading exception, for code not using gpu offscreen */
 -static void view3d_opengl_read_Z_pixels(ARegion *ar, int x, int y, int w, int h, int format, int type, void *data)
 -{
 -
 -	glReadPixels(ar->winrct.xmin + x, ar->winrct.ymin + y, w, h, format, type, data);
 -}
 -
 -void ED_view3d_backbuf_validate(ViewContext *vc)
 -{
 -	if (vc->v3d->flag & V3D_INVALID_BACKBUF)
 -		backdrawview3d(vc->scene, vc->win, vc->ar, vc->v3d);
 -}
 -
 -/**
 - * allow for small values [0.5 - 2.5],
 - * and large values, FLT_MAX by clamping by the area size
 - */
 -int ED_view3d_backbuf_sample_size_clamp(ARegion *ar, const float dist)
 -{
 -	return (int)min_ff(ceilf(dist), (float)max_ii(ar->winx, ar->winx));
 -}
 -
 -/* samples a single pixel (copied from vpaint) */
 -unsigned int ED_view3d_backbuf_sample(ViewContext *vc, int x, int y)
 -{
 -	unsigned int col;
 -	
 -	if (x >= vc->ar->winx || y >= vc->ar->winy) {
 -		return 0;
 -	}
 -
 -	ED_view3d_backbuf_validate(vc);
 -
 -	view3d_opengl_read_pixels(vc->ar, x, y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &col);
 -	glReadBuffer(GL_BACK);
 -	
 -	if (ENDIAN_ORDER == B_ENDIAN) {
 -		BLI_endian_switch_uint32(&col);
 -	}
 -	
 -	return GPU_select_to_index(col);
 -}
 -
 -/* reads full rect, converts indices */
 -ImBuf *ED_view3d_backbuf_read(ViewContext *vc, int xmin, int ymin, int xmax, int ymax)
 -{
 -	struct ImBuf *ibuf_clip;
 -	/* clip */
 -	const rcti clip = {
 -	    max_ii(xmin, 0), min_ii(xmax, vc->ar->winx - 1),
 -	    max_ii(ymin, 0), min_ii(ymax, vc->ar->winy - 1)};
 -	const int size_clip[2] = {
 -	    BLI_rcti_size_x(&clip) + 1,
 -	    BLI_rcti_size_y(&clip) + 1};
 -
 -	if (UNLIKELY((clip.xmin > clip.xmax) ||
 -	             (clip.ymin > clip.ymax)))
 -	{
 -		return NULL;
 -	}
 -
 -	ibuf_clip = IMB_allocImBuf(size_clip[0], size_clip[1], 32, IB_rect);
 -
 -	ED_view3d_backbuf_validate(vc);
 -
 -	view3d_opengl_read_pixels(vc->ar, clip.xmin, clip.ymin, size_clip[0], size_clip[1], GL_RGBA, GL_UNSIGNED_BYTE, ibuf_clip->rect);
 -
 -	glReadBuffer(GL_BACK);
 -
 -	if (ENDIAN_ORDER == B_ENDIAN) {
 -		IMB_convert_rgba_to_abgr(ibuf_clip);
 -	}
 -
 -	GPU_select_to_index_array(ibuf_clip->rect, size_clip[0] * size_clip[1]);
 -	
 -	if ((clip.xmin == xmin) &&
 -	    (clip.xmax == xmax) &&
 -	    (clip.ymin == ymin) &&
 -	    (clip.ymax == ymax))
 -	{
 -		return ibuf_clip;
 -	}
 -	else {
 -		/* put clipped result into a non-clipped buffer */
 -		struct ImBuf *ibuf_full;
 -		const int size[2] = {
 -		    (xmax - xmin + 1),
 -		    (ymax - ymin + 1)};
 -
 -		ibuf_full = IMB_allocImBuf(size[0], size[1], 32, IB_rect);
 -
 -		IMB_rectcpy(
 -		        ibuf_full, ibuf_clip,
 -		        clip.xmin - xmin, clip.ymin - ymin,
 -		        0, 0,
 -		        size_clip[0], size_clip[1]);
 -		IMB_freeImBuf(ibuf_clip);
 -		return ibuf_full;
 -	}
 -}
 -
 -/* smart function to sample a rect spiralling outside, nice for backbuf selection */
 -unsigned int ED_view3d_backbuf_sample_rect(
 -        ViewContext *vc, const int mval[2], int size,
 -        unsigned int min, unsigned int max, float *r_dist)
 -{
 -	struct ImBuf *buf;
 -	const unsigned int *bufmin, *bufmax, *tbuf;
 -	int minx, miny;
 -	int a, b, rc, nr, amount, dirvec[4][2];
 -	unsigned int index = 0;
 -
 -	amount = (size - 1) / 2;
 -
 -	minx = mval[0] - (amount + 1);
 -	miny = mval[1] - (amount + 1);
 -	buf = ED_view3d_backbuf_read(vc, minx, miny, minx + size - 1, miny + size - 1);
 -	if (!buf) return 0;
 -
 -	rc = 0;
 -	
 -	dirvec[0][0] = 1; dirvec[0][1] = 0;
 -	dirvec[1][0] = 0; dirvec[1][1] = -size;
 -	dirvec[2][0] = -1; dirvec[2][1] = 0;
 -	dirvec[3][0] = 0; dirvec[3][1] = size;
 -	
 -	bufmin = buf->rect;
 -	tbuf = buf->rect;
 -	bufmax = buf->rect + size * size;
 -	tbuf += amount * size + amount;
 -	
 -	for (nr = 1; nr <= size; nr++) {
 -		
 -		for (a = 0; a < 2; a++) {
 -			for (b = 0; b < nr; b++) {
 -				if (*tbuf && *tbuf >= min && *tbuf < max) {
 -					/* we got a hit */
 -
 -					/* get x,y pixel coords from the offset
 -					 * (manhatten distance in keeping with other screen-based selection) */
 -					*r_dist = (float)(
 -					        abs(((int)(tbuf - buf->rect) % size) - (size / 2)) +
 -					        abs(((int)(tbuf - buf->rect) / size) - (size / 2)));
 -
 -					/* indices start at 1 here */
 -					index = (*tbuf - min) + 1;
 -					goto exit;
 -				}
 -				
 -				tbuf += (dirvec[rc][0] + dirvec[rc][1]);
 -				
 -				if (tbuf < bufmin || tbuf >= bufmax) {
 -					goto exit;
 -				}
 -			}
 -			rc++;
 -			rc &= 3;
 -		}
 -	}
 -
 -exit:
 -	IMB_freeImBuf(buf);
 -	return index;
 -}
 -
 -
 -/* ************************************************************* */
 -
 -static void view3d_stereo_bgpic_setup(Scene *scene, View3D *v3d, Image *ima, ImageUser *iuser)
 -{
 -	if (BKE_image_is_stere

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list