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

Campbell Barton noreply at git.blender.org
Fri Aug 25 14:18:07 CEST 2017


Commit: 8e6c18a98f5b006f16873d14198b615631dd48ed
Author: Campbell Barton
Date:   Fri Aug 25 22:22:50 2017 +1000
Branches: blender2.8
https://developer.blender.org/rB8e6c18a98f5b006f16873d14198b615631dd48ed

Merge branch 'master' into blender2.8

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



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

diff --cc source/blender/editors/space_view3d/view3d_draw_legacy.c
index 6184ed63543,00000000000..73ffe949823
mode 100644,000000..100644
--- a/source/blender/editors/space_view3d/view3d_draw_legacy.c
+++ b/source/blender/editors/space_view3d/view3d_draw_legacy.c
@@@ -1,2184 -1,0 +1,2192 @@@
 +/*
 + * ***** BEGIN GPL LICENSE BLOCK *****
 + *
 + * This program is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU General Public License
 + * as published by the Free Software Foundation; either version 2
 + * of the License, or (at your option) any later version. 
 + *
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 + *
 + * You should have received a copy of the GNU General Public License
 + * along with this program; if not, write to the Free Software Foundation,
 + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 + *
 + * The Original Code is Copyright (C) 2008 Blender Foundation.
 + * All rights reserved.
 + *
 + * 
 + * Contributor(s): Blender Foundation
 + *
 + * ***** END GPL LICENSE BLOCK *****
 + */
 +
 +/** \file blender/editors/space_view3d/view3d_draw_legacy.c
 + *  \ingroup spview3d
 + */
 +
 +#include <string.h>
 +#include <stdio.h>
 +#include <math.h>
 +
 +#include "DNA_armature_types.h"
 +#include "DNA_camera_types.h"
 +#include "DNA_customdata_types.h"
 +#include "DNA_object_types.h"
 +#include "DNA_group_types.h"
 +#include "DNA_mesh_types.h"
 +#include "DNA_key_types.h"
 +#include "DNA_lamp_types.h"
 +#include "DNA_scene_types.h"
 +#include "DNA_world_types.h"
 +#include "DNA_brush_types.h"
 +
 +#include "MEM_guardedalloc.h"
 +
 +#include "BLI_blenlib.h"
 +#include "BLI_math.h"
 +#include "BLI_jitter.h"
 +#include "BLI_utildefines.h"
 +#include "BLI_endian_switch.h"
 +#include "BLI_threads.h"
 +
 +#include "BKE_anim.h"
 +#include "BKE_camera.h"
 +#include "BKE_context.h"
 +#include "BKE_customdata.h"
 +#include "BKE_DerivedMesh.h"
 +#include "BKE_image.h"
 +#include "BKE_key.h"
 +#include "BKE_layer.h"
 +#include "BKE_main.h"
 +#include "BKE_object.h"
 +#include "BKE_global.h"
 +#include "BKE_paint.h"
 +#include "BKE_scene.h"
 +#include "BKE_screen.h"
 +#include "BKE_unit.h"
 +#include "BKE_movieclip.h"
 +
 +#include "DEG_depsgraph.h"
 +
 +#include "RE_engine.h"
 +
 +#include "IMB_imbuf_types.h"
 +#include "IMB_imbuf.h"
 +#include "IMB_colormanagement.h"
 +
 +#include "BIF_glutil.h"
 +
 +#include "WM_api.h"
 +#include "WM_types.h"
 +
 +#include "BLF_api.h"
 +#include "BLT_translation.h"
 +
 +#include "ED_armature.h"
 +#include "ED_keyframing.h"
 +#include "ED_gpencil.h"
 +#include "ED_screen.h"
 +#include "ED_space_api.h"
 +#include "ED_screen_types.h"
 +#include "ED_transform.h"
 +
 +#include "UI_interface.h"
 +#include "UI_interface_icons.h"
 +#include "UI_resources.h"
 +
 +#include "GPU_draw.h"
 +#include "GPU_framebuffer.h"
 +#include "GPU_lamp.h"
 +#include "GPU_material.h"
 +#include "GPU_compositing.h"
 +#include "GPU_extensions.h"
 +#include "GPU_immediate.h"
 +#include "GPU_immediate_util.h"
 +#include "GPU_select.h"
 +#include "GPU_matrix.h"
 +
 +#include "RE_engine.h"
 +
 +#include "DRW_engine.h"
 +
 +#include "view3d_intern.h"  /* own include */
 +
 +/* ********* custom clipping *********** */
 +
 +static void view3d_draw_clipping(RegionView3D *rv3d)
 +{
 +	BoundBox *bb = rv3d->clipbb;
 +
 +	if (bb) {
 +		const unsigned int clipping_index[6][4] = {
 +			{0, 1, 2, 3},
 +			{0, 4, 5, 1},
 +			{4, 7, 6, 5},
 +			{7, 3, 2, 6},
 +			{1, 5, 6, 2},
 +			{7, 4, 0, 3}
 +		};
 +
 +		/* fill in zero alpha for rendering & re-projection [#31530] */
 +		unsigned char col[4];
 +		UI_GetThemeColor4ubv(TH_V3D_CLIPPING_BORDER, col);
 +		glColor4ubv(col);
 +
 +		glEnable(GL_BLEND);
 +		glEnableClientState(GL_VERTEX_ARRAY);
 +		glVertexPointer(3, GL_FLOAT, 0, bb->vec);
 +		glDrawElements(GL_QUADS, sizeof(clipping_index) / sizeof(unsigned int), GL_UNSIGNED_INT, clipping_index);
 +		glDisableClientState(GL_VERTEX_ARRAY);
 +		glDisable(GL_BLEND);
 +	}
 +}
 +
 +void ED_view3d_clipping_set(RegionView3D *rv3d)
 +{
 +	double plane[4];
 +	const unsigned int tot = (rv3d->viewlock & RV3D_BOXCLIP) ? 4 : 6;
 +
 +	for (unsigned a = 0; a < tot; a++) {
 +		copy_v4db_v4fl(plane, rv3d->clip[a]);
 +		glClipPlane(GL_CLIP_PLANE0 + a, plane);
 +		glEnable(GL_CLIP_PLANE0 + a);
 +	}
 +}
 +
 +/* use these to temp disable/enable clipping when 'rv3d->rflag & RV3D_CLIPPING' is set */
 +void ED_view3d_clipping_disable(void)
 +{
 +	for (unsigned a = 0; a < 6; a++) {
 +		glDisable(GL_CLIP_PLANE0 + a);
 +	}
 +}
 +void ED_view3d_clipping_enable(void)
 +{
 +	for (unsigned a = 0; a < 6; a++) {
 +		glEnable(GL_CLIP_PLANE0 + a);
 +	}
 +}
 +
 +static bool view3d_clipping_test(const float co[3], const float clip[6][4])
 +{
 +	if (plane_point_side_v3(clip[0], co) > 0.0f)
 +		if (plane_point_side_v3(clip[1], co) > 0.0f)
 +			if (plane_point_side_v3(clip[2], co) > 0.0f)
 +				if (plane_point_side_v3(clip[3], co) > 0.0f)
 +					return false;
 +
 +	return true;
 +}
 +
 +/* for 'local' ED_view3d_clipping_local must run first
 + * then all comparisons can be done in localspace */
 +bool ED_view3d_clipping_test(const RegionView3D *rv3d, const float co[3], const bool is_local)
 +{
 +	return view3d_clipping_test(co, is_local ? rv3d->clip_local : rv3d->clip);
 +}
 +
 +/* ********* end custom clipping *********** */
 +
 +static void draw_view_icon(RegionView3D *rv3d, rcti *rect)
 +{
 +	BIFIconID icon;
 +	
 +	if (ELEM(rv3d->view, RV3D_VIEW_TOP, RV3D_VIEW_BOTTOM))
 +		icon = ICON_AXIS_TOP;
 +	else if (ELEM(rv3d->view, RV3D_VIEW_FRONT, RV3D_VIEW_BACK))
 +		icon = ICON_AXIS_FRONT;
 +	else if (ELEM(rv3d->view, RV3D_VIEW_RIGHT, RV3D_VIEW_LEFT))
 +		icon = ICON_AXIS_SIDE;
 +	else return;
 +	
 +	glEnable(GL_BLEND);
 +	glBlendFunc(GL_SRC_ALPHA,  GL_ONE_MINUS_SRC_ALPHA); 
 +	
 +	UI_icon_draw(5.0 + rect->xmin, 5.0 + rect->ymin, icon);
 +	
 +	glDisable(GL_BLEND);
 +}
 +
 +/* *********************** backdraw for selection *************** */
 +
 +static void backdrawview3d(const struct EvaluationContext *eval_ctx, Scene *scene, SceneLayer *sl, wmWindow *win, ARegion *ar, View3D *v3d)
 +{
 +	RegionView3D *rv3d = ar->regiondata;
 +	struct Base *base = sl->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->flag & BASE_VISIBLED) != 0))
 +		draw_object_backbufsel(eval_ctx, 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);
 +		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,

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list