2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2008-12-18 17:38:21 +00:00
|
|
|
* 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
|
2018-06-01 18:19:39 +02:00
|
|
|
* of the License, or (at your option) any later version.
|
2008-12-18 17:38:21 +00:00
|
|
|
*
|
|
|
|
* 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,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2008-12-18 17:38:21 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2008 Blender Foundation.
|
|
|
|
* All rights reserved.
|
|
|
|
*/
|
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
* \ingroup spview3d
|
2011-02-27 20:29:51 +00:00
|
|
|
*/
|
|
|
|
|
2016-10-06 19:55:06 +00:00
|
|
|
#include <math.h>
|
|
|
|
|
2017-11-20 14:11:45 +11:00
|
|
|
#include "BLI_listbase.h"
|
|
|
|
#include "BLI_math.h"
|
|
|
|
#include "BLI_rect.h"
|
|
|
|
#include "BLI_string.h"
|
|
|
|
#include "BLI_threads.h"
|
2018-02-18 22:33:05 +11:00
|
|
|
#include "BLI_jitter_2d.h"
|
2017-11-20 14:11:45 +11:00
|
|
|
|
2008-12-18 17:38:21 +00:00
|
|
|
|
2016-10-06 19:55:06 +00:00
|
|
|
#include "BKE_camera.h"
|
2018-11-13 18:30:44 -02:00
|
|
|
#include "BKE_collection.h"
|
2016-10-06 19:55:06 +00:00
|
|
|
#include "BKE_context.h"
|
2017-05-03 21:59:03 +10:00
|
|
|
#include "BKE_global.h"
|
2017-02-14 17:47:11 +01:00
|
|
|
#include "BKE_key.h"
|
2013-12-26 17:24:42 +06:00
|
|
|
#include "BKE_main.h"
|
2016-10-06 19:55:06 +00:00
|
|
|
#include "BKE_scene.h"
|
2016-12-05 02:50:28 -05:00
|
|
|
#include "BKE_object.h"
|
|
|
|
#include "BKE_paint.h"
|
2016-10-06 19:55:06 +00:00
|
|
|
#include "BKE_unit.h"
|
|
|
|
|
2016-10-14 01:38:04 +00:00
|
|
|
#include "BLF_api.h"
|
|
|
|
|
2017-02-14 17:47:11 +01:00
|
|
|
#include "BLT_translation.h"
|
|
|
|
|
|
|
|
#include "DNA_armature_types.h"
|
2016-12-05 02:50:28 -05:00
|
|
|
#include "DNA_brush_types.h"
|
2016-10-06 19:55:06 +00:00
|
|
|
#include "DNA_camera_types.h"
|
2017-02-14 17:47:11 +01:00
|
|
|
#include "DNA_key_types.h"
|
2016-10-07 01:45:28 +00:00
|
|
|
#include "DNA_mesh_types.h"
|
2016-10-06 19:55:06 +00:00
|
|
|
#include "DNA_object_types.h"
|
|
|
|
#include "DNA_view3d_types.h"
|
|
|
|
#include "DNA_windowmanager_types.h"
|
|
|
|
|
2017-03-08 20:00:09 +01:00
|
|
|
#include "DRW_engine.h"
|
|
|
|
|
2017-02-14 17:47:11 +01:00
|
|
|
#include "ED_armature.h"
|
2008-12-21 10:33:24 +00:00
|
|
|
#include "ED_keyframing.h"
|
2009-08-26 12:01:15 +00:00
|
|
|
#include "ED_gpencil.h"
|
2008-12-18 17:38:21 +00:00
|
|
|
#include "ED_screen.h"
|
2016-10-13 02:50:42 +00:00
|
|
|
#include "ED_transform.h"
|
2008-12-18 17:38:21 +00:00
|
|
|
|
2017-05-03 00:05:57 +10:00
|
|
|
#include "DEG_depsgraph_query.h"
|
|
|
|
|
2018-05-03 11:20:10 +02:00
|
|
|
#include "GPU_batch.h"
|
2018-07-15 10:34:31 +02:00
|
|
|
#include "GPU_batch_presets.h"
|
2017-05-03 21:59:03 +10:00
|
|
|
#include "GPU_draw.h"
|
2016-10-25 04:39:55 -04:00
|
|
|
#include "GPU_matrix.h"
|
2016-10-06 19:55:06 +00:00
|
|
|
#include "GPU_immediate.h"
|
2017-04-05 18:30:14 +10:00
|
|
|
#include "GPU_immediate_util.h"
|
2016-10-24 18:58:12 +00:00
|
|
|
#include "GPU_material.h"
|
2016-10-13 04:22:28 +00:00
|
|
|
#include "GPU_viewport.h"
|
2018-06-27 19:07:23 -06:00
|
|
|
#include "GPU_state.h"
|
|
|
|
#include "GPU_framebuffer.h"
|
2016-10-06 19:55:06 +00:00
|
|
|
|
2016-10-21 20:50:00 +00:00
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
2016-10-14 01:38:04 +00:00
|
|
|
#include "UI_interface.h"
|
2016-10-06 19:55:06 +00:00
|
|
|
#include "UI_resources.h"
|
|
|
|
|
2016-10-07 01:45:28 +00:00
|
|
|
#include "RE_engine.h"
|
|
|
|
|
2016-10-06 19:55:06 +00:00
|
|
|
#include "WM_api.h"
|
2017-04-07 00:35:57 +10:00
|
|
|
#include "WM_types.h"
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2017-11-13 19:43:34 +11:00
|
|
|
#include "RNA_access.h"
|
|
|
|
|
2017-05-03 21:59:03 +10:00
|
|
|
#include "IMB_imbuf.h"
|
|
|
|
#include "IMB_imbuf_types.h"
|
|
|
|
|
2012-07-08 20:36:00 +00:00
|
|
|
#include "view3d_intern.h" /* own include */
|
2008-12-18 17:38:21 +00:00
|
|
|
|
2019-03-28 15:00:27 +11:00
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name General Functions
|
|
|
|
* \{ */
|
2016-10-06 19:55:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \note keep this synced with #ED_view3d_mats_rv3d_backup/#ED_view3d_mats_rv3d_restore
|
|
|
|
*/
|
2017-08-16 12:45:11 +10:00
|
|
|
void ED_view3d_update_viewmat(
|
2018-04-06 12:07:27 +02:00
|
|
|
Depsgraph *depsgraph, Scene *scene, View3D *v3d, ARegion *ar,
|
2017-08-16 12:45:11 +10:00
|
|
|
float viewmat[4][4], float winmat[4][4], const rcti *rect)
|
2016-10-06 19:55:06 +00:00
|
|
|
{
|
|
|
|
RegionView3D *rv3d = ar->regiondata;
|
2009-11-21 16:44:05 +00:00
|
|
|
|
2016-10-06 19:55:06 +00:00
|
|
|
/* setup window matrices */
|
2019-03-26 21:16:47 +11:00
|
|
|
if (winmat) {
|
2016-10-06 19:55:06 +00:00
|
|
|
copy_m4_m4(rv3d->winmat, winmat);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
|
|
|
else {
|
2018-01-18 15:58:02 +01:00
|
|
|
view3d_winmatrix_set(depsgraph, ar, v3d, rect);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2016-10-06 19:55:06 +00:00
|
|
|
|
|
|
|
/* setup view matrix */
|
2018-01-23 11:24:44 +11:00
|
|
|
if (viewmat) {
|
2016-10-06 19:55:06 +00:00
|
|
|
copy_m4_m4(rv3d->viewmat, viewmat);
|
2018-01-23 11:24:44 +11:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
float rect_scale[2];
|
|
|
|
if (rect) {
|
|
|
|
rect_scale[0] = (float)BLI_rcti_size_x(rect) / (float)ar->winx;
|
|
|
|
rect_scale[1] = (float)BLI_rcti_size_y(rect) / (float)ar->winy;
|
|
|
|
}
|
|
|
|
/* note: calls BKE_object_where_is_calc for camera... */
|
2018-04-06 12:07:27 +02:00
|
|
|
view3d_viewmatrix_set(depsgraph, scene, v3d, rv3d, rect ? rect_scale : NULL);
|
2018-01-23 11:24:44 +11:00
|
|
|
}
|
2016-12-01 10:29:46 +01:00
|
|
|
/* update utility matrices */
|
2016-10-06 19:55:06 +00:00
|
|
|
mul_m4_m4m4(rv3d->persmat, rv3d->winmat, rv3d->viewmat);
|
|
|
|
invert_m4_m4(rv3d->persinv, rv3d->persmat);
|
|
|
|
invert_m4_m4(rv3d->viewinv, rv3d->viewmat);
|
|
|
|
|
|
|
|
/* calculate GLSL view dependent values */
|
|
|
|
|
|
|
|
/* store window coordinates scaling/offset */
|
|
|
|
if (rv3d->persp == RV3D_CAMOB && v3d->camera) {
|
2016-12-01 10:29:46 +01:00
|
|
|
rctf cameraborder;
|
2018-04-06 12:07:27 +02:00
|
|
|
ED_view3d_calc_camera_border(scene, depsgraph, ar, v3d, rv3d, &cameraborder, false);
|
2016-10-06 19:55:06 +00:00
|
|
|
rv3d->viewcamtexcofac[0] = (float)ar->winx / BLI_rctf_size_x(&cameraborder);
|
|
|
|
rv3d->viewcamtexcofac[1] = (float)ar->winy / BLI_rctf_size_y(&cameraborder);
|
|
|
|
|
|
|
|
rv3d->viewcamtexcofac[2] = -rv3d->viewcamtexcofac[0] * cameraborder.xmin / (float)ar->winx;
|
|
|
|
rv3d->viewcamtexcofac[3] = -rv3d->viewcamtexcofac[1] * cameraborder.ymin / (float)ar->winy;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rv3d->viewcamtexcofac[0] = rv3d->viewcamtexcofac[1] = 1.0f;
|
|
|
|
rv3d->viewcamtexcofac[2] = rv3d->viewcamtexcofac[3] = 0.0f;
|
|
|
|
}
|
|
|
|
|
2019-02-27 12:02:02 +11:00
|
|
|
/* calculate pixelsize factor once, is used for lights and obcenters */
|
2016-10-06 19:55:06 +00:00
|
|
|
{
|
|
|
|
/* note: '1.0f / len_v3(v1)' replaced 'len_v3(rv3d->viewmat[0])'
|
2017-04-30 03:14:57 +10:00
|
|
|
* because of float point precision problems at large values [#23908] */
|
2016-10-06 19:55:06 +00:00
|
|
|
float v1[3], v2[3];
|
|
|
|
float len_px, len_sc;
|
|
|
|
|
|
|
|
v1[0] = rv3d->persmat[0][0];
|
|
|
|
v1[1] = rv3d->persmat[1][0];
|
|
|
|
v1[2] = rv3d->persmat[2][0];
|
|
|
|
|
|
|
|
v2[0] = rv3d->persmat[0][1];
|
|
|
|
v2[1] = rv3d->persmat[1][1];
|
|
|
|
v2[2] = rv3d->persmat[2][1];
|
|
|
|
|
|
|
|
len_px = 2.0f / sqrtf(min_ff(len_squared_v3(v1), len_squared_v3(v2)));
|
|
|
|
len_sc = (float)MAX2(ar->winx, ar->winy);
|
|
|
|
|
|
|
|
rv3d->pixsize = len_px / len_sc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-10 15:54:23 +02:00
|
|
|
static void view3d_main_region_setup_view(
|
2018-04-06 12:07:27 +02:00
|
|
|
Depsgraph *depsgraph, Scene *scene,
|
2017-08-16 12:45:11 +10:00
|
|
|
View3D *v3d, ARegion *ar, float viewmat[4][4], float winmat[4][4], const rcti *rect)
|
2016-10-06 19:55:06 +00:00
|
|
|
{
|
|
|
|
RegionView3D *rv3d = ar->regiondata;
|
|
|
|
|
2018-04-06 12:07:27 +02:00
|
|
|
ED_view3d_update_viewmat(depsgraph, scene, v3d, ar, viewmat, winmat, rect);
|
2016-10-06 19:55:06 +00:00
|
|
|
|
|
|
|
/* set for opengl */
|
2018-07-15 15:27:15 +02:00
|
|
|
GPU_matrix_projection_set(rv3d->winmat);
|
|
|
|
GPU_matrix_set(rv3d->viewmat);
|
2016-10-06 19:55:06 +00:00
|
|
|
}
|
|
|
|
|
2017-05-10 15:25:26 +02:00
|
|
|
static bool view3d_stereo3d_active(wmWindow *win, Scene *scene, View3D *v3d, RegionView3D *rv3d)
|
2016-10-06 19:55:06 +00:00
|
|
|
{
|
2017-05-10 15:25:26 +02:00
|
|
|
if ((scene->r.scemode & R_MULTIVIEW) == 0) {
|
2016-10-06 19:55:06 +00:00
|
|
|
return false;
|
2017-05-10 15:25:26 +02:00
|
|
|
}
|
2016-10-06 19:55:06 +00:00
|
|
|
|
2017-05-10 15:25:26 +02:00
|
|
|
if ((v3d->camera == NULL) || (v3d->camera->type != OB_CAMERA) || rv3d->persp != RV3D_CAMOB) {
|
2016-10-06 19:55:06 +00:00
|
|
|
return false;
|
2017-05-10 15:25:26 +02:00
|
|
|
}
|
2016-10-06 19:55:06 +00:00
|
|
|
|
2017-05-10 15:25:26 +02:00
|
|
|
switch (v3d->stereo3d_camera) {
|
|
|
|
case STEREO_MONO_ID:
|
2016-10-06 19:55:06 +00:00
|
|
|
return false;
|
2017-05-10 15:25:26 +02:00
|
|
|
break;
|
|
|
|
case STEREO_3D_ID:
|
|
|
|
/* win will be NULL when calling this from the selection or draw loop. */
|
|
|
|
if ((win == NULL) || (WM_stereo3d_enabled(win, true) == false)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (((scene->r.views_format & SCE_VIEWS_FORMAT_MULTIVIEW) != 0) &&
|
|
|
|
!BKE_scene_multiview_is_stereo3d(&scene->r))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
/* We always need the stereo calculation for left and right cameras. */
|
|
|
|
case STEREO_LEFT_ID:
|
|
|
|
case STEREO_RIGHT_ID:
|
|
|
|
default:
|
|
|
|
break;
|
2016-10-06 19:55:06 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-01-24 20:30:41 +11:00
|
|
|
|
2016-10-06 19:55:06 +00:00
|
|
|
/* setup the view and win matrices for the multiview cameras
|
|
|
|
*
|
|
|
|
* unlike view3d_stereo3d_setup_offscreen, when view3d_stereo3d_setup is called
|
|
|
|
* we have no winmatrix (i.e., projection matrix) defined at that time.
|
|
|
|
* Since the camera and the camera shift are needed for the winmat calculation
|
|
|
|
* we do a small hack to replace it temporarily so we don't need to change the
|
|
|
|
* view3d)main_region_setup_view() code to account for that.
|
|
|
|
*/
|
2017-08-16 12:45:11 +10:00
|
|
|
static void view3d_stereo3d_setup(
|
2018-04-06 12:07:27 +02:00
|
|
|
Depsgraph *depsgraph, Scene *scene, View3D *v3d, ARegion *ar, const rcti *rect)
|
2016-10-06 19:55:06 +00:00
|
|
|
{
|
|
|
|
bool is_left;
|
|
|
|
const char *names[2] = { STEREO_LEFT_NAME, STEREO_RIGHT_NAME };
|
|
|
|
const char *viewname;
|
|
|
|
|
|
|
|
/* show only left or right camera */
|
2019-03-26 21:16:47 +11:00
|
|
|
if (v3d->stereo3d_camera != STEREO_3D_ID) {
|
2016-10-06 19:55:06 +00:00
|
|
|
v3d->multiview_eye = v3d->stereo3d_camera;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2016-10-06 19:55:06 +00:00
|
|
|
|
|
|
|
is_left = v3d->multiview_eye == STEREO_LEFT_ID;
|
|
|
|
viewname = names[is_left ? STEREO_LEFT_ID : STEREO_RIGHT_ID];
|
|
|
|
|
|
|
|
/* update the viewport matrices with the new camera */
|
|
|
|
if (scene->r.views_format == SCE_VIEWS_FORMAT_STEREO_3D) {
|
2019-01-11 10:47:48 -02:00
|
|
|
Camera *data, *data_eval;
|
2016-10-06 19:55:06 +00:00
|
|
|
float viewmat[4][4];
|
|
|
|
float shiftx;
|
|
|
|
|
|
|
|
data = (Camera *)v3d->camera->data;
|
2019-01-11 10:47:48 -02:00
|
|
|
data_eval = (Camera *)DEG_get_evaluated_id(depsgraph, &data->id);
|
|
|
|
|
|
|
|
shiftx = data_eval->shiftx;
|
2016-10-06 19:55:06 +00:00
|
|
|
|
2018-02-16 01:17:43 +11:00
|
|
|
BLI_thread_lock(LOCK_VIEW3D);
|
2019-01-11 10:47:48 -02:00
|
|
|
data_eval->shiftx = BKE_camera_multiview_shift_x(&scene->r, v3d->camera, viewname);
|
2016-10-06 19:55:06 +00:00
|
|
|
|
|
|
|
BKE_camera_multiview_view_matrix(&scene->r, v3d->camera, is_left, viewmat);
|
2018-04-06 12:07:27 +02:00
|
|
|
view3d_main_region_setup_view(depsgraph, scene, v3d, ar, viewmat, NULL, rect);
|
2016-10-06 19:55:06 +00:00
|
|
|
|
2019-01-11 10:47:48 -02:00
|
|
|
data_eval->shiftx = shiftx;
|
2018-02-16 01:17:43 +11:00
|
|
|
BLI_thread_unlock(LOCK_VIEW3D);
|
2016-10-06 19:55:06 +00:00
|
|
|
}
|
|
|
|
else { /* SCE_VIEWS_FORMAT_MULTIVIEW */
|
|
|
|
float viewmat[4][4];
|
|
|
|
Object *view_ob = v3d->camera;
|
|
|
|
Object *camera = BKE_camera_multiview_render(scene, v3d->camera, viewname);
|
|
|
|
|
2018-02-16 01:17:43 +11:00
|
|
|
BLI_thread_lock(LOCK_VIEW3D);
|
2016-10-06 19:55:06 +00:00
|
|
|
v3d->camera = camera;
|
|
|
|
|
|
|
|
BKE_camera_multiview_view_matrix(&scene->r, camera, false, viewmat);
|
2018-04-06 12:07:27 +02:00
|
|
|
view3d_main_region_setup_view(depsgraph, scene, v3d, ar, viewmat, NULL, rect);
|
2016-10-06 19:55:06 +00:00
|
|
|
|
|
|
|
v3d->camera = view_ob;
|
2018-02-16 01:17:43 +11:00
|
|
|
BLI_thread_unlock(LOCK_VIEW3D);
|
2016-10-06 19:55:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-10 15:25:26 +02:00
|
|
|
/**
|
|
|
|
* Set the correct matrices
|
|
|
|
*/
|
2017-05-10 15:54:23 +02:00
|
|
|
void ED_view3d_draw_setup_view(
|
2018-04-06 12:07:27 +02:00
|
|
|
wmWindow *win, Depsgraph *depsgraph, Scene *scene, ARegion *ar, View3D *v3d,
|
2017-05-10 15:54:23 +02:00
|
|
|
float viewmat[4][4], float winmat[4][4], const rcti *rect)
|
2017-05-10 15:25:26 +02:00
|
|
|
{
|
|
|
|
RegionView3D *rv3d = ar->regiondata;
|
|
|
|
|
|
|
|
/* Setup the view matrix. */
|
|
|
|
if (view3d_stereo3d_active(win, scene, v3d, rv3d)) {
|
2018-04-06 12:07:27 +02:00
|
|
|
view3d_stereo3d_setup(depsgraph, scene, v3d, ar, rect);
|
2009-08-12 14:11:53 +00:00
|
|
|
}
|
|
|
|
else {
|
2018-04-06 12:07:27 +02:00
|
|
|
view3d_main_region_setup_view(depsgraph, scene, v3d, ar, viewmat, winmat, rect);
|
2017-05-10 15:25:26 +02:00
|
|
|
}
|
|
|
|
}
|
2009-08-12 17:02:03 +00:00
|
|
|
|
2019-03-28 15:00:27 +11:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Draw View Border
|
|
|
|
* \{ */
|
2016-10-14 01:38:04 +00:00
|
|
|
|
|
|
|
static void view3d_camera_border(
|
2018-04-06 12:07:27 +02:00
|
|
|
const Scene *scene, struct Depsgraph *depsgraph,
|
2018-01-18 15:58:02 +01:00
|
|
|
const ARegion *ar, const View3D *v3d, const RegionView3D *rv3d,
|
2016-10-14 01:38:04 +00:00
|
|
|
rctf *r_viewborder, const bool no_shift, const bool no_zoom)
|
|
|
|
{
|
|
|
|
CameraParams params;
|
|
|
|
rctf rect_view, rect_camera;
|
2018-05-25 11:05:51 +02:00
|
|
|
Object *camera_eval = DEG_get_evaluated_object(depsgraph, v3d->camera);
|
2016-10-14 01:38:04 +00:00
|
|
|
|
|
|
|
/* get viewport viewplane */
|
|
|
|
BKE_camera_params_init(¶ms);
|
2018-01-18 15:58:02 +01:00
|
|
|
BKE_camera_params_from_view3d(¶ms, depsgraph, v3d, rv3d);
|
2019-03-26 21:16:47 +11:00
|
|
|
if (no_zoom) {
|
2016-10-14 01:38:04 +00:00
|
|
|
params.zoom = 1.0f;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2016-10-14 01:38:04 +00:00
|
|
|
BKE_camera_params_compute_viewplane(¶ms, ar->winx, ar->winy, 1.0f, 1.0f);
|
|
|
|
rect_view = params.viewplane;
|
|
|
|
|
|
|
|
/* get camera viewplane */
|
|
|
|
BKE_camera_params_init(¶ms);
|
|
|
|
/* fallback for non camera objects */
|
2019-02-16 12:21:44 +11:00
|
|
|
params.clip_start = v3d->clip_start;
|
|
|
|
params.clip_end = v3d->clip_end;
|
2018-05-25 11:05:51 +02:00
|
|
|
BKE_camera_params_from_object(¶ms, camera_eval);
|
2016-10-14 01:38:04 +00:00
|
|
|
if (no_shift) {
|
|
|
|
params.shiftx = 0.0f;
|
|
|
|
params.shifty = 0.0f;
|
|
|
|
}
|
|
|
|
BKE_camera_params_compute_viewplane(¶ms, scene->r.xsch, scene->r.ysch, scene->r.xasp, scene->r.yasp);
|
|
|
|
rect_camera = params.viewplane;
|
|
|
|
|
|
|
|
/* get camera border within viewport */
|
|
|
|
r_viewborder->xmin = ((rect_camera.xmin - rect_view.xmin) / BLI_rctf_size_x(&rect_view)) * ar->winx;
|
|
|
|
r_viewborder->xmax = ((rect_camera.xmax - rect_view.xmin) / BLI_rctf_size_x(&rect_view)) * ar->winx;
|
|
|
|
r_viewborder->ymin = ((rect_camera.ymin - rect_view.ymin) / BLI_rctf_size_y(&rect_view)) * ar->winy;
|
|
|
|
r_viewborder->ymax = ((rect_camera.ymax - rect_view.ymin) / BLI_rctf_size_y(&rect_view)) * ar->winy;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ED_view3d_calc_camera_border_size(
|
2018-04-06 12:07:27 +02:00
|
|
|
const Scene *scene, Depsgraph *depsgraph,
|
2018-01-18 15:58:02 +01:00
|
|
|
const ARegion *ar, const View3D *v3d, const RegionView3D *rv3d,
|
2016-10-14 01:38:04 +00:00
|
|
|
float r_size[2])
|
|
|
|
{
|
|
|
|
rctf viewborder;
|
|
|
|
|
2018-01-18 15:58:02 +01:00
|
|
|
view3d_camera_border(scene, depsgraph, ar, v3d, rv3d, &viewborder, true, true);
|
2016-10-14 01:38:04 +00:00
|
|
|
r_size[0] = BLI_rctf_size_x(&viewborder);
|
|
|
|
r_size[1] = BLI_rctf_size_y(&viewborder);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ED_view3d_calc_camera_border(
|
2018-04-06 12:07:27 +02:00
|
|
|
const Scene *scene, Depsgraph *depsgraph,
|
2018-01-18 15:58:02 +01:00
|
|
|
const ARegion *ar, const View3D *v3d, const RegionView3D *rv3d,
|
2016-10-14 01:38:04 +00:00
|
|
|
rctf *r_viewborder, const bool no_shift)
|
|
|
|
{
|
2018-01-18 15:58:02 +01:00
|
|
|
view3d_camera_border(scene, depsgraph, ar, v3d, rv3d, r_viewborder, no_shift, false);
|
2016-10-14 01:38:04 +00:00
|
|
|
}
|
|
|
|
|
Reworked version of dashed line shader.
Using geometry shader allows us to get rid of the 'line origin' extra
vertex attribute, which means dashed shader no longer requires fiddling
with those vertex attributes definition, and, most importantly, does not
require anymore special drawing code!
As you can see, this makes code much simpler, and much less verbose,
especially in complex cases.
In addition, changed how dashes are handled, to have two 'modes', a
simple one with single color (using default "color" uniform name), and a
more advanced one allowing more complex and multi-color patterns.
Note that since GLSL 1.2 does not support geometry shaders, a hack was
added for now (which gives solid lines, but at least does not make
Blender crash).
2017-05-01 16:21:53 +02:00
|
|
|
static void drawviewborder_grid3(uint shdr_pos, float x1, float x2, float y1, float y2, float fac)
|
2016-10-14 01:38:04 +00:00
|
|
|
{
|
|
|
|
float x3, y3, x4, y4;
|
|
|
|
|
|
|
|
x3 = x1 + fac * (x2 - x1);
|
|
|
|
y3 = y1 + fac * (y2 - y1);
|
|
|
|
x4 = x1 + (1.0f - fac) * (x2 - x1);
|
|
|
|
y4 = y1 + (1.0f - fac) * (y2 - y1);
|
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
immBegin(GPU_PRIM_LINES, 8);
|
2017-04-26 12:17:46 +02:00
|
|
|
|
Reworked version of dashed line shader.
Using geometry shader allows us to get rid of the 'line origin' extra
vertex attribute, which means dashed shader no longer requires fiddling
with those vertex attributes definition, and, most importantly, does not
require anymore special drawing code!
As you can see, this makes code much simpler, and much less verbose,
especially in complex cases.
In addition, changed how dashes are handled, to have two 'modes', a
simple one with single color (using default "color" uniform name), and a
more advanced one allowing more complex and multi-color patterns.
Note that since GLSL 1.2 does not support geometry shaders, a hack was
added for now (which gives solid lines, but at least does not make
Blender crash).
2017-05-01 16:21:53 +02:00
|
|
|
immVertex2f(shdr_pos, x1, y3);
|
|
|
|
immVertex2f(shdr_pos, x2, y3);
|
2016-10-14 01:38:04 +00:00
|
|
|
|
Reworked version of dashed line shader.
Using geometry shader allows us to get rid of the 'line origin' extra
vertex attribute, which means dashed shader no longer requires fiddling
with those vertex attributes definition, and, most importantly, does not
require anymore special drawing code!
As you can see, this makes code much simpler, and much less verbose,
especially in complex cases.
In addition, changed how dashes are handled, to have two 'modes', a
simple one with single color (using default "color" uniform name), and a
more advanced one allowing more complex and multi-color patterns.
Note that since GLSL 1.2 does not support geometry shaders, a hack was
added for now (which gives solid lines, but at least does not make
Blender crash).
2017-05-01 16:21:53 +02:00
|
|
|
immVertex2f(shdr_pos, x1, y4);
|
|
|
|
immVertex2f(shdr_pos, x2, y4);
|
2016-10-14 01:38:04 +00:00
|
|
|
|
Reworked version of dashed line shader.
Using geometry shader allows us to get rid of the 'line origin' extra
vertex attribute, which means dashed shader no longer requires fiddling
with those vertex attributes definition, and, most importantly, does not
require anymore special drawing code!
As you can see, this makes code much simpler, and much less verbose,
especially in complex cases.
In addition, changed how dashes are handled, to have two 'modes', a
simple one with single color (using default "color" uniform name), and a
more advanced one allowing more complex and multi-color patterns.
Note that since GLSL 1.2 does not support geometry shaders, a hack was
added for now (which gives solid lines, but at least does not make
Blender crash).
2017-05-01 16:21:53 +02:00
|
|
|
immVertex2f(shdr_pos, x3, y1);
|
|
|
|
immVertex2f(shdr_pos, x3, y2);
|
2016-10-14 01:38:04 +00:00
|
|
|
|
Reworked version of dashed line shader.
Using geometry shader allows us to get rid of the 'line origin' extra
vertex attribute, which means dashed shader no longer requires fiddling
with those vertex attributes definition, and, most importantly, does not
require anymore special drawing code!
As you can see, this makes code much simpler, and much less verbose,
especially in complex cases.
In addition, changed how dashes are handled, to have two 'modes', a
simple one with single color (using default "color" uniform name), and a
more advanced one allowing more complex and multi-color patterns.
Note that since GLSL 1.2 does not support geometry shaders, a hack was
added for now (which gives solid lines, but at least does not make
Blender crash).
2017-05-01 16:21:53 +02:00
|
|
|
immVertex2f(shdr_pos, x4, y1);
|
|
|
|
immVertex2f(shdr_pos, x4, y2);
|
2017-04-26 12:17:46 +02:00
|
|
|
|
2016-10-14 01:38:04 +00:00
|
|
|
immEnd();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* harmonious triangle */
|
2017-04-26 12:17:46 +02:00
|
|
|
static void drawviewborder_triangle(
|
Reworked version of dashed line shader.
Using geometry shader allows us to get rid of the 'line origin' extra
vertex attribute, which means dashed shader no longer requires fiddling
with those vertex attributes definition, and, most importantly, does not
require anymore special drawing code!
As you can see, this makes code much simpler, and much less verbose,
especially in complex cases.
In addition, changed how dashes are handled, to have two 'modes', a
simple one with single color (using default "color" uniform name), and a
more advanced one allowing more complex and multi-color patterns.
Note that since GLSL 1.2 does not support geometry shaders, a hack was
added for now (which gives solid lines, but at least does not make
Blender crash).
2017-05-01 16:21:53 +02:00
|
|
|
uint shdr_pos, float x1, float x2, float y1, float y2, const char golden, const char dir)
|
2016-10-14 01:38:04 +00:00
|
|
|
{
|
|
|
|
float ofs;
|
|
|
|
float w = x2 - x1;
|
|
|
|
float h = y2 - y1;
|
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
immBegin(GPU_PRIM_LINES, 6);
|
2017-04-26 12:17:46 +02:00
|
|
|
|
2016-10-14 01:38:04 +00:00
|
|
|
if (w > h) {
|
|
|
|
if (golden) {
|
|
|
|
ofs = w * (1.0f - (1.0f / 1.61803399f));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ofs = h * (h / w);
|
|
|
|
}
|
2019-03-26 21:16:47 +11:00
|
|
|
if (dir == 'B') {
|
|
|
|
SWAP(float, y1, y2);
|
|
|
|
}
|
2016-10-14 01:38:04 +00:00
|
|
|
|
Reworked version of dashed line shader.
Using geometry shader allows us to get rid of the 'line origin' extra
vertex attribute, which means dashed shader no longer requires fiddling
with those vertex attributes definition, and, most importantly, does not
require anymore special drawing code!
As you can see, this makes code much simpler, and much less verbose,
especially in complex cases.
In addition, changed how dashes are handled, to have two 'modes', a
simple one with single color (using default "color" uniform name), and a
more advanced one allowing more complex and multi-color patterns.
Note that since GLSL 1.2 does not support geometry shaders, a hack was
added for now (which gives solid lines, but at least does not make
Blender crash).
2017-05-01 16:21:53 +02:00
|
|
|
immVertex2f(shdr_pos, x1, y1);
|
|
|
|
immVertex2f(shdr_pos, x2, y2);
|
2016-10-14 01:38:04 +00:00
|
|
|
|
Reworked version of dashed line shader.
Using geometry shader allows us to get rid of the 'line origin' extra
vertex attribute, which means dashed shader no longer requires fiddling
with those vertex attributes definition, and, most importantly, does not
require anymore special drawing code!
As you can see, this makes code much simpler, and much less verbose,
especially in complex cases.
In addition, changed how dashes are handled, to have two 'modes', a
simple one with single color (using default "color" uniform name), and a
more advanced one allowing more complex and multi-color patterns.
Note that since GLSL 1.2 does not support geometry shaders, a hack was
added for now (which gives solid lines, but at least does not make
Blender crash).
2017-05-01 16:21:53 +02:00
|
|
|
immVertex2f(shdr_pos, x2, y1);
|
|
|
|
immVertex2f(shdr_pos, x1 + (w - ofs), y2);
|
2016-10-14 01:38:04 +00:00
|
|
|
|
Reworked version of dashed line shader.
Using geometry shader allows us to get rid of the 'line origin' extra
vertex attribute, which means dashed shader no longer requires fiddling
with those vertex attributes definition, and, most importantly, does not
require anymore special drawing code!
As you can see, this makes code much simpler, and much less verbose,
especially in complex cases.
In addition, changed how dashes are handled, to have two 'modes', a
simple one with single color (using default "color" uniform name), and a
more advanced one allowing more complex and multi-color patterns.
Note that since GLSL 1.2 does not support geometry shaders, a hack was
added for now (which gives solid lines, but at least does not make
Blender crash).
2017-05-01 16:21:53 +02:00
|
|
|
immVertex2f(shdr_pos, x1, y2);
|
|
|
|
immVertex2f(shdr_pos, x1 + ofs, y1);
|
2016-10-14 01:38:04 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (golden) {
|
|
|
|
ofs = h * (1.0f - (1.0f / 1.61803399f));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ofs = w * (w / h);
|
|
|
|
}
|
2019-03-26 21:16:47 +11:00
|
|
|
if (dir == 'B') {
|
|
|
|
SWAP(float, x1, x2);
|
|
|
|
}
|
2016-10-14 01:38:04 +00:00
|
|
|
|
Reworked version of dashed line shader.
Using geometry shader allows us to get rid of the 'line origin' extra
vertex attribute, which means dashed shader no longer requires fiddling
with those vertex attributes definition, and, most importantly, does not
require anymore special drawing code!
As you can see, this makes code much simpler, and much less verbose,
especially in complex cases.
In addition, changed how dashes are handled, to have two 'modes', a
simple one with single color (using default "color" uniform name), and a
more advanced one allowing more complex and multi-color patterns.
Note that since GLSL 1.2 does not support geometry shaders, a hack was
added for now (which gives solid lines, but at least does not make
Blender crash).
2017-05-01 16:21:53 +02:00
|
|
|
immVertex2f(shdr_pos, x1, y1);
|
|
|
|
immVertex2f(shdr_pos, x2, y2);
|
2016-10-14 01:38:04 +00:00
|
|
|
|
Reworked version of dashed line shader.
Using geometry shader allows us to get rid of the 'line origin' extra
vertex attribute, which means dashed shader no longer requires fiddling
with those vertex attributes definition, and, most importantly, does not
require anymore special drawing code!
As you can see, this makes code much simpler, and much less verbose,
especially in complex cases.
In addition, changed how dashes are handled, to have two 'modes', a
simple one with single color (using default "color" uniform name), and a
more advanced one allowing more complex and multi-color patterns.
Note that since GLSL 1.2 does not support geometry shaders, a hack was
added for now (which gives solid lines, but at least does not make
Blender crash).
2017-05-01 16:21:53 +02:00
|
|
|
immVertex2f(shdr_pos, x2, y1);
|
|
|
|
immVertex2f(shdr_pos, x1, y1 + ofs);
|
2016-10-14 01:38:04 +00:00
|
|
|
|
Reworked version of dashed line shader.
Using geometry shader allows us to get rid of the 'line origin' extra
vertex attribute, which means dashed shader no longer requires fiddling
with those vertex attributes definition, and, most importantly, does not
require anymore special drawing code!
As you can see, this makes code much simpler, and much less verbose,
especially in complex cases.
In addition, changed how dashes are handled, to have two 'modes', a
simple one with single color (using default "color" uniform name), and a
more advanced one allowing more complex and multi-color patterns.
Note that since GLSL 1.2 does not support geometry shaders, a hack was
added for now (which gives solid lines, but at least does not make
Blender crash).
2017-05-01 16:21:53 +02:00
|
|
|
immVertex2f(shdr_pos, x1, y2);
|
|
|
|
immVertex2f(shdr_pos, x2, y1 + (h - ofs));
|
2016-10-14 01:38:04 +00:00
|
|
|
}
|
2017-04-26 12:17:46 +02:00
|
|
|
|
2016-10-14 01:38:04 +00:00
|
|
|
immEnd();
|
|
|
|
}
|
|
|
|
|
2018-04-06 12:07:27 +02:00
|
|
|
static void drawviewborder(Scene *scene, Depsgraph *depsgraph, ARegion *ar, View3D *v3d)
|
2016-10-14 01:38:04 +00:00
|
|
|
{
|
|
|
|
float x1, x2, y1, y2;
|
|
|
|
float x1i, x2i, y1i, y2i;
|
|
|
|
|
|
|
|
rctf viewborder;
|
|
|
|
Camera *ca = NULL;
|
|
|
|
RegionView3D *rv3d = ar->regiondata;
|
|
|
|
|
2019-03-26 21:16:47 +11:00
|
|
|
if (v3d->camera == NULL) {
|
2016-10-14 01:38:04 +00:00
|
|
|
return;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
|
|
|
if (v3d->camera->type == OB_CAMERA) {
|
2016-10-14 01:38:04 +00:00
|
|
|
ca = v3d->camera->data;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2011-09-11 04:31:09 +00:00
|
|
|
|
2018-01-18 15:58:02 +01:00
|
|
|
ED_view3d_calc_camera_border(scene, depsgraph, ar, v3d, rv3d, &viewborder, false);
|
2016-10-14 01:38:04 +00:00
|
|
|
/* the offsets */
|
|
|
|
x1 = viewborder.xmin;
|
|
|
|
y1 = viewborder.ymin;
|
|
|
|
x2 = viewborder.xmax;
|
|
|
|
y2 = viewborder.ymax;
|
2012-12-09 10:48:18 +00:00
|
|
|
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_line_width(1.0f);
|
2016-10-14 01:38:04 +00:00
|
|
|
|
|
|
|
/* apply offsets so the real 3D camera shows through */
|
|
|
|
|
|
|
|
/* note: quite un-scientific but without this bit extra
|
|
|
|
* 0.0001 on the lower left the 2D border sometimes
|
|
|
|
* obscures the 3D camera border */
|
|
|
|
/* note: with VIEW3D_CAMERA_BORDER_HACK defined this error isn't noticeable
|
|
|
|
* but keep it here in case we need to remove the workaround */
|
|
|
|
x1i = (int)(x1 - 1.0001f);
|
|
|
|
y1i = (int)(y1 - 1.0001f);
|
|
|
|
x2i = (int)(x2 + (1.0f - 0.0001f));
|
|
|
|
y2i = (int)(y2 + (1.0f - 0.0001f));
|
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
Reworked version of dashed line shader.
Using geometry shader allows us to get rid of the 'line origin' extra
vertex attribute, which means dashed shader no longer requires fiddling
with those vertex attributes definition, and, most importantly, does not
require anymore special drawing code!
As you can see, this makes code much simpler, and much less verbose,
especially in complex cases.
In addition, changed how dashes are handled, to have two 'modes', a
simple one with single color (using default "color" uniform name), and a
more advanced one allowing more complex and multi-color patterns.
Note that since GLSL 1.2 does not support geometry shaders, a hack was
added for now (which gives solid lines, but at least does not make
Blender crash).
2017-05-01 16:21:53 +02:00
|
|
|
|
2017-04-26 12:17:46 +02:00
|
|
|
/* First, solid lines. */
|
|
|
|
{
|
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
2016-10-14 01:38:04 +00:00
|
|
|
|
2017-04-26 12:17:46 +02:00
|
|
|
/* passepartout, specified in camera edit buttons */
|
|
|
|
if (ca && (ca->flag & CAM_SHOWPASSEPARTOUT) && ca->passepartalpha > 0.000001f) {
|
|
|
|
const float winx = (ar->winx + 1);
|
|
|
|
const float winy = (ar->winy + 1);
|
2016-10-14 01:38:04 +00:00
|
|
|
|
2017-04-26 12:17:46 +02:00
|
|
|
float alpha = 1.0f;
|
2016-10-14 01:38:04 +00:00
|
|
|
|
2017-04-26 12:17:46 +02:00
|
|
|
if (ca->passepartalpha != 1.0f) {
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
|
|
|
|
GPU_blend(true);
|
2017-04-26 12:17:46 +02:00
|
|
|
alpha = ca->passepartalpha;
|
|
|
|
}
|
2016-10-14 01:38:04 +00:00
|
|
|
|
2017-04-26 12:17:46 +02:00
|
|
|
immUniformColor4f(0.0f, 0.0f, 0.0f, alpha);
|
2016-10-14 01:38:04 +00:00
|
|
|
|
2019-03-26 21:16:47 +11:00
|
|
|
if (x1i > 0.0f) {
|
Reworked version of dashed line shader.
Using geometry shader allows us to get rid of the 'line origin' extra
vertex attribute, which means dashed shader no longer requires fiddling
with those vertex attributes definition, and, most importantly, does not
require anymore special drawing code!
As you can see, this makes code much simpler, and much less verbose,
especially in complex cases.
In addition, changed how dashes are handled, to have two 'modes', a
simple one with single color (using default "color" uniform name), and a
more advanced one allowing more complex and multi-color patterns.
Note that since GLSL 1.2 does not support geometry shaders, a hack was
added for now (which gives solid lines, but at least does not make
Blender crash).
2017-05-01 16:21:53 +02:00
|
|
|
immRectf(shdr_pos, 0.0f, winy, x1i, 0.0f);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
|
|
|
if (x2i < winx) {
|
Reworked version of dashed line shader.
Using geometry shader allows us to get rid of the 'line origin' extra
vertex attribute, which means dashed shader no longer requires fiddling
with those vertex attributes definition, and, most importantly, does not
require anymore special drawing code!
As you can see, this makes code much simpler, and much less verbose,
especially in complex cases.
In addition, changed how dashes are handled, to have two 'modes', a
simple one with single color (using default "color" uniform name), and a
more advanced one allowing more complex and multi-color patterns.
Note that since GLSL 1.2 does not support geometry shaders, a hack was
added for now (which gives solid lines, but at least does not make
Blender crash).
2017-05-01 16:21:53 +02:00
|
|
|
immRectf(shdr_pos, x2i, winy, winx, 0.0f);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
|
|
|
if (y2i < winy) {
|
Reworked version of dashed line shader.
Using geometry shader allows us to get rid of the 'line origin' extra
vertex attribute, which means dashed shader no longer requires fiddling
with those vertex attributes definition, and, most importantly, does not
require anymore special drawing code!
As you can see, this makes code much simpler, and much less verbose,
especially in complex cases.
In addition, changed how dashes are handled, to have two 'modes', a
simple one with single color (using default "color" uniform name), and a
more advanced one allowing more complex and multi-color patterns.
Note that since GLSL 1.2 does not support geometry shaders, a hack was
added for now (which gives solid lines, but at least does not make
Blender crash).
2017-05-01 16:21:53 +02:00
|
|
|
immRectf(shdr_pos, x1i, winy, x2i, y2i);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
|
|
|
if (y2i > 0.0f) {
|
Reworked version of dashed line shader.
Using geometry shader allows us to get rid of the 'line origin' extra
vertex attribute, which means dashed shader no longer requires fiddling
with those vertex attributes definition, and, most importantly, does not
require anymore special drawing code!
As you can see, this makes code much simpler, and much less verbose,
especially in complex cases.
In addition, changed how dashes are handled, to have two 'modes', a
simple one with single color (using default "color" uniform name), and a
more advanced one allowing more complex and multi-color patterns.
Note that since GLSL 1.2 does not support geometry shaders, a hack was
added for now (which gives solid lines, but at least does not make
Blender crash).
2017-05-01 16:21:53 +02:00
|
|
|
immRectf(shdr_pos, x1i, y1i, x2i, 0.0f);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2016-10-14 01:38:04 +00:00
|
|
|
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_blend(false);
|
2017-04-26 12:17:46 +02:00
|
|
|
}
|
2016-10-14 01:38:04 +00:00
|
|
|
|
2017-04-26 12:17:46 +02:00
|
|
|
immUniformThemeColor(TH_BACK);
|
2017-09-26 15:21:01 +10:00
|
|
|
imm_draw_box_wire_2d(shdr_pos, x1i, y1i, x2i, y2i);
|
2016-10-14 01:38:04 +00:00
|
|
|
|
|
|
|
#ifdef VIEW3D_CAMERA_BORDER_HACK
|
2017-04-26 12:17:46 +02:00
|
|
|
if (view3d_camera_border_hack_test == true) {
|
|
|
|
immUniformColor3ubv(view3d_camera_border_hack_col);
|
2017-09-26 15:21:01 +10:00
|
|
|
imm_draw_box_wire_2d(shdr_pos, x1i + 1, y1i + 1, x2i - 1, y2i - 1);
|
2017-04-26 12:17:46 +02:00
|
|
|
view3d_camera_border_hack_test = false;
|
|
|
|
}
|
2016-10-14 01:38:04 +00:00
|
|
|
#endif
|
|
|
|
|
2017-04-26 12:17:46 +02:00
|
|
|
immUnbindProgram();
|
2016-10-14 01:38:04 +00:00
|
|
|
}
|
|
|
|
|
2018-12-14 10:18:01 +11:00
|
|
|
/* When overlays are disabled, only show camera outline & passepartout. */
|
2019-03-05 15:09:25 +11:00
|
|
|
if (v3d->flag2 & V3D_HIDE_OVERLAYS) {
|
2018-12-14 10:18:01 +11:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-04-26 12:17:46 +02:00
|
|
|
/* And now, the dashed lines! */
|
2017-07-13 16:44:02 +02:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
|
2017-04-26 12:17:46 +02:00
|
|
|
|
2017-06-02 15:12:39 +10:00
|
|
|
{
|
2017-04-26 20:51:17 +02:00
|
|
|
float viewport_size[4];
|
2018-07-02 18:27:05 +02:00
|
|
|
GPU_viewport_size_get_f(viewport_size);
|
2017-04-26 20:51:17 +02:00
|
|
|
immUniform2f("viewport_size", viewport_size[2], viewport_size[3]);
|
|
|
|
|
2018-07-01 08:42:16 +02:00
|
|
|
immUniform1i("colors_len", 0); /* "simple" mode */
|
2017-04-26 12:17:46 +02:00
|
|
|
immUniform1f("dash_width", 6.0f);
|
Reworked version of dashed line shader.
Using geometry shader allows us to get rid of the 'line origin' extra
vertex attribute, which means dashed shader no longer requires fiddling
with those vertex attributes definition, and, most importantly, does not
require anymore special drawing code!
As you can see, this makes code much simpler, and much less verbose,
especially in complex cases.
In addition, changed how dashes are handled, to have two 'modes', a
simple one with single color (using default "color" uniform name), and a
more advanced one allowing more complex and multi-color patterns.
Note that since GLSL 1.2 does not support geometry shaders, a hack was
added for now (which gives solid lines, but at least does not make
Blender crash).
2017-05-01 16:21:53 +02:00
|
|
|
immUniform1f("dash_factor", 0.5f);
|
2017-04-26 12:17:46 +02:00
|
|
|
|
|
|
|
/* outer line not to confuse with object selection */
|
|
|
|
if (v3d->flag2 & V3D_LOCK_CAMERA) {
|
Reworked version of dashed line shader.
Using geometry shader allows us to get rid of the 'line origin' extra
vertex attribute, which means dashed shader no longer requires fiddling
with those vertex attributes definition, and, most importantly, does not
require anymore special drawing code!
As you can see, this makes code much simpler, and much less verbose,
especially in complex cases.
In addition, changed how dashes are handled, to have two 'modes', a
simple one with single color (using default "color" uniform name), and a
more advanced one allowing more complex and multi-color patterns.
Note that since GLSL 1.2 does not support geometry shaders, a hack was
added for now (which gives solid lines, but at least does not make
Blender crash).
2017-05-01 16:21:53 +02:00
|
|
|
immUniformThemeColor(TH_REDALERT);
|
2017-09-26 15:21:01 +10:00
|
|
|
imm_draw_box_wire_2d(shdr_pos, x1i - 1, y1i - 1, x2i + 1, y2i + 1);
|
2017-04-26 12:17:46 +02:00
|
|
|
}
|
2016-10-14 01:38:04 +00:00
|
|
|
|
Reworked version of dashed line shader.
Using geometry shader allows us to get rid of the 'line origin' extra
vertex attribute, which means dashed shader no longer requires fiddling
with those vertex attributes definition, and, most importantly, does not
require anymore special drawing code!
As you can see, this makes code much simpler, and much less verbose,
especially in complex cases.
In addition, changed how dashes are handled, to have two 'modes', a
simple one with single color (using default "color" uniform name), and a
more advanced one allowing more complex and multi-color patterns.
Note that since GLSL 1.2 does not support geometry shaders, a hack was
added for now (which gives solid lines, but at least does not make
Blender crash).
2017-05-01 16:21:53 +02:00
|
|
|
immUniformThemeColor(TH_VIEW_OVERLAY);
|
2017-09-26 15:21:01 +10:00
|
|
|
imm_draw_box_wire_2d(shdr_pos, x1i, y1i, x2i, y2i);
|
2017-06-02 15:12:39 +10:00
|
|
|
}
|
2016-10-14 01:38:04 +00:00
|
|
|
|
2018-12-14 10:18:01 +11:00
|
|
|
/* Render Border. */
|
2017-06-02 15:12:39 +10:00
|
|
|
if (scene->r.mode & R_BORDER) {
|
|
|
|
float x3, y3, x4, y4;
|
2016-10-14 01:38:04 +00:00
|
|
|
|
2017-06-02 15:12:39 +10:00
|
|
|
x3 = floorf(x1 + (scene->r.border.xmin * (x2 - x1))) - 1;
|
|
|
|
y3 = floorf(y1 + (scene->r.border.ymin * (y2 - y1))) - 1;
|
|
|
|
x4 = floorf(x1 + (scene->r.border.xmax * (x2 - x1))) + (U.pixelsize - 1);
|
|
|
|
y4 = floorf(y1 + (scene->r.border.ymax * (y2 - y1))) + (U.pixelsize - 1);
|
2016-10-14 01:38:04 +00:00
|
|
|
|
2017-06-02 15:12:39 +10:00
|
|
|
immUniformColor3f(1.0f, 0.25f, 0.25f);
|
2017-09-26 15:21:01 +10:00
|
|
|
imm_draw_box_wire_2d(shdr_pos, x3, y3, x4, y4);
|
2017-06-02 15:12:39 +10:00
|
|
|
}
|
2016-10-14 01:38:04 +00:00
|
|
|
|
2017-06-02 15:12:39 +10:00
|
|
|
/* safety border */
|
|
|
|
if (ca) {
|
|
|
|
immUniformThemeColorBlend(TH_VIEW_OVERLAY, TH_BACK, 0.25f);
|
2016-10-14 01:38:04 +00:00
|
|
|
|
2017-06-02 15:12:39 +10:00
|
|
|
if (ca->dtx & CAM_DTX_CENTER) {
|
|
|
|
float x3, y3;
|
2016-10-14 01:38:04 +00:00
|
|
|
|
2017-06-02 15:12:39 +10:00
|
|
|
x3 = x1 + 0.5f * (x2 - x1);
|
|
|
|
y3 = y1 + 0.5f * (y2 - y1);
|
2016-10-14 01:38:04 +00:00
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
immBegin(GPU_PRIM_LINES, 4);
|
2016-10-14 01:38:04 +00:00
|
|
|
|
2017-06-02 15:12:39 +10:00
|
|
|
immVertex2f(shdr_pos, x1, y3);
|
|
|
|
immVertex2f(shdr_pos, x2, y3);
|
2016-10-14 01:38:04 +00:00
|
|
|
|
2017-06-02 15:12:39 +10:00
|
|
|
immVertex2f(shdr_pos, x3, y1);
|
|
|
|
immVertex2f(shdr_pos, x3, y2);
|
2016-10-14 01:38:04 +00:00
|
|
|
|
2017-06-02 15:12:39 +10:00
|
|
|
immEnd();
|
|
|
|
}
|
2016-10-14 01:38:04 +00:00
|
|
|
|
2017-06-02 15:12:39 +10:00
|
|
|
if (ca->dtx & CAM_DTX_CENTER_DIAG) {
|
2018-07-18 00:12:21 +02:00
|
|
|
immBegin(GPU_PRIM_LINES, 4);
|
2016-10-14 01:38:04 +00:00
|
|
|
|
2017-06-02 15:12:39 +10:00
|
|
|
immVertex2f(shdr_pos, x1, y1);
|
|
|
|
immVertex2f(shdr_pos, x2, y2);
|
2016-10-14 01:38:04 +00:00
|
|
|
|
2017-06-02 15:12:39 +10:00
|
|
|
immVertex2f(shdr_pos, x1, y2);
|
|
|
|
immVertex2f(shdr_pos, x2, y1);
|
2016-10-14 01:38:04 +00:00
|
|
|
|
2017-06-02 15:12:39 +10:00
|
|
|
immEnd();
|
|
|
|
}
|
2016-10-14 01:38:04 +00:00
|
|
|
|
2017-06-02 15:12:39 +10:00
|
|
|
if (ca->dtx & CAM_DTX_THIRDS) {
|
|
|
|
drawviewborder_grid3(shdr_pos, x1, x2, y1, y2, 1.0f / 3.0f);
|
|
|
|
}
|
2016-10-14 01:38:04 +00:00
|
|
|
|
2017-06-02 15:12:39 +10:00
|
|
|
if (ca->dtx & CAM_DTX_GOLDEN) {
|
|
|
|
drawviewborder_grid3(shdr_pos, x1, x2, y1, y2, 1.0f - (1.0f / 1.61803399f));
|
|
|
|
}
|
2016-10-14 01:38:04 +00:00
|
|
|
|
2017-06-02 15:12:39 +10:00
|
|
|
if (ca->dtx & CAM_DTX_GOLDEN_TRI_A) {
|
|
|
|
drawviewborder_triangle(shdr_pos, x1, x2, y1, y2, 0, 'A');
|
|
|
|
}
|
2016-10-14 01:38:04 +00:00
|
|
|
|
2017-06-02 15:12:39 +10:00
|
|
|
if (ca->dtx & CAM_DTX_GOLDEN_TRI_B) {
|
|
|
|
drawviewborder_triangle(shdr_pos, x1, x2, y1, y2, 0, 'B');
|
|
|
|
}
|
2016-10-14 01:38:04 +00:00
|
|
|
|
2017-06-02 15:12:39 +10:00
|
|
|
if (ca->dtx & CAM_DTX_HARMONY_TRI_A) {
|
|
|
|
drawviewborder_triangle(shdr_pos, x1, x2, y1, y2, 1, 'A');
|
|
|
|
}
|
2016-10-14 01:38:04 +00:00
|
|
|
|
2017-06-02 15:12:39 +10:00
|
|
|
if (ca->dtx & CAM_DTX_HARMONY_TRI_B) {
|
|
|
|
drawviewborder_triangle(shdr_pos, x1, x2, y1, y2, 1, 'B');
|
|
|
|
}
|
2016-10-14 01:38:04 +00:00
|
|
|
|
2017-06-02 15:12:39 +10:00
|
|
|
if (ca->flag & CAM_SHOW_SAFE_MARGINS) {
|
|
|
|
UI_draw_safe_areas(
|
|
|
|
shdr_pos, x1, x2, y1, y2,
|
|
|
|
scene->safe_areas.title, scene->safe_areas.action);
|
2017-04-26 12:17:46 +02:00
|
|
|
|
2017-06-02 15:12:39 +10:00
|
|
|
if (ca->flag & CAM_SHOW_SAFE_CENTER) {
|
|
|
|
UI_draw_safe_areas(
|
|
|
|
shdr_pos, x1, x2, y1, y2,
|
|
|
|
scene->safe_areas.title_center, scene->safe_areas.action_center);
|
2016-10-14 01:38:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ca->flag & CAM_SHOWSENSOR) {
|
|
|
|
/* determine sensor fit, and get sensor x/y, for auto fit we
|
|
|
|
* assume and square sensor and only use sensor_x */
|
|
|
|
float sizex = scene->r.xsch * scene->r.xasp;
|
|
|
|
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 */
|
Reworked version of dashed line shader.
Using geometry shader allows us to get rid of the 'line origin' extra
vertex attribute, which means dashed shader no longer requires fiddling
with those vertex attributes definition, and, most importantly, does not
require anymore special drawing code!
As you can see, this makes code much simpler, and much less verbose,
especially in complex cases.
In addition, changed how dashes are handled, to have two 'modes', a
simple one with single color (using default "color" uniform name), and a
more advanced one allowing more complex and multi-color patterns.
Note that since GLSL 1.2 does not support geometry shaders, a hack was
added for now (which gives solid lines, but at least does not make
Blender crash).
2017-05-01 16:21:53 +02:00
|
|
|
immUniformThemeColorShade(TH_VIEW_OVERLAY, 100);
|
2011-07-30 05:23:10 +00:00
|
|
|
|
2017-04-26 12:17:46 +02:00
|
|
|
/* TODO Was using UI_draw_roundbox_4fv(false, rect.xmin, rect.ymin, rect.xmax, rect.ymax, 2.0f, color).
|
|
|
|
* We'll probably need a new imm_draw_line_roundbox_dashed dor that - though in practice the
|
|
|
|
* 2.0f round corner effect was nearly not visible anyway... */
|
2017-09-26 15:21:01 +10:00
|
|
|
imm_draw_box_wire_2d(shdr_pos, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
|
2016-10-14 01:38:04 +00:00
|
|
|
}
|
2017-04-26 12:17:46 +02:00
|
|
|
}
|
2016-10-14 01:38:04 +00:00
|
|
|
|
2017-06-02 15:12:39 +10:00
|
|
|
immUnbindProgram();
|
|
|
|
/* end dashed lines */
|
|
|
|
|
2016-10-14 01:38:04 +00:00
|
|
|
/* camera name - draw in highlighted text color */
|
2018-12-14 10:18:01 +11:00
|
|
|
if (ca && ((v3d->overlay.flag & V3D_OVERLAY_HIDE_TEXT) == 0) && (ca->flag & CAM_SHOWNAME)) {
|
2017-02-05 00:54:21 -05:00
|
|
|
UI_FontThemeColor(BLF_default(), TH_TEXT_HI);
|
2017-06-02 15:12:39 +10:00
|
|
|
BLF_draw_default(
|
|
|
|
x1i, y1i - (0.7f * U.widget_unit), 0.0f,
|
|
|
|
v3d->camera->id.name + 2, sizeof(v3d->camera->id.name) - 2);
|
2016-10-14 01:38:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-16 17:28:12 +02:00
|
|
|
static void drawrenderborder(ARegion *ar, View3D *v3d)
|
2016-10-14 01:24:27 +00:00
|
|
|
{
|
|
|
|
/* use the same program for everything */
|
2018-07-18 00:12:21 +02:00
|
|
|
uint shdr_pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
2016-10-14 01:24:27 +00:00
|
|
|
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_line_width(1.0f);
|
2016-10-14 01:24:27 +00:00
|
|
|
|
2017-07-13 16:44:02 +02:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
|
2016-10-14 01:24:27 +00:00
|
|
|
|
2017-04-26 20:51:17 +02:00
|
|
|
float viewport_size[4];
|
2018-07-02 18:27:05 +02:00
|
|
|
GPU_viewport_size_get_f(viewport_size);
|
2017-04-26 20:51:17 +02:00
|
|
|
immUniform2f("viewport_size", viewport_size[2], viewport_size[3]);
|
2017-04-26 13:02:13 +02:00
|
|
|
|
2018-07-01 08:42:16 +02:00
|
|
|
immUniform1i("colors_len", 0); /* "simple" mode */
|
Reworked version of dashed line shader.
Using geometry shader allows us to get rid of the 'line origin' extra
vertex attribute, which means dashed shader no longer requires fiddling
with those vertex attributes definition, and, most importantly, does not
require anymore special drawing code!
As you can see, this makes code much simpler, and much less verbose,
especially in complex cases.
In addition, changed how dashes are handled, to have two 'modes', a
simple one with single color (using default "color" uniform name), and a
more advanced one allowing more complex and multi-color patterns.
Note that since GLSL 1.2 does not support geometry shaders, a hack was
added for now (which gives solid lines, but at least does not make
Blender crash).
2017-05-01 16:21:53 +02:00
|
|
|
immUniform4f("color", 1.0f, 0.25f, 0.25f, 1.0f);
|
2017-04-26 13:02:13 +02:00
|
|
|
immUniform1f("dash_width", 6.0f);
|
Reworked version of dashed line shader.
Using geometry shader allows us to get rid of the 'line origin' extra
vertex attribute, which means dashed shader no longer requires fiddling
with those vertex attributes definition, and, most importantly, does not
require anymore special drawing code!
As you can see, this makes code much simpler, and much less verbose,
especially in complex cases.
In addition, changed how dashes are handled, to have two 'modes', a
simple one with single color (using default "color" uniform name), and a
more advanced one allowing more complex and multi-color patterns.
Note that since GLSL 1.2 does not support geometry shaders, a hack was
added for now (which gives solid lines, but at least does not make
Blender crash).
2017-05-01 16:21:53 +02:00
|
|
|
immUniform1f("dash_factor", 0.5f);
|
2017-04-26 13:02:13 +02:00
|
|
|
|
2017-09-26 15:21:01 +10:00
|
|
|
imm_draw_box_wire_2d(shdr_pos,
|
Reworked version of dashed line shader.
Using geometry shader allows us to get rid of the 'line origin' extra
vertex attribute, which means dashed shader no longer requires fiddling
with those vertex attributes definition, and, most importantly, does not
require anymore special drawing code!
As you can see, this makes code much simpler, and much less verbose,
especially in complex cases.
In addition, changed how dashes are handled, to have two 'modes', a
simple one with single color (using default "color" uniform name), and a
more advanced one allowing more complex and multi-color patterns.
Note that since GLSL 1.2 does not support geometry shaders, a hack was
added for now (which gives solid lines, but at least does not make
Blender crash).
2017-05-01 16:21:53 +02:00
|
|
|
v3d->render_border.xmin * ar->winx, v3d->render_border.ymin * ar->winy,
|
|
|
|
v3d->render_border.xmax * ar->winx, v3d->render_border.ymax * ar->winy);
|
2016-10-14 01:24:27 +00:00
|
|
|
|
|
|
|
immUnbindProgram();
|
|
|
|
}
|
|
|
|
|
2017-04-27 02:36:56 +10:00
|
|
|
void ED_view3d_draw_depth(
|
2018-04-06 12:07:27 +02:00
|
|
|
Depsgraph *depsgraph,
|
2017-05-03 00:05:57 +10:00
|
|
|
ARegion *ar, View3D *v3d, bool alphaoverride)
|
2017-04-27 01:01:20 +10:00
|
|
|
{
|
2017-08-25 20:45:16 +10:00
|
|
|
struct bThemeState theme_state;
|
2018-04-06 12:07:27 +02:00
|
|
|
Scene *scene = DEG_get_evaluated_scene(depsgraph);
|
2017-04-27 01:01:20 +10:00
|
|
|
RegionView3D *rv3d = ar->regiondata;
|
|
|
|
|
|
|
|
short flag = v3d->flag;
|
|
|
|
float glalphaclip = U.glalphaclip;
|
|
|
|
int obcenter_dia = U.obcenter_dia;
|
|
|
|
/* temp set drawtype to solid */
|
|
|
|
/* Setting these temporarily is not nice */
|
|
|
|
v3d->flag &= ~V3D_SELECT_OUTLINE;
|
2019-01-15 23:24:20 +11:00
|
|
|
|
|
|
|
/* not that nice but means we wont zoom into billboards */
|
|
|
|
U.glalphaclip = alphaoverride ? 0.5f : glalphaclip;
|
|
|
|
|
2017-04-27 01:01:20 +10:00
|
|
|
U.obcenter_dia = 0;
|
|
|
|
|
2017-08-25 20:45:16 +10:00
|
|
|
/* Tools may request depth outside of regular drawing code. */
|
|
|
|
UI_Theme_Store(&theme_state);
|
|
|
|
UI_SetTheme(SPACE_VIEW3D, RGN_TYPE_WINDOW);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2018-04-06 12:07:27 +02:00
|
|
|
ED_view3d_draw_setup_view(NULL, depsgraph, scene, ar, v3d, NULL, NULL, NULL);
|
2017-04-27 01:01:20 +10:00
|
|
|
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_clear(GPU_DEPTH_BIT);
|
2017-04-27 01:01:20 +10:00
|
|
|
|
|
|
|
if (rv3d->rflag & RV3D_CLIPPING) {
|
|
|
|
ED_view3d_clipping_set(rv3d);
|
|
|
|
}
|
|
|
|
/* get surface depth without bias */
|
|
|
|
rv3d->rflag |= RV3D_ZOFFSET_DISABLED;
|
|
|
|
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_depth_test(true);
|
2017-04-27 01:01:20 +10:00
|
|
|
|
2019-03-26 12:19:00 -03:00
|
|
|
GPUViewport *viewport = WM_draw_region_get_viewport(ar, 0);
|
|
|
|
DRW_draw_depth_loop(depsgraph, ar, v3d, viewport);
|
2017-04-27 01:01:20 +10:00
|
|
|
|
|
|
|
if (rv3d->rflag & RV3D_CLIPPING) {
|
|
|
|
ED_view3d_clipping_disable();
|
|
|
|
}
|
|
|
|
rv3d->rflag &= ~RV3D_ZOFFSET_DISABLED;
|
|
|
|
|
2018-07-03 19:22:00 +02:00
|
|
|
/* Reset default for UI */
|
|
|
|
GPU_depth_test(false);
|
2017-04-27 01:01:20 +10:00
|
|
|
|
|
|
|
U.glalphaclip = glalphaclip;
|
|
|
|
v3d->flag = flag;
|
|
|
|
U.obcenter_dia = obcenter_dia;
|
2017-08-25 20:45:16 +10:00
|
|
|
|
|
|
|
UI_Theme_Restore(&theme_state);
|
2017-04-27 01:01:20 +10:00
|
|
|
}
|
|
|
|
|
2016-10-06 19:55:06 +00:00
|
|
|
/* ******************** other elements ***************** */
|
|
|
|
|
|
|
|
/** could move this elsewhere, but tied into #ED_view3d_grid_scale */
|
|
|
|
float ED_scene_grid_scale(Scene *scene, const char **grid_unit)
|
|
|
|
{
|
|
|
|
/* apply units */
|
|
|
|
if (scene->unit.system) {
|
|
|
|
const void *usys;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
bUnit_GetSystem(scene->unit.system, B_UNIT_LENGTH, &usys, &len);
|
|
|
|
|
|
|
|
if (usys) {
|
|
|
|
int i = bUnit_GetBaseUnit(usys);
|
2019-03-26 21:16:47 +11:00
|
|
|
if (grid_unit) {
|
2016-10-06 19:55:06 +00:00
|
|
|
*grid_unit = bUnit_GetNameDisplay(usys, i);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2016-10-06 19:55:06 +00:00
|
|
|
return (float)bUnit_GetScaler(usys, i) / scene->unit.scale_length;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1.0f;
|
|
|
|
}
|
|
|
|
|
|
|
|
float ED_view3d_grid_scale(Scene *scene, View3D *v3d, const char **grid_unit)
|
|
|
|
{
|
|
|
|
return v3d->grid * ED_scene_grid_scale(scene, grid_unit);
|
|
|
|
}
|
|
|
|
|
2018-12-31 13:45:20 -02:00
|
|
|
/* Simulates the grid scale that is actually viewed.
|
|
|
|
* The actual code is seen in `object_grid_frag.glsl` (see `grid_res`).
|
|
|
|
* Currently the simulation is only done when RV3D_VIEW_IS_AXIS. */
|
2018-10-30 14:21:50 -03:00
|
|
|
float ED_view3d_grid_view_scale(
|
|
|
|
Scene *scene, View3D *v3d, RegionView3D *rv3d, const char **grid_unit)
|
|
|
|
{
|
|
|
|
float grid_scale = ED_view3d_grid_scale(scene, v3d, grid_unit);
|
|
|
|
if (!rv3d->is_persp && RV3D_VIEW_IS_AXIS(rv3d->view)) {
|
|
|
|
/* Decrease the distance between grid snap points depending on zoom. */
|
|
|
|
float grid_subdiv = v3d->gridsubdiv;
|
|
|
|
if (grid_subdiv > 1) {
|
2018-12-21 16:56:55 -02:00
|
|
|
/* Allow 3 more subdivisions (see OBJECT_engine_init). */
|
|
|
|
grid_scale /= powf(grid_subdiv, 3);
|
|
|
|
|
2019-02-26 11:11:04 -03:00
|
|
|
/* `3.0` was a value obtained by trial and error in order to get
|
|
|
|
* a nice snap distance.*/
|
|
|
|
float grid_res = 3.0 * (rv3d->dist / v3d->lens);
|
|
|
|
float lvl = (logf(grid_res / grid_scale) / logf(grid_subdiv));
|
2018-12-21 16:56:55 -02:00
|
|
|
|
|
|
|
CLAMP_MIN(lvl, 0.0f);
|
|
|
|
|
|
|
|
grid_scale *= pow(grid_subdiv, (int)lvl);
|
2018-10-30 14:21:50 -03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-06 13:04:34 +01:00
|
|
|
return grid_scale;
|
2018-10-30 14:21:50 -03:00
|
|
|
}
|
|
|
|
|
2018-02-09 22:14:17 +11:00
|
|
|
static void draw_view_axis(RegionView3D *rv3d, const rcti *rect)
|
2016-12-05 02:50:28 -05:00
|
|
|
{
|
|
|
|
const float k = U.rvisize * U.pixelsize; /* axis size */
|
2019-01-15 23:24:20 +11:00
|
|
|
/* axis alpha offset (rvibright has range 0-10) */
|
|
|
|
const int bright = - 20 * (10 - U.rvibright);
|
2016-12-05 02:50:28 -05:00
|
|
|
|
2018-06-11 10:02:29 +02:00
|
|
|
/* Axis center in screen coordinates.
|
|
|
|
*
|
|
|
|
* - Unit size offset so small text doesn't draw outside the screen
|
|
|
|
* - Extra X offset because of the panel expander.
|
|
|
|
*/
|
|
|
|
const float startx = rect->xmax - (k + UI_UNIT_X * 1.5);
|
|
|
|
const float starty = rect->ymax - (k + UI_UNIT_Y);
|
2016-12-05 02:50:28 -05:00
|
|
|
|
|
|
|
float axis_pos[3][2];
|
2019-03-01 23:43:34 +11:00
|
|
|
uchar axis_col[3][4];
|
2016-12-05 02:50:28 -05:00
|
|
|
|
|
|
|
int axis_order[3] = {0, 1, 2};
|
|
|
|
axis_sort_v3(rv3d->viewinv[2], axis_order);
|
|
|
|
|
|
|
|
for (int axis_i = 0; axis_i < 3; axis_i++) {
|
|
|
|
int i = axis_order[axis_i];
|
|
|
|
|
|
|
|
/* get position of each axis tip on screen */
|
|
|
|
float vec[3] = { 0.0f };
|
|
|
|
vec[i] = 1.0f;
|
|
|
|
mul_qt_v3(rv3d->viewquat, vec);
|
|
|
|
axis_pos[i][0] = startx + vec[0] * k;
|
|
|
|
axis_pos[i][1] = starty + vec[1] * k;
|
|
|
|
|
|
|
|
/* get color of each axis */
|
|
|
|
UI_GetThemeColorShade3ubv(TH_AXIS_X + i, bright, axis_col[i]); /* rgb */
|
|
|
|
axis_col[i][3] = 255 * hypotf(vec[0], vec[1]); /* alpha */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* draw axis lines */
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_line_width(2.0f);
|
|
|
|
GPU_line_smooth(true);
|
|
|
|
GPU_blend(true);
|
|
|
|
GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
|
2016-12-05 02:50:28 -05:00
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
GPUVertFormat *format = immVertexFormat();
|
|
|
|
uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
|
|
|
|
uint col = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
|
2016-12-05 02:50:28 -05:00
|
|
|
|
|
|
|
immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
|
2018-07-18 00:12:21 +02:00
|
|
|
immBegin(GPU_PRIM_LINES, 6);
|
2016-12-05 02:50:28 -05:00
|
|
|
|
|
|
|
for (int axis_i = 0; axis_i < 3; axis_i++) {
|
|
|
|
int i = axis_order[axis_i];
|
|
|
|
|
2018-10-09 11:01:50 +11:00
|
|
|
immAttr4ubv(col, axis_col[i]);
|
2016-12-05 02:50:28 -05:00
|
|
|
immVertex2f(pos, startx, starty);
|
2018-10-09 11:01:50 +11:00
|
|
|
immAttr4ubv(col, axis_col[i]);
|
2016-12-05 02:50:28 -05:00
|
|
|
immVertex2fv(pos, axis_pos[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
immEnd();
|
|
|
|
immUnbindProgram();
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_line_smooth(false);
|
2016-12-05 02:50:28 -05:00
|
|
|
|
|
|
|
/* draw axis names */
|
|
|
|
for (int axis_i = 0; axis_i < 3; axis_i++) {
|
|
|
|
int i = axis_order[axis_i];
|
|
|
|
|
|
|
|
const char axis_text[2] = {'x' + i, '\0'};
|
2017-02-05 00:54:21 -05:00
|
|
|
BLF_color4ubv(BLF_default(), axis_col[i]);
|
2016-12-05 02:50:28 -05:00
|
|
|
BLF_draw_default_ascii(axis_pos[i][0] + 2, axis_pos[i][1] + 2, 0.0f, axis_text, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef WITH_INPUT_NDOF
|
|
|
|
/* draw center and axis of rotation for ongoing 3D mouse navigation */
|
2018-12-11 12:34:37 +11:00
|
|
|
static void draw_rotation_guide(const RegionView3D *rv3d)
|
2016-12-05 02:50:28 -05:00
|
|
|
{
|
|
|
|
float o[3]; /* center of rotation */
|
|
|
|
float end[3]; /* endpoints for drawing */
|
|
|
|
|
|
|
|
GLubyte color[4] = {0, 108, 255, 255}; /* bright blue so it matches device LEDs */
|
|
|
|
|
|
|
|
negate_v3_v3(o, rv3d->ofs);
|
|
|
|
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_blend(true);
|
|
|
|
GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
|
2016-12-05 02:50:28 -05:00
|
|
|
glDepthMask(GL_FALSE); /* don't overwrite zbuf */
|
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
GPUVertFormat *format = immVertexFormat();
|
|
|
|
uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
|
|
|
|
uint col = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
|
2016-12-05 02:50:28 -05:00
|
|
|
|
|
|
|
immBindBuiltinProgram(GPU_SHADER_3D_SMOOTH_COLOR);
|
|
|
|
|
|
|
|
if (rv3d->rot_angle != 0.0f) {
|
|
|
|
/* -- draw rotation axis -- */
|
|
|
|
float scaled_axis[3];
|
|
|
|
const float scale = rv3d->dist;
|
|
|
|
mul_v3_v3fl(scaled_axis, rv3d->rot_axis, scale);
|
|
|
|
|
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
immBegin(GPU_PRIM_LINE_STRIP, 3);
|
2016-12-05 02:50:28 -05:00
|
|
|
color[3] = 0; /* more transparent toward the ends */
|
2018-10-09 11:01:50 +11:00
|
|
|
immAttr4ubv(col, color);
|
2016-12-05 02:50:28 -05:00
|
|
|
add_v3_v3v3(end, o, scaled_axis);
|
|
|
|
immVertex3fv(pos, end);
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
color[3] = 0.2f + fabsf(rv3d->rot_angle); /* modulate opacity with angle */
|
|
|
|
/* ^^ neat idea, but angle is frame-rate dependent, so it's usually close to 0.2 */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
color[3] = 127; /* more opaque toward the center */
|
2018-10-09 11:01:50 +11:00
|
|
|
immAttr4ubv(col, color);
|
2016-12-05 02:50:28 -05:00
|
|
|
immVertex3fv(pos, o);
|
|
|
|
|
|
|
|
color[3] = 0;
|
2018-10-09 11:01:50 +11:00
|
|
|
immAttr4ubv(col, color);
|
2016-12-05 02:50:28 -05:00
|
|
|
sub_v3_v3v3(end, o, scaled_axis);
|
|
|
|
immVertex3fv(pos, end);
|
|
|
|
immEnd();
|
2018-06-04 09:39:04 +02:00
|
|
|
|
2016-12-05 02:50:28 -05:00
|
|
|
/* -- draw ring around rotation center -- */
|
|
|
|
{
|
|
|
|
#define ROT_AXIS_DETAIL 13
|
|
|
|
|
|
|
|
const float s = 0.05f * scale;
|
|
|
|
const float step = 2.0f * (float)(M_PI / ROT_AXIS_DETAIL);
|
|
|
|
|
|
|
|
float q[4]; /* rotate ring so it's perpendicular to axis */
|
|
|
|
const int upright = fabsf(rv3d->rot_axis[2]) >= 0.95f;
|
|
|
|
if (!upright) {
|
|
|
|
const float up[3] = {0.0f, 0.0f, 1.0f};
|
|
|
|
float vis_angle, vis_axis[3];
|
|
|
|
|
|
|
|
cross_v3_v3v3(vis_axis, up, rv3d->rot_axis);
|
|
|
|
vis_angle = acosf(dot_v3v3(up, rv3d->rot_axis));
|
|
|
|
axis_angle_to_quat(q, vis_axis, vis_angle);
|
|
|
|
}
|
|
|
|
|
2018-07-18 00:12:21 +02:00
|
|
|
immBegin(GPU_PRIM_LINE_LOOP, ROT_AXIS_DETAIL);
|
2016-12-05 02:50:28 -05:00
|
|
|
color[3] = 63; /* somewhat faint */
|
2018-10-09 11:01:50 +11:00
|
|
|
immAttr4ubv(col, color);
|
2016-12-05 02:50:28 -05:00
|
|
|
float angle = 0.0f;
|
|
|
|
for (int i = 0; i < ROT_AXIS_DETAIL; ++i, angle += step) {
|
|
|
|
float p[3] = {s * cosf(angle), s * sinf(angle), 0.0f};
|
|
|
|
|
|
|
|
if (!upright) {
|
|
|
|
mul_qt_v3(q, p);
|
|
|
|
}
|
|
|
|
|
|
|
|
add_v3_v3(p, o);
|
|
|
|
immVertex3fv(pos, p);
|
|
|
|
}
|
|
|
|
immEnd();
|
|
|
|
|
|
|
|
#undef ROT_AXIS_DETAIL
|
|
|
|
}
|
|
|
|
|
|
|
|
color[3] = 255; /* solid dot */
|
|
|
|
}
|
2019-03-26 21:16:47 +11:00
|
|
|
else {
|
2016-12-05 02:50:28 -05:00
|
|
|
color[3] = 127; /* see-through dot */
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2016-12-05 02:50:28 -05:00
|
|
|
|
2017-02-28 03:09:44 -05:00
|
|
|
immUnbindProgram();
|
|
|
|
|
2016-12-05 02:50:28 -05:00
|
|
|
/* -- draw rotation center -- */
|
2017-02-28 03:09:44 -05:00
|
|
|
immBindBuiltinProgram(GPU_SHADER_3D_POINT_FIXED_SIZE_VARYING_COLOR);
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_point_size(5.0f);
|
2018-07-18 00:12:21 +02:00
|
|
|
immBegin(GPU_PRIM_POINTS, 1);
|
2018-10-09 11:01:50 +11:00
|
|
|
immAttr4ubv(col, color);
|
2016-12-05 02:50:28 -05:00
|
|
|
immVertex3fv(pos, o);
|
|
|
|
immEnd();
|
|
|
|
immUnbindProgram();
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
/* find screen coordinates for rotation center, then draw pretty icon */
|
|
|
|
mul_m4_v3(rv3d->persinv, rot_center);
|
|
|
|
UI_icon_draw(rot_center[0], rot_center[1], ICON_NDOF_TURN);
|
|
|
|
/* ^^ just playing around, does not work */
|
|
|
|
#endif
|
|
|
|
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_blend(false);
|
2016-12-05 02:50:28 -05:00
|
|
|
glDepthMask(GL_TRUE);
|
|
|
|
}
|
|
|
|
#endif /* WITH_INPUT_NDOF */
|
|
|
|
|
2016-10-14 01:38:04 +00:00
|
|
|
/**
|
2018-09-02 18:28:27 +10:00
|
|
|
* Render and camera border
|
|
|
|
*/
|
2016-10-14 01:38:04 +00:00
|
|
|
static void view3d_draw_border(const bContext *C, ARegion *ar)
|
|
|
|
{
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
2018-01-18 15:58:02 +01:00
|
|
|
Depsgraph *depsgraph = CTX_data_depsgraph(C);
|
2016-10-14 01:38:04 +00:00
|
|
|
RegionView3D *rv3d = ar->regiondata;
|
|
|
|
View3D *v3d = CTX_wm_view3d(C);
|
|
|
|
|
|
|
|
if (rv3d->persp == RV3D_CAMOB) {
|
2018-01-18 15:58:02 +01:00
|
|
|
drawviewborder(scene, depsgraph, ar, v3d);
|
2016-10-14 01:38:04 +00:00
|
|
|
}
|
|
|
|
else if (v3d->flag2 & V3D_RENDER_BORDER) {
|
|
|
|
drawrenderborder(ar, v3d);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-28 15:00:27 +11:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Draw Text & Info
|
|
|
|
* \{ */
|
|
|
|
|
2016-10-14 01:38:04 +00:00
|
|
|
/**
|
2019-03-28 15:00:27 +11:00
|
|
|
* Draw Info
|
2018-09-02 18:28:27 +10:00
|
|
|
*/
|
2017-01-10 18:17:29 +01:00
|
|
|
static void view3d_draw_grease_pencil(const bContext *UNUSED(C))
|
2016-10-14 01:38:04 +00:00
|
|
|
{
|
|
|
|
/* TODO viewport */
|
|
|
|
}
|
|
|
|
|
2017-02-14 17:47:11 +01:00
|
|
|
/**
|
2018-09-02 18:28:27 +10:00
|
|
|
* Viewport Name
|
|
|
|
*/
|
2017-02-14 17:47:11 +01:00
|
|
|
static const char *view3d_get_name(View3D *v3d, RegionView3D *rv3d)
|
|
|
|
{
|
|
|
|
const char *name = NULL;
|
|
|
|
|
|
|
|
switch (rv3d->view) {
|
|
|
|
case RV3D_VIEW_FRONT:
|
2019-03-26 21:16:47 +11:00
|
|
|
if (rv3d->persp == RV3D_ORTHO) {
|
|
|
|
name = IFACE_("Front Orthographic");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
name = IFACE_("Front Perspective");
|
|
|
|
}
|
2017-02-14 17:47:11 +01:00
|
|
|
break;
|
|
|
|
case RV3D_VIEW_BACK:
|
2019-03-26 21:16:47 +11:00
|
|
|
if (rv3d->persp == RV3D_ORTHO) {
|
|
|
|
name = IFACE_("Back Orthographic");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
name = IFACE_("Back Perspective");
|
|
|
|
}
|
2017-02-14 17:47:11 +01:00
|
|
|
break;
|
|
|
|
case RV3D_VIEW_TOP:
|
2019-03-26 21:16:47 +11:00
|
|
|
if (rv3d->persp == RV3D_ORTHO) {
|
|
|
|
name = IFACE_("Top Orthographic");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
name = IFACE_("Top Perspective");
|
|
|
|
}
|
2017-02-14 17:47:11 +01:00
|
|
|
break;
|
|
|
|
case RV3D_VIEW_BOTTOM:
|
2019-03-26 21:16:47 +11:00
|
|
|
if (rv3d->persp == RV3D_ORTHO) {
|
|
|
|
name = IFACE_("Bottom Orthographic");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
name = IFACE_("Bottom Perspective");
|
|
|
|
}
|
2017-02-14 17:47:11 +01:00
|
|
|
break;
|
|
|
|
case RV3D_VIEW_RIGHT:
|
2019-03-26 21:16:47 +11:00
|
|
|
if (rv3d->persp == RV3D_ORTHO) {
|
|
|
|
name = IFACE_("Right Orthographic");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
name = IFACE_("Right Perspective");
|
|
|
|
}
|
2017-02-14 17:47:11 +01:00
|
|
|
break;
|
|
|
|
case RV3D_VIEW_LEFT:
|
2019-03-26 21:16:47 +11:00
|
|
|
if (rv3d->persp == RV3D_ORTHO) {
|
|
|
|
name = IFACE_("Left Orthographic");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
name = IFACE_("Left Perspective");
|
|
|
|
}
|
2017-02-14 17:47:11 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
if (rv3d->persp == RV3D_CAMOB) {
|
|
|
|
if ((v3d->camera) && (v3d->camera->type == OB_CAMERA)) {
|
|
|
|
Camera *cam;
|
|
|
|
cam = v3d->camera->data;
|
|
|
|
if (cam->type == CAM_PERSP) {
|
2018-11-03 02:18:22 +01:00
|
|
|
name = IFACE_("Camera Perspective");
|
2017-02-14 17:47:11 +01:00
|
|
|
}
|
|
|
|
else if (cam->type == CAM_ORTHO) {
|
2018-11-03 02:18:22 +01:00
|
|
|
name = IFACE_("Camera Orthographic");
|
2017-02-14 17:47:11 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
BLI_assert(cam->type == CAM_PANO);
|
2018-11-03 02:18:22 +01:00
|
|
|
name = IFACE_("Camera Panoramic");
|
2017-02-14 17:47:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
name = IFACE_("Object as Camera");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2018-11-03 02:18:22 +01:00
|
|
|
name = (rv3d->persp == RV3D_ORTHO) ? IFACE_("User Orthographic") : IFACE_("User Perspective");
|
2017-02-14 17:47:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
2018-10-25 11:47:37 +02:00
|
|
|
static void draw_viewport_name(ARegion *ar, View3D *v3d, int xoffset, int *yoffset)
|
2017-02-14 17:47:11 +01:00
|
|
|
{
|
|
|
|
RegionView3D *rv3d = ar->regiondata;
|
|
|
|
const char *name = view3d_get_name(v3d, rv3d);
|
2018-11-03 03:47:25 +01:00
|
|
|
const int font_id = BLF_default();
|
|
|
|
|
2017-02-14 17:47:11 +01:00
|
|
|
/* increase size for unicode languages (Chinese in utf-8...) */
|
|
|
|
#ifdef WITH_INTERNATIONAL
|
|
|
|
char tmpstr[96];
|
|
|
|
#else
|
|
|
|
char tmpstr[32];
|
|
|
|
#endif
|
|
|
|
|
2018-11-03 03:47:25 +01:00
|
|
|
BLF_enable(font_id, BLF_SHADOW);
|
|
|
|
BLF_shadow(font_id, 5, (const float[4]){0.0f, 0.0f, 0.0f, 1.0f});
|
|
|
|
BLF_shadow_offset(font_id, 1, -1);
|
|
|
|
|
Objects: support for hiding all objects in a collection.
In the outliner there are now icons for it, Ctrl+Click isolates a
single collections.
In the 3D view, Ctrl+H key opens a menu that is more or less the
equivalent of the old layer buttons in the header. Regular Click isolates
the collection, Shift+Click toggle the collection visibility. Pressing
number keys and letters works in this menu, which can help for quickly
selecting a specific collection.
Shortcuts for quick switching by just pressing 1/2/3/.. keys are available
again. The order can be confusing with nested collections, but that seems
unavoidable. The first numbers control the top level collections, and then
sub collections if numbers are left.
Remaining design issues:
* The 3D view menu needs to be improved: support for sub collections,
staying open on shift+click, access from the 3D view header somewhere,
shortcut key display.
* Currently collection hiding just controls per-object hiding, we plan
to separate this state still so alt+H doesn't affect collection hiding.
2018-06-18 19:49:53 +02:00
|
|
|
if (v3d->localvd) {
|
2017-02-14 17:47:11 +01:00
|
|
|
BLI_snprintf(tmpstr, sizeof(tmpstr), IFACE_("%s (Local)"), name);
|
|
|
|
name = tmpstr;
|
|
|
|
}
|
|
|
|
|
|
|
|
UI_FontThemeColor(BLF_default(), TH_TEXT_HI);
|
2018-10-25 11:47:37 +02:00
|
|
|
|
|
|
|
*yoffset -= U.widget_unit;
|
|
|
|
|
2017-02-14 17:47:11 +01:00
|
|
|
#ifdef WITH_INTERNATIONAL
|
2018-10-25 11:47:37 +02:00
|
|
|
BLF_draw_default(xoffset, *yoffset, 0.0f, name, sizeof(tmpstr));
|
2017-02-14 17:47:11 +01:00
|
|
|
#else
|
2018-10-25 11:47:37 +02:00
|
|
|
BLF_draw_default_ascii(xoffset, *yoffset, 0.0f, name, sizeof(tmpstr));
|
2017-02-14 17:47:11 +01:00
|
|
|
#endif
|
2018-11-03 03:47:25 +01:00
|
|
|
|
|
|
|
BLF_disable(font_id, BLF_SHADOW);
|
2017-02-14 17:47:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* draw info beside axes in bottom left-corner:
|
2018-11-13 18:30:44 -02:00
|
|
|
* framenum, collection, object name, bone name (if available), marker name (if available)
|
2017-02-14 17:47:11 +01:00
|
|
|
*/
|
|
|
|
|
2018-11-13 18:30:44 -02:00
|
|
|
static void draw_selected_name(Scene *scene, ViewLayer *view_layer, Object *ob, int xoffset, int *yoffset)
|
2017-02-14 17:47:11 +01:00
|
|
|
{
|
|
|
|
const int cfra = CFRA;
|
|
|
|
const char *msg_pin = " (Pinned)";
|
|
|
|
const char *msg_sep = " : ";
|
|
|
|
|
|
|
|
const int font_id = BLF_default();
|
|
|
|
|
|
|
|
char info[300];
|
|
|
|
char *s = info;
|
|
|
|
|
|
|
|
s += sprintf(s, "(%d)", cfra);
|
|
|
|
|
2018-11-13 18:30:44 -02:00
|
|
|
if ((ob == NULL) || (ob->mode == OB_MODE_OBJECT)) {
|
|
|
|
LayerCollection *layer_collection = view_layer->active_collection;
|
2018-11-13 21:30:10 -02:00
|
|
|
s += sprintf(s, " %s%s", BKE_collection_ui_name_get(layer_collection->collection), (ob == NULL) ? "" : " |");
|
2018-11-13 18:30:44 -02:00
|
|
|
}
|
|
|
|
|
2017-02-14 17:47:11 +01:00
|
|
|
/*
|
|
|
|
* info can contain:
|
|
|
|
* - a frame (7 + 2)
|
2018-11-13 18:30:44 -02:00
|
|
|
* - a collection name (MAX_NAME + 3)
|
2017-02-14 17:47:11 +01:00
|
|
|
* - 3 object names (MAX_NAME)
|
|
|
|
* - 2 BREAD_CRUMB_SEPARATORs (6)
|
|
|
|
* - a SHAPE_KEY_PINNED marker and a trailing '\0' (9+1) - translated, so give some room!
|
|
|
|
* - a marker name (MAX_NAME + 3)
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* get name of marker on current frame (if available) */
|
|
|
|
const char *markern = BKE_scene_find_marker_name(scene, cfra);
|
|
|
|
|
|
|
|
/* check if there is an object */
|
|
|
|
if (ob) {
|
|
|
|
*s++ = ' ';
|
|
|
|
s += BLI_strcpy_rlen(s, ob->id.name + 2);
|
|
|
|
|
|
|
|
/* name(s) to display depends on type of object */
|
|
|
|
if (ob->type == OB_ARMATURE) {
|
|
|
|
bArmature *arm = ob->data;
|
|
|
|
|
|
|
|
/* show name of active bone too (if possible) */
|
|
|
|
if (arm->edbo) {
|
|
|
|
if (arm->act_edbone) {
|
|
|
|
s += BLI_strcpy_rlen(s, msg_sep);
|
|
|
|
s += BLI_strcpy_rlen(s, arm->act_edbone->name);
|
|
|
|
}
|
|
|
|
}
|
2018-04-05 18:20:27 +02:00
|
|
|
else if (ob->mode & OB_MODE_POSE) {
|
2017-02-14 17:47:11 +01:00
|
|
|
if (arm->act_bone) {
|
|
|
|
|
|
|
|
if (arm->act_bone->layer & arm->layer) {
|
|
|
|
s += BLI_strcpy_rlen(s, msg_sep);
|
|
|
|
s += BLI_strcpy_rlen(s, arm->act_bone->name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (ELEM(ob->type, OB_MESH, OB_LATTICE, OB_CURVE)) {
|
|
|
|
/* try to display active bone and active shapekey too (if they exist) */
|
|
|
|
|
2018-04-05 18:20:27 +02:00
|
|
|
if (ob->type == OB_MESH && ob->mode & OB_MODE_WEIGHT_PAINT) {
|
2017-02-14 17:47:11 +01:00
|
|
|
Object *armobj = BKE_object_pose_armature_get(ob);
|
2018-04-05 18:20:27 +02:00
|
|
|
if (armobj && armobj->mode & OB_MODE_POSE) {
|
2017-02-14 17:47:11 +01:00
|
|
|
bArmature *arm = armobj->data;
|
2018-02-09 02:31:09 +11:00
|
|
|
if (arm->act_bone) {
|
|
|
|
if (arm->act_bone->layer & arm->layer) {
|
|
|
|
s += BLI_strcpy_rlen(s, msg_sep);
|
|
|
|
s += BLI_strcpy_rlen(s, arm->act_bone->name);
|
2017-02-14 17:47:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Key *key = BKE_key_from_object(ob);
|
|
|
|
if (key) {
|
|
|
|
KeyBlock *kb = BLI_findlink(&key->block, ob->shapenr - 1);
|
|
|
|
if (kb) {
|
|
|
|
s += BLI_strcpy_rlen(s, msg_sep);
|
|
|
|
s += BLI_strcpy_rlen(s, kb->name);
|
|
|
|
if (ob->shapeflag & OB_SHAPE_LOCK) {
|
|
|
|
s += BLI_strcpy_rlen(s, IFACE_(msg_pin));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* color depends on whether there is a keyframe */
|
2019-01-15 23:24:20 +11:00
|
|
|
if (id_frame_has_keyframe((ID *)ob, /* BKE_scene_frame_get(scene) */ (float)cfra, ANIMFILTER_KEYS_LOCAL)) {
|
2017-02-14 17:47:11 +01:00
|
|
|
UI_FontThemeColor(font_id, TH_TIME_KEYFRAME);
|
2019-01-15 23:24:20 +11:00
|
|
|
}
|
|
|
|
else if (ED_gpencil_has_keyframe_v3d(scene, ob, cfra)) {
|
2017-02-14 17:47:11 +01:00
|
|
|
UI_FontThemeColor(font_id, TH_TIME_GP_KEYFRAME);
|
2019-01-15 23:24:20 +11:00
|
|
|
}
|
|
|
|
else {
|
2017-02-14 17:47:11 +01:00
|
|
|
UI_FontThemeColor(font_id, TH_TEXT_HI);
|
2019-01-15 23:24:20 +11:00
|
|
|
}
|
2017-02-14 17:47:11 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* no object */
|
2019-03-26 21:16:47 +11:00
|
|
|
if (ED_gpencil_has_keyframe_v3d(scene, NULL, cfra)) {
|
2017-02-14 17:47:11 +01:00
|
|
|
UI_FontThemeColor(font_id, TH_TIME_GP_KEYFRAME);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
|
|
|
else {
|
2017-02-14 17:47:11 +01:00
|
|
|
UI_FontThemeColor(font_id, TH_TEXT_HI);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2017-02-14 17:47:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (markern) {
|
|
|
|
s += sprintf(s, " <%s>", markern);
|
|
|
|
}
|
|
|
|
|
2018-11-03 03:47:25 +01:00
|
|
|
BLF_enable(font_id, BLF_SHADOW);
|
|
|
|
BLF_shadow(font_id, 5, (const float[4]){0.0f, 0.0f, 0.0f, 1.0f});
|
|
|
|
BLF_shadow_offset(font_id, 1, -1);
|
|
|
|
|
2018-10-25 11:47:37 +02:00
|
|
|
*yoffset -= U.widget_unit;
|
|
|
|
BLF_draw_default(xoffset, *yoffset, 0.0f, info, sizeof(info));
|
2018-11-03 03:47:25 +01:00
|
|
|
|
|
|
|
BLF_disable(font_id, BLF_SHADOW);
|
2017-02-14 17:47:11 +01:00
|
|
|
}
|
|
|
|
|
2016-10-06 14:14:41 +00:00
|
|
|
/**
|
2018-09-02 18:28:27 +10:00
|
|
|
* Information drawn on top of the solid plates and composed data
|
|
|
|
*/
|
2018-10-25 11:47:37 +02:00
|
|
|
void view3d_draw_region_info(const bContext *C, ARegion *ar)
|
2016-10-06 14:14:41 +00:00
|
|
|
{
|
2017-02-14 17:47:11 +01:00
|
|
|
RegionView3D *rv3d = ar->regiondata;
|
|
|
|
View3D *v3d = CTX_wm_view3d(C);
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
wmWindowManager *wm = CTX_wm_manager(C);
|
|
|
|
|
2018-12-11 12:34:37 +11:00
|
|
|
#ifdef WITH_INPUT_NDOF
|
|
|
|
if ((U.ndof_flag & NDOF_SHOW_GUIDE) &&
|
|
|
|
((rv3d->viewlock & RV3D_LOCKED) == 0) &&
|
|
|
|
(rv3d->persp != RV3D_CAMOB))
|
|
|
|
{
|
|
|
|
/* TODO: draw something else (but not this) during fly mode */
|
|
|
|
draw_rotation_guide(rv3d);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-10-14 01:38:04 +00:00
|
|
|
/* correct projection matrix */
|
|
|
|
ED_region_pixelspace(ar);
|
|
|
|
|
2018-09-27 15:49:59 +02:00
|
|
|
/* local coordinate visible rect inside region, to accommodate overlapping ui */
|
2016-12-05 02:50:28 -05:00
|
|
|
rcti rect;
|
2016-10-14 01:38:04 +00:00
|
|
|
ED_region_visible_rect(ar, &rect);
|
|
|
|
|
2017-05-04 15:46:09 +02:00
|
|
|
|
2016-10-14 01:38:04 +00:00
|
|
|
view3d_draw_border(C, ar);
|
|
|
|
view3d_draw_grease_pencil(C);
|
|
|
|
|
2018-04-08 16:58:36 +02:00
|
|
|
BLF_batch_draw_begin();
|
|
|
|
|
2018-07-14 23:49:00 +02:00
|
|
|
if ((U.uiflag & USER_SHOW_GIZMO_AXIS) ||
|
|
|
|
/* No need to display gizmo and this info. */
|
2018-07-15 14:24:10 +02:00
|
|
|
(v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_NAVIGATE)))
|
2018-06-05 14:24:58 +02:00
|
|
|
{
|
2018-07-11 10:38:01 +02:00
|
|
|
/* pass */
|
|
|
|
}
|
|
|
|
else {
|
2017-02-14 17:47:11 +01:00
|
|
|
draw_view_axis(rv3d, &rect);
|
|
|
|
}
|
2016-12-05 02:50:28 -05:00
|
|
|
|
2018-10-25 11:47:37 +02:00
|
|
|
int xoffset = rect.xmin + U.widget_unit;
|
|
|
|
int yoffset = rect.ymax;
|
|
|
|
|
2019-03-05 15:09:25 +11:00
|
|
|
if ((v3d->flag2 & V3D_HIDE_OVERLAYS) == 0 &&
|
2018-06-05 14:24:58 +02:00
|
|
|
(v3d->overlay.flag & V3D_OVERLAY_HIDE_TEXT) == 0)
|
|
|
|
{
|
2018-06-01 08:26:55 +02:00
|
|
|
if ((U.uiflag & USER_SHOW_FPS) && ED_screen_animation_no_scrub(wm)) {
|
2018-10-25 11:47:37 +02:00
|
|
|
ED_scene_draw_fps(scene, xoffset, &yoffset);
|
2018-06-01 08:26:55 +02:00
|
|
|
}
|
|
|
|
else if (U.uiflag & USER_SHOW_VIEWPORTNAME) {
|
2018-10-25 11:47:37 +02:00
|
|
|
draw_viewport_name(ar, v3d, xoffset, &yoffset);
|
2018-06-01 08:26:55 +02:00
|
|
|
}
|
2016-12-05 02:50:28 -05:00
|
|
|
|
2018-06-01 08:26:55 +02:00
|
|
|
if (U.uiflag & USER_DRAWVIEWINFO) {
|
|
|
|
ViewLayer *view_layer = CTX_data_view_layer(C);
|
|
|
|
Object *ob = OBACT(view_layer);
|
2018-11-13 18:30:44 -02:00
|
|
|
draw_selected_name(scene, view_layer, ob, xoffset, &yoffset);
|
2018-06-01 08:26:55 +02:00
|
|
|
}
|
2018-04-08 16:58:36 +02:00
|
|
|
|
2018-06-01 08:31:32 +02:00
|
|
|
#if 0 /* TODO */
|
2018-06-01 08:26:55 +02:00
|
|
|
if (grid_unit) { /* draw below the viewport name */
|
|
|
|
char numstr[32] = "";
|
2016-12-05 02:50:28 -05:00
|
|
|
|
2018-06-01 08:26:55 +02:00
|
|
|
UI_FontThemeColor(BLF_default(), TH_TEXT_HI);
|
|
|
|
if (v3d->grid != 1.0f) {
|
|
|
|
BLI_snprintf(numstr, sizeof(numstr), "%s x %.4g", grid_unit, v3d->grid);
|
|
|
|
}
|
2017-02-14 17:47:11 +01:00
|
|
|
|
2018-10-25 11:47:37 +02:00
|
|
|
*yoffset -= U.widget_unit;
|
|
|
|
BLF_draw_default_ascii(xoffset, *yoffset, numstr[0] ? numstr : grid_unit, sizeof(numstr));
|
2018-06-01 08:26:55 +02:00
|
|
|
}
|
2018-06-01 08:31:32 +02:00
|
|
|
#endif
|
2017-02-14 17:47:11 +01:00
|
|
|
}
|
2018-06-01 08:26:55 +02:00
|
|
|
|
2018-10-25 11:47:37 +02:00
|
|
|
if ((v3d->overlay.flag & V3D_OVERLAY_HIDE_TEXT) == 0) {
|
|
|
|
DRW_draw_region_engine_info(xoffset, yoffset);
|
|
|
|
}
|
|
|
|
|
2018-04-08 16:58:36 +02:00
|
|
|
BLF_batch_draw_end();
|
2016-10-06 14:14:41 +00:00
|
|
|
}
|
|
|
|
|
2019-03-28 15:00:27 +11:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Draw Viewport Contents
|
|
|
|
* \{ */
|
|
|
|
|
2017-05-18 18:34:04 +02:00
|
|
|
static void view3d_draw_view(const bContext *C, ARegion *ar)
|
2017-02-07 11:20:15 +01:00
|
|
|
{
|
2018-04-06 12:07:27 +02:00
|
|
|
ED_view3d_draw_setup_view(CTX_wm_window(C), CTX_data_depsgraph(C), CTX_data_scene(C), ar, CTX_wm_view3d(C), NULL, NULL, NULL);
|
2017-02-07 11:20:15 +01:00
|
|
|
|
2018-09-27 15:49:59 +02:00
|
|
|
/* Only 100% compliant on new spec goes below */
|
2017-03-08 20:00:09 +01:00
|
|
|
DRW_draw_view(C);
|
2017-02-07 11:20:15 +01:00
|
|
|
}
|
|
|
|
|
2018-04-17 13:35:05 +02:00
|
|
|
RenderEngineType *ED_view3d_engine_type(Scene *scene, int drawtype)
|
|
|
|
{
|
2018-04-20 16:40:08 +02:00
|
|
|
/*
|
2018-09-27 15:49:59 +02:00
|
|
|
* Temporary viewport draw modes until we have a proper system.
|
2018-04-20 16:40:08 +02:00
|
|
|
* all modes are done in the draw manager, except
|
|
|
|
* cycles material as it is an external render engine.
|
|
|
|
*/
|
|
|
|
if (strcmp(scene->r.engine, RE_engine_id_CYCLES) == 0 && drawtype == OB_MATERIAL) {
|
2018-04-17 13:35:05 +02:00
|
|
|
return RE_engines_find(RE_engine_id_BLENDER_EEVEE);
|
|
|
|
}
|
2018-04-20 16:40:08 +02:00
|
|
|
return RE_engines_find(scene->r.engine);
|
2018-04-17 13:35:05 +02:00
|
|
|
}
|
|
|
|
|
2016-10-04 20:00:46 +00:00
|
|
|
void view3d_main_region_draw(const bContext *C, ARegion *ar)
|
2008-12-18 17:38:21 +00:00
|
|
|
{
|
2018-06-25 12:50:32 +02:00
|
|
|
Main *bmain = CTX_data_main(C);
|
2016-10-04 20:00:46 +00:00
|
|
|
View3D *v3d = CTX_wm_view3d(C);
|
2017-02-07 11:20:15 +01:00
|
|
|
|
2017-05-18 18:34:04 +02:00
|
|
|
view3d_draw_view(C, ar);
|
2018-02-13 18:18:04 +01:00
|
|
|
|
2018-06-25 12:50:32 +02:00
|
|
|
GPU_free_images_old(bmain);
|
2018-03-11 23:43:09 +01:00
|
|
|
GPU_pass_cache_garbage_collect();
|
|
|
|
|
2018-05-03 11:20:10 +02:00
|
|
|
/* XXX This is in order to draw UI batches with the DRW
|
|
|
|
* olg context since we now use it for drawing the entire area */
|
|
|
|
gpu_batch_presets_reset();
|
|
|
|
|
2018-04-27 20:07:40 +02:00
|
|
|
/* No depth test for drawing action zones afterwards. */
|
2018-06-27 19:07:23 -06:00
|
|
|
GPU_depth_test(false);
|
2018-04-27 20:07:40 +02:00
|
|
|
|
2016-10-07 01:45:28 +00:00
|
|
|
v3d->flag |= V3D_INVALID_BACKBUF;
|
2016-10-06 19:55:06 +00:00
|
|
|
}
|
|
|
|
|
2019-03-28 15:00:27 +11:00
|
|
|
/** \} */
|
|
|
|
|
2017-05-03 21:59:03 +10:00
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Offscreen Drawing
|
|
|
|
* \{ */
|
|
|
|
|
|
|
|
static void view3d_stereo3d_setup_offscreen(
|
2018-04-06 12:07:27 +02:00
|
|
|
Depsgraph *depsgraph, Scene *scene, View3D *v3d, ARegion *ar,
|
2017-05-03 21:59:03 +10:00
|
|
|
float winmat[4][4], const char *viewname)
|
|
|
|
{
|
|
|
|
/* update the viewport matrices with the new camera */
|
|
|
|
if (scene->r.views_format == SCE_VIEWS_FORMAT_STEREO_3D) {
|
|
|
|
float viewmat[4][4];
|
|
|
|
const bool is_left = STREQ(viewname, STEREO_LEFT_NAME);
|
|
|
|
|
|
|
|
BKE_camera_multiview_view_matrix(&scene->r, v3d->camera, is_left, viewmat);
|
2018-04-06 12:07:27 +02:00
|
|
|
view3d_main_region_setup_view(depsgraph, scene, v3d, ar, viewmat, winmat, NULL);
|
2017-05-03 21:59:03 +10:00
|
|
|
}
|
|
|
|
else { /* SCE_VIEWS_FORMAT_MULTIVIEW */
|
|
|
|
float viewmat[4][4];
|
|
|
|
Object *camera = BKE_camera_multiview_render(scene, v3d->camera, viewname);
|
|
|
|
|
|
|
|
BKE_camera_multiview_view_matrix(&scene->r, camera, false, viewmat);
|
2018-04-06 12:07:27 +02:00
|
|
|
view3d_main_region_setup_view(depsgraph, scene, v3d, ar, viewmat, winmat, NULL);
|
2017-05-03 21:59:03 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ED_view3d_draw_offscreen(
|
2018-04-06 12:07:27 +02:00
|
|
|
Depsgraph *depsgraph, Scene *scene,
|
Remove Blender Internal and legacy viewport from Blender 2.8.
Brecht authored this commit, but he gave me the honours to actually
do it. Here it goes; Blender Internal. Bye bye, you did great!
* Point density, voxel data, ocean, environment map textures were removed,
as these only worked within BI rendering. Note that the ocean modifier
and the Cycles point density shader node continue to work.
* Dynamic paint using material shading was removed, as this only worked
with BI. If we ever wanted to support this again probably it should go
through the baking API.
* GPU shader export through the Python API was removed. This only worked
for the old BI GLSL shaders, which no longer exists. Doing something
similar for Eevee would be significantly more complicated because it
uses a lot of multiplass rendering and logic outside the shader, it's
probably impractical.
* Collada material import / export code is mostly gone, as it only worked
for BI materials. We need to add Cycles / Eevee material support at some
point.
* The mesh noise operator was removed since it only worked with BI
material texture slots. A displacement modifier can be used instead.
* The delete texture paint slot operator was removed since it only worked
for BI material texture slots. Could be added back with node support.
* Not all legacy viewport features are supported in the new viewport, but
their code was removed. If we need to bring anything back we can look at
older git revisions.
* There is some legacy viewport code that I could not remove yet, and some
that I probably missed.
* Shader node execution code was left mostly intact, even though it is not
used anywhere now. We may eventually use this to replace the texture
nodes with Cycles / Eevee shader nodes.
* The Cycles Bake panel now includes settings for baking multires normal
and displacement maps. The underlying code needs to be merged properly,
and we plan to add back support for multires AO baking and add support
to Cycles baking for features like vertex color, displacement, and other
missing baking features.
* This commit removes DNA and the Python API for BI material, lamp, world
and scene settings. This breaks a lot of addons.
* There is more DNA that can be removed or renamed, where Cycles or Eevee
are reusing some old BI properties but the names are not really correct
anymore.
* Texture slots for materials, lamps and world were removed. They remain
for brushes, particles and freestyle linestyles.
* 'BLENDER_RENDER' remains in the COMPAT_ENGINES of UI panels. Cycles and
other renderers use this to find all panels to show, minus a few panels
that they have their own replacement for.
2018-04-19 17:34:44 +02:00
|
|
|
int drawtype,
|
2017-10-16 17:15:03 -02:00
|
|
|
View3D *v3d, ARegion *ar, int winx, int winy,
|
2017-05-03 21:59:03 +10:00
|
|
|
float viewmat[4][4], float winmat[4][4],
|
Remove Blender Internal and legacy viewport from Blender 2.8.
Brecht authored this commit, but he gave me the honours to actually
do it. Here it goes; Blender Internal. Bye bye, you did great!
* Point density, voxel data, ocean, environment map textures were removed,
as these only worked within BI rendering. Note that the ocean modifier
and the Cycles point density shader node continue to work.
* Dynamic paint using material shading was removed, as this only worked
with BI. If we ever wanted to support this again probably it should go
through the baking API.
* GPU shader export through the Python API was removed. This only worked
for the old BI GLSL shaders, which no longer exists. Doing something
similar for Eevee would be significantly more complicated because it
uses a lot of multiplass rendering and logic outside the shader, it's
probably impractical.
* Collada material import / export code is mostly gone, as it only worked
for BI materials. We need to add Cycles / Eevee material support at some
point.
* The mesh noise operator was removed since it only worked with BI
material texture slots. A displacement modifier can be used instead.
* The delete texture paint slot operator was removed since it only worked
for BI material texture slots. Could be added back with node support.
* Not all legacy viewport features are supported in the new viewport, but
their code was removed. If we need to bring anything back we can look at
older git revisions.
* There is some legacy viewport code that I could not remove yet, and some
that I probably missed.
* Shader node execution code was left mostly intact, even though it is not
used anywhere now. We may eventually use this to replace the texture
nodes with Cycles / Eevee shader nodes.
* The Cycles Bake panel now includes settings for baking multires normal
and displacement maps. The underlying code needs to be merged properly,
and we plan to add back support for multires AO baking and add support
to Cycles baking for features like vertex color, displacement, and other
missing baking features.
* This commit removes DNA and the Python API for BI material, lamp, world
and scene settings. This breaks a lot of addons.
* There is more DNA that can be removed or renamed, where Cycles or Eevee
are reusing some old BI properties but the names are not really correct
anymore.
* Texture slots for materials, lamps and world were removed. They remain
for brushes, particles and freestyle linestyles.
* 'BLENDER_RENDER' remains in the COMPAT_ENGINES of UI panels. Cycles and
other renderers use this to find all panels to show, minus a few panels
that they have their own replacement for.
2018-04-19 17:34:44 +02:00
|
|
|
bool do_sky, bool UNUSED(is_persp), const char *viewname,
|
2019-03-28 22:38:55 +01:00
|
|
|
GPUFXSettings *UNUSED(fx_settings), const bool do_color_management,
|
2018-01-05 10:18:44 +01:00
|
|
|
GPUOffScreen *ofs, GPUViewport *viewport)
|
2017-05-03 21:59:03 +10:00
|
|
|
{
|
|
|
|
RegionView3D *rv3d = ar->regiondata;
|
Remove Blender Internal and legacy viewport from Blender 2.8.
Brecht authored this commit, but he gave me the honours to actually
do it. Here it goes; Blender Internal. Bye bye, you did great!
* Point density, voxel data, ocean, environment map textures were removed,
as these only worked within BI rendering. Note that the ocean modifier
and the Cycles point density shader node continue to work.
* Dynamic paint using material shading was removed, as this only worked
with BI. If we ever wanted to support this again probably it should go
through the baking API.
* GPU shader export through the Python API was removed. This only worked
for the old BI GLSL shaders, which no longer exists. Doing something
similar for Eevee would be significantly more complicated because it
uses a lot of multiplass rendering and logic outside the shader, it's
probably impractical.
* Collada material import / export code is mostly gone, as it only worked
for BI materials. We need to add Cycles / Eevee material support at some
point.
* The mesh noise operator was removed since it only worked with BI
material texture slots. A displacement modifier can be used instead.
* The delete texture paint slot operator was removed since it only worked
for BI material texture slots. Could be added back with node support.
* Not all legacy viewport features are supported in the new viewport, but
their code was removed. If we need to bring anything back we can look at
older git revisions.
* There is some legacy viewport code that I could not remove yet, and some
that I probably missed.
* Shader node execution code was left mostly intact, even though it is not
used anywhere now. We may eventually use this to replace the texture
nodes with Cycles / Eevee shader nodes.
* The Cycles Bake panel now includes settings for baking multires normal
and displacement maps. The underlying code needs to be merged properly,
and we plan to add back support for multires AO baking and add support
to Cycles baking for features like vertex color, displacement, and other
missing baking features.
* This commit removes DNA and the Python API for BI material, lamp, world
and scene settings. This breaks a lot of addons.
* There is more DNA that can be removed or renamed, where Cycles or Eevee
are reusing some old BI properties but the names are not really correct
anymore.
* Texture slots for materials, lamps and world were removed. They remain
for brushes, particles and freestyle linestyles.
* 'BLENDER_RENDER' remains in the COMPAT_ENGINES of UI panels. Cycles and
other renderers use this to find all panels to show, minus a few panels
that they have their own replacement for.
2018-04-19 17:34:44 +02:00
|
|
|
RenderEngineType *engine_type = ED_view3d_engine_type(scene, drawtype);
|
2017-05-03 21:59:03 +10:00
|
|
|
|
|
|
|
/* set temporary new size */
|
|
|
|
int bwinx = ar->winx;
|
|
|
|
int bwiny = ar->winy;
|
|
|
|
rcti brect = ar->winrct;
|
|
|
|
|
|
|
|
ar->winx = winx;
|
|
|
|
ar->winy = winy;
|
|
|
|
ar->winrct.xmin = 0;
|
|
|
|
ar->winrct.ymin = 0;
|
|
|
|
ar->winrct.xmax = winx;
|
|
|
|
ar->winrct.ymax = winy;
|
|
|
|
|
|
|
|
struct bThemeState theme_state;
|
|
|
|
UI_Theme_Store(&theme_state);
|
|
|
|
UI_SetTheme(SPACE_VIEW3D, RGN_TYPE_WINDOW);
|
|
|
|
|
|
|
|
/* set flags */
|
2019-02-02 13:39:51 +11:00
|
|
|
G.f |= G_FLAG_RENDER_VIEWPORT;
|
2017-05-03 21:59:03 +10:00
|
|
|
|
2018-12-17 13:21:49 +11:00
|
|
|
{
|
2017-05-03 21:59:03 +10:00
|
|
|
/* free images which can have changed on frame-change
|
|
|
|
* warning! can be slow so only free animated images - campbell */
|
2018-06-25 12:50:32 +02:00
|
|
|
GPU_free_images_anim(G.main); /* XXX :((( */
|
2017-05-03 21:59:03 +10:00
|
|
|
}
|
|
|
|
|
2018-07-15 15:27:15 +02:00
|
|
|
GPU_matrix_push_projection();
|
|
|
|
GPU_matrix_identity_set();
|
|
|
|
GPU_matrix_push();
|
|
|
|
GPU_matrix_identity_set();
|
2017-05-03 21:59:03 +10:00
|
|
|
|
2019-03-26 21:16:47 +11:00
|
|
|
if ((viewname != NULL && viewname[0] != '\0') && (viewmat == NULL) && rv3d->persp == RV3D_CAMOB && v3d->camera) {
|
2018-04-06 12:07:27 +02:00
|
|
|
view3d_stereo3d_setup_offscreen(depsgraph, scene, v3d, ar, winmat, viewname);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
|
|
|
else {
|
2018-04-06 12:07:27 +02:00
|
|
|
view3d_main_region_setup_view(depsgraph, scene, v3d, ar, viewmat, winmat, NULL);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2018-01-18 15:58:02 +01:00
|
|
|
|
2017-05-03 22:13:57 +10:00
|
|
|
/* main drawing call */
|
Remove Blender Internal and legacy viewport from Blender 2.8.
Brecht authored this commit, but he gave me the honours to actually
do it. Here it goes; Blender Internal. Bye bye, you did great!
* Point density, voxel data, ocean, environment map textures were removed,
as these only worked within BI rendering. Note that the ocean modifier
and the Cycles point density shader node continue to work.
* Dynamic paint using material shading was removed, as this only worked
with BI. If we ever wanted to support this again probably it should go
through the baking API.
* GPU shader export through the Python API was removed. This only worked
for the old BI GLSL shaders, which no longer exists. Doing something
similar for Eevee would be significantly more complicated because it
uses a lot of multiplass rendering and logic outside the shader, it's
probably impractical.
* Collada material import / export code is mostly gone, as it only worked
for BI materials. We need to add Cycles / Eevee material support at some
point.
* The mesh noise operator was removed since it only worked with BI
material texture slots. A displacement modifier can be used instead.
* The delete texture paint slot operator was removed since it only worked
for BI material texture slots. Could be added back with node support.
* Not all legacy viewport features are supported in the new viewport, but
their code was removed. If we need to bring anything back we can look at
older git revisions.
* There is some legacy viewport code that I could not remove yet, and some
that I probably missed.
* Shader node execution code was left mostly intact, even though it is not
used anywhere now. We may eventually use this to replace the texture
nodes with Cycles / Eevee shader nodes.
* The Cycles Bake panel now includes settings for baking multires normal
and displacement maps. The underlying code needs to be merged properly,
and we plan to add back support for multires AO baking and add support
to Cycles baking for features like vertex color, displacement, and other
missing baking features.
* This commit removes DNA and the Python API for BI material, lamp, world
and scene settings. This breaks a lot of addons.
* There is more DNA that can be removed or renamed, where Cycles or Eevee
are reusing some old BI properties but the names are not really correct
anymore.
* Texture slots for materials, lamps and world were removed. They remain
for brushes, particles and freestyle linestyles.
* 'BLENDER_RENDER' remains in the COMPAT_ENGINES of UI panels. Cycles and
other renderers use this to find all panels to show, minus a few panels
that they have their own replacement for.
2018-04-19 17:34:44 +02:00
|
|
|
DRW_draw_render_loop_offscreen(
|
|
|
|
depsgraph, engine_type, ar, v3d,
|
2019-03-28 22:38:55 +01:00
|
|
|
do_sky, do_color_management, ofs, viewport);
|
2017-05-03 21:59:03 +10:00
|
|
|
|
|
|
|
/* restore size */
|
|
|
|
ar->winx = bwinx;
|
|
|
|
ar->winy = bwiny;
|
|
|
|
ar->winrct = brect;
|
|
|
|
|
2018-07-15 15:27:15 +02:00
|
|
|
GPU_matrix_pop_projection();
|
|
|
|
GPU_matrix_pop();
|
2017-05-03 21:59:03 +10:00
|
|
|
|
|
|
|
UI_Theme_Restore(&theme_state);
|
|
|
|
|
2019-02-02 13:39:51 +11:00
|
|
|
G.f &= ~G_FLAG_RENDER_VIEWPORT;
|
2017-05-03 21:59:03 +10:00
|
|
|
}
|
|
|
|
|
2016-10-06 19:55:06 +00:00
|
|
|
/**
|
2017-05-03 21:59:03 +10:00
|
|
|
* Utility func for ED_view3d_draw_offscreen
|
|
|
|
*
|
|
|
|
* \param ofs: Optional off-screen buffer, can be NULL.
|
|
|
|
* (avoids re-creating when doing multiple GL renders).
|
|
|
|
*/
|
|
|
|
ImBuf *ED_view3d_draw_offscreen_imbuf(
|
2018-04-06 12:07:27 +02:00
|
|
|
Depsgraph *depsgraph, Scene *scene,
|
Remove Blender Internal and legacy viewport from Blender 2.8.
Brecht authored this commit, but he gave me the honours to actually
do it. Here it goes; Blender Internal. Bye bye, you did great!
* Point density, voxel data, ocean, environment map textures were removed,
as these only worked within BI rendering. Note that the ocean modifier
and the Cycles point density shader node continue to work.
* Dynamic paint using material shading was removed, as this only worked
with BI. If we ever wanted to support this again probably it should go
through the baking API.
* GPU shader export through the Python API was removed. This only worked
for the old BI GLSL shaders, which no longer exists. Doing something
similar for Eevee would be significantly more complicated because it
uses a lot of multiplass rendering and logic outside the shader, it's
probably impractical.
* Collada material import / export code is mostly gone, as it only worked
for BI materials. We need to add Cycles / Eevee material support at some
point.
* The mesh noise operator was removed since it only worked with BI
material texture slots. A displacement modifier can be used instead.
* The delete texture paint slot operator was removed since it only worked
for BI material texture slots. Could be added back with node support.
* Not all legacy viewport features are supported in the new viewport, but
their code was removed. If we need to bring anything back we can look at
older git revisions.
* There is some legacy viewport code that I could not remove yet, and some
that I probably missed.
* Shader node execution code was left mostly intact, even though it is not
used anywhere now. We may eventually use this to replace the texture
nodes with Cycles / Eevee shader nodes.
* The Cycles Bake panel now includes settings for baking multires normal
and displacement maps. The underlying code needs to be merged properly,
and we plan to add back support for multires AO baking and add support
to Cycles baking for features like vertex color, displacement, and other
missing baking features.
* This commit removes DNA and the Python API for BI material, lamp, world
and scene settings. This breaks a lot of addons.
* There is more DNA that can be removed or renamed, where Cycles or Eevee
are reusing some old BI properties but the names are not really correct
anymore.
* Texture slots for materials, lamps and world were removed. They remain
for brushes, particles and freestyle linestyles.
* 'BLENDER_RENDER' remains in the COMPAT_ENGINES of UI panels. Cycles and
other renderers use this to find all panels to show, minus a few panels
that they have their own replacement for.
2018-04-19 17:34:44 +02:00
|
|
|
int drawtype,
|
2017-10-16 17:15:03 -02:00
|
|
|
View3D *v3d, ARegion *ar, int sizex, int sizey,
|
2019-03-01 23:43:34 +11:00
|
|
|
uint flag, uint draw_flags,
|
2017-11-27 14:08:35 +01:00
|
|
|
int alpha_mode, int samples, const char *viewname,
|
2017-05-03 21:59:03 +10:00
|
|
|
/* output vars */
|
2018-03-22 16:10:54 +01:00
|
|
|
GPUOffScreen *ofs, char err_out[256])
|
2017-05-03 21:59:03 +10:00
|
|
|
{
|
|
|
|
RegionView3D *rv3d = ar->regiondata;
|
|
|
|
const bool draw_sky = (alpha_mode == R_ADDSKY);
|
2017-11-27 14:08:35 +01:00
|
|
|
const bool use_full_sample = (draw_flags & V3D_OFSDRAW_USE_FULL_SAMPLE);
|
2017-05-03 21:59:03 +10:00
|
|
|
|
|
|
|
/* view state */
|
|
|
|
GPUFXSettings fx_settings = v3d->fx_settings;
|
|
|
|
bool is_ortho = false;
|
|
|
|
float winmat[4][4];
|
|
|
|
|
|
|
|
if (ofs && ((GPU_offscreen_width(ofs) != sizex) || (GPU_offscreen_height(ofs) != sizey))) {
|
|
|
|
/* sizes differ, can't reuse */
|
|
|
|
ofs = NULL;
|
|
|
|
}
|
|
|
|
|
2018-07-31 18:20:57 +02:00
|
|
|
GPUFrameBuffer *old_fb = GPU_framebuffer_active_get();
|
|
|
|
|
|
|
|
if (old_fb) {
|
|
|
|
GPU_framebuffer_restore();
|
|
|
|
}
|
|
|
|
|
2017-05-03 21:59:03 +10:00
|
|
|
const bool own_ofs = (ofs == NULL);
|
2018-02-26 19:41:17 +01:00
|
|
|
DRW_opengl_context_enable();
|
2017-05-03 21:59:03 +10:00
|
|
|
|
|
|
|
if (own_ofs) {
|
|
|
|
/* bind */
|
2018-02-13 18:18:04 +01:00
|
|
|
ofs = GPU_offscreen_create(sizex, sizey, use_full_sample ? 0 : samples, true, false, err_out);
|
2017-05-03 21:59:03 +10:00
|
|
|
if (ofs == NULL) {
|
2018-02-26 19:41:17 +01:00
|
|
|
DRW_opengl_context_disable();
|
2017-05-03 21:59:03 +10:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GPU_offscreen_bind(ofs, true);
|
|
|
|
|
|
|
|
/* read in pixels & stamp */
|
|
|
|
ImBuf *ibuf = IMB_allocImBuf(sizex, sizey, 32, flag);
|
|
|
|
|
|
|
|
/* render 3d view */
|
|
|
|
if (rv3d->persp == RV3D_CAMOB && v3d->camera) {
|
|
|
|
CameraParams params;
|
|
|
|
Object *camera = BKE_camera_multiview_render(scene, v3d->camera, viewname);
|
2018-05-25 11:05:51 +02:00
|
|
|
const Object *camera_eval = DEG_get_evaluated_object(
|
|
|
|
depsgraph,
|
|
|
|
camera);
|
2017-05-03 21:59:03 +10:00
|
|
|
|
|
|
|
BKE_camera_params_init(¶ms);
|
|
|
|
/* fallback for non camera objects */
|
2019-02-16 12:21:44 +11:00
|
|
|
params.clip_start = v3d->clip_start;
|
|
|
|
params.clip_end = v3d->clip_end;
|
2018-05-25 11:05:51 +02:00
|
|
|
BKE_camera_params_from_object(¶ms, camera_eval);
|
|
|
|
BKE_camera_multiview_params(&scene->r, ¶ms, camera_eval, viewname);
|
2017-05-03 21:59:03 +10:00
|
|
|
BKE_camera_params_compute_viewplane(¶ms, sizex, sizey, scene->r.xasp, scene->r.yasp);
|
|
|
|
BKE_camera_params_compute_matrix(¶ms);
|
|
|
|
|
|
|
|
BKE_camera_to_gpu_dof(camera, &fx_settings);
|
|
|
|
|
|
|
|
is_ortho = params.is_ortho;
|
|
|
|
copy_m4_m4(winmat, params.winmat);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rctf viewplane;
|
2019-02-16 12:21:44 +11:00
|
|
|
float clip_start, clipend;
|
2017-05-03 21:59:03 +10:00
|
|
|
|
2019-02-16 12:21:44 +11:00
|
|
|
is_ortho = ED_view3d_viewplane_get(depsgraph, v3d, rv3d, sizex, sizey, &viewplane, &clip_start, &clipend, NULL);
|
2017-05-03 21:59:03 +10:00
|
|
|
if (is_ortho) {
|
|
|
|
orthographic_m4(winmat, viewplane.xmin, viewplane.xmax, viewplane.ymin, viewplane.ymax, -clipend, clipend);
|
|
|
|
}
|
|
|
|
else {
|
2019-02-16 12:21:44 +11:00
|
|
|
perspective_m4(winmat, viewplane.xmin, viewplane.xmax, viewplane.ymin, viewplane.ymax, clip_start, clipend);
|
2017-05-03 21:59:03 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-27 14:08:35 +01:00
|
|
|
if ((samples && use_full_sample) == 0) {
|
2019-03-28 22:38:55 +01:00
|
|
|
const bool do_color_management = (ibuf->rect_float == NULL);
|
2017-05-03 21:59:03 +10:00
|
|
|
/* Single-pass render, common case */
|
|
|
|
ED_view3d_draw_offscreen(
|
Remove Blender Internal and legacy viewport from Blender 2.8.
Brecht authored this commit, but he gave me the honours to actually
do it. Here it goes; Blender Internal. Bye bye, you did great!
* Point density, voxel data, ocean, environment map textures were removed,
as these only worked within BI rendering. Note that the ocean modifier
and the Cycles point density shader node continue to work.
* Dynamic paint using material shading was removed, as this only worked
with BI. If we ever wanted to support this again probably it should go
through the baking API.
* GPU shader export through the Python API was removed. This only worked
for the old BI GLSL shaders, which no longer exists. Doing something
similar for Eevee would be significantly more complicated because it
uses a lot of multiplass rendering and logic outside the shader, it's
probably impractical.
* Collada material import / export code is mostly gone, as it only worked
for BI materials. We need to add Cycles / Eevee material support at some
point.
* The mesh noise operator was removed since it only worked with BI
material texture slots. A displacement modifier can be used instead.
* The delete texture paint slot operator was removed since it only worked
for BI material texture slots. Could be added back with node support.
* Not all legacy viewport features are supported in the new viewport, but
their code was removed. If we need to bring anything back we can look at
older git revisions.
* There is some legacy viewport code that I could not remove yet, and some
that I probably missed.
* Shader node execution code was left mostly intact, even though it is not
used anywhere now. We may eventually use this to replace the texture
nodes with Cycles / Eevee shader nodes.
* The Cycles Bake panel now includes settings for baking multires normal
and displacement maps. The underlying code needs to be merged properly,
and we plan to add back support for multires AO baking and add support
to Cycles baking for features like vertex color, displacement, and other
missing baking features.
* This commit removes DNA and the Python API for BI material, lamp, world
and scene settings. This breaks a lot of addons.
* There is more DNA that can be removed or renamed, where Cycles or Eevee
are reusing some old BI properties but the names are not really correct
anymore.
* Texture slots for materials, lamps and world were removed. They remain
for brushes, particles and freestyle linestyles.
* 'BLENDER_RENDER' remains in the COMPAT_ENGINES of UI panels. Cycles and
other renderers use this to find all panels to show, minus a few panels
that they have their own replacement for.
2018-04-19 17:34:44 +02:00
|
|
|
depsgraph, scene, drawtype,
|
2018-04-06 10:55:11 +02:00
|
|
|
v3d, ar, sizex, sizey, NULL, winmat,
|
Remove Blender Internal and legacy viewport from Blender 2.8.
Brecht authored this commit, but he gave me the honours to actually
do it. Here it goes; Blender Internal. Bye bye, you did great!
* Point density, voxel data, ocean, environment map textures were removed,
as these only worked within BI rendering. Note that the ocean modifier
and the Cycles point density shader node continue to work.
* Dynamic paint using material shading was removed, as this only worked
with BI. If we ever wanted to support this again probably it should go
through the baking API.
* GPU shader export through the Python API was removed. This only worked
for the old BI GLSL shaders, which no longer exists. Doing something
similar for Eevee would be significantly more complicated because it
uses a lot of multiplass rendering and logic outside the shader, it's
probably impractical.
* Collada material import / export code is mostly gone, as it only worked
for BI materials. We need to add Cycles / Eevee material support at some
point.
* The mesh noise operator was removed since it only worked with BI
material texture slots. A displacement modifier can be used instead.
* The delete texture paint slot operator was removed since it only worked
for BI material texture slots. Could be added back with node support.
* Not all legacy viewport features are supported in the new viewport, but
their code was removed. If we need to bring anything back we can look at
older git revisions.
* There is some legacy viewport code that I could not remove yet, and some
that I probably missed.
* Shader node execution code was left mostly intact, even though it is not
used anywhere now. We may eventually use this to replace the texture
nodes with Cycles / Eevee shader nodes.
* The Cycles Bake panel now includes settings for baking multires normal
and displacement maps. The underlying code needs to be merged properly,
and we plan to add back support for multires AO baking and add support
to Cycles baking for features like vertex color, displacement, and other
missing baking features.
* This commit removes DNA and the Python API for BI material, lamp, world
and scene settings. This breaks a lot of addons.
* There is more DNA that can be removed or renamed, where Cycles or Eevee
are reusing some old BI properties but the names are not really correct
anymore.
* Texture slots for materials, lamps and world were removed. They remain
for brushes, particles and freestyle linestyles.
* 'BLENDER_RENDER' remains in the COMPAT_ENGINES of UI panels. Cycles and
other renderers use this to find all panels to show, minus a few panels
that they have their own replacement for.
2018-04-19 17:34:44 +02:00
|
|
|
draw_sky, !is_ortho, viewname,
|
2019-03-28 22:38:55 +01:00
|
|
|
&fx_settings, do_color_management, ofs, NULL);
|
2017-05-03 21:59:03 +10:00
|
|
|
|
|
|
|
if (ibuf->rect_float) {
|
|
|
|
GPU_offscreen_read_pixels(ofs, GL_FLOAT, ibuf->rect_float);
|
|
|
|
}
|
|
|
|
else if (ibuf->rect) {
|
|
|
|
GPU_offscreen_read_pixels(ofs, GL_UNSIGNED_BYTE, ibuf->rect);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* Multi-pass render, use accumulation buffer & jitter for 'full' oversampling.
|
|
|
|
* Use because OpenGL may use a lower quality MSAA, and only over-sample edges. */
|
|
|
|
static float jit_ofs[32][2];
|
|
|
|
float winmat_jitter[4][4];
|
2018-01-03 13:22:19 +01:00
|
|
|
float *rect_temp = (ibuf->rect_float) ? ibuf->rect_float : MEM_mallocN(sizex * sizey * sizeof(float[4]), "rect_temp");
|
|
|
|
float *accum_buffer = MEM_mallocN(sizex * sizey * sizeof(float[4]), "accum_buffer");
|
2018-01-05 10:18:44 +01:00
|
|
|
GPUViewport *viewport = GPU_viewport_create_from_offscreen(ofs);
|
2017-05-03 21:59:03 +10:00
|
|
|
|
|
|
|
BLI_jitter_init(jit_ofs, samples);
|
|
|
|
|
|
|
|
/* first sample buffer, also initializes 'rv3d->persmat' */
|
|
|
|
ED_view3d_draw_offscreen(
|
Remove Blender Internal and legacy viewport from Blender 2.8.
Brecht authored this commit, but he gave me the honours to actually
do it. Here it goes; Blender Internal. Bye bye, you did great!
* Point density, voxel data, ocean, environment map textures were removed,
as these only worked within BI rendering. Note that the ocean modifier
and the Cycles point density shader node continue to work.
* Dynamic paint using material shading was removed, as this only worked
with BI. If we ever wanted to support this again probably it should go
through the baking API.
* GPU shader export through the Python API was removed. This only worked
for the old BI GLSL shaders, which no longer exists. Doing something
similar for Eevee would be significantly more complicated because it
uses a lot of multiplass rendering and logic outside the shader, it's
probably impractical.
* Collada material import / export code is mostly gone, as it only worked
for BI materials. We need to add Cycles / Eevee material support at some
point.
* The mesh noise operator was removed since it only worked with BI
material texture slots. A displacement modifier can be used instead.
* The delete texture paint slot operator was removed since it only worked
for BI material texture slots. Could be added back with node support.
* Not all legacy viewport features are supported in the new viewport, but
their code was removed. If we need to bring anything back we can look at
older git revisions.
* There is some legacy viewport code that I could not remove yet, and some
that I probably missed.
* Shader node execution code was left mostly intact, even though it is not
used anywhere now. We may eventually use this to replace the texture
nodes with Cycles / Eevee shader nodes.
* The Cycles Bake panel now includes settings for baking multires normal
and displacement maps. The underlying code needs to be merged properly,
and we plan to add back support for multires AO baking and add support
to Cycles baking for features like vertex color, displacement, and other
missing baking features.
* This commit removes DNA and the Python API for BI material, lamp, world
and scene settings. This breaks a lot of addons.
* There is more DNA that can be removed or renamed, where Cycles or Eevee
are reusing some old BI properties but the names are not really correct
anymore.
* Texture slots for materials, lamps and world were removed. They remain
for brushes, particles and freestyle linestyles.
* 'BLENDER_RENDER' remains in the COMPAT_ENGINES of UI panels. Cycles and
other renderers use this to find all panels to show, minus a few panels
that they have their own replacement for.
2018-04-19 17:34:44 +02:00
|
|
|
depsgraph, scene, drawtype,
|
2018-04-06 10:55:11 +02:00
|
|
|
v3d, ar, sizex, sizey, NULL, winmat,
|
Remove Blender Internal and legacy viewport from Blender 2.8.
Brecht authored this commit, but he gave me the honours to actually
do it. Here it goes; Blender Internal. Bye bye, you did great!
* Point density, voxel data, ocean, environment map textures were removed,
as these only worked within BI rendering. Note that the ocean modifier
and the Cycles point density shader node continue to work.
* Dynamic paint using material shading was removed, as this only worked
with BI. If we ever wanted to support this again probably it should go
through the baking API.
* GPU shader export through the Python API was removed. This only worked
for the old BI GLSL shaders, which no longer exists. Doing something
similar for Eevee would be significantly more complicated because it
uses a lot of multiplass rendering and logic outside the shader, it's
probably impractical.
* Collada material import / export code is mostly gone, as it only worked
for BI materials. We need to add Cycles / Eevee material support at some
point.
* The mesh noise operator was removed since it only worked with BI
material texture slots. A displacement modifier can be used instead.
* The delete texture paint slot operator was removed since it only worked
for BI material texture slots. Could be added back with node support.
* Not all legacy viewport features are supported in the new viewport, but
their code was removed. If we need to bring anything back we can look at
older git revisions.
* There is some legacy viewport code that I could not remove yet, and some
that I probably missed.
* Shader node execution code was left mostly intact, even though it is not
used anywhere now. We may eventually use this to replace the texture
nodes with Cycles / Eevee shader nodes.
* The Cycles Bake panel now includes settings for baking multires normal
and displacement maps. The underlying code needs to be merged properly,
and we plan to add back support for multires AO baking and add support
to Cycles baking for features like vertex color, displacement, and other
missing baking features.
* This commit removes DNA and the Python API for BI material, lamp, world
and scene settings. This breaks a lot of addons.
* There is more DNA that can be removed or renamed, where Cycles or Eevee
are reusing some old BI properties but the names are not really correct
anymore.
* Texture slots for materials, lamps and world were removed. They remain
for brushes, particles and freestyle linestyles.
* 'BLENDER_RENDER' remains in the COMPAT_ENGINES of UI panels. Cycles and
other renderers use this to find all panels to show, minus a few panels
that they have their own replacement for.
2018-04-19 17:34:44 +02:00
|
|
|
draw_sky, !is_ortho, viewname,
|
2019-03-28 22:38:55 +01:00
|
|
|
&fx_settings, false, ofs, viewport);
|
2018-01-03 13:22:19 +01:00
|
|
|
GPU_offscreen_read_pixels(ofs, GL_FLOAT, accum_buffer);
|
2017-05-03 21:59:03 +10:00
|
|
|
|
|
|
|
/* skip the first sample */
|
|
|
|
for (int j = 1; j < samples; j++) {
|
|
|
|
copy_m4_m4(winmat_jitter, winmat);
|
|
|
|
window_translate_m4(
|
|
|
|
winmat_jitter, rv3d->persmat,
|
|
|
|
(jit_ofs[j][0] * 2.0f) / sizex,
|
|
|
|
(jit_ofs[j][1] * 2.0f) / sizey);
|
|
|
|
|
|
|
|
ED_view3d_draw_offscreen(
|
Remove Blender Internal and legacy viewport from Blender 2.8.
Brecht authored this commit, but he gave me the honours to actually
do it. Here it goes; Blender Internal. Bye bye, you did great!
* Point density, voxel data, ocean, environment map textures were removed,
as these only worked within BI rendering. Note that the ocean modifier
and the Cycles point density shader node continue to work.
* Dynamic paint using material shading was removed, as this only worked
with BI. If we ever wanted to support this again probably it should go
through the baking API.
* GPU shader export through the Python API was removed. This only worked
for the old BI GLSL shaders, which no longer exists. Doing something
similar for Eevee would be significantly more complicated because it
uses a lot of multiplass rendering and logic outside the shader, it's
probably impractical.
* Collada material import / export code is mostly gone, as it only worked
for BI materials. We need to add Cycles / Eevee material support at some
point.
* The mesh noise operator was removed since it only worked with BI
material texture slots. A displacement modifier can be used instead.
* The delete texture paint slot operator was removed since it only worked
for BI material texture slots. Could be added back with node support.
* Not all legacy viewport features are supported in the new viewport, but
their code was removed. If we need to bring anything back we can look at
older git revisions.
* There is some legacy viewport code that I could not remove yet, and some
that I probably missed.
* Shader node execution code was left mostly intact, even though it is not
used anywhere now. We may eventually use this to replace the texture
nodes with Cycles / Eevee shader nodes.
* The Cycles Bake panel now includes settings for baking multires normal
and displacement maps. The underlying code needs to be merged properly,
and we plan to add back support for multires AO baking and add support
to Cycles baking for features like vertex color, displacement, and other
missing baking features.
* This commit removes DNA and the Python API for BI material, lamp, world
and scene settings. This breaks a lot of addons.
* There is more DNA that can be removed or renamed, where Cycles or Eevee
are reusing some old BI properties but the names are not really correct
anymore.
* Texture slots for materials, lamps and world were removed. They remain
for brushes, particles and freestyle linestyles.
* 'BLENDER_RENDER' remains in the COMPAT_ENGINES of UI panels. Cycles and
other renderers use this to find all panels to show, minus a few panels
that they have their own replacement for.
2018-04-19 17:34:44 +02:00
|
|
|
depsgraph, scene, drawtype,
|
2018-04-06 10:55:11 +02:00
|
|
|
v3d, ar, sizex, sizey, NULL, winmat_jitter,
|
Remove Blender Internal and legacy viewport from Blender 2.8.
Brecht authored this commit, but he gave me the honours to actually
do it. Here it goes; Blender Internal. Bye bye, you did great!
* Point density, voxel data, ocean, environment map textures were removed,
as these only worked within BI rendering. Note that the ocean modifier
and the Cycles point density shader node continue to work.
* Dynamic paint using material shading was removed, as this only worked
with BI. If we ever wanted to support this again probably it should go
through the baking API.
* GPU shader export through the Python API was removed. This only worked
for the old BI GLSL shaders, which no longer exists. Doing something
similar for Eevee would be significantly more complicated because it
uses a lot of multiplass rendering and logic outside the shader, it's
probably impractical.
* Collada material import / export code is mostly gone, as it only worked
for BI materials. We need to add Cycles / Eevee material support at some
point.
* The mesh noise operator was removed since it only worked with BI
material texture slots. A displacement modifier can be used instead.
* The delete texture paint slot operator was removed since it only worked
for BI material texture slots. Could be added back with node support.
* Not all legacy viewport features are supported in the new viewport, but
their code was removed. If we need to bring anything back we can look at
older git revisions.
* There is some legacy viewport code that I could not remove yet, and some
that I probably missed.
* Shader node execution code was left mostly intact, even though it is not
used anywhere now. We may eventually use this to replace the texture
nodes with Cycles / Eevee shader nodes.
* The Cycles Bake panel now includes settings for baking multires normal
and displacement maps. The underlying code needs to be merged properly,
and we plan to add back support for multires AO baking and add support
to Cycles baking for features like vertex color, displacement, and other
missing baking features.
* This commit removes DNA and the Python API for BI material, lamp, world
and scene settings. This breaks a lot of addons.
* There is more DNA that can be removed or renamed, where Cycles or Eevee
are reusing some old BI properties but the names are not really correct
anymore.
* Texture slots for materials, lamps and world were removed. They remain
for brushes, particles and freestyle linestyles.
* 'BLENDER_RENDER' remains in the COMPAT_ENGINES of UI panels. Cycles and
other renderers use this to find all panels to show, minus a few panels
that they have their own replacement for.
2018-04-19 17:34:44 +02:00
|
|
|
draw_sky, !is_ortho, viewname,
|
2019-03-28 22:38:55 +01:00
|
|
|
&fx_settings, false, ofs, viewport);
|
2018-01-03 13:22:19 +01:00
|
|
|
GPU_offscreen_read_pixels(ofs, GL_FLOAT, rect_temp);
|
2017-05-03 21:59:03 +10:00
|
|
|
|
2019-03-01 23:43:34 +11:00
|
|
|
uint i = sizex * sizey * 4;
|
2017-05-03 21:59:03 +10:00
|
|
|
while (i--) {
|
|
|
|
accum_buffer[i] += rect_temp[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-05 10:18:44 +01:00
|
|
|
{
|
|
|
|
/* don't free data owned by 'ofs' */
|
|
|
|
GPU_viewport_clear_from_offscreen(viewport);
|
|
|
|
GPU_viewport_free(viewport);
|
|
|
|
}
|
|
|
|
|
2018-01-03 13:22:19 +01:00
|
|
|
if (ibuf->rect_float == NULL) {
|
|
|
|
MEM_freeN(rect_temp);
|
|
|
|
}
|
|
|
|
|
2017-05-03 21:59:03 +10:00
|
|
|
if (ibuf->rect_float) {
|
|
|
|
float *rect_float = ibuf->rect_float;
|
2019-03-01 23:43:34 +11:00
|
|
|
uint i = sizex * sizey * 4;
|
2017-05-03 21:59:03 +10:00
|
|
|
while (i--) {
|
2018-01-03 13:22:19 +01:00
|
|
|
rect_float[i] = accum_buffer[i] / samples;
|
2017-05-03 21:59:03 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2019-03-01 23:43:34 +11:00
|
|
|
uchar *rect_ub = (uchar *)ibuf->rect;
|
|
|
|
uint i = sizex * sizey * 4;
|
2017-05-03 21:59:03 +10:00
|
|
|
while (i--) {
|
2019-03-01 23:43:34 +11:00
|
|
|
rect_ub[i] = (uchar)(255.0f * accum_buffer[i] / samples);
|
2017-05-03 21:59:03 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MEM_freeN(accum_buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* unbind */
|
|
|
|
GPU_offscreen_unbind(ofs, true);
|
|
|
|
|
|
|
|
if (own_ofs) {
|
|
|
|
GPU_offscreen_free(ofs);
|
|
|
|
}
|
|
|
|
|
2018-02-26 19:41:17 +01:00
|
|
|
DRW_opengl_context_disable();
|
|
|
|
|
2018-07-31 18:20:57 +02:00
|
|
|
if (old_fb) {
|
|
|
|
GPU_framebuffer_bind(old_fb);
|
|
|
|
}
|
|
|
|
|
2019-03-26 21:16:47 +11:00
|
|
|
if (ibuf->rect_float && ibuf->rect) {
|
2017-05-03 21:59:03 +10:00
|
|
|
IMB_rect_from_float(ibuf);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2017-05-03 21:59:03 +10:00
|
|
|
|
|
|
|
return ibuf;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates own fake 3d views (wrapping #ED_view3d_draw_offscreen_imbuf)
|
|
|
|
*
|
|
|
|
* \param ofs: Optional off-screen buffer can be NULL.
|
|
|
|
* (avoids re-creating when doing multiple GL renders).
|
|
|
|
*
|
|
|
|
* \note used by the sequencer
|
|
|
|
*/
|
|
|
|
ImBuf *ED_view3d_draw_offscreen_imbuf_simple(
|
2018-04-06 12:07:27 +02:00
|
|
|
Depsgraph *depsgraph, Scene *scene,
|
Remove Blender Internal and legacy viewport from Blender 2.8.
Brecht authored this commit, but he gave me the honours to actually
do it. Here it goes; Blender Internal. Bye bye, you did great!
* Point density, voxel data, ocean, environment map textures were removed,
as these only worked within BI rendering. Note that the ocean modifier
and the Cycles point density shader node continue to work.
* Dynamic paint using material shading was removed, as this only worked
with BI. If we ever wanted to support this again probably it should go
through the baking API.
* GPU shader export through the Python API was removed. This only worked
for the old BI GLSL shaders, which no longer exists. Doing something
similar for Eevee would be significantly more complicated because it
uses a lot of multiplass rendering and logic outside the shader, it's
probably impractical.
* Collada material import / export code is mostly gone, as it only worked
for BI materials. We need to add Cycles / Eevee material support at some
point.
* The mesh noise operator was removed since it only worked with BI
material texture slots. A displacement modifier can be used instead.
* The delete texture paint slot operator was removed since it only worked
for BI material texture slots. Could be added back with node support.
* Not all legacy viewport features are supported in the new viewport, but
their code was removed. If we need to bring anything back we can look at
older git revisions.
* There is some legacy viewport code that I could not remove yet, and some
that I probably missed.
* Shader node execution code was left mostly intact, even though it is not
used anywhere now. We may eventually use this to replace the texture
nodes with Cycles / Eevee shader nodes.
* The Cycles Bake panel now includes settings for baking multires normal
and displacement maps. The underlying code needs to be merged properly,
and we plan to add back support for multires AO baking and add support
to Cycles baking for features like vertex color, displacement, and other
missing baking features.
* This commit removes DNA and the Python API for BI material, lamp, world
and scene settings. This breaks a lot of addons.
* There is more DNA that can be removed or renamed, where Cycles or Eevee
are reusing some old BI properties but the names are not really correct
anymore.
* Texture slots for materials, lamps and world were removed. They remain
for brushes, particles and freestyle linestyles.
* 'BLENDER_RENDER' remains in the COMPAT_ENGINES of UI panels. Cycles and
other renderers use this to find all panels to show, minus a few panels
that they have their own replacement for.
2018-04-19 17:34:44 +02:00
|
|
|
int drawtype,
|
2017-10-16 17:15:03 -02:00
|
|
|
Object *camera, int width, int height,
|
2019-03-01 23:43:34 +11:00
|
|
|
uint flag, uint draw_flags,
|
2017-11-27 14:08:35 +01:00
|
|
|
int alpha_mode, int samples, const char *viewname,
|
2018-03-22 16:10:54 +01:00
|
|
|
GPUOffScreen *ofs, char err_out[256])
|
2017-05-03 21:59:03 +10:00
|
|
|
{
|
|
|
|
View3D v3d = {NULL};
|
|
|
|
ARegion ar = {NULL};
|
|
|
|
RegionView3D rv3d = {{{0}}};
|
|
|
|
|
|
|
|
/* connect data */
|
|
|
|
v3d.regionbase.first = v3d.regionbase.last = &ar;
|
|
|
|
ar.regiondata = &rv3d;
|
|
|
|
ar.regiontype = RGN_TYPE_WINDOW;
|
|
|
|
|
|
|
|
v3d.camera = camera;
|
2018-07-11 14:20:39 +02:00
|
|
|
v3d.shading.type = drawtype;
|
2019-03-05 15:09:25 +11:00
|
|
|
v3d.flag2 = V3D_HIDE_OVERLAYS;
|
2017-05-03 21:59:03 +10:00
|
|
|
|
2017-11-27 14:08:35 +01:00
|
|
|
if (draw_flags & V3D_OFSDRAW_USE_GPENCIL) {
|
2018-07-31 10:22:19 +02:00
|
|
|
v3d.flag2 |= V3D_SHOW_ANNOTATION;
|
2012-10-16 11:57:46 +00:00
|
|
|
}
|
Remove Blender Internal and legacy viewport from Blender 2.8.
Brecht authored this commit, but he gave me the honours to actually
do it. Here it goes; Blender Internal. Bye bye, you did great!
* Point density, voxel data, ocean, environment map textures were removed,
as these only worked within BI rendering. Note that the ocean modifier
and the Cycles point density shader node continue to work.
* Dynamic paint using material shading was removed, as this only worked
with BI. If we ever wanted to support this again probably it should go
through the baking API.
* GPU shader export through the Python API was removed. This only worked
for the old BI GLSL shaders, which no longer exists. Doing something
similar for Eevee would be significantly more complicated because it
uses a lot of multiplass rendering and logic outside the shader, it's
probably impractical.
* Collada material import / export code is mostly gone, as it only worked
for BI materials. We need to add Cycles / Eevee material support at some
point.
* The mesh noise operator was removed since it only worked with BI
material texture slots. A displacement modifier can be used instead.
* The delete texture paint slot operator was removed since it only worked
for BI material texture slots. Could be added back with node support.
* Not all legacy viewport features are supported in the new viewport, but
their code was removed. If we need to bring anything back we can look at
older git revisions.
* There is some legacy viewport code that I could not remove yet, and some
that I probably missed.
* Shader node execution code was left mostly intact, even though it is not
used anywhere now. We may eventually use this to replace the texture
nodes with Cycles / Eevee shader nodes.
* The Cycles Bake panel now includes settings for baking multires normal
and displacement maps. The underlying code needs to be merged properly,
and we plan to add back support for multires AO baking and add support
to Cycles baking for features like vertex color, displacement, and other
missing baking features.
* This commit removes DNA and the Python API for BI material, lamp, world
and scene settings. This breaks a lot of addons.
* There is more DNA that can be removed or renamed, where Cycles or Eevee
are reusing some old BI properties but the names are not really correct
anymore.
* Texture slots for materials, lamps and world were removed. They remain
for brushes, particles and freestyle linestyles.
* 'BLENDER_RENDER' remains in the COMPAT_ENGINES of UI panels. Cycles and
other renderers use this to find all panels to show, minus a few panels
that they have their own replacement for.
2018-04-19 17:34:44 +02:00
|
|
|
|
2018-07-27 15:05:46 +02:00
|
|
|
v3d.shading.background_type = V3D_SHADING_BACKGROUND_WORLD;
|
Remove Blender Internal and legacy viewport from Blender 2.8.
Brecht authored this commit, but he gave me the honours to actually
do it. Here it goes; Blender Internal. Bye bye, you did great!
* Point density, voxel data, ocean, environment map textures were removed,
as these only worked within BI rendering. Note that the ocean modifier
and the Cycles point density shader node continue to work.
* Dynamic paint using material shading was removed, as this only worked
with BI. If we ever wanted to support this again probably it should go
through the baking API.
* GPU shader export through the Python API was removed. This only worked
for the old BI GLSL shaders, which no longer exists. Doing something
similar for Eevee would be significantly more complicated because it
uses a lot of multiplass rendering and logic outside the shader, it's
probably impractical.
* Collada material import / export code is mostly gone, as it only worked
for BI materials. We need to add Cycles / Eevee material support at some
point.
* The mesh noise operator was removed since it only worked with BI
material texture slots. A displacement modifier can be used instead.
* The delete texture paint slot operator was removed since it only worked
for BI material texture slots. Could be added back with node support.
* Not all legacy viewport features are supported in the new viewport, but
their code was removed. If we need to bring anything back we can look at
older git revisions.
* There is some legacy viewport code that I could not remove yet, and some
that I probably missed.
* Shader node execution code was left mostly intact, even though it is not
used anywhere now. We may eventually use this to replace the texture
nodes with Cycles / Eevee shader nodes.
* The Cycles Bake panel now includes settings for baking multires normal
and displacement maps. The underlying code needs to be merged properly,
and we plan to add back support for multires AO baking and add support
to Cycles baking for features like vertex color, displacement, and other
missing baking features.
* This commit removes DNA and the Python API for BI material, lamp, world
and scene settings. This breaks a lot of addons.
* There is more DNA that can be removed or renamed, where Cycles or Eevee
are reusing some old BI properties but the names are not really correct
anymore.
* Texture slots for materials, lamps and world were removed. They remain
for brushes, particles and freestyle linestyles.
* 'BLENDER_RENDER' remains in the COMPAT_ENGINES of UI panels. Cycles and
other renderers use this to find all panels to show, minus a few panels
that they have their own replacement for.
2018-04-19 17:34:44 +02:00
|
|
|
|
2017-11-27 14:08:35 +01:00
|
|
|
if (draw_flags & V3D_OFSDRAW_USE_CAMERA_DOF) {
|
|
|
|
if (camera->type == OB_CAMERA) {
|
|
|
|
v3d.fx_settings.dof = &((Camera *)camera->data)->gpu_dof;
|
|
|
|
v3d.fx_settings.fx_flag |= GPU_FX_FLAG_DOF;
|
|
|
|
}
|
2012-12-17 05:36:00 +00:00
|
|
|
}
|
2017-05-03 21:59:03 +10:00
|
|
|
|
|
|
|
rv3d.persp = RV3D_CAMOB;
|
|
|
|
|
|
|
|
copy_m4_m4(rv3d.viewinv, v3d.camera->obmat);
|
|
|
|
normalize_m4(rv3d.viewinv);
|
|
|
|
invert_m4_m4(rv3d.viewmat, rv3d.viewinv);
|
|
|
|
|
|
|
|
{
|
|
|
|
CameraParams params;
|
2018-05-25 11:05:51 +02:00
|
|
|
const Object *view_camera_eval = DEG_get_evaluated_object(
|
|
|
|
depsgraph,
|
|
|
|
BKE_camera_multiview_render(scene, v3d.camera, viewname));
|
2017-05-03 21:59:03 +10:00
|
|
|
|
|
|
|
BKE_camera_params_init(¶ms);
|
2018-05-25 11:05:51 +02:00
|
|
|
BKE_camera_params_from_object(¶ms, view_camera_eval);
|
|
|
|
BKE_camera_multiview_params(&scene->r, ¶ms, view_camera_eval, viewname);
|
2017-05-03 21:59:03 +10:00
|
|
|
BKE_camera_params_compute_viewplane(¶ms, width, height, scene->r.xasp, scene->r.yasp);
|
|
|
|
BKE_camera_params_compute_matrix(¶ms);
|
|
|
|
|
|
|
|
copy_m4_m4(rv3d.winmat, params.winmat);
|
2019-02-16 12:21:44 +11:00
|
|
|
v3d.clip_start = params.clip_start;
|
|
|
|
v3d.clip_end = params.clip_end;
|
2017-05-03 21:59:03 +10:00
|
|
|
v3d.lens = params.lens;
|
|
|
|
}
|
|
|
|
|
|
|
|
mul_m4_m4m4(rv3d.persmat, rv3d.winmat, rv3d.viewmat);
|
|
|
|
invert_m4_m4(rv3d.persinv, rv3d.viewinv);
|
|
|
|
|
|
|
|
return ED_view3d_draw_offscreen_imbuf(
|
Remove Blender Internal and legacy viewport from Blender 2.8.
Brecht authored this commit, but he gave me the honours to actually
do it. Here it goes; Blender Internal. Bye bye, you did great!
* Point density, voxel data, ocean, environment map textures were removed,
as these only worked within BI rendering. Note that the ocean modifier
and the Cycles point density shader node continue to work.
* Dynamic paint using material shading was removed, as this only worked
with BI. If we ever wanted to support this again probably it should go
through the baking API.
* GPU shader export through the Python API was removed. This only worked
for the old BI GLSL shaders, which no longer exists. Doing something
similar for Eevee would be significantly more complicated because it
uses a lot of multiplass rendering and logic outside the shader, it's
probably impractical.
* Collada material import / export code is mostly gone, as it only worked
for BI materials. We need to add Cycles / Eevee material support at some
point.
* The mesh noise operator was removed since it only worked with BI
material texture slots. A displacement modifier can be used instead.
* The delete texture paint slot operator was removed since it only worked
for BI material texture slots. Could be added back with node support.
* Not all legacy viewport features are supported in the new viewport, but
their code was removed. If we need to bring anything back we can look at
older git revisions.
* There is some legacy viewport code that I could not remove yet, and some
that I probably missed.
* Shader node execution code was left mostly intact, even though it is not
used anywhere now. We may eventually use this to replace the texture
nodes with Cycles / Eevee shader nodes.
* The Cycles Bake panel now includes settings for baking multires normal
and displacement maps. The underlying code needs to be merged properly,
and we plan to add back support for multires AO baking and add support
to Cycles baking for features like vertex color, displacement, and other
missing baking features.
* This commit removes DNA and the Python API for BI material, lamp, world
and scene settings. This breaks a lot of addons.
* There is more DNA that can be removed or renamed, where Cycles or Eevee
are reusing some old BI properties but the names are not really correct
anymore.
* Texture slots for materials, lamps and world were removed. They remain
for brushes, particles and freestyle linestyles.
* 'BLENDER_RENDER' remains in the COMPAT_ENGINES of UI panels. Cycles and
other renderers use this to find all panels to show, minus a few panels
that they have their own replacement for.
2018-04-19 17:34:44 +02:00
|
|
|
depsgraph, scene, drawtype,
|
2018-04-06 10:55:11 +02:00
|
|
|
&v3d, &ar, width, height, flag,
|
2018-03-22 16:10:54 +01:00
|
|
|
draw_flags, alpha_mode, samples, viewname, ofs, err_out);
|
2017-05-03 21:59:03 +10:00
|
|
|
}
|
|
|
|
|
2019-01-23 20:44:08 +11:00
|
|
|
/** \} */
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/** \name Viewport Clipping
|
|
|
|
* \{ */
|
|
|
|
|
|
|
|
static bool view3d_clipping_test(const float co[3], const float clip[6][4])
|
|
|
|
{
|
2019-03-26 21:16:47 +11:00
|
|
|
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) {
|
2019-01-23 20:44:08 +11:00
|
|
|
return false;
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-01-23 20:44:08 +11:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2017-05-03 21:59:03 +10:00
|
|
|
/** \} */
|