2008-12-18 17:38:21 +00:00
|
|
|
/**
|
2010-03-21 01:14:04 +00:00
|
|
|
* $Id$
|
2008-12-18 17:38:21 +00:00
|
|
|
*
|
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
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.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Contributor(s): Blender Foundation
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
#include "DNA_armature_types.h"
|
|
|
|
#include "DNA_camera_types.h"
|
2009-01-07 14:46:50 +00:00
|
|
|
#include "DNA_customdata_types.h"
|
2010-08-04 04:01:27 +00:00
|
|
|
#include "DNA_object_types.h"
|
2008-12-19 12:14:58 +00:00
|
|
|
#include "DNA_group_types.h"
|
2008-12-18 17:38:21 +00:00
|
|
|
#include "DNA_key_types.h"
|
2009-06-08 20:08:19 +00:00
|
|
|
#include "DNA_lamp_types.h"
|
2008-12-18 17:38:21 +00:00
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
#include "DNA_world_types.h"
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
#include "BLI_blenlib.h"
|
2009-11-10 20:43:45 +00:00
|
|
|
#include "BLI_math.h"
|
2008-12-18 17:38:21 +00:00
|
|
|
#include "BLI_rand.h"
|
|
|
|
|
|
|
|
#include "BKE_anim.h"
|
2.5
New: Custom region draw callbacks.
For Martin: an example is now in space_view3d/view3d_edit.c
On middlemouse rotate view, it draws a small square in center.
It works likes this:
#include "ED_space_api.h"
handle= ED_region_draw_cb_activate(region->type, drawfunc, type)
and to stop it:
ED_region_draw_cb_exit(region->type, handle)
drawfunc is of type (const bContext *C, ARegion *ar)
currently it gets called only as type REGION_DRAW_POST, later we
can add more (PRE, POST_XRAY, POST_2D, etc).
For correct usage, these calls should return leaving view transform
unaltered.
2009-01-09 15:04:52 +00:00
|
|
|
#include "BKE_context.h"
|
2009-01-07 14:46:50 +00:00
|
|
|
#include "BKE_customdata.h"
|
2008-12-18 17:38:21 +00:00
|
|
|
#include "BKE_image.h"
|
|
|
|
#include "BKE_key.h"
|
|
|
|
#include "BKE_object.h"
|
|
|
|
#include "BKE_global.h"
|
2009-08-15 19:48:50 +00:00
|
|
|
#include "BKE_paint.h"
|
2008-12-18 17:38:21 +00:00
|
|
|
#include "BKE_scene.h"
|
2009-08-12 14:11:53 +00:00
|
|
|
#include "BKE_unit.h"
|
2008-12-18 17:38:21 +00:00
|
|
|
|
|
|
|
#include "RE_pipeline.h" // make_stars
|
|
|
|
|
|
|
|
#include "IMB_imbuf_types.h"
|
|
|
|
#include "IMB_imbuf.h"
|
|
|
|
|
|
|
|
#include "BIF_gl.h"
|
|
|
|
#include "BIF_glutil.h"
|
|
|
|
|
|
|
|
#include "WM_api.h"
|
2009-05-05 23:10:32 +00:00
|
|
|
#include "BLF_api.h"
|
2008-12-18 17:38:21 +00:00
|
|
|
|
2009-01-07 14:46:50 +00: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"
|
2.5
New: Custom region draw callbacks.
For Martin: an example is now in space_view3d/view3d_edit.c
On middlemouse rotate view, it draws a small square in center.
It works likes this:
#include "ED_space_api.h"
handle= ED_region_draw_cb_activate(region->type, drawfunc, type)
and to stop it:
ED_region_draw_cb_exit(region->type, handle)
drawfunc is of type (const bContext *C, ARegion *ar)
currently it gets called only as type REGION_DRAW_POST, later we
can add more (PRE, POST_XRAY, POST_2D, etc).
For correct usage, these calls should return leaving view transform
unaltered.
2009-01-09 15:04:52 +00:00
|
|
|
#include "ED_space_api.h"
|
2010-02-12 00:44:26 +00:00
|
|
|
#include "ED_screen_types.h"
|
2009-07-08 16:17:47 +00:00
|
|
|
#include "ED_transform.h"
|
2008-12-18 17:38:21 +00:00
|
|
|
|
|
|
|
#include "UI_interface.h"
|
|
|
|
#include "UI_interface_icons.h"
|
|
|
|
#include "UI_resources.h"
|
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
#include "GPU_draw.h"
|
|
|
|
#include "GPU_material.h"
|
2010-03-08 20:08:04 +00:00
|
|
|
#include "GPU_extensions.h"
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2008-12-18 17:38:21 +00:00
|
|
|
#include "view3d_intern.h" // own include
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void star_stuff_init_func(void)
|
|
|
|
{
|
|
|
|
cpack(-1);
|
|
|
|
glPointSize(1.0);
|
|
|
|
glBegin(GL_POINTS);
|
|
|
|
}
|
|
|
|
static void star_stuff_vertex_func(float* i)
|
|
|
|
{
|
|
|
|
glVertex3fv(i);
|
|
|
|
}
|
|
|
|
static void star_stuff_term_func(void)
|
|
|
|
{
|
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
|
|
|
|
void circf(float x, float y, float rad)
|
|
|
|
{
|
|
|
|
GLUquadricObj *qobj = gluNewQuadric();
|
|
|
|
|
|
|
|
gluQuadricDrawStyle(qobj, GLU_FILL);
|
|
|
|
|
|
|
|
glPushMatrix();
|
|
|
|
|
|
|
|
glTranslatef(x, y, 0.);
|
|
|
|
|
|
|
|
gluDisk( qobj, 0.0, rad, 32, 1);
|
|
|
|
|
|
|
|
glPopMatrix();
|
|
|
|
|
|
|
|
gluDeleteQuadric(qobj);
|
|
|
|
}
|
|
|
|
|
|
|
|
void circ(float x, float y, float rad)
|
|
|
|
{
|
|
|
|
GLUquadricObj *qobj = gluNewQuadric();
|
|
|
|
|
|
|
|
gluQuadricDrawStyle(qobj, GLU_SILHOUETTE);
|
|
|
|
|
|
|
|
glPushMatrix();
|
|
|
|
|
|
|
|
glTranslatef(x, y, 0.);
|
|
|
|
|
|
|
|
gluDisk( qobj, 0.0, rad, 32, 1);
|
|
|
|
|
|
|
|
glPopMatrix();
|
|
|
|
|
|
|
|
gluDeleteQuadric(qobj);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ********* custom clipping *********** */
|
|
|
|
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
static void view3d_draw_clipping(RegionView3D *rv3d)
|
2008-12-18 17:38:21 +00:00
|
|
|
{
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
BoundBox *bb= rv3d->clipbb;
|
2008-12-18 17:38:21 +00:00
|
|
|
|
2009-01-20 18:31:11 +00:00
|
|
|
if(bb) {
|
|
|
|
UI_ThemeColorShade(TH_BACK, -8);
|
|
|
|
|
|
|
|
glBegin(GL_QUADS);
|
|
|
|
|
|
|
|
glVertex3fv(bb->vec[0]); glVertex3fv(bb->vec[1]); glVertex3fv(bb->vec[2]); glVertex3fv(bb->vec[3]);
|
|
|
|
glVertex3fv(bb->vec[0]); glVertex3fv(bb->vec[4]); glVertex3fv(bb->vec[5]); glVertex3fv(bb->vec[1]);
|
|
|
|
glVertex3fv(bb->vec[4]); glVertex3fv(bb->vec[7]); glVertex3fv(bb->vec[6]); glVertex3fv(bb->vec[5]);
|
|
|
|
glVertex3fv(bb->vec[7]); glVertex3fv(bb->vec[3]); glVertex3fv(bb->vec[2]); glVertex3fv(bb->vec[6]);
|
|
|
|
glVertex3fv(bb->vec[1]); glVertex3fv(bb->vec[5]); glVertex3fv(bb->vec[6]); glVertex3fv(bb->vec[2]);
|
|
|
|
glVertex3fv(bb->vec[7]); glVertex3fv(bb->vec[4]); glVertex3fv(bb->vec[0]); glVertex3fv(bb->vec[3]);
|
|
|
|
|
|
|
|
glEnd();
|
|
|
|
}
|
2008-12-18 17:38:21 +00:00
|
|
|
}
|
|
|
|
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
void view3d_set_clipping(RegionView3D *rv3d)
|
2008-12-18 17:38:21 +00:00
|
|
|
{
|
|
|
|
double plane[4];
|
2009-01-20 18:31:11 +00:00
|
|
|
int a, tot=4;
|
|
|
|
|
|
|
|
if(rv3d->viewlock) tot= 6;
|
2008-12-18 17:38:21 +00:00
|
|
|
|
2009-01-20 18:31:11 +00:00
|
|
|
for(a=0; a<tot; a++) {
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
QUATCOPY(plane, rv3d->clip[a]);
|
2008-12-18 17:38:21 +00:00
|
|
|
glClipPlane(GL_CLIP_PLANE0+a, plane);
|
|
|
|
glEnable(GL_CLIP_PLANE0+a);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void view3d_clr_clipping(void)
|
|
|
|
{
|
|
|
|
int a;
|
|
|
|
|
2009-01-20 18:31:11 +00:00
|
|
|
for(a=0; a<6; a++) {
|
2008-12-18 17:38:21 +00:00
|
|
|
glDisable(GL_CLIP_PLANE0+a);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-23 09:28:42 +00:00
|
|
|
static int test_clipping(float *vec, float clip[][4])
|
2008-12-18 17:38:21 +00:00
|
|
|
{
|
|
|
|
float view[3];
|
2010-07-26 06:34:56 +00:00
|
|
|
copy_v3_v3(view, vec);
|
2008-12-18 17:38:21 +00:00
|
|
|
|
2009-11-21 16:44:05 +00:00
|
|
|
if(0.0f < clip[0][3] + INPR(view, clip[0]))
|
|
|
|
if(0.0f < clip[1][3] + INPR(view, clip[1]))
|
|
|
|
if(0.0f < clip[2][3] + INPR(view, clip[2]))
|
|
|
|
if(0.0f < clip[3][3] + INPR(view, clip[3]))
|
2008-12-18 17:38:21 +00:00
|
|
|
return 0;
|
2009-11-21 16:44:05 +00:00
|
|
|
|
2008-12-18 17:38:21 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2009-11-21 16:44:05 +00:00
|
|
|
/* for 'local' ED_view3d_local_clipping must run first
|
|
|
|
* then all comparisons can be done in localspace */
|
|
|
|
int view3d_test_clipping(RegionView3D *rv3d, float *vec, int local)
|
|
|
|
{
|
|
|
|
return test_clipping(vec, local ? rv3d->clip_local : rv3d->clip);
|
|
|
|
}
|
|
|
|
|
2008-12-18 17:38:21 +00:00
|
|
|
/* ********* end custom clipping *********** */
|
|
|
|
|
|
|
|
|
|
|
|
static void drawgrid_draw(ARegion *ar, float wx, float wy, float x, float y, float dx)
|
2010-07-30 08:43:22 +00:00
|
|
|
{
|
|
|
|
float v1[2], v2[2];
|
|
|
|
|
2008-12-18 17:38:21 +00:00
|
|
|
x+= (wx);
|
|
|
|
y+= (wy);
|
2010-07-30 08:43:22 +00:00
|
|
|
|
|
|
|
v1[1]= 0.0f;
|
|
|
|
v2[1]= (float)ar->winy;
|
|
|
|
|
|
|
|
v1[0] = v2[0] = x-dx*floor(x/dx);
|
2008-12-18 17:38:21 +00:00
|
|
|
|
2010-07-30 08:43:22 +00:00
|
|
|
glBegin(GL_LINES);
|
|
|
|
|
|
|
|
while(v1[0] < ar->winx) {
|
|
|
|
glVertex2fv(v1);
|
|
|
|
glVertex2fv(v2);
|
|
|
|
v1[0] = v2[0] = v1[0] + dx;
|
2008-12-18 17:38:21 +00:00
|
|
|
}
|
|
|
|
|
2010-07-30 08:43:22 +00:00
|
|
|
v1[0]= 0.0f;
|
|
|
|
v2[0]= (float)ar->winx;
|
2008-12-18 17:38:21 +00:00
|
|
|
|
2010-07-30 08:43:22 +00:00
|
|
|
v1[1]= v2[1]= y-dx*floor(y/dx);
|
|
|
|
|
|
|
|
while(v1[1] < ar->winy) {
|
|
|
|
glVertex2fv(v1);
|
|
|
|
glVertex2fv(v2);
|
|
|
|
v1[1] = v2[1] = v1[1] + dx;
|
2008-12-18 17:38:21 +00:00
|
|
|
}
|
|
|
|
|
2010-07-30 08:43:22 +00:00
|
|
|
glEnd();
|
2008-12-18 17:38:21 +00:00
|
|
|
}
|
|
|
|
|
2009-08-12 14:11:53 +00:00
|
|
|
#define GRID_MIN_PX 6.0f
|
|
|
|
|
2009-08-13 07:37:41 +00:00
|
|
|
static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, char **grid_unit)
|
2008-12-18 17:38:21 +00:00
|
|
|
{
|
|
|
|
/* extern short bgpicmode; */
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
RegionView3D *rv3d= ar->regiondata;
|
2008-12-18 17:38:21 +00:00
|
|
|
float wx, wy, x, y, fw, fx, fy, dx;
|
|
|
|
float vec4[4];
|
|
|
|
char col[3], col2[3];
|
|
|
|
|
2009-08-12 14:11:53 +00:00
|
|
|
*grid_unit= NULL;
|
|
|
|
|
2008-12-18 17:38:21 +00:00
|
|
|
vec4[0]=vec4[1]=vec4[2]=0.0;
|
|
|
|
vec4[3]= 1.0;
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_m4_v4(rv3d->persmat, vec4);
|
2008-12-18 17:38:21 +00:00
|
|
|
fx= vec4[0];
|
|
|
|
fy= vec4[1];
|
|
|
|
fw= vec4[3];
|
|
|
|
|
|
|
|
wx= (ar->winx/2.0); /* because of rounding errors, grid at wrong location */
|
|
|
|
wy= (ar->winy/2.0);
|
|
|
|
|
|
|
|
x= (wx)*fx/fw;
|
|
|
|
y= (wy)*fy/fw;
|
|
|
|
|
2009-08-13 07:37:41 +00:00
|
|
|
vec4[0]=vec4[1]= (unit->system) ? 1.0 : v3d->grid;
|
2009-08-12 17:02:03 +00:00
|
|
|
|
2008-12-18 17:38:21 +00:00
|
|
|
vec4[2]= 0.0;
|
|
|
|
vec4[3]= 1.0;
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_m4_v4(rv3d->persmat, vec4);
|
2008-12-18 17:38:21 +00:00
|
|
|
fx= vec4[0];
|
|
|
|
fy= vec4[1];
|
|
|
|
fw= vec4[3];
|
|
|
|
|
|
|
|
dx= fabs(x-(wx)*fx/fw);
|
|
|
|
if(dx==0) dx= fabs(y-(wy)*fy/fw);
|
|
|
|
|
|
|
|
glDepthMask(0); // disable write in zbuffer
|
|
|
|
|
|
|
|
/* check zoom out */
|
|
|
|
UI_ThemeColor(TH_GRID);
|
|
|
|
|
2009-08-13 07:37:41 +00:00
|
|
|
if(unit->system) {
|
2009-08-12 17:02:03 +00:00
|
|
|
/* Use GRID_MIN_PX*2 for units because very very small grid
|
|
|
|
* items are less useful when dealing with units */
|
2009-08-12 14:11:53 +00:00
|
|
|
void *usys;
|
|
|
|
int len, i;
|
|
|
|
double scalar;
|
|
|
|
float dx_scalar;
|
|
|
|
float blend_fac;
|
|
|
|
|
2009-08-13 07:37:41 +00:00
|
|
|
bUnit_GetSystem(&usys, &len, unit->system, B_UNIT_LENGTH);
|
2009-08-12 14:11:53 +00:00
|
|
|
|
|
|
|
if(usys) {
|
|
|
|
i= len;
|
|
|
|
while(i--) {
|
|
|
|
scalar= bUnit_GetScaler(usys, i);
|
|
|
|
|
2010-04-05 05:32:16 +00:00
|
|
|
dx_scalar = dx * scalar / unit->scale_length;
|
2009-08-12 17:02:03 +00:00
|
|
|
if (dx_scalar < (GRID_MIN_PX*2))
|
2009-08-12 14:11:53 +00:00
|
|
|
continue;
|
|
|
|
|
2009-08-12 17:02:03 +00:00
|
|
|
/* Store the smallest drawn grid size units name so users know how big each grid cell is */
|
|
|
|
if(*grid_unit==NULL) {
|
2009-08-17 12:48:56 +00:00
|
|
|
*grid_unit= bUnit_GetNameDisplay(usys, i);
|
2009-12-27 18:09:17 +00:00
|
|
|
rv3d->gridview= (scalar * unit->scale_length);
|
2009-08-12 17:02:03 +00:00
|
|
|
}
|
|
|
|
blend_fac= 1-((GRID_MIN_PX*2)/dx_scalar);
|
2009-08-12 14:11:53 +00:00
|
|
|
|
|
|
|
/* tweak to have the fade a bit nicer */
|
|
|
|
blend_fac= (blend_fac * blend_fac) * 2.0f;
|
|
|
|
CLAMP(blend_fac, 0.3f, 1.0f);
|
|
|
|
|
|
|
|
|
|
|
|
UI_ThemeColorBlend(TH_BACK, TH_GRID, blend_fac);
|
|
|
|
|
|
|
|
drawgrid_draw(ar, wx, wy, x, y, dx_scalar);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2009-08-12 17:02:03 +00:00
|
|
|
short sublines = v3d->gridsubdiv;
|
|
|
|
|
2009-08-12 14:11:53 +00:00
|
|
|
if(dx<GRID_MIN_PX) {
|
2009-12-27 18:09:17 +00:00
|
|
|
rv3d->gridview*= sublines;
|
2008-12-18 17:38:21 +00:00
|
|
|
dx*= sublines;
|
|
|
|
|
2009-08-12 14:11:53 +00:00
|
|
|
if(dx<GRID_MIN_PX) {
|
2009-12-27 18:09:17 +00:00
|
|
|
rv3d->gridview*= sublines;
|
2009-08-12 14:11:53 +00:00
|
|
|
dx*= sublines;
|
|
|
|
|
|
|
|
if(dx<GRID_MIN_PX) {
|
2009-12-27 18:09:17 +00:00
|
|
|
rv3d->gridview*= sublines;
|
2009-08-12 14:11:53 +00:00
|
|
|
dx*=sublines;
|
|
|
|
if(dx<GRID_MIN_PX);
|
|
|
|
else {
|
|
|
|
UI_ThemeColor(TH_GRID);
|
|
|
|
drawgrid_draw(ar, wx, wy, x, y, dx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else { // start blending out
|
2009-12-07 00:50:40 +00:00
|
|
|
UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/(GRID_MIN_PX*6));
|
2008-12-18 17:38:21 +00:00
|
|
|
drawgrid_draw(ar, wx, wy, x, y, dx);
|
2009-08-12 14:11:53 +00:00
|
|
|
|
|
|
|
UI_ThemeColor(TH_GRID);
|
|
|
|
drawgrid_draw(ar, wx, wy, x, y, sublines*dx);
|
2008-12-18 17:38:21 +00:00
|
|
|
}
|
|
|
|
}
|
2009-08-12 14:11:53 +00:00
|
|
|
else { // start blending out (GRID_MIN_PX < dx < (GRID_MIN_PX*10))
|
2009-12-07 00:50:40 +00:00
|
|
|
UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/(GRID_MIN_PX*6));
|
2008-12-18 17:38:21 +00:00
|
|
|
drawgrid_draw(ar, wx, wy, x, y, dx);
|
2009-08-12 14:11:53 +00:00
|
|
|
|
2008-12-18 17:38:21 +00:00
|
|
|
UI_ThemeColor(TH_GRID);
|
|
|
|
drawgrid_draw(ar, wx, wy, x, y, sublines*dx);
|
|
|
|
}
|
|
|
|
}
|
2009-08-12 14:11:53 +00:00
|
|
|
else {
|
|
|
|
if(dx>(GRID_MIN_PX*10)) { // start blending in
|
2009-12-27 18:09:17 +00:00
|
|
|
rv3d->gridview/= sublines;
|
2008-12-18 17:38:21 +00:00
|
|
|
dx/= sublines;
|
2009-08-12 14:11:53 +00:00
|
|
|
if(dx>(GRID_MIN_PX*10)) { // start blending in
|
2009-12-27 18:09:17 +00:00
|
|
|
rv3d->gridview/= sublines;
|
2009-08-12 14:11:53 +00:00
|
|
|
dx/= sublines;
|
|
|
|
if(dx>(GRID_MIN_PX*10)) {
|
|
|
|
UI_ThemeColor(TH_GRID);
|
|
|
|
drawgrid_draw(ar, wx, wy, x, y, dx);
|
|
|
|
}
|
|
|
|
else {
|
2009-12-07 00:50:40 +00:00
|
|
|
UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/(GRID_MIN_PX*6));
|
2009-08-12 14:11:53 +00:00
|
|
|
drawgrid_draw(ar, wx, wy, x, y, dx);
|
|
|
|
UI_ThemeColor(TH_GRID);
|
|
|
|
drawgrid_draw(ar, wx, wy, x, y, dx*sublines);
|
|
|
|
}
|
2008-12-18 17:38:21 +00:00
|
|
|
}
|
|
|
|
else {
|
2009-12-07 00:50:40 +00:00
|
|
|
UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/(GRID_MIN_PX*6));
|
2008-12-18 17:38:21 +00:00
|
|
|
drawgrid_draw(ar, wx, wy, x, y, dx);
|
|
|
|
UI_ThemeColor(TH_GRID);
|
|
|
|
drawgrid_draw(ar, wx, wy, x, y, dx*sublines);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2009-12-07 00:50:40 +00:00
|
|
|
UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/(GRID_MIN_PX*6));
|
2008-12-18 17:38:21 +00:00
|
|
|
drawgrid_draw(ar, wx, wy, x, y, dx);
|
2009-08-12 14:11:53 +00:00
|
|
|
UI_ThemeColor(TH_GRID);
|
2008-12-18 17:38:21 +00:00
|
|
|
drawgrid_draw(ar, wx, wy, x, y, dx*sublines);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-12 14:11:53 +00:00
|
|
|
|
2008-12-18 17:38:21 +00:00
|
|
|
x+= (wx);
|
|
|
|
y+= (wy);
|
|
|
|
UI_GetThemeColor3ubv(TH_GRID, col);
|
|
|
|
|
|
|
|
setlinestyle(0);
|
|
|
|
|
|
|
|
/* center cross */
|
2009-10-27 02:54:25 +00:00
|
|
|
if( ELEM(rv3d->view, RV3D_VIEW_RIGHT, RV3D_VIEW_LEFT))
|
2009-04-30 11:47:35 +00:00
|
|
|
UI_make_axis_color(col, col2, 'y');
|
|
|
|
else UI_make_axis_color(col, col2, 'x');
|
2008-12-18 17:38:21 +00:00
|
|
|
glColor3ubv((GLubyte *)col2);
|
|
|
|
|
|
|
|
fdrawline(0.0, y, (float)ar->winx, y);
|
|
|
|
|
2009-10-27 02:54:25 +00:00
|
|
|
if( ELEM(rv3d->view, RV3D_VIEW_TOP, RV3D_VIEW_BOTTOM))
|
2009-04-30 11:47:35 +00:00
|
|
|
UI_make_axis_color(col, col2, 'y');
|
|
|
|
else UI_make_axis_color(col, col2, 'z');
|
2008-12-18 17:38:21 +00:00
|
|
|
glColor3ubv((GLubyte *)col2);
|
|
|
|
|
|
|
|
fdrawline(x, 0.0, x, (float)ar->winy);
|
|
|
|
|
|
|
|
glDepthMask(1); // enable write in zbuffer
|
|
|
|
}
|
2009-08-12 14:11:53 +00:00
|
|
|
#undef GRID_MIN_PX
|
2008-12-18 17:38:21 +00:00
|
|
|
|
2009-01-02 19:10:35 +00:00
|
|
|
static void drawfloor(Scene *scene, View3D *v3d)
|
2008-12-18 17:38:21 +00:00
|
|
|
{
|
|
|
|
float vert[3], grid;
|
|
|
|
int a, gridlines, emphasise;
|
|
|
|
char col[3], col2[3];
|
|
|
|
short draw_line = 0;
|
|
|
|
|
|
|
|
vert[2]= 0.0;
|
|
|
|
|
|
|
|
if(v3d->gridlines<3) return;
|
|
|
|
|
2009-01-02 19:10:35 +00:00
|
|
|
if(v3d->zbuf && scene->obedit) glDepthMask(0); // for zbuffer-select
|
2008-12-18 17:38:21 +00:00
|
|
|
|
|
|
|
gridlines= v3d->gridlines/2;
|
|
|
|
grid= gridlines*v3d->grid;
|
|
|
|
|
|
|
|
UI_GetThemeColor3ubv(TH_GRID, col);
|
|
|
|
UI_GetThemeColor3ubv(TH_BACK, col2);
|
|
|
|
|
|
|
|
/* emphasise division lines lighter instead of darker, if background is darker than grid */
|
|
|
|
if ( ((col[0]+col[1]+col[2])/3+10) > (col2[0]+col2[1]+col2[2])/3 )
|
|
|
|
emphasise = 20;
|
|
|
|
else
|
|
|
|
emphasise = -10;
|
|
|
|
|
|
|
|
/* draw the Y axis and/or grid lines */
|
|
|
|
for(a= -gridlines;a<=gridlines;a++) {
|
|
|
|
if(a==0) {
|
|
|
|
/* check for the 'show Y axis' preference */
|
|
|
|
if (v3d->gridflag & V3D_SHOW_Y) {
|
2009-04-30 11:47:35 +00:00
|
|
|
UI_make_axis_color(col, col2, 'y');
|
2008-12-18 17:38:21 +00:00
|
|
|
glColor3ubv((GLubyte *)col2);
|
|
|
|
|
|
|
|
draw_line = 1;
|
|
|
|
} else if (v3d->gridflag & V3D_SHOW_FLOOR) {
|
|
|
|
UI_ThemeColorShade(TH_GRID, emphasise);
|
|
|
|
} else {
|
|
|
|
draw_line = 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* check for the 'show grid floor' preference */
|
|
|
|
if (v3d->gridflag & V3D_SHOW_FLOOR) {
|
|
|
|
if( (a % 10)==0) {
|
|
|
|
UI_ThemeColorShade(TH_GRID, emphasise);
|
|
|
|
}
|
|
|
|
else UI_ThemeColorShade(TH_GRID, 10);
|
|
|
|
|
|
|
|
draw_line = 1;
|
|
|
|
} else {
|
|
|
|
draw_line = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (draw_line) {
|
|
|
|
glBegin(GL_LINE_STRIP);
|
2010-03-22 09:30:00 +00:00
|
|
|
vert[0]= a*v3d->grid;
|
|
|
|
vert[1]= grid;
|
|
|
|
glVertex3fv(vert);
|
|
|
|
vert[1]= -grid;
|
|
|
|
glVertex3fv(vert);
|
2008-12-18 17:38:21 +00:00
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* draw the X axis and/or grid lines */
|
|
|
|
for(a= -gridlines;a<=gridlines;a++) {
|
|
|
|
if(a==0) {
|
|
|
|
/* check for the 'show X axis' preference */
|
|
|
|
if (v3d->gridflag & V3D_SHOW_X) {
|
2009-04-30 11:47:35 +00:00
|
|
|
UI_make_axis_color(col, col2, 'x');
|
2008-12-18 17:38:21 +00:00
|
|
|
glColor3ubv((GLubyte *)col2);
|
|
|
|
|
|
|
|
draw_line = 1;
|
|
|
|
} else if (v3d->gridflag & V3D_SHOW_FLOOR) {
|
|
|
|
UI_ThemeColorShade(TH_GRID, emphasise);
|
|
|
|
} else {
|
|
|
|
draw_line = 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* check for the 'show grid floor' preference */
|
|
|
|
if (v3d->gridflag & V3D_SHOW_FLOOR) {
|
|
|
|
if( (a % 10)==0) {
|
|
|
|
UI_ThemeColorShade(TH_GRID, emphasise);
|
|
|
|
}
|
|
|
|
else UI_ThemeColorShade(TH_GRID, 10);
|
|
|
|
|
|
|
|
draw_line = 1;
|
|
|
|
} else {
|
|
|
|
draw_line = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (draw_line) {
|
|
|
|
glBegin(GL_LINE_STRIP);
|
2010-03-22 09:30:00 +00:00
|
|
|
vert[1]= a*v3d->grid;
|
|
|
|
vert[0]= grid;
|
|
|
|
glVertex3fv(vert );
|
|
|
|
vert[0]= -grid;
|
|
|
|
glVertex3fv(vert);
|
2008-12-18 17:38:21 +00:00
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* draw the Z axis line */
|
|
|
|
/* check for the 'show Z axis' preference */
|
|
|
|
if (v3d->gridflag & V3D_SHOW_Z) {
|
2009-04-30 11:47:35 +00:00
|
|
|
UI_make_axis_color(col, col2, 'z');
|
2008-12-18 17:38:21 +00:00
|
|
|
glColor3ubv((GLubyte *)col2);
|
|
|
|
|
|
|
|
glBegin(GL_LINE_STRIP);
|
|
|
|
vert[0]= 0;
|
|
|
|
vert[1]= 0;
|
|
|
|
vert[2]= grid;
|
|
|
|
glVertex3fv(vert );
|
|
|
|
vert[2]= -grid;
|
|
|
|
glVertex3fv(vert);
|
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
|
2009-01-02 19:10:35 +00:00
|
|
|
if(v3d->zbuf && scene->obedit) glDepthMask(1);
|
2008-12-18 17:38:21 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void drawcursor(Scene *scene, ARegion *ar, View3D *v3d)
|
|
|
|
{
|
|
|
|
short mx,my,co[2];
|
|
|
|
int flag;
|
|
|
|
|
|
|
|
/* we dont want the clipping for cursor */
|
|
|
|
flag= v3d->flag;
|
|
|
|
v3d->flag= 0;
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
project_short(ar, give_cursor(scene, v3d), co);
|
2008-12-18 17:38:21 +00:00
|
|
|
v3d->flag= flag;
|
|
|
|
|
|
|
|
mx = co[0];
|
|
|
|
my = co[1];
|
|
|
|
|
|
|
|
if(mx!=IS_CLIPPED) {
|
|
|
|
setlinestyle(0);
|
|
|
|
cpack(0xFF);
|
|
|
|
circ((float)mx, (float)my, 10.0);
|
|
|
|
setlinestyle(4);
|
|
|
|
cpack(0xFFFFFF);
|
|
|
|
circ((float)mx, (float)my, 10.0);
|
|
|
|
setlinestyle(0);
|
|
|
|
cpack(0x0);
|
|
|
|
|
|
|
|
sdrawline(mx-20, my, mx-5, my);
|
|
|
|
sdrawline(mx+5, my, mx+20, my);
|
|
|
|
sdrawline(mx, my-20, mx, my-5);
|
|
|
|
sdrawline(mx, my+5, mx, my+20);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Draw a live substitute of the view icon, which is always shown */
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
static void draw_view_axis(RegionView3D *rv3d)
|
2008-12-18 17:38:21 +00:00
|
|
|
{
|
|
|
|
const float k = U.rvisize; /* axis size */
|
|
|
|
const float toll = 0.5; /* used to see when view is quasi-orthogonal */
|
|
|
|
const float start = k + 1.0; /* axis center in screen coordinates, x=y */
|
|
|
|
float ydisp = 0.0; /* vertical displacement to allow obj info text */
|
|
|
|
|
|
|
|
/* rvibright ranges approx. from original axis icon color to gizmo color */
|
|
|
|
float bright = U.rvibright / 15.0f;
|
|
|
|
|
|
|
|
unsigned char col[3];
|
|
|
|
unsigned char gridcol[3];
|
|
|
|
float colf[3];
|
|
|
|
|
|
|
|
float vec[4];
|
|
|
|
float dx, dy;
|
|
|
|
float h, s, v;
|
|
|
|
|
|
|
|
/* thickness of lines is proportional to k */
|
|
|
|
/* (log(k)-1) gives a more suitable thickness, but fps decreased by about 3 fps */
|
|
|
|
glLineWidth(k / 10);
|
|
|
|
//glLineWidth(log(k)-1); // a bit slow
|
|
|
|
|
|
|
|
UI_GetThemeColor3ubv(TH_GRID, (char *)gridcol);
|
|
|
|
|
|
|
|
/* X */
|
|
|
|
vec[0] = vec[3] = 1;
|
|
|
|
vec[1] = vec[2] = 0;
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_qt_v3(rv3d->viewquat, vec);
|
2008-12-18 17:38:21 +00:00
|
|
|
|
2009-04-30 11:47:35 +00:00
|
|
|
UI_make_axis_color((char *)gridcol, (char *)col, 'x');
|
2008-12-18 17:38:21 +00:00
|
|
|
rgb_to_hsv(col[0]/255.0f, col[1]/255.0f, col[2]/255.0f, &h, &s, &v);
|
|
|
|
s = s<0.5 ? s+0.5 : 1.0;
|
|
|
|
v = 0.3;
|
|
|
|
v = (v<1.0-(bright) ? v+bright : 1.0);
|
|
|
|
hsv_to_rgb(h, s, v, colf, colf+1, colf+2);
|
|
|
|
glColor3fv(colf);
|
|
|
|
|
|
|
|
dx = vec[0] * k;
|
|
|
|
dy = vec[1] * k;
|
|
|
|
fdrawline(start, start + ydisp, start + dx, start + dy + ydisp);
|
|
|
|
if (fabs(dx) > toll || fabs(dy) > toll) {
|
2009-05-05 23:10:32 +00:00
|
|
|
BLF_draw_default(start + dx + 2, start + dy + ydisp + 2, 0.0f, "x");
|
2008-12-18 17:38:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Y */
|
|
|
|
vec[1] = vec[3] = 1;
|
|
|
|
vec[0] = vec[2] = 0;
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_qt_v3(rv3d->viewquat, vec);
|
2008-12-18 17:38:21 +00:00
|
|
|
|
2009-04-30 11:47:35 +00:00
|
|
|
UI_make_axis_color((char *)gridcol, (char *)col, 'y');
|
2008-12-18 17:38:21 +00:00
|
|
|
rgb_to_hsv(col[0]/255.0f, col[1]/255.0f, col[2]/255.0f, &h, &s, &v);
|
|
|
|
s = s<0.5 ? s+0.5 : 1.0;
|
|
|
|
v = 0.3;
|
|
|
|
v = (v<1.0-(bright) ? v+bright : 1.0);
|
|
|
|
hsv_to_rgb(h, s, v, colf, colf+1, colf+2);
|
|
|
|
glColor3fv(colf);
|
|
|
|
|
|
|
|
dx = vec[0] * k;
|
|
|
|
dy = vec[1] * k;
|
|
|
|
fdrawline(start, start + ydisp, start + dx, start + dy + ydisp);
|
|
|
|
if (fabs(dx) > toll || fabs(dy) > toll) {
|
2009-05-05 23:10:32 +00:00
|
|
|
BLF_draw_default(start + dx + 2, start + dy + ydisp + 2, 0.0f, "y");
|
2008-12-18 17:38:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Z */
|
|
|
|
vec[2] = vec[3] = 1;
|
|
|
|
vec[1] = vec[0] = 0;
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_qt_v3(rv3d->viewquat, vec);
|
2008-12-18 17:38:21 +00:00
|
|
|
|
2009-04-30 11:47:35 +00:00
|
|
|
UI_make_axis_color((char *)gridcol, (char *)col, 'z');
|
2008-12-18 17:38:21 +00:00
|
|
|
rgb_to_hsv(col[0]/255.0f, col[1]/255.0f, col[2]/255.0f, &h, &s, &v);
|
|
|
|
s = s<0.5 ? s+0.5 : 1.0;
|
|
|
|
v = 0.5;
|
|
|
|
v = (v<1.0-(bright) ? v+bright : 1.0);
|
|
|
|
hsv_to_rgb(h, s, v, colf, colf+1, colf+2);
|
|
|
|
glColor3fv(colf);
|
|
|
|
|
|
|
|
dx = vec[0] * k;
|
|
|
|
dy = vec[1] * k;
|
|
|
|
fdrawline(start, start + ydisp, start + dx, start + dy + ydisp);
|
|
|
|
if (fabs(dx) > toll || fabs(dy) > toll) {
|
2009-05-05 23:10:32 +00:00
|
|
|
BLF_draw_default(start + dx + 2, start + dy + ydisp + 2, 0.0f, "z");
|
2008-12-18 17:38:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* restore line-width */
|
|
|
|
glLineWidth(1.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
static void draw_view_icon(RegionView3D *rv3d)
|
2008-12-18 17:38:21 +00:00
|
|
|
{
|
|
|
|
BIFIconID icon;
|
|
|
|
|
2009-10-27 02:54:25 +00:00
|
|
|
if( ELEM(rv3d->view, RV3D_VIEW_TOP, RV3D_VIEW_BOTTOM))
|
2009-01-20 19:03:26 +00:00
|
|
|
icon= ICON_AXIS_TOP;
|
2009-10-27 02:54:25 +00:00
|
|
|
else if( ELEM(rv3d->view, RV3D_VIEW_FRONT, RV3D_VIEW_BACK))
|
2009-01-20 19:03:26 +00:00
|
|
|
icon= ICON_AXIS_FRONT;
|
2009-10-27 02:54:25 +00:00
|
|
|
else if( ELEM(rv3d->view, RV3D_VIEW_RIGHT, RV3D_VIEW_LEFT))
|
2009-01-20 19:03:26 +00:00
|
|
|
icon= ICON_AXIS_SIDE;
|
2008-12-18 17:38:21 +00:00
|
|
|
else return ;
|
|
|
|
|
|
|
|
glEnable(GL_BLEND);
|
|
|
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
|
|
|
|
|
|
UI_icon_draw(5.0, 5.0, icon);
|
|
|
|
|
|
|
|
glDisable(GL_BLEND);
|
|
|
|
}
|
|
|
|
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
static char *view3d_get_name(View3D *v3d, RegionView3D *rv3d)
|
2008-12-18 17:38:21 +00:00
|
|
|
{
|
|
|
|
char *name = NULL;
|
|
|
|
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
switch (rv3d->view) {
|
2009-10-27 02:54:25 +00:00
|
|
|
case RV3D_VIEW_FRONT:
|
|
|
|
if (rv3d->persp == RV3D_ORTHO) name = "Front Ortho";
|
2009-01-20 14:23:32 +00:00
|
|
|
else name = "Front Persp";
|
2008-12-18 17:38:21 +00:00
|
|
|
break;
|
2009-10-27 02:54:25 +00:00
|
|
|
case RV3D_VIEW_BACK:
|
|
|
|
if (rv3d->persp == RV3D_ORTHO) name = "Back Ortho";
|
2009-01-20 14:23:32 +00:00
|
|
|
else name = "Back Persp";
|
2008-12-18 17:38:21 +00:00
|
|
|
break;
|
2009-10-27 02:54:25 +00:00
|
|
|
case RV3D_VIEW_TOP:
|
|
|
|
if (rv3d->persp == RV3D_ORTHO) name = "Top Ortho";
|
2009-01-20 14:23:32 +00:00
|
|
|
else name = "Top Persp";
|
2008-12-18 17:38:21 +00:00
|
|
|
break;
|
2009-10-27 02:54:25 +00:00
|
|
|
case RV3D_VIEW_BOTTOM:
|
|
|
|
if (rv3d->persp == RV3D_ORTHO) name = "Bottom Ortho";
|
2009-01-20 14:23:32 +00:00
|
|
|
else name = "Bottom Persp";
|
|
|
|
break;
|
2009-10-27 02:54:25 +00:00
|
|
|
case RV3D_VIEW_RIGHT:
|
|
|
|
if (rv3d->persp == RV3D_ORTHO) name = "Right Ortho";
|
2009-01-20 14:23:32 +00:00
|
|
|
else name = "Right Persp";
|
|
|
|
break;
|
2009-10-27 02:54:25 +00:00
|
|
|
case RV3D_VIEW_LEFT:
|
|
|
|
if (rv3d->persp == RV3D_ORTHO) name = "Left Ortho";
|
2009-01-20 14:23:32 +00:00
|
|
|
else name = "Left Persp";
|
|
|
|
break;
|
|
|
|
|
2008-12-18 17:38:21 +00:00
|
|
|
default:
|
2009-10-27 02:54:25 +00:00
|
|
|
if (rv3d->persp==RV3D_CAMOB) {
|
2008-12-18 17:38:21 +00:00
|
|
|
if ((v3d->camera) && (v3d->camera->type == OB_CAMERA)) {
|
|
|
|
Camera *cam;
|
|
|
|
cam = v3d->camera->data;
|
|
|
|
name = (cam->type != CAM_ORTHO) ? "Camera Persp" : "Camera Ortho";
|
|
|
|
} else {
|
|
|
|
name = "Object as Camera";
|
|
|
|
}
|
|
|
|
} else {
|
2009-10-27 02:54:25 +00:00
|
|
|
name = (rv3d->persp == RV3D_ORTHO) ? "User Ortho" : "User Persp";
|
2008-12-18 17:38:21 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void draw_viewport_name(ARegion *ar, View3D *v3d)
|
|
|
|
{
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
RegionView3D *rv3d= ar->regiondata;
|
|
|
|
char *name = view3d_get_name(v3d, rv3d);
|
2008-12-18 17:38:21 +00:00
|
|
|
char *printable = NULL;
|
|
|
|
|
2009-09-22 04:40:16 +00:00
|
|
|
if (v3d->localvd) {
|
2010-02-08 13:55:31 +00:00
|
|
|
printable = MEM_mallocN(strlen(name) + strlen(" (Local)_"), "viewport_name"); /* '_' gives space for '\0' */
|
2008-12-18 17:38:21 +00:00
|
|
|
strcpy(printable, name);
|
|
|
|
strcat(printable, " (Local)");
|
|
|
|
} else {
|
|
|
|
printable = name;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (printable) {
|
|
|
|
UI_ThemeColor(TH_TEXT_HI);
|
2009-09-13 03:08:46 +00:00
|
|
|
BLF_draw_default(22, ar->winy-17, 0.0f, printable);
|
2008-12-18 17:38:21 +00:00
|
|
|
}
|
|
|
|
|
2009-09-22 04:40:16 +00:00
|
|
|
if (v3d->localvd) {
|
2010-02-08 13:55:31 +00:00
|
|
|
MEM_freeN(printable);
|
2008-12-18 17:38:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* draw info beside axes in bottom left-corner:
|
|
|
|
* framenum, object name, bone name (if available), marker name (if available)
|
|
|
|
*/
|
|
|
|
static void draw_selected_name(Scene *scene, Object *ob, View3D *v3d)
|
|
|
|
{
|
|
|
|
char info[256], *markern;
|
|
|
|
short offset=30;
|
|
|
|
|
|
|
|
/* get name of marker on current frame (if available) */
|
2010-02-06 14:56:25 +00:00
|
|
|
markern= scene_find_marker_name(scene, CFRA);
|
2008-12-18 17:38:21 +00:00
|
|
|
|
|
|
|
/* check if there is an object */
|
|
|
|
if(ob) {
|
|
|
|
/* name(s) to display depends on type of object */
|
|
|
|
if(ob->type==OB_ARMATURE) {
|
|
|
|
bArmature *arm= ob->data;
|
|
|
|
char *name= NULL;
|
|
|
|
|
|
|
|
/* show name of active bone too (if possible) */
|
2009-01-02 19:10:35 +00:00
|
|
|
if(arm->edbo) {
|
2009-11-09 21:03:54 +00:00
|
|
|
|
|
|
|
if(arm->act_edbone)
|
|
|
|
name= ((EditBone *)arm->act_edbone)->name;
|
|
|
|
|
2008-12-18 17:38:21 +00:00
|
|
|
}
|
2009-11-09 21:03:54 +00:00
|
|
|
else if(ob->mode & OB_MODE_POSE) {
|
|
|
|
if(arm->act_bone) {
|
|
|
|
|
|
|
|
if(arm->act_bone->layer & arm->layer)
|
|
|
|
name= arm->act_bone->name;
|
|
|
|
|
2008-12-18 17:38:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if(name && markern)
|
|
|
|
sprintf(info, "(%d) %s %s <%s>", CFRA, ob->id.name+2, name, markern);
|
|
|
|
else if(name)
|
|
|
|
sprintf(info, "(%d) %s %s", CFRA, ob->id.name+2, name);
|
|
|
|
else
|
|
|
|
sprintf(info, "(%d) %s", CFRA, ob->id.name+2);
|
|
|
|
}
|
|
|
|
else if(ELEM3(ob->type, OB_MESH, OB_LATTICE, OB_CURVE)) {
|
|
|
|
Key *key= NULL;
|
|
|
|
KeyBlock *kb = NULL;
|
|
|
|
char shapes[75];
|
|
|
|
|
|
|
|
/* try to display active shapekey too */
|
|
|
|
shapes[0] = 0;
|
|
|
|
key = ob_get_key(ob);
|
|
|
|
if(key){
|
|
|
|
kb = BLI_findlink(&key->block, ob->shapenr-1);
|
|
|
|
if(kb){
|
|
|
|
sprintf(shapes, ": %s ", kb->name);
|
|
|
|
if(ob->shapeflag == OB_SHAPE_LOCK){
|
2009-12-26 20:23:13 +00:00
|
|
|
strcat(shapes, " (Pinned)");
|
2008-12-18 17:38:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(markern)
|
|
|
|
sprintf(info, "(%d) %s %s <%s>", CFRA, ob->id.name+2, shapes, markern);
|
|
|
|
else
|
|
|
|
sprintf(info, "(%d) %s %s", CFRA, ob->id.name+2, shapes);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* standard object */
|
|
|
|
if (markern)
|
|
|
|
sprintf(info, "(%d) %s <%s>", CFRA, ob->id.name+2, markern);
|
|
|
|
else
|
|
|
|
sprintf(info, "(%d) %s", CFRA, ob->id.name+2);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* colour depends on whether there is a keyframe */
|
2010-06-27 05:39:55 +00:00
|
|
|
if (id_frame_has_keyframe((ID *)ob, /*BKE_curframe(scene)*/(float)(CFRA), v3d->keyflags))
|
2008-12-21 10:33:24 +00:00
|
|
|
UI_ThemeColor(TH_VERTEX_SELECT);
|
|
|
|
else
|
2008-12-18 17:38:21 +00:00
|
|
|
UI_ThemeColor(TH_TEXT_HI);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* no object */
|
|
|
|
if (markern)
|
|
|
|
sprintf(info, "(%d) <%s>", CFRA, markern);
|
|
|
|
else
|
|
|
|
sprintf(info, "(%d)", CFRA);
|
|
|
|
|
|
|
|
/* colour is always white */
|
|
|
|
UI_ThemeColor(TH_TEXT_HI);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (U.uiflag & USER_SHOW_ROTVIEWICON)
|
|
|
|
offset = 14 + (U.rvisize * 2);
|
2009-05-05 23:10:32 +00:00
|
|
|
|
|
|
|
BLF_draw_default(offset, 10, 0.0f, info);
|
2008-12-18 17:38:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void view3d_get_viewborder_size(Scene *scene, ARegion *ar, float size_r[2])
|
|
|
|
{
|
|
|
|
float winmax= MAX2(ar->winx, ar->winy);
|
2010-03-05 14:06:39 +00:00
|
|
|
float aspect= (scene->r.xsch*scene->r.xasp) / (scene->r.ysch*scene->r.yasp);
|
2008-12-18 17:38:21 +00:00
|
|
|
|
|
|
|
if(aspect>1.0) {
|
|
|
|
size_r[0]= winmax;
|
|
|
|
size_r[1]= winmax/aspect;
|
|
|
|
} else {
|
|
|
|
size_r[0]= winmax*aspect;
|
|
|
|
size_r[1]= winmax;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-25 08:31:52 +00:00
|
|
|
void view3d_calc_camera_border(Scene *scene, ARegion *ar, RegionView3D *rv3d, View3D *v3d, rctf *viewborder_r)
|
2008-12-18 17:38:21 +00:00
|
|
|
{
|
|
|
|
float zoomfac, size[2];
|
|
|
|
float dx= 0.0f, dy= 0.0f;
|
|
|
|
|
|
|
|
view3d_get_viewborder_size(scene, ar, size);
|
|
|
|
|
2010-04-16 02:14:56 +00:00
|
|
|
if (rv3d == NULL)
|
|
|
|
rv3d = ar->regiondata;
|
|
|
|
|
2008-12-18 17:38:21 +00:00
|
|
|
/* magic zoom calculation, no idea what
|
|
|
|
* it signifies, if you find out, tell me! -zr
|
|
|
|
*/
|
|
|
|
/* simple, its magic dude!
|
|
|
|
* well, to be honest, this gives a natural feeling zooming
|
|
|
|
* with multiple keypad presses (ton)
|
|
|
|
*/
|
|
|
|
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
zoomfac= (M_SQRT2 + rv3d->camzoom/50.0);
|
2008-12-18 17:38:21 +00:00
|
|
|
zoomfac= (zoomfac*zoomfac)*0.25;
|
|
|
|
|
|
|
|
size[0]= size[0]*zoomfac;
|
|
|
|
size[1]= size[1]*zoomfac;
|
|
|
|
|
|
|
|
/* center in window */
|
|
|
|
viewborder_r->xmin= 0.5*ar->winx - 0.5*size[0];
|
|
|
|
viewborder_r->ymin= 0.5*ar->winy - 0.5*size[1];
|
|
|
|
viewborder_r->xmax= viewborder_r->xmin + size[0];
|
|
|
|
viewborder_r->ymax= viewborder_r->ymin + size[1];
|
|
|
|
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
dx= ar->winx*rv3d->camdx*zoomfac*2.0f;
|
|
|
|
dy= ar->winy*rv3d->camdy*zoomfac*2.0f;
|
2008-12-18 17:38:21 +00:00
|
|
|
|
|
|
|
/* apply offset */
|
|
|
|
viewborder_r->xmin-= dx;
|
|
|
|
viewborder_r->ymin-= dy;
|
|
|
|
viewborder_r->xmax-= dx;
|
|
|
|
viewborder_r->ymax-= dy;
|
|
|
|
|
|
|
|
if(v3d->camera && v3d->camera->type==OB_CAMERA) {
|
|
|
|
Camera *cam= v3d->camera->data;
|
|
|
|
float w = viewborder_r->xmax - viewborder_r->xmin;
|
|
|
|
float h = viewborder_r->ymax - viewborder_r->ymin;
|
|
|
|
float side = MAX2(w, h);
|
|
|
|
|
|
|
|
viewborder_r->xmin+= cam->shiftx*side;
|
|
|
|
viewborder_r->xmax+= cam->shiftx*side;
|
|
|
|
viewborder_r->ymin+= cam->shifty*side;
|
|
|
|
viewborder_r->ymax+= cam->shifty*side;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
void view3d_set_1_to_1_viewborder(Scene *scene, ARegion *ar)
|
2008-12-18 17:38:21 +00:00
|
|
|
{
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
RegionView3D *rv3d= ar->regiondata;
|
2008-12-18 17:38:21 +00:00
|
|
|
float size[2];
|
|
|
|
int im_width= (scene->r.size*scene->r.xsch)/100;
|
|
|
|
|
|
|
|
view3d_get_viewborder_size(scene, ar, size);
|
|
|
|
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
rv3d->camzoom= (sqrt(4.0*im_width/size[0]) - M_SQRT2)*50.0;
|
2010-09-11 04:39:00 +00:00
|
|
|
rv3d->camzoom= CLAMPIS(rv3d->camzoom, RV3D_CAMZOOM_MIN, RV3D_CAMZOOM_MAX);
|
2008-12-18 17:38:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d)
|
|
|
|
{
|
|
|
|
float fac, a;
|
|
|
|
float x1, x2, y1, y2;
|
2010-07-26 21:35:24 +00:00
|
|
|
float x1i, x2i, y1i, y2i;
|
2008-12-18 17:38:21 +00:00
|
|
|
float x3, y3, x4, y4;
|
|
|
|
rctf viewborder;
|
|
|
|
Camera *ca= NULL;
|
2010-04-16 02:14:56 +00:00
|
|
|
RegionView3D *rv3d= (RegionView3D *)ar->regiondata;
|
2008-12-18 17:38:21 +00:00
|
|
|
|
|
|
|
if(v3d->camera==NULL)
|
|
|
|
return;
|
|
|
|
if(v3d->camera->type==OB_CAMERA)
|
|
|
|
ca = v3d->camera->data;
|
|
|
|
|
2010-08-25 08:31:52 +00:00
|
|
|
view3d_calc_camera_border(scene, ar, rv3d, v3d, &viewborder);
|
2010-07-26 21:35:24 +00:00
|
|
|
/* the offsets */
|
2008-12-18 17:38:21 +00:00
|
|
|
x1= viewborder.xmin;
|
|
|
|
y1= viewborder.ymin;
|
|
|
|
x2= viewborder.xmax;
|
|
|
|
y2= viewborder.ymax;
|
|
|
|
|
2010-07-26 21:35:24 +00:00
|
|
|
/* apply offsets so the real 3D camera shows through */
|
|
|
|
x1i= (int)(x1 - 1.0f);
|
|
|
|
y1i= (int)(y1 - 1.0f);
|
|
|
|
x2i= (int)(x2 + 1.0f);
|
|
|
|
y2i= (int)(y2 + 1.0f);
|
|
|
|
|
2008-12-18 17:38:21 +00:00
|
|
|
/* passepartout, specified in camera edit buttons */
|
|
|
|
if (ca && (ca->flag & CAM_SHOWPASSEPARTOUT) && ca->passepartalpha > 0.000001) {
|
|
|
|
if (ca->passepartalpha == 1.0) {
|
|
|
|
glColor3f(0, 0, 0);
|
|
|
|
} else {
|
|
|
|
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
|
|
|
|
glEnable(GL_BLEND);
|
|
|
|
glColor4f(0, 0, 0, ca->passepartalpha);
|
|
|
|
}
|
2010-07-26 21:35:24 +00:00
|
|
|
if (x1i > 0.0)
|
|
|
|
glRectf(0.0, (float)ar->winy, x1i, 0.0);
|
|
|
|
if (x2i < (float)ar->winx)
|
|
|
|
glRectf(x2i, (float)ar->winy, (float)ar->winx, 0.0);
|
|
|
|
if (y2i < (float)ar->winy)
|
|
|
|
glRectf(x1i, (float)ar->winy, x2i, y2i);
|
|
|
|
if (y2i > 0.0)
|
|
|
|
glRectf(x1i, y1i, x2i, 0.0);
|
2008-12-18 17:38:21 +00:00
|
|
|
|
|
|
|
glDisable(GL_BLEND);
|
|
|
|
}
|
2010-07-26 21:35:24 +00:00
|
|
|
|
2008-12-18 17:38:21 +00:00
|
|
|
/* edge */
|
2010-07-26 21:35:24 +00:00
|
|
|
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
|
|
|
|
2008-12-18 17:38:21 +00:00
|
|
|
setlinestyle(0);
|
|
|
|
UI_ThemeColor(TH_BACK);
|
2010-07-26 21:35:24 +00:00
|
|
|
glRectf(x1i, y1i, x2i, y2i);
|
2008-12-18 17:38:21 +00:00
|
|
|
|
|
|
|
setlinestyle(3);
|
|
|
|
UI_ThemeColor(TH_WIRE);
|
2010-07-26 21:35:24 +00:00
|
|
|
glRectf(x1i, y1i, x2i, y2i);
|
|
|
|
|
2008-12-18 17:38:21 +00:00
|
|
|
/* border */
|
|
|
|
if(scene->r.mode & R_BORDER) {
|
|
|
|
|
|
|
|
cpack(0);
|
|
|
|
x3= x1+ scene->r.border.xmin*(x2-x1);
|
|
|
|
y3= y1+ scene->r.border.ymin*(y2-y1);
|
|
|
|
x4= x1+ scene->r.border.xmax*(x2-x1);
|
|
|
|
y4= y1+ scene->r.border.ymax*(y2-y1);
|
|
|
|
|
|
|
|
cpack(0x4040FF);
|
|
|
|
glRectf(x3, y3, x4, y4);
|
|
|
|
}
|
2010-07-26 21:35:24 +00:00
|
|
|
|
2008-12-18 17:38:21 +00:00
|
|
|
/* safety border */
|
|
|
|
if (ca && (ca->flag & CAM_SHOWTITLESAFE)) {
|
|
|
|
fac= 0.1;
|
|
|
|
|
|
|
|
a= fac*(x2-x1);
|
|
|
|
x1+= a;
|
|
|
|
x2-= a;
|
|
|
|
|
|
|
|
a= fac*(y2-y1);
|
|
|
|
y1+= a;
|
|
|
|
y2-= a;
|
|
|
|
|
|
|
|
UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0);
|
|
|
|
|
|
|
|
uiSetRoundBox(15);
|
2010-09-15 12:18:50 +00:00
|
|
|
uiDrawBox(GL_LINE_LOOP, x1, y1, x2, y2, 12.0);
|
2008-12-18 17:38:21 +00:00
|
|
|
}
|
2010-07-26 21:35:24 +00:00
|
|
|
|
2008-12-18 17:38:21 +00:00
|
|
|
setlinestyle(0);
|
|
|
|
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
2010-07-26 21:35:24 +00:00
|
|
|
|
2010-01-08 14:45:26 +00:00
|
|
|
/* camera name - draw in highlighted text color */
|
|
|
|
if (ca && (ca->flag & CAM_SHOWNAME)) {
|
|
|
|
UI_ThemeColor(TH_TEXT_HI);
|
2010-07-26 21:35:24 +00:00
|
|
|
BLF_draw_default(x1i, y1i-15, 0.0f, v3d->camera->id.name+2);
|
2010-01-08 14:45:26 +00:00
|
|
|
UI_ThemeColor(TH_WIRE);
|
|
|
|
}
|
2008-12-18 17:38:21 +00:00
|
|
|
}
|
|
|
|
|
2009-01-01 19:18:03 +00:00
|
|
|
/* *********************** backdraw for selection *************** */
|
|
|
|
|
2010-07-23 14:46:31 +00:00
|
|
|
static void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d)
|
2009-01-01 19:18:03 +00:00
|
|
|
{
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
RegionView3D *rv3d= ar->regiondata;
|
2009-08-15 20:36:15 +00:00
|
|
|
struct Base *base = scene->basact;
|
2009-08-20 19:46:53 +00:00
|
|
|
rcti winrct;
|
2009-01-01 19:18:03 +00:00
|
|
|
|
2009-08-15 21:46:25 +00:00
|
|
|
if(base && (base->object->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT) ||
|
2010-03-22 09:30:00 +00:00
|
|
|
paint_facesel_test(base->object)));
|
2009-08-16 01:25:53 +00:00
|
|
|
else if((base && (base->object->mode & OB_MODE_TEXTURE_PAINT)) &&
|
|
|
|
scene->toolsettings && (scene->toolsettings->imapaint.flag & IMAGEPAINT_PROJECT_DISABLE));
|
2009-08-16 02:35:44 +00:00
|
|
|
else if((base && (base->object->mode & OB_MODE_PARTICLE_EDIT)) && v3d->drawtype>OB_WIRE && (v3d->flag & V3D_ZBUF_SELECT));
|
2009-01-02 19:10:35 +00:00
|
|
|
else if(scene->obedit && v3d->drawtype>OB_WIRE && (v3d->flag & V3D_ZBUF_SELECT));
|
2009-01-01 19:18:03 +00:00
|
|
|
else {
|
2009-12-17 14:38:30 +00:00
|
|
|
v3d->flag &= ~V3D_INVALID_BACKBUF;
|
2009-01-01 19:18:03 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-12-17 14:38:30 +00:00
|
|
|
if( !(v3d->flag & V3D_INVALID_BACKBUF) ) return;
|
2009-01-01 19:18:03 +00:00
|
|
|
|
|
|
|
// if(test) {
|
|
|
|
// if(qtest()) {
|
|
|
|
// addafterqueue(ar->win, BACKBUFDRAW, 1);
|
|
|
|
// return;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
if(v3d->drawtype > OB_WIRE) v3d->zbuf= TRUE;
|
|
|
|
|
|
|
|
glDisable(GL_DITHER);
|
|
|
|
|
2009-08-20 19:46:53 +00:00
|
|
|
region_scissor_winrct(ar, &winrct);
|
|
|
|
glScissor(winrct.xmin, winrct.ymin, winrct.xmax - winrct.xmin, winrct.ymax - winrct.ymin);
|
|
|
|
|
2009-01-01 19:18:03 +00:00
|
|
|
glClearColor(0.0, 0.0, 0.0, 0.0);
|
|
|
|
if(v3d->zbuf) {
|
|
|
|
glEnable(GL_DEPTH_TEST);
|
|
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
glClear(GL_COLOR_BUFFER_BIT);
|
|
|
|
glDisable(GL_DEPTH_TEST);
|
|
|
|
}
|
|
|
|
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
if(rv3d->rflag & RV3D_CLIPPING)
|
|
|
|
view3d_set_clipping(rv3d);
|
2009-01-01 19:18:03 +00:00
|
|
|
|
|
|
|
G.f |= G_BACKBUFSEL;
|
|
|
|
|
|
|
|
if(base && (base->lay & v3d->lay)) {
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
draw_object_backbufsel(scene, v3d, rv3d, base->object);
|
2009-01-01 19:18:03 +00:00
|
|
|
}
|
|
|
|
|
2009-12-17 14:38:30 +00:00
|
|
|
v3d->flag &= ~V3D_INVALID_BACKBUF;
|
2010-07-21 16:49:43 +00:00
|
|
|
ar->swap= 0; /* mark invalid backbuf for wm draw */
|
2009-01-01 19:18:03 +00:00
|
|
|
|
|
|
|
G.f &= ~G_BACKBUFSEL;
|
|
|
|
v3d->zbuf= FALSE;
|
|
|
|
glDisable(GL_DEPTH_TEST);
|
|
|
|
glEnable(GL_DITHER);
|
|
|
|
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
if(rv3d->rflag & RV3D_CLIPPING)
|
2009-01-01 19:18:03 +00:00
|
|
|
view3d_clr_clipping();
|
|
|
|
|
|
|
|
/* it is important to end a view in a transform compatible with buttons */
|
|
|
|
// persp(PERSP_WIN); // set ortho
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2009-01-15 15:01:39 +00:00
|
|
|
void view3d_validate_backbuf(ViewContext *vc)
|
2009-01-01 19:18:03 +00:00
|
|
|
{
|
2009-12-17 14:38:30 +00:00
|
|
|
if(vc->v3d->flag & V3D_INVALID_BACKBUF)
|
2009-01-01 19:18:03 +00:00
|
|
|
backdrawview3d(vc->scene, vc->ar, vc->v3d);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* samples a single pixel (copied from vpaint) */
|
|
|
|
unsigned int view3d_sample_backbuf(ViewContext *vc, int x, int y)
|
|
|
|
{
|
|
|
|
unsigned int col;
|
|
|
|
|
|
|
|
if(x >= vc->ar->winx || y >= vc->ar->winy) return 0;
|
|
|
|
x+= vc->ar->winrct.xmin;
|
|
|
|
y+= vc->ar->winrct.ymin;
|
|
|
|
|
2009-01-15 15:01:39 +00:00
|
|
|
view3d_validate_backbuf(vc);
|
2009-01-01 19:18:03 +00:00
|
|
|
|
|
|
|
glReadPixels(x, y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &col);
|
|
|
|
glReadBuffer(GL_BACK);
|
|
|
|
|
|
|
|
if(ENDIAN_ORDER==B_ENDIAN) SWITCH_INT(col);
|
|
|
|
|
|
|
|
return WM_framebuffer_to_index(col);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* reads full rect, converts indices */
|
|
|
|
ImBuf *view3d_read_backbuf(ViewContext *vc, short xmin, short ymin, short xmax, short ymax)
|
|
|
|
{
|
|
|
|
unsigned int *dr, *rd;
|
|
|
|
struct ImBuf *ibuf, *ibuf1;
|
|
|
|
int a;
|
|
|
|
short xminc, yminc, xmaxc, ymaxc, xs, ys;
|
|
|
|
|
|
|
|
/* clip */
|
|
|
|
if(xmin<0) xminc= 0; else xminc= xmin;
|
|
|
|
if(xmax >= vc->ar->winx) xmaxc= vc->ar->winx-1; else xmaxc= xmax;
|
|
|
|
if(xminc > xmaxc) return NULL;
|
|
|
|
|
|
|
|
if(ymin<0) yminc= 0; else yminc= ymin;
|
|
|
|
if(ymax >= vc->ar->winy) ymaxc= vc->ar->winy-1; else ymaxc= ymax;
|
|
|
|
if(yminc > ymaxc) return NULL;
|
|
|
|
|
2010-10-16 14:32:17 +00:00
|
|
|
ibuf= IMB_allocImBuf((xmaxc-xminc+1), (ymaxc-yminc+1), 32, IB_rect);
|
2009-01-01 19:18:03 +00:00
|
|
|
|
2009-01-15 15:01:39 +00:00
|
|
|
view3d_validate_backbuf(vc);
|
2009-01-01 19:18:03 +00:00
|
|
|
|
|
|
|
glReadPixels(vc->ar->winrct.xmin+xminc, vc->ar->winrct.ymin+yminc, (xmaxc-xminc+1), (ymaxc-yminc+1), GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
|
|
|
|
glReadBuffer(GL_BACK);
|
|
|
|
|
|
|
|
if(ENDIAN_ORDER==B_ENDIAN) IMB_convert_rgba_to_abgr(ibuf);
|
|
|
|
|
|
|
|
a= (xmaxc-xminc+1)*(ymaxc-yminc+1);
|
|
|
|
dr= ibuf->rect;
|
|
|
|
while(a--) {
|
|
|
|
if(*dr) *dr= WM_framebuffer_to_index(*dr);
|
|
|
|
dr++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* put clipped result back, if needed */
|
|
|
|
if(xminc==xmin && xmaxc==xmax && yminc==ymin && ymaxc==ymax)
|
|
|
|
return ibuf;
|
|
|
|
|
2010-10-16 14:32:17 +00:00
|
|
|
ibuf1= IMB_allocImBuf( (xmax-xmin+1),(ymax-ymin+1),32,IB_rect);
|
2009-01-01 19:18:03 +00:00
|
|
|
rd= ibuf->rect;
|
|
|
|
dr= ibuf1->rect;
|
|
|
|
|
|
|
|
for(ys= ymin; ys<=ymax; ys++) {
|
|
|
|
for(xs= xmin; xs<=xmax; xs++, dr++) {
|
|
|
|
if( xs>=xminc && xs<=xmaxc && ys>=yminc && ys<=ymaxc) {
|
|
|
|
*dr= *rd;
|
|
|
|
rd++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
IMB_freeImBuf(ibuf);
|
|
|
|
return ibuf1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* smart function to sample a rect spiralling outside, nice for backbuf selection */
|
2009-01-15 15:01:39 +00:00
|
|
|
unsigned int view3d_sample_backbuf_rect(ViewContext *vc, short mval[2], int size,
|
|
|
|
unsigned int min, unsigned int max, int *dist, short strict,
|
|
|
|
void *handle, unsigned int (*indextest)(void *handle, unsigned int index))
|
2009-01-01 19:18:03 +00:00
|
|
|
{
|
|
|
|
struct ImBuf *buf;
|
|
|
|
unsigned int *bufmin, *bufmax, *tbuf;
|
|
|
|
int minx, miny;
|
|
|
|
int a, b, rc, nr, amount, dirvec[4][2];
|
|
|
|
int distance=0;
|
|
|
|
unsigned int index = 0;
|
|
|
|
short indexok = 0;
|
|
|
|
|
|
|
|
amount= (size-1)/2;
|
|
|
|
|
|
|
|
minx = mval[0]-(amount+1);
|
|
|
|
miny = mval[1]-(amount+1);
|
|
|
|
buf = view3d_read_backbuf(vc, minx, miny, minx+size-1, miny+size-1);
|
|
|
|
if (!buf) return 0;
|
|
|
|
|
|
|
|
rc= 0;
|
|
|
|
|
|
|
|
dirvec[0][0]= 1; dirvec[0][1]= 0;
|
|
|
|
dirvec[1][0]= 0; dirvec[1][1]= -size;
|
|
|
|
dirvec[2][0]= -1; dirvec[2][1]= 0;
|
|
|
|
dirvec[3][0]= 0; dirvec[3][1]= size;
|
|
|
|
|
|
|
|
bufmin = buf->rect;
|
|
|
|
tbuf = buf->rect;
|
|
|
|
bufmax = buf->rect + size*size;
|
|
|
|
tbuf+= amount*size+ amount;
|
|
|
|
|
|
|
|
for(nr=1; nr<=size; nr++) {
|
|
|
|
|
|
|
|
for(a=0; a<2; a++) {
|
|
|
|
for(b=0; b<nr; b++, distance++) {
|
|
|
|
if (*tbuf && *tbuf>=min && *tbuf<max) { //we got a hit
|
|
|
|
if(strict){
|
2009-01-15 15:01:39 +00:00
|
|
|
indexok = indextest(handle, *tbuf - min+1);
|
2009-01-01 19:18:03 +00:00
|
|
|
if(indexok){
|
|
|
|
*dist= (short) sqrt( (float)distance );
|
|
|
|
index = *tbuf - min+1;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
*dist= (short) sqrt( (float)distance ); // XXX, this distance is wrong -
|
|
|
|
index = *tbuf - min+1; // messy yah, but indices start at 1
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
tbuf+= (dirvec[rc][0]+dirvec[rc][1]);
|
|
|
|
|
|
|
|
if(tbuf<bufmin || tbuf>=bufmax) {
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
rc++;
|
|
|
|
rc &= 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
exit:
|
|
|
|
IMB_freeImBuf(buf);
|
|
|
|
return index;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ************************************************************* */
|
|
|
|
|
2008-12-18 17:38:21 +00:00
|
|
|
static void draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d)
|
|
|
|
{
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
RegionView3D *rv3d= ar->regiondata;
|
2008-12-18 17:38:21 +00:00
|
|
|
BGpic *bgpic;
|
|
|
|
Image *ima;
|
|
|
|
ImBuf *ibuf= NULL;
|
|
|
|
float vec[4], fac, asp, zoomx, zoomy;
|
|
|
|
float x1, y1, x2, y2, cx, cy;
|
2010-01-19 14:04:33 +00:00
|
|
|
|
2010-01-19 22:44:43 +00:00
|
|
|
|
|
|
|
for ( bgpic= v3d->bgpicbase.first; bgpic; bgpic= bgpic->next ) {
|
|
|
|
|
|
|
|
if( (bgpic->view == 0) || /* zero for any */
|
|
|
|
(bgpic->view & (1<<rv3d->view)) || /* check agaist flags */
|
|
|
|
(rv3d->persp==RV3D_CAMOB && bgpic->view == (1<<RV3D_VIEW_CAMERA))
|
|
|
|
) {
|
|
|
|
ima= bgpic->ima;
|
|
|
|
if(ima==NULL)
|
|
|
|
continue;
|
|
|
|
BKE_image_user_calc_frame(&bgpic->iuser, CFRA, 0);
|
|
|
|
ibuf= BKE_image_get_ibuf(ima, &bgpic->iuser);
|
|
|
|
if(ibuf==NULL || (ibuf->rect==NULL && ibuf->rect_float==NULL) )
|
|
|
|
continue;
|
|
|
|
if(ibuf->channels!=4)
|
|
|
|
continue;
|
|
|
|
if(ibuf->rect==NULL)
|
|
|
|
IMB_rect_from_float(ibuf);
|
|
|
|
|
|
|
|
if(rv3d->persp==RV3D_CAMOB) {
|
|
|
|
rctf vb;
|
|
|
|
|
2010-08-25 08:31:52 +00:00
|
|
|
view3d_calc_camera_border(scene, ar, rv3d, v3d, &vb);
|
2010-01-19 22:44:43 +00:00
|
|
|
|
|
|
|
x1= vb.xmin;
|
|
|
|
y1= vb.ymin;
|
|
|
|
x2= vb.xmax;
|
|
|
|
y2= vb.ymax;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
float sco[2];
|
|
|
|
|
|
|
|
/* calc window coord */
|
|
|
|
initgrabz(rv3d, 0.0, 0.0, 0.0);
|
|
|
|
window_to_3d_delta(ar, vec, 1, 0);
|
|
|
|
fac= MAX3( fabs(vec[0]), fabs(vec[1]), fabs(vec[1]) );
|
|
|
|
fac= 1.0/fac;
|
|
|
|
|
|
|
|
asp= ( (float)ibuf->y)/(float)ibuf->x;
|
|
|
|
|
|
|
|
vec[0] = vec[1] = vec[2] = 0.0;
|
|
|
|
view3d_project_float(ar, vec, sco, rv3d->persmat);
|
|
|
|
cx = sco[0];
|
|
|
|
cy = sco[1];
|
|
|
|
|
|
|
|
x1= cx+ fac*(bgpic->xof-bgpic->size);
|
|
|
|
y1= cy+ asp*fac*(bgpic->yof-bgpic->size);
|
|
|
|
x2= cx+ fac*(bgpic->xof+bgpic->size);
|
|
|
|
y2= cy+ asp*fac*(bgpic->yof+bgpic->size);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* complete clip? */
|
|
|
|
|
|
|
|
if(x2 < 0 ) continue;
|
|
|
|
if(y2 < 0 ) continue;
|
|
|
|
if(x1 > ar->winx ) continue;
|
|
|
|
if(y1 > ar->winy ) continue;
|
|
|
|
|
|
|
|
zoomx= (x2-x1)/ibuf->x;
|
|
|
|
zoomy= (y2-y1)/ibuf->y;
|
|
|
|
|
|
|
|
/* for some reason; zoomlevels down refuses to use GL_ALPHA_SCALE */
|
|
|
|
if(zoomx < 1.0f || zoomy < 1.0f) {
|
|
|
|
float tzoom= MIN2(zoomx, zoomy);
|
|
|
|
int mip= 0;
|
|
|
|
|
|
|
|
if(ibuf->mipmap[0]==NULL)
|
2010-03-14 18:22:04 +00:00
|
|
|
IMB_makemipmap(ibuf, 0);
|
2010-01-19 22:44:43 +00:00
|
|
|
|
|
|
|
while(tzoom < 1.0f && mip<8 && ibuf->mipmap[mip]) {
|
|
|
|
tzoom*= 2.0f;
|
|
|
|
zoomx*= 2.0f;
|
|
|
|
zoomy*= 2.0f;
|
|
|
|
mip++;
|
|
|
|
}
|
|
|
|
if(mip>0)
|
|
|
|
ibuf= ibuf->mipmap[mip-1];
|
|
|
|
}
|
|
|
|
|
|
|
|
if(v3d->zbuf) glDisable(GL_DEPTH_TEST);
|
|
|
|
glDepthMask(0);
|
|
|
|
|
2010-02-01 15:32:55 +00:00
|
|
|
glEnable(GL_BLEND);
|
2010-01-19 22:44:43 +00:00
|
|
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
|
|
|
2010-02-01 15:32:55 +00:00
|
|
|
glMatrixMode(GL_PROJECTION);
|
|
|
|
glPushMatrix();
|
|
|
|
glMatrixMode(GL_MODELVIEW);
|
|
|
|
glPushMatrix();
|
2010-01-19 22:44:43 +00:00
|
|
|
ED_region_pixelspace(ar);
|
|
|
|
|
|
|
|
glPixelZoom(zoomx, zoomy);
|
|
|
|
glColor4f(1.0, 1.0, 1.0, 1.0-bgpic->blend);
|
|
|
|
glaDrawPixelsTex(x1, y1, ibuf->x, ibuf->y, GL_UNSIGNED_BYTE, ibuf->rect);
|
|
|
|
|
|
|
|
glPixelZoom(1.0, 1.0);
|
|
|
|
glPixelTransferf(GL_ALPHA_SCALE, 1.0f);
|
|
|
|
|
2010-02-01 15:32:55 +00:00
|
|
|
glMatrixMode(GL_PROJECTION);
|
|
|
|
glPopMatrix();
|
|
|
|
glMatrixMode(GL_MODELVIEW);
|
|
|
|
glPopMatrix();
|
2010-01-19 22:44:43 +00:00
|
|
|
|
|
|
|
glDisable(GL_BLEND);
|
|
|
|
|
|
|
|
glDepthMask(1);
|
|
|
|
if(v3d->zbuf) glEnable(GL_DEPTH_TEST);
|
2008-12-18 17:38:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
/* ****************** View3d afterdraw *************** */
|
|
|
|
|
|
|
|
typedef struct View3DAfter {
|
|
|
|
struct View3DAfter *next, *prev;
|
|
|
|
struct Base *base;
|
2010-08-25 14:23:02 +00:00
|
|
|
int flag;
|
2008-12-19 12:14:58 +00:00
|
|
|
} View3DAfter;
|
|
|
|
|
|
|
|
/* temp storage of Objects that need to be drawn as last */
|
2010-08-25 14:23:02 +00:00
|
|
|
void add_view3d_after(ListBase *lb, Base *base, int flag)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
|
|
|
View3DAfter *v3da= MEM_callocN(sizeof(View3DAfter), "View 3d after");
|
2010-08-25 14:23:02 +00:00
|
|
|
BLI_addtail(lb, v3da);
|
2008-12-19 12:14:58 +00:00
|
|
|
v3da->base= base;
|
|
|
|
v3da->flag= flag;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* disables write in zbuffer and draws it over */
|
2008-12-19 14:14:43 +00:00
|
|
|
static void view3d_draw_transp(Scene *scene, ARegion *ar, View3D *v3d)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
|
|
|
View3DAfter *v3da, *next;
|
|
|
|
|
|
|
|
glDepthMask(0);
|
|
|
|
v3d->transp= TRUE;
|
|
|
|
|
2010-08-25 14:23:02 +00:00
|
|
|
for(v3da= v3d->afterdraw_transp.first; v3da; v3da= next) {
|
2008-12-19 12:14:58 +00:00
|
|
|
next= v3da->next;
|
2010-08-25 14:23:02 +00:00
|
|
|
draw_object(scene, ar, v3d, v3da->base, v3da->flag);
|
|
|
|
BLI_remlink(&v3d->afterdraw_transp, v3da);
|
|
|
|
MEM_freeN(v3da);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
v3d->transp= FALSE;
|
|
|
|
|
|
|
|
glDepthMask(1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-08-25 14:23:02 +00:00
|
|
|
/* clears zbuffer and draws it over */
|
|
|
|
static void view3d_draw_xray(Scene *scene, ARegion *ar, View3D *v3d, int clear)
|
|
|
|
{
|
|
|
|
View3DAfter *v3da, *next;
|
|
|
|
|
|
|
|
if(clear && v3d->zbuf)
|
|
|
|
glClear(GL_DEPTH_BUFFER_BIT);
|
|
|
|
|
|
|
|
v3d->xray= TRUE;
|
|
|
|
for(v3da= v3d->afterdraw_xray.first; v3da; v3da= next) {
|
|
|
|
next= v3da->next;
|
|
|
|
draw_object(scene, ar, v3d, v3da->base, v3da->flag);
|
|
|
|
BLI_remlink(&v3d->afterdraw_xray, v3da);
|
|
|
|
MEM_freeN(v3da);
|
|
|
|
}
|
|
|
|
v3d->xray= FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* clears zbuffer and draws it over */
|
|
|
|
static void view3d_draw_xraytransp(Scene *scene, ARegion *ar, View3D *v3d, int clear)
|
|
|
|
{
|
|
|
|
View3DAfter *v3da, *next;
|
|
|
|
|
|
|
|
if(clear && v3d->zbuf)
|
|
|
|
glClear(GL_DEPTH_BUFFER_BIT);
|
|
|
|
|
|
|
|
v3d->xray= TRUE;
|
|
|
|
v3d->transp= TRUE;
|
|
|
|
|
|
|
|
for(v3da= v3d->afterdraw_xraytransp.first; v3da; v3da= next) {
|
|
|
|
next= v3da->next;
|
|
|
|
draw_object(scene, ar, v3d, v3da->base, v3da->flag);
|
|
|
|
BLI_remlink(&v3d->afterdraw_xraytransp, v3da);
|
|
|
|
MEM_freeN(v3da);
|
|
|
|
}
|
|
|
|
|
|
|
|
v3d->transp= FALSE;
|
|
|
|
v3d->xray= FALSE;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
/* *********************** */
|
|
|
|
|
|
|
|
/*
|
|
|
|
In most cases call draw_dupli_objects,
|
|
|
|
draw_dupli_objects_color was added because when drawing set dupli's
|
|
|
|
we need to force the color
|
|
|
|
*/
|
2010-03-01 17:53:33 +00:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
int dupli_ob_sort(void *arg1, void *arg2)
|
|
|
|
{
|
|
|
|
void *p1= ((DupliObject *)arg1)->ob;
|
|
|
|
void *p2= ((DupliObject *)arg2)->ob;
|
|
|
|
int val = 0;
|
|
|
|
if (p1 < p2) val = -1;
|
|
|
|
else if (p1 > p2) val = 1;
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-03-04 15:58:27 +00:00
|
|
|
|
2010-03-05 08:53:16 +00:00
|
|
|
static DupliObject *dupli_step(DupliObject *dob)
|
2010-03-04 15:58:27 +00:00
|
|
|
{
|
2010-03-05 08:53:16 +00:00
|
|
|
while(dob && dob->no_draw)
|
|
|
|
dob= dob->next;
|
|
|
|
return dob;
|
2010-03-04 15:58:27 +00:00
|
|
|
}
|
|
|
|
|
2008-12-19 14:14:43 +00:00
|
|
|
static void draw_dupli_objects_color(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int color)
|
2010-03-04 15:58:27 +00:00
|
|
|
{
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
RegionView3D *rv3d= ar->regiondata;
|
2008-12-19 12:14:58 +00:00
|
|
|
ListBase *lb;
|
2010-03-05 08:53:16 +00:00
|
|
|
DupliObject *dob_prev= NULL, *dob, *dob_next;
|
2008-12-19 12:14:58 +00:00
|
|
|
Base tbase;
|
2010-02-06 14:32:50 +00:00
|
|
|
BoundBox bb, *bb_tmp; /* use a copy because draw_object, calls clear_mesh_caches */
|
2008-12-19 12:14:58 +00:00
|
|
|
GLuint displist=0;
|
|
|
|
short transflag, use_displist= -1; /* -1 is initialize */
|
|
|
|
char dt, dtx;
|
|
|
|
|
|
|
|
if (base->object->restrictflag & OB_RESTRICT_VIEW) return;
|
|
|
|
|
|
|
|
tbase.flag= OB_FROMDUPLI|base->flag;
|
|
|
|
lb= object_duplilist(scene, base->object);
|
2010-03-01 17:53:33 +00:00
|
|
|
// BLI_sortlist(lb, dupli_ob_sort); // might be nice to have if we have a dupli list with mixed objects.
|
2010-03-04 15:58:27 +00:00
|
|
|
|
2010-03-05 08:53:16 +00:00
|
|
|
dob=dupli_step(lb->first);
|
|
|
|
if(dob) dob_next= dupli_step(dob->next);
|
|
|
|
|
|
|
|
for( ; dob ; dob_prev= dob, dob= dob_next, dob_next= dob_next ? dupli_step(dob_next->next) : NULL) {
|
2010-03-04 15:58:27 +00:00
|
|
|
tbase.object= dob->ob;
|
|
|
|
|
|
|
|
/* extra service: draw the duplicator in drawtype of parent */
|
|
|
|
/* MIN2 for the drawtype to allow bounding box objects in groups for lods */
|
|
|
|
dt= tbase.object->dt; tbase.object->dt= MIN2(tbase.object->dt, base->object->dt);
|
|
|
|
dtx= tbase.object->dtx; tbase.object->dtx= base->object->dtx;
|
|
|
|
|
|
|
|
/* negative scale flag has to propagate */
|
|
|
|
transflag= tbase.object->transflag;
|
|
|
|
if(base->object->transflag & OB_NEG_SCALE)
|
|
|
|
tbase.object->transflag ^= OB_NEG_SCALE;
|
|
|
|
|
|
|
|
UI_ThemeColorBlend(color, TH_BACK, 0.5);
|
|
|
|
|
|
|
|
/* generate displist, test for new object */
|
|
|
|
if(dob_prev && dob_prev->ob != dob->ob) {
|
|
|
|
if(use_displist==1)
|
2008-12-19 12:14:58 +00:00
|
|
|
glDeleteLists(displist, 1);
|
2010-03-04 15:58:27 +00:00
|
|
|
|
|
|
|
use_displist= -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* generate displist */
|
|
|
|
if(use_displist == -1) {
|
|
|
|
|
|
|
|
/* note, since this was added, its checked dob->type==OB_DUPLIGROUP
|
|
|
|
* however this is very slow, it was probably needed for the NLA
|
|
|
|
* offset feature (used in group-duplicate.blend but no longer works in 2.5)
|
|
|
|
* so for now it should be ok to - campbell */
|
|
|
|
|
|
|
|
if( (dob_next==NULL || dob_next->ob != dob->ob) || /* if this is the last no need to make a displist */
|
|
|
|
(dob->ob->type == OB_LAMP) || /* lamp drawing messes with matrices, could be handled smarter... but this works */
|
|
|
|
(dob->type == OB_DUPLIGROUP && dob->animated) ||
|
|
|
|
!(bb_tmp= object_get_boundbox(dob->ob))
|
|
|
|
) {
|
|
|
|
// printf("draw_dupli_objects_color: skipping displist for %s\n", dob->ob->id.name+2);
|
|
|
|
use_displist= 0;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
else {
|
2010-03-04 15:58:27 +00:00
|
|
|
// printf("draw_dupli_objects_color: using displist for %s\n", dob->ob->id.name+2);
|
|
|
|
bb= *bb_tmp; /* must make a copy */
|
|
|
|
|
|
|
|
/* disable boundbox check for list creation */
|
|
|
|
object_boundbox_flag(dob->ob, OB_BB_DISABLED, 1);
|
|
|
|
/* need this for next part of code */
|
|
|
|
unit_m4(dob->ob->obmat); /* obmat gets restored */
|
|
|
|
|
|
|
|
displist= glGenLists(1);
|
|
|
|
glNewList(displist, GL_COMPILE);
|
2008-12-19 14:14:43 +00:00
|
|
|
draw_object(scene, ar, v3d, &tbase, DRAW_CONSTCOLOR);
|
2010-03-04 15:58:27 +00:00
|
|
|
glEndList();
|
2010-03-04 14:59:20 +00:00
|
|
|
|
2010-03-04 15:58:27 +00:00
|
|
|
use_displist= 1;
|
|
|
|
object_boundbox_flag(dob->ob, OB_BB_DISABLED, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(use_displist) {
|
|
|
|
glMultMatrixf(dob->mat);
|
|
|
|
if(boundbox_clip(rv3d, dob->mat, &bb))
|
|
|
|
glCallList(displist);
|
|
|
|
glLoadMatrixf(rv3d->viewmat);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2010-03-04 15:58:27 +00:00
|
|
|
else {
|
|
|
|
copy_m4_m4(dob->ob->obmat, dob->mat);
|
|
|
|
draw_object(scene, ar, v3d, &tbase, DRAW_CONSTCOLOR);
|
|
|
|
}
|
|
|
|
|
|
|
|
tbase.object->dt= dt;
|
|
|
|
tbase.object->dtx= dtx;
|
|
|
|
tbase.object->transflag= transflag;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Transp afterdraw disabled, afterdraw only stores base pointers, and duplis can be same obj */
|
|
|
|
|
|
|
|
free_object_duplilist(lb); /* does restore */
|
|
|
|
|
|
|
|
if(use_displist)
|
|
|
|
glDeleteLists(displist, 1);
|
|
|
|
}
|
|
|
|
|
2008-12-19 14:14:43 +00:00
|
|
|
static void draw_dupli_objects(Scene *scene, ARegion *ar, View3D *v3d, Base *base)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
|
|
|
/* define the color here so draw_dupli_objects_color can be called
|
|
|
|
* from the set loop */
|
|
|
|
|
|
|
|
int color= (base->flag & SELECT)?TH_SELECT:TH_WIRE;
|
|
|
|
/* debug */
|
|
|
|
if(base->object->dup_group && base->object->dup_group->id.us<1)
|
|
|
|
color= TH_REDALERT;
|
|
|
|
|
2008-12-19 14:14:43 +00:00
|
|
|
draw_dupli_objects_color(scene, ar, v3d, base, color);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-10-15 12:29:02 +00:00
|
|
|
void view3d_update_depths(ARegion *ar)
|
2008-12-18 17:38:21 +00:00
|
|
|
{
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
RegionView3D *rv3d= ar->regiondata;
|
|
|
|
|
2008-12-18 17:38:21 +00:00
|
|
|
/* Create storage for, and, if necessary, copy depth buffer */
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
if(!rv3d->depths) rv3d->depths= MEM_callocN(sizeof(ViewDepths),"ViewDepths");
|
|
|
|
if(rv3d->depths) {
|
|
|
|
ViewDepths *d= rv3d->depths;
|
2008-12-18 17:38:21 +00:00
|
|
|
if(d->w != ar->winx ||
|
|
|
|
d->h != ar->winy ||
|
|
|
|
!d->depths) {
|
|
|
|
d->w= ar->winx;
|
|
|
|
d->h= ar->winy;
|
|
|
|
if(d->depths)
|
|
|
|
MEM_freeN(d->depths);
|
|
|
|
d->depths= MEM_mallocN(sizeof(float)*d->w*d->h,"View depths");
|
|
|
|
d->damaged= 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(d->damaged) {
|
|
|
|
glReadPixels(ar->winrct.xmin,ar->winrct.ymin,d->w,d->h,
|
|
|
|
GL_DEPTH_COMPONENT,GL_FLOAT, d->depths);
|
|
|
|
|
|
|
|
glGetDoublev(GL_DEPTH_RANGE,d->depth_range);
|
|
|
|
|
|
|
|
d->damaged= 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-01-01 16:46:27 +00:00
|
|
|
void draw_depth_gpencil(Scene *scene, ARegion *ar, View3D *v3d)
|
|
|
|
{
|
2010-01-03 01:55:20 +00:00
|
|
|
short zbuf= v3d->zbuf;
|
2010-01-01 16:46:27 +00:00
|
|
|
RegionView3D *rv3d= ar->regiondata;
|
|
|
|
|
|
|
|
setwinmatrixview3d(ar, v3d, NULL); /* 0= no pick rect */
|
|
|
|
setviewmatrixview3d(scene, v3d, rv3d); /* note: calls where_is_object for camera... */
|
|
|
|
|
|
|
|
mul_m4_m4m4(rv3d->persmat, rv3d->viewmat, rv3d->winmat);
|
|
|
|
invert_m4_m4(rv3d->persinv, rv3d->persmat);
|
|
|
|
invert_m4_m4(rv3d->viewinv, rv3d->viewmat);
|
|
|
|
|
|
|
|
glClear(GL_DEPTH_BUFFER_BIT);
|
|
|
|
|
2010-02-01 15:32:55 +00:00
|
|
|
glLoadMatrixf(rv3d->viewmat);
|
2010-01-01 16:46:27 +00:00
|
|
|
|
|
|
|
v3d->zbuf= TRUE;
|
|
|
|
glEnable(GL_DEPTH_TEST);
|
|
|
|
|
2010-08-25 08:31:52 +00:00
|
|
|
draw_gpencil_view3d_ext(scene, v3d, ar, 1);
|
2010-01-03 01:55:20 +00:00
|
|
|
|
|
|
|
v3d->zbuf= zbuf;
|
|
|
|
|
2010-01-01 16:46:27 +00:00
|
|
|
}
|
|
|
|
|
2008-12-19 14:14:43 +00:00
|
|
|
void draw_depth(Scene *scene, ARegion *ar, View3D *v3d, int (* func)(void *))
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
RegionView3D *rv3d= ar->regiondata;
|
2008-12-19 12:14:58 +00:00
|
|
|
Base *base;
|
|
|
|
Scene *sce;
|
2010-01-03 01:55:20 +00:00
|
|
|
short zbuf= v3d->zbuf;
|
|
|
|
short flag= v3d->flag;
|
|
|
|
float glalphaclip= U.glalphaclip;
|
|
|
|
int obcenter_dia= U.obcenter_dia;
|
2008-12-19 12:14:58 +00:00
|
|
|
/* temp set drawtype to solid */
|
|
|
|
|
|
|
|
/* Setting these temporarily is not nice */
|
|
|
|
v3d->flag &= ~V3D_SELECT_OUTLINE;
|
2010-01-03 01:55:20 +00:00
|
|
|
U.glalphaclip = 0.5; /* not that nice but means we wont zoom into billboards */
|
|
|
|
U.obcenter_dia= 0;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
setwinmatrixview3d(ar, v3d, NULL); /* 0= no pick rect */
|
|
|
|
setviewmatrixview3d(scene, v3d, rv3d); /* note: calls where_is_object for camera... */
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_m4_m4m4(rv3d->persmat, rv3d->viewmat, rv3d->winmat);
|
|
|
|
invert_m4_m4(rv3d->persinv, rv3d->persmat);
|
|
|
|
invert_m4_m4(rv3d->viewinv, rv3d->viewmat);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
glClear(GL_DEPTH_BUFFER_BIT);
|
|
|
|
|
2010-02-01 15:32:55 +00:00
|
|
|
glLoadMatrixf(rv3d->viewmat);
|
2008-12-19 12:14:58 +00:00
|
|
|
// persp(PERSP_STORE); // store correct view for persp(PERSP_VIEW) calls
|
|
|
|
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
if(rv3d->rflag & RV3D_CLIPPING) {
|
|
|
|
view3d_set_clipping(rv3d);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
v3d->zbuf= TRUE;
|
|
|
|
glEnable(GL_DEPTH_TEST);
|
|
|
|
|
|
|
|
/* draw set first */
|
|
|
|
if(scene->set) {
|
|
|
|
for(SETLOOPER(scene->set, base)) {
|
|
|
|
if(v3d->lay & base->lay) {
|
|
|
|
if (func == NULL || func(base)) {
|
2008-12-19 14:14:43 +00:00
|
|
|
draw_object(scene, ar, v3d, base, 0);
|
2008-12-19 12:14:58 +00:00
|
|
|
if(base->object->transflag & OB_DUPLI) {
|
2008-12-19 14:14:43 +00:00
|
|
|
draw_dupli_objects_color(scene, ar, v3d, base, TH_WIRE);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for(base= scene->base.first; base; base= base->next) {
|
|
|
|
if(v3d->lay & base->lay) {
|
|
|
|
if (func == NULL || func(base)) {
|
|
|
|
/* dupli drawing */
|
|
|
|
if(base->object->transflag & OB_DUPLI) {
|
2008-12-19 14:14:43 +00:00
|
|
|
draw_dupli_objects(scene, ar, v3d, base);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2008-12-19 14:14:43 +00:00
|
|
|
draw_object(scene, ar, v3d, base, 0);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* this isnt that nice, draw xray objects as if they are normal */
|
2010-08-25 14:23:02 +00:00
|
|
|
if ( v3d->afterdraw_transp.first ||
|
|
|
|
v3d->afterdraw_xray.first ||
|
|
|
|
v3d->afterdraw_xraytransp.first
|
|
|
|
) {
|
2008-12-19 12:14:58 +00:00
|
|
|
View3DAfter *v3da, *next;
|
2010-07-26 01:59:50 +00:00
|
|
|
int mask_orig;
|
2010-08-25 14:23:02 +00:00
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
v3d->xray= TRUE;
|
|
|
|
|
2010-07-26 01:59:50 +00:00
|
|
|
/* transp materials can change the depth mask, see #21388 */
|
|
|
|
glGetIntegerv(GL_DEPTH_WRITEMASK, &mask_orig);
|
|
|
|
|
2010-08-25 14:23:02 +00:00
|
|
|
|
|
|
|
if(v3d->afterdraw_xray.first || v3d->afterdraw_xraytransp.first) {
|
|
|
|
glDepthFunc(GL_ALWAYS); /* always write into the depth bufer, overwriting front z values */
|
|
|
|
for(v3da= v3d->afterdraw_xray.first; v3da; v3da= next) {
|
|
|
|
next= v3da->next;
|
2008-12-19 14:14:43 +00:00
|
|
|
draw_object(scene, ar, v3d, v3da->base, 0);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2010-08-25 14:23:02 +00:00
|
|
|
glDepthFunc(GL_LEQUAL); /* Now write the depth buffer normally */
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2010-08-25 14:23:02 +00:00
|
|
|
|
|
|
|
/* draw 3 passes, transp/xray/xraytransp */
|
2008-12-19 12:14:58 +00:00
|
|
|
v3d->xray= FALSE;
|
2010-08-25 14:23:02 +00:00
|
|
|
v3d->transp= TRUE;
|
|
|
|
for(v3da= v3d->afterdraw_transp.first; v3da; v3da= next) {
|
2008-12-19 12:14:58 +00:00
|
|
|
next= v3da->next;
|
2010-08-25 14:23:02 +00:00
|
|
|
draw_object(scene, ar, v3d, v3da->base, 0);
|
|
|
|
BLI_remlink(&v3d->afterdraw_transp, v3da);
|
|
|
|
MEM_freeN(v3da);
|
|
|
|
}
|
|
|
|
|
|
|
|
v3d->xray= TRUE;
|
|
|
|
v3d->transp= FALSE;
|
|
|
|
for(v3da= v3d->afterdraw_xray.first; v3da; v3da= next) {
|
|
|
|
next= v3da->next;
|
|
|
|
draw_object(scene, ar, v3d, v3da->base, 0);
|
|
|
|
BLI_remlink(&v3d->afterdraw_xray, v3da);
|
|
|
|
MEM_freeN(v3da);
|
|
|
|
}
|
|
|
|
|
|
|
|
v3d->xray= TRUE;
|
|
|
|
v3d->transp= TRUE;
|
|
|
|
for(v3da= v3d->afterdraw_xraytransp.first; v3da; v3da= next) {
|
|
|
|
next= v3da->next;
|
|
|
|
draw_object(scene, ar, v3d, v3da->base, 0);
|
|
|
|
BLI_remlink(&v3d->afterdraw_xraytransp, v3da);
|
2008-12-19 12:14:58 +00:00
|
|
|
MEM_freeN(v3da);
|
|
|
|
}
|
2010-08-25 14:23:02 +00:00
|
|
|
|
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
v3d->xray= FALSE;
|
|
|
|
v3d->transp= FALSE;
|
2010-07-26 01:59:50 +00:00
|
|
|
|
|
|
|
glDepthMask(mask_orig);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
2010-02-12 11:03:41 +00:00
|
|
|
if(rv3d->rflag & RV3D_CLIPPING)
|
|
|
|
view3d_clr_clipping();
|
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
v3d->zbuf = zbuf;
|
2010-02-12 11:03:41 +00:00
|
|
|
if(!v3d->zbuf) glDisable(GL_DEPTH_TEST);
|
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
U.glalphaclip = glalphaclip;
|
|
|
|
v3d->flag = flag;
|
2010-01-03 01:55:20 +00:00
|
|
|
U.obcenter_dia= obcenter_dia;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct View3DShadow {
|
|
|
|
struct View3DShadow *next, *prev;
|
|
|
|
GPULamp *lamp;
|
|
|
|
} View3DShadow;
|
|
|
|
|
|
|
|
static void gpu_render_lamp_update(Scene *scene, View3D *v3d, Object *ob, Object *par, float obmat[][4], ListBase *shadows)
|
|
|
|
{
|
|
|
|
GPULamp *lamp;
|
2009-06-08 20:08:19 +00:00
|
|
|
Lamp *la = (Lamp*)ob->data;
|
2008-12-19 12:14:58 +00:00
|
|
|
View3DShadow *shadow;
|
|
|
|
|
|
|
|
lamp = GPU_lamp_from_blender(scene, ob, par);
|
|
|
|
|
|
|
|
if(lamp) {
|
2010-07-30 10:44:00 +00:00
|
|
|
GPU_lamp_update(lamp, ob->lay, (ob->restrictflag & OB_RESTRICT_RENDER), obmat);
|
2009-06-08 20:08:19 +00:00
|
|
|
GPU_lamp_update_colors(lamp, la->r, la->g, la->b, la->energy);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
if((ob->lay & v3d->lay) && GPU_lamp_has_shadow_buffer(lamp)) {
|
|
|
|
shadow= MEM_callocN(sizeof(View3DShadow), "View3DShadow");
|
|
|
|
shadow->lamp = lamp;
|
|
|
|
BLI_addtail(shadows, shadow);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gpu_update_lamps_shadows(Scene *scene, View3D *v3d)
|
|
|
|
{
|
|
|
|
ListBase shadows;
|
|
|
|
View3DShadow *shadow;
|
|
|
|
Scene *sce;
|
|
|
|
Base *base;
|
|
|
|
Object *ob;
|
2010-04-06 01:34:55 +00:00
|
|
|
ARegion ar;
|
|
|
|
RegionView3D rv3d;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
shadows.first= shadows.last= NULL;
|
|
|
|
|
|
|
|
/* update lamp transform and gather shadow lamps */
|
|
|
|
for(SETLOOPER(scene, base)) {
|
|
|
|
ob= base->object;
|
|
|
|
|
|
|
|
if(ob->type == OB_LAMP)
|
|
|
|
gpu_render_lamp_update(scene, v3d, ob, NULL, ob->obmat, &shadows);
|
|
|
|
|
|
|
|
if (ob->transflag & OB_DUPLI) {
|
|
|
|
DupliObject *dob;
|
|
|
|
ListBase *lb = object_duplilist(scene, ob);
|
|
|
|
|
|
|
|
for(dob=lb->first; dob; dob=dob->next)
|
|
|
|
if(dob->ob->type==OB_LAMP)
|
|
|
|
gpu_render_lamp_update(scene, v3d, dob->ob, ob, dob->mat, &shadows);
|
|
|
|
|
|
|
|
free_object_duplilist(lb);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* render shadows after updating all lamps, nested object_duplilist
|
|
|
|
* don't work correct since it's replacing object matrices */
|
|
|
|
for(shadow=shadows.first; shadow; shadow=shadow->next) {
|
|
|
|
/* this needs to be done better .. */
|
|
|
|
float viewmat[4][4], winmat[4][4];
|
2010-07-04 17:22:24 +00:00
|
|
|
int drawtype, lay, winsize, flag2=v3d->flag2;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
drawtype= v3d->drawtype;
|
|
|
|
lay= v3d->lay;
|
|
|
|
|
|
|
|
v3d->drawtype = OB_SOLID;
|
|
|
|
v3d->lay &= GPU_lamp_shadow_layer(shadow->lamp);
|
|
|
|
v3d->flag2 &= ~V3D_SOLID_TEX;
|
2010-07-04 17:22:24 +00:00
|
|
|
v3d->flag2 |= V3D_RENDER_OVERRIDE;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
GPU_lamp_shadow_buffer_bind(shadow->lamp, viewmat, &winsize, winmat);
|
2010-04-06 01:34:55 +00:00
|
|
|
|
|
|
|
memset(&ar, 0, sizeof(ar));
|
|
|
|
memset(&rv3d, 0, sizeof(rv3d));
|
|
|
|
|
|
|
|
ar.regiondata= &rv3d;
|
|
|
|
ar.regiontype= RGN_TYPE_WINDOW;
|
|
|
|
rv3d.persp= RV3D_CAMOB;
|
|
|
|
copy_m4_m4(rv3d.winmat, winmat);
|
|
|
|
copy_m4_m4(rv3d.viewmat, viewmat);
|
|
|
|
invert_m4_m4(rv3d.viewinv, rv3d.viewmat);
|
|
|
|
mul_m4_m4m4(rv3d.persmat, rv3d.viewmat, rv3d.winmat);
|
|
|
|
invert_m4_m4(rv3d.persinv, rv3d.viewinv);
|
|
|
|
|
|
|
|
ED_view3d_draw_offscreen(scene, v3d, &ar, winsize, winsize, viewmat, winmat);
|
2008-12-19 12:14:58 +00:00
|
|
|
GPU_lamp_shadow_buffer_unbind(shadow->lamp);
|
|
|
|
|
|
|
|
v3d->drawtype= drawtype;
|
|
|
|
v3d->lay= lay;
|
2010-07-04 17:22:24 +00:00
|
|
|
v3d->flag2 = flag2;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BLI_freelistN(&shadows);
|
|
|
|
}
|
|
|
|
|
2009-01-07 14:46:50 +00:00
|
|
|
/* *********************** customdata **************** */
|
|
|
|
|
|
|
|
/* goes over all modes and view3d settings */
|
2009-08-18 15:27:48 +00:00
|
|
|
static CustomDataMask get_viewedit_datamask(bScreen *screen, Scene *scene, Object *ob)
|
2009-01-07 14:46:50 +00:00
|
|
|
{
|
|
|
|
CustomDataMask mask = CD_MASK_BAREMESH;
|
|
|
|
ScrArea *sa;
|
|
|
|
|
|
|
|
/* check if we need tfaces & mcols due to face select or texture paint */
|
2009-08-16 01:25:53 +00:00
|
|
|
if(paint_facesel_test(ob) || (ob && ob->mode & OB_MODE_TEXTURE_PAINT))
|
2009-01-07 14:46:50 +00:00
|
|
|
mask |= CD_MASK_MTFACE | CD_MASK_MCOL;
|
|
|
|
|
|
|
|
/* check if we need tfaces & mcols due to view mode */
|
|
|
|
for(sa = screen->areabase.first; sa; sa = sa->next) {
|
|
|
|
if(sa->spacetype == SPACE_VIEW3D) {
|
|
|
|
View3D *view = sa->spacedata.first;
|
|
|
|
if(view->drawtype == OB_SHADED) {
|
|
|
|
/* this includes normals for mesh_create_shadedColors */
|
|
|
|
mask |= CD_MASK_MTFACE | CD_MASK_MCOL | CD_MASK_NORMAL | CD_MASK_ORCO;
|
|
|
|
}
|
|
|
|
if((view->drawtype == OB_TEXTURE) || ((view->drawtype == OB_SOLID) && (view->flag2 & V3D_SOLID_TEX))) {
|
|
|
|
mask |= CD_MASK_MTFACE | CD_MASK_MCOL;
|
2010-03-04 15:58:27 +00:00
|
|
|
|
2009-08-18 15:27:48 +00:00
|
|
|
if(scene->gm.matmode == GAME_MAT_GLSL)
|
2009-01-07 14:46:50 +00:00
|
|
|
mask |= CD_MASK_ORCO;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check if we need mcols due to vertex paint or weightpaint */
|
2009-08-15 21:46:25 +00:00
|
|
|
if(ob) {
|
|
|
|
if(ob->mode & OB_MODE_VERTEX_PAINT)
|
|
|
|
mask |= CD_MASK_MCOL;
|
|
|
|
if(ob->mode & OB_MODE_WEIGHT_PAINT)
|
|
|
|
mask |= CD_MASK_WEIGHT_MCOL;
|
|
|
|
}
|
2009-08-15 18:58:01 +00:00
|
|
|
|
2009-01-07 14:46:50 +00:00
|
|
|
return mask;
|
|
|
|
}
|
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
static void view3d_main_area_setup_view(Scene *scene, View3D *v3d, ARegion *ar, float viewmat[][4], float winmat[][4])
|
2008-12-18 17:38:21 +00:00
|
|
|
{
|
2009-10-28 18:03:04 +00:00
|
|
|
RegionView3D *rv3d= ar->regiondata;
|
|
|
|
|
|
|
|
/* setup window matrices */
|
|
|
|
if(winmat)
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_m4_m4(rv3d->winmat, winmat);
|
2009-10-28 18:03:04 +00:00
|
|
|
else
|
|
|
|
setwinmatrixview3d(ar, v3d, NULL); /* NULL= no pickrect */
|
2008-12-18 17:38:21 +00:00
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
/* setup view matrix */
|
|
|
|
if(viewmat)
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_m4_m4(rv3d->viewmat, viewmat);
|
2009-10-28 18:03:04 +00:00
|
|
|
else
|
|
|
|
setviewmatrixview3d(scene, v3d, rv3d); /* note: calls where_is_object for camera... */
|
2008-12-18 17:38:21 +00:00
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
/* update utilitity matrices */
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_m4_m4m4(rv3d->persmat, rv3d->viewmat, rv3d->winmat);
|
|
|
|
invert_m4_m4(rv3d->persinv, rv3d->persmat);
|
|
|
|
invert_m4_m4(rv3d->viewinv, rv3d->viewmat);
|
2010-09-28 04:25:16 +00:00
|
|
|
|
2008-12-18 17:38:21 +00:00
|
|
|
/* calculate pixelsize factor once, is used for lamps and obcenters */
|
|
|
|
{
|
2010-09-28 04:25:16 +00:00
|
|
|
/* note: '1.0f / len_v3(v1)' replaced 'len_v3(rv3d->viewmat[0])'
|
|
|
|
* because of float point precission problems at large values [#23908] */
|
|
|
|
float v1[3]= {rv3d->persmat[0][0], rv3d->persmat[1][0], rv3d->persmat[2][0]};
|
|
|
|
float v2[3]= {rv3d->persmat[0][1], rv3d->persmat[1][1], rv3d->persmat[2][1]};
|
|
|
|
float len1= 1.0f / len_v3(v1);
|
|
|
|
float len2= 1.0f / len_v3(v2);
|
|
|
|
|
|
|
|
rv3d->pixsize = (2.0f * MAX2(len1, len2)) / (float)MAX2(ar->winx, ar->winy);
|
2008-12-18 17:38:21 +00:00
|
|
|
}
|
2010-09-19 06:41:44 +00:00
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
/* set for opengl */
|
|
|
|
glMatrixMode(GL_PROJECTION);
|
2010-02-01 15:32:55 +00:00
|
|
|
glLoadMatrixf(rv3d->winmat);
|
2009-10-28 18:03:04 +00:00
|
|
|
glMatrixMode(GL_MODELVIEW);
|
2010-02-01 15:32:55 +00:00
|
|
|
glLoadMatrixf(rv3d->viewmat);
|
2009-10-28 18:03:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar, int winx, int winy, float viewmat[][4], float winmat[][4])
|
|
|
|
{
|
|
|
|
Scene *sce;
|
|
|
|
Base *base;
|
2010-07-29 10:09:20 +00:00
|
|
|
float backcol[3];
|
2009-10-28 18:03:04 +00:00
|
|
|
int bwinx, bwiny;
|
2010-08-25 08:31:52 +00:00
|
|
|
rcti brect;
|
2009-10-28 18:03:04 +00:00
|
|
|
|
2009-12-08 19:27:30 +00:00
|
|
|
glPushMatrix();
|
2009-10-28 18:03:04 +00:00
|
|
|
|
|
|
|
/* set temporary new size */
|
|
|
|
bwinx= ar->winx;
|
|
|
|
bwiny= ar->winy;
|
2010-08-25 08:31:52 +00:00
|
|
|
brect= ar->winrct;
|
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
ar->winx= winx;
|
2010-08-25 08:31:52 +00:00
|
|
|
ar->winy= winy;
|
|
|
|
ar->winrct.xmin= 0;
|
|
|
|
ar->winrct.ymin= 0;
|
|
|
|
ar->winrct.xmax= winx;
|
|
|
|
ar->winrct.ymax= winy;
|
|
|
|
|
2010-07-04 17:22:24 +00:00
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
/* set flags */
|
|
|
|
G.f |= G_RENDER_OGL;
|
2010-05-20 16:08:06 +00:00
|
|
|
|
|
|
|
/* free images which can have changed on frame-change
|
|
|
|
* warning! can be slow so only free animated images - campbell */
|
|
|
|
GPU_free_images_anim();
|
2009-10-28 18:03:04 +00:00
|
|
|
|
2010-01-06 00:02:37 +00:00
|
|
|
/* set background color, fallback on the view background color */
|
|
|
|
if(scene->world) {
|
2010-07-29 10:09:20 +00:00
|
|
|
if(scene->r.color_mgt_flag & R_COLOR_MANAGEMENT)
|
|
|
|
linearrgb_to_srgb_v3_v3(backcol, &scene->world->horr);
|
|
|
|
else
|
|
|
|
copy_v3_v3(backcol, &scene->world->horr);
|
|
|
|
glClearColor(backcol[0], backcol[1], backcol[2], 0.0);
|
2010-01-06 00:02:37 +00:00
|
|
|
}
|
|
|
|
else {
|
2010-04-06 07:02:16 +00:00
|
|
|
UI_ThemeClearColor(TH_BACK);
|
2010-01-06 00:02:37 +00:00
|
|
|
}
|
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
|
|
|
|
|
|
|
|
/* setup view matrices */
|
|
|
|
view3d_main_area_setup_view(scene, v3d, ar, viewmat, winmat);
|
|
|
|
|
|
|
|
/* set zbuffer */
|
2008-12-18 17:38:21 +00:00
|
|
|
if(v3d->drawtype > OB_WIRE) {
|
2009-10-28 18:03:04 +00:00
|
|
|
v3d->zbuf= TRUE;
|
|
|
|
glEnable(GL_DEPTH_TEST);
|
2008-12-18 17:38:21 +00:00
|
|
|
}
|
2009-10-28 18:03:04 +00:00
|
|
|
else
|
|
|
|
v3d->zbuf= FALSE;
|
|
|
|
|
|
|
|
/* draw set first */
|
|
|
|
if(scene->set) {
|
|
|
|
for(SETLOOPER(scene->set, base)) {
|
|
|
|
if(v3d->lay & base->lay) {
|
|
|
|
UI_ThemeColorBlend(TH_WIRE, TH_BACK, 0.6f);
|
|
|
|
draw_object(scene, ar, v3d, base, DRAW_CONSTCOLOR|DRAW_SCENESET);
|
|
|
|
|
|
|
|
if(base->object->transflag & OB_DUPLI)
|
|
|
|
draw_dupli_objects_color(scene, ar, v3d, base, TH_WIRE);
|
|
|
|
}
|
|
|
|
}
|
2008-12-18 17:38:21 +00:00
|
|
|
}
|
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
/* then draw not selected and the duplis, but skip editmode object */
|
|
|
|
for(base= scene->base.first; base; base= base->next) {
|
|
|
|
if(v3d->lay & base->lay) {
|
|
|
|
/* dupli drawing */
|
|
|
|
if(base->object->transflag & OB_DUPLI)
|
|
|
|
draw_dupli_objects(scene, ar, v3d, base);
|
|
|
|
|
|
|
|
draw_object(scene, ar, v3d, base, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* transp and X-ray afterdraw stuff */
|
2010-08-25 14:23:02 +00:00
|
|
|
if(v3d->afterdraw_transp.first) view3d_draw_transp(scene, ar, v3d);
|
|
|
|
if(v3d->afterdraw_xray.first) view3d_draw_xray(scene, ar, v3d, 1); // clears zbuffer if it is used!
|
|
|
|
if(v3d->afterdraw_xraytransp.first) view3d_draw_xraytransp(scene, ar, v3d, 1);
|
2009-10-28 18:03:04 +00:00
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
if(v3d->zbuf) {
|
|
|
|
v3d->zbuf= FALSE;
|
|
|
|
glDisable(GL_DEPTH_TEST);
|
|
|
|
}
|
|
|
|
|
2009-11-09 08:03:43 +00:00
|
|
|
/* draw grease-pencil stuff */
|
2010-08-25 08:31:52 +00:00
|
|
|
draw_gpencil_view3d_ext(scene, v3d, ar, 1);
|
2009-11-09 08:03:43 +00:00
|
|
|
|
|
|
|
ED_region_pixelspace(ar);
|
|
|
|
|
|
|
|
/* draw grease-pencil stuff - needed to get paint-buffer shown too (since it's 2D) */
|
2010-08-25 08:31:52 +00:00
|
|
|
draw_gpencil_view3d_ext(scene, v3d, ar, 0);
|
2009-11-09 08:03:43 +00:00
|
|
|
|
2010-05-20 16:08:06 +00:00
|
|
|
/* freeing the images again here could be done after the operator runs, leaving for now */
|
|
|
|
GPU_free_images_anim();
|
2009-10-28 18:03:04 +00:00
|
|
|
|
|
|
|
/* restore size */
|
|
|
|
ar->winx= bwinx;
|
|
|
|
ar->winy= bwiny;
|
2010-08-25 08:31:52 +00:00
|
|
|
ar->winrct = brect;
|
2009-10-28 18:03:04 +00:00
|
|
|
|
2009-12-08 19:27:30 +00:00
|
|
|
glPopMatrix();
|
2010-03-08 21:33:51 +00:00
|
|
|
|
|
|
|
glColor4ub(255, 255, 255, 255); // XXX, without this the sequencer flickers with opengl draw enabled, need to find out why - campbell
|
2010-06-04 12:23:38 +00:00
|
|
|
|
|
|
|
G.f &= ~G_RENDER_OGL;
|
2009-10-28 18:03:04 +00:00
|
|
|
}
|
|
|
|
|
2010-03-08 20:08:04 +00:00
|
|
|
/* utility func for ED_view3d_draw_offscreen */
|
2010-08-26 23:30:15 +00:00
|
|
|
ImBuf *ED_view3d_draw_offscreen_imbuf(Scene *scene, View3D *v3d, ARegion *ar, int sizex, int sizey, unsigned int flag)
|
2010-03-08 20:08:04 +00:00
|
|
|
{
|
|
|
|
RegionView3D *rv3d= ar->regiondata;
|
|
|
|
ImBuf *ibuf;
|
|
|
|
GPUOffScreen *ofs;
|
|
|
|
|
|
|
|
/* bind */
|
|
|
|
ofs= GPU_offscreen_create(sizex, sizey);
|
|
|
|
if(ofs == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
GPU_offscreen_bind(ofs);
|
|
|
|
|
|
|
|
/* render 3d view */
|
|
|
|
if(rv3d->persp==RV3D_CAMOB && v3d->camera) {
|
|
|
|
float winmat[4][4];
|
|
|
|
float _clipsta, _clipend, _lens, _yco, _dx, _dy;
|
|
|
|
rctf _viewplane;
|
|
|
|
|
|
|
|
object_camera_matrix(&scene->r, v3d->camera, sizex, sizey, 0, winmat, &_viewplane, &_clipsta, &_clipend, &_lens, &_yco, &_dx, &_dy);
|
|
|
|
|
|
|
|
ED_view3d_draw_offscreen(scene, v3d, ar, sizex, sizey, NULL, winmat);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ED_view3d_draw_offscreen(scene, v3d, ar, sizex, sizey, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* read in pixels & stamp */
|
2010-10-16 14:32:17 +00:00
|
|
|
ibuf= IMB_allocImBuf(sizex, sizey, 32, flag);
|
2010-03-08 20:08:04 +00:00
|
|
|
|
2010-08-26 23:30:15 +00:00
|
|
|
if(ibuf->rect_float)
|
|
|
|
glReadPixels(0, 0, sizex, sizey, GL_RGBA, GL_FLOAT, ibuf->rect_float);
|
|
|
|
else if(ibuf->rect)
|
|
|
|
glReadPixels(0, 0, sizex, sizey, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
|
|
|
|
|
2010-03-08 20:08:04 +00:00
|
|
|
//if((scene->r.stamp & R_STAMP_ALL) && (scene->r.stamp & R_STAMP_DRAW))
|
|
|
|
// BKE_stamp_buf(scene, NULL, rr->rectf, rr->rectx, rr->recty, 4);
|
|
|
|
|
|
|
|
/* unbind */
|
|
|
|
GPU_offscreen_unbind(ofs);
|
|
|
|
GPU_offscreen_free(ofs);
|
|
|
|
|
2010-08-26 23:30:15 +00:00
|
|
|
if(ibuf->rect_float && ibuf->rect)
|
|
|
|
IMB_rect_from_float(ibuf);
|
|
|
|
|
2010-03-08 20:08:04 +00:00
|
|
|
return ibuf;
|
|
|
|
}
|
|
|
|
|
2010-03-08 21:33:51 +00:00
|
|
|
/* creates own 3d views, used by the sequencer */
|
2010-08-26 23:30:15 +00:00
|
|
|
ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Scene *scene, int width, int height, unsigned int flag, int drawtype)
|
2010-03-08 21:33:51 +00:00
|
|
|
{
|
|
|
|
View3D v3d;
|
|
|
|
ARegion ar;
|
|
|
|
RegionView3D rv3d;
|
|
|
|
|
|
|
|
memset(&v3d, 0, sizeof(v3d));
|
|
|
|
memset(&ar, 0, sizeof(ar));
|
|
|
|
memset(&rv3d, 0, sizeof(rv3d));
|
|
|
|
|
|
|
|
/* connect data */
|
|
|
|
v3d.regionbase.first= v3d.regionbase.last= &ar;
|
|
|
|
ar.regiondata= &rv3d;
|
|
|
|
ar.regiontype= RGN_TYPE_WINDOW;
|
|
|
|
|
|
|
|
v3d.camera= scene->camera;
|
|
|
|
v3d.lay= scene->lay;
|
2010-03-16 17:37:34 +00:00
|
|
|
v3d.drawtype = drawtype;
|
2010-03-16 17:49:31 +00:00
|
|
|
v3d.flag2 = V3D_RENDER_OVERRIDE;
|
2010-03-08 21:33:51 +00:00
|
|
|
|
|
|
|
rv3d.persp= RV3D_CAMOB;
|
|
|
|
|
|
|
|
copy_m4_m4(rv3d.viewinv, v3d.camera->obmat);
|
|
|
|
normalize_m4(rv3d.viewinv);
|
|
|
|
invert_m4_m4(rv3d.viewmat, rv3d.viewinv);
|
|
|
|
|
|
|
|
{
|
|
|
|
float _yco, _dx, _dy;
|
|
|
|
rctf _viewplane;
|
|
|
|
object_camera_matrix(&scene->r, v3d.camera, width, height, 0, rv3d.winmat, &_viewplane, &v3d.near, &v3d.far, &v3d.lens, &_yco, &_dx, &_dy);
|
|
|
|
}
|
|
|
|
|
|
|
|
mul_m4_m4m4(rv3d.persmat, rv3d.viewmat, rv3d.winmat);
|
|
|
|
invert_m4_m4(rv3d.persinv, rv3d.viewinv);
|
|
|
|
|
2010-08-26 23:30:15 +00:00
|
|
|
return ED_view3d_draw_offscreen_imbuf(scene, &v3d, &ar, width, height, flag);
|
2010-03-08 21:33:51 +00:00
|
|
|
|
|
|
|
// seq_view3d_cb(scene, cfra, render_size, seqrectx, seqrecty);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-12 00:44:26 +00:00
|
|
|
/* NOTE: the info that this uses is updated in ED_refresh_viewport_fps(),
|
|
|
|
* which currently gets called during SCREEN_OT_animation_step.
|
|
|
|
*/
|
|
|
|
static void draw_viewport_fps(Scene *scene, ARegion *ar)
|
|
|
|
{
|
|
|
|
ScreenFrameRateInfo *fpsi= scene->fps_info;
|
|
|
|
float fps;
|
|
|
|
char printable[16];
|
|
|
|
int i, tot;
|
|
|
|
|
|
|
|
if (!fpsi || !fpsi->lredrawtime || !fpsi->redrawtime)
|
|
|
|
return;
|
|
|
|
|
|
|
|
printable[0] = '\0';
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
/* this is too simple, better do an average */
|
|
|
|
fps = (float)(1.0/(fpsi->lredrawtime-fpsi->redrawtime))
|
|
|
|
#else
|
|
|
|
fpsi->redrawtimes_fps[fpsi->redrawtime_index] = (float)(1.0/(fpsi->lredrawtime-fpsi->redrawtime));
|
|
|
|
|
|
|
|
for (i=0, tot=0, fps=0.0f ; i < REDRAW_FRAME_AVERAGE ; i++) {
|
|
|
|
if (fpsi->redrawtimes_fps[i]) {
|
|
|
|
fps += fpsi->redrawtimes_fps[i];
|
|
|
|
tot++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (tot) {
|
|
|
|
fpsi->redrawtime_index = (fpsi->redrawtime_index + 1) % REDRAW_FRAME_AVERAGE;
|
|
|
|
|
|
|
|
//fpsi->redrawtime_index++;
|
|
|
|
//if (fpsi->redrawtime >= REDRAW_FRAME_AVERAGE)
|
|
|
|
// fpsi->redrawtime = 0;
|
|
|
|
|
|
|
|
fps = fps / tot;
|
|
|
|
}
|
|
|
|
#endif
|
2010-04-15 16:44:38 +00:00
|
|
|
|
2010-02-12 00:44:26 +00:00
|
|
|
/* is this more then half a frame behind? */
|
|
|
|
if (fps+0.5 < FPS) {
|
|
|
|
UI_ThemeColor(TH_REDALERT);
|
2010-04-15 17:44:48 +00:00
|
|
|
BLI_snprintf(printable, sizeof(printable), "fps: %.2f", (float)fps);
|
2010-02-12 00:44:26 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
UI_ThemeColor(TH_TEXT_HI);
|
2010-04-15 17:44:48 +00:00
|
|
|
BLI_snprintf(printable, sizeof(printable), "fps: %i", (int)(fps+0.5));
|
2010-02-12 00:44:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BLF_draw_default(22, ar->winy-17, 0.0f, printable);
|
|
|
|
}
|
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
void view3d_main_area_draw(const bContext *C, ARegion *ar)
|
|
|
|
{
|
|
|
|
Scene *scene= CTX_data_scene(C);
|
|
|
|
View3D *v3d = CTX_wm_view3d(C);
|
|
|
|
RegionView3D *rv3d= CTX_wm_region_view3d(C);
|
|
|
|
Scene *sce;
|
|
|
|
Base *base;
|
|
|
|
Object *ob;
|
2010-07-29 10:09:20 +00:00
|
|
|
float backcol[3];
|
2010-10-02 19:45:53 +00:00
|
|
|
int retopo= 0, sculptparticle= 0;
|
|
|
|
unsigned int lay_used;
|
2009-10-28 18:03:04 +00:00
|
|
|
Object *obact = OBACT;
|
|
|
|
char *grid_unit= NULL;
|
2010-02-03 20:45:35 +00:00
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
/* from now on all object derived meshes check this */
|
|
|
|
v3d->customdata_mask= get_viewedit_datamask(CTX_wm_screen(C), scene, obact);
|
2010-03-04 15:58:27 +00:00
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
/* shadow buffers, before we setup matrices */
|
|
|
|
if(draw_glsl_material(scene, NULL, v3d, v3d->drawtype))
|
|
|
|
gpu_update_lamps_shadows(scene, v3d);
|
2010-03-09 06:20:08 +00:00
|
|
|
|
|
|
|
/* reset default OpenGL lights if needed (i.e. after preferences have been altered) */
|
|
|
|
if (rv3d->rflag & RV3D_GPULIGHT_UPDATE) {
|
|
|
|
rv3d->rflag &= ~RV3D_GPULIGHT_UPDATE;
|
|
|
|
GPU_default_lights();
|
|
|
|
}
|
2009-10-28 18:03:04 +00:00
|
|
|
|
|
|
|
/* clear background */
|
2010-07-29 10:09:20 +00:00
|
|
|
if((v3d->flag2 & V3D_RENDER_OVERRIDE) && scene->world) {
|
|
|
|
if(scene->r.color_mgt_flag & R_COLOR_MANAGEMENT)
|
|
|
|
linearrgb_to_srgb_v3_v3(backcol, &scene->world->horr);
|
|
|
|
else
|
|
|
|
copy_v3_v3(backcol, &scene->world->horr);
|
|
|
|
glClearColor(backcol[0], backcol[1], backcol[2], 0.0);
|
|
|
|
}
|
2010-07-19 19:57:28 +00:00
|
|
|
else
|
|
|
|
UI_ThemeClearColor(TH_BACK);
|
|
|
|
|
2009-10-28 18:03:04 +00:00
|
|
|
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
|
|
|
|
|
|
|
|
/* setup view matrices */
|
|
|
|
view3d_main_area_setup_view(scene, v3d, ar, NULL, NULL);
|
|
|
|
|
2010-02-03 20:45:35 +00:00
|
|
|
ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW);
|
|
|
|
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
if(rv3d->rflag & RV3D_CLIPPING)
|
|
|
|
view3d_draw_clipping(rv3d);
|
2008-12-18 17:38:21 +00:00
|
|
|
|
|
|
|
/* set zbuffer after we draw clipping region */
|
|
|
|
if(v3d->drawtype > OB_WIRE) {
|
|
|
|
v3d->zbuf= TRUE;
|
|
|
|
glEnable(GL_DEPTH_TEST);
|
|
|
|
}
|
2009-10-07 22:05:30 +00:00
|
|
|
else
|
|
|
|
v3d->zbuf= FALSE;
|
2010-01-08 09:30:36 +00:00
|
|
|
|
|
|
|
/* enables anti-aliasing for 3D view drawing */
|
2010-01-31 09:49:46 +00:00
|
|
|
/*if (!(U.gameflags & USER_DISABLE_AA))
|
|
|
|
glEnable(GL_MULTISAMPLE_ARB);*/
|
2008-12-18 17:38:21 +00:00
|
|
|
|
|
|
|
// needs to be done always, gridview is adjusted in drawgrid() now
|
2009-12-27 18:09:17 +00:00
|
|
|
rv3d->gridview= v3d->grid;
|
2008-12-18 17:38:21 +00:00
|
|
|
|
2010-03-16 17:49:31 +00:00
|
|
|
if ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) {
|
|
|
|
|
|
|
|
if(rv3d->view==0 || rv3d->persp != RV3D_ORTHO) {
|
|
|
|
drawfloor(scene, v3d);
|
|
|
|
if(rv3d->persp==RV3D_CAMOB) {
|
|
|
|
if(scene->world) {
|
|
|
|
if(scene->world->mode & WO_STARS) {
|
|
|
|
RE_make_stars(NULL, scene, star_stuff_init_func, star_stuff_vertex_func,
|
|
|
|
star_stuff_term_func);
|
|
|
|
}
|
2008-12-18 17:38:21 +00:00
|
|
|
}
|
2010-03-16 17:49:31 +00:00
|
|
|
if(v3d->flag & V3D_DISPBGPICS) draw_bgpic(scene, ar, v3d);
|
2008-12-18 17:38:21 +00:00
|
|
|
}
|
|
|
|
}
|
2010-03-16 17:49:31 +00:00
|
|
|
else {
|
|
|
|
ED_region_pixelspace(ar);
|
|
|
|
drawgrid(&scene->unit, ar, v3d, &grid_unit);
|
|
|
|
/* XXX make function? replaces persp(1) */
|
|
|
|
glMatrixMode(GL_PROJECTION);
|
|
|
|
glLoadMatrixf(rv3d->winmat);
|
|
|
|
glMatrixMode(GL_MODELVIEW);
|
|
|
|
glLoadMatrixf(rv3d->viewmat);
|
|
|
|
|
|
|
|
if(v3d->flag & V3D_DISPBGPICS) {
|
|
|
|
draw_bgpic(scene, ar, v3d);
|
|
|
|
}
|
2008-12-18 17:38:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
if(rv3d->rflag & RV3D_CLIPPING)
|
|
|
|
view3d_set_clipping(rv3d);
|
2010-03-04 15:58:27 +00:00
|
|
|
|
2008-12-18 17:38:21 +00:00
|
|
|
/* draw set first */
|
|
|
|
if(scene->set) {
|
|
|
|
for(SETLOOPER(scene->set, base)) {
|
|
|
|
|
|
|
|
if(v3d->lay & base->lay) {
|
|
|
|
|
|
|
|
UI_ThemeColorBlend(TH_WIRE, TH_BACK, 0.6f);
|
2008-12-19 14:14:43 +00:00
|
|
|
draw_object(scene, ar, v3d, base, DRAW_CONSTCOLOR|DRAW_SCENESET);
|
2008-12-18 17:38:21 +00:00
|
|
|
|
|
|
|
if(base->object->transflag & OB_DUPLI) {
|
2008-12-19 14:14:43 +00:00
|
|
|
draw_dupli_objects_color(scene, ar, v3d, base, TH_WIRE);
|
2008-12-18 17:38:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Transp and X-ray afterdraw stuff for sets is done later */
|
|
|
|
}
|
2010-03-04 15:58:27 +00:00
|
|
|
|
2010-10-02 09:28:41 +00:00
|
|
|
lay_used= 0;
|
|
|
|
|
2008-12-18 17:38:21 +00:00
|
|
|
/* then draw not selected and the duplis, but skip editmode object */
|
|
|
|
for(base= scene->base.first; base; base= base->next) {
|
2010-10-02 19:45:53 +00:00
|
|
|
lay_used |= base->lay & ((1<<20)-1);
|
2010-10-02 09:28:41 +00:00
|
|
|
|
2008-12-18 17:38:21 +00:00
|
|
|
if(v3d->lay & base->lay) {
|
|
|
|
|
|
|
|
/* dupli drawing */
|
|
|
|
if(base->object->transflag & OB_DUPLI) {
|
2008-12-19 14:14:43 +00:00
|
|
|
draw_dupli_objects(scene, ar, v3d, base);
|
2008-12-18 17:38:21 +00:00
|
|
|
}
|
|
|
|
if((base->flag & SELECT)==0) {
|
2009-01-02 19:10:35 +00:00
|
|
|
if(base->object!=scene->obedit)
|
2008-12-19 14:14:43 +00:00
|
|
|
draw_object(scene, ar, v3d, base, 0);
|
2008-12-18 17:38:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-01-13 19:57:36 +00:00
|
|
|
|
2010-10-02 09:28:41 +00:00
|
|
|
if(v3d->lay_used != lay_used) { /* happens when loading old files or loading with UI load */
|
|
|
|
ARegion *ar;
|
|
|
|
ScrArea *sa= CTX_wm_area(C);
|
|
|
|
|
|
|
|
/* find header and force tag redraw */
|
|
|
|
for(ar= sa->regionbase.first; ar; ar= ar->next)
|
|
|
|
if(ar->regiontype==RGN_TYPE_HEADER) {
|
|
|
|
ED_region_tag_redraw(ar);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
v3d->lay_used= lay_used;
|
|
|
|
}
|
|
|
|
|
2008-12-18 17:38:21 +00:00
|
|
|
// retopo= retopo_mesh_check() || retopo_curve_check();
|
2009-10-27 19:53:34 +00:00
|
|
|
sculptparticle= (obact && obact->mode & (OB_MODE_PARTICLE_EDIT)) && !scene->obedit;
|
2008-12-18 17:38:21 +00:00
|
|
|
if(retopo)
|
2010-10-15 12:29:02 +00:00
|
|
|
view3d_update_depths(ar);
|
2008-12-18 17:38:21 +00:00
|
|
|
|
|
|
|
/* draw selected and editmode */
|
|
|
|
for(base= scene->base.first; base; base= base->next) {
|
|
|
|
if(v3d->lay & base->lay) {
|
2009-01-02 19:10:35 +00:00
|
|
|
if (base->object==scene->obedit || ( base->flag & SELECT) )
|
2008-12-19 14:14:43 +00:00
|
|
|
draw_object(scene, ar, v3d, base, 0);
|
2008-12-18 17:38:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!retopo && sculptparticle && !(obact && (obact->dtx & OB_DRAWXRAY))) {
|
2010-10-15 12:29:02 +00:00
|
|
|
view3d_update_depths(ar);
|
2008-12-18 17:38:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// REEB_draw();
|
|
|
|
|
|
|
|
/* Transp and X-ray afterdraw stuff */
|
2010-08-25 14:23:02 +00:00
|
|
|
if(v3d->afterdraw_transp.first) view3d_draw_transp(scene, ar, v3d);
|
|
|
|
if(v3d->afterdraw_xray.first) view3d_draw_xray(scene, ar, v3d, 1); // clears zbuffer if it is used!
|
|
|
|
if(v3d->afterdraw_xraytransp.first) view3d_draw_xraytransp(scene, ar, v3d, 1);
|
2008-12-18 17:38:21 +00:00
|
|
|
|
2010-02-09 09:56:04 +00:00
|
|
|
ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW);
|
|
|
|
|
2008-12-18 17:38:21 +00:00
|
|
|
if(!retopo && sculptparticle && (obact && (OBACT->dtx & OB_DRAWXRAY))) {
|
2010-10-15 12:29:02 +00:00
|
|
|
view3d_update_depths(ar);
|
2008-12-18 17:38:21 +00:00
|
|
|
}
|
|
|
|
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
if(rv3d->rflag & RV3D_CLIPPING)
|
2008-12-18 17:38:21 +00:00
|
|
|
view3d_clr_clipping();
|
|
|
|
|
2009-07-08 15:01:28 +00:00
|
|
|
BIF_draw_manipulator(C);
|
2008-12-18 17:38:21 +00:00
|
|
|
|
2010-01-08 09:30:36 +00:00
|
|
|
/* Disable back anti-aliasing */
|
2010-01-31 09:49:46 +00:00
|
|
|
/*if (!(U.gameflags & USER_DISABLE_AA))
|
|
|
|
glDisable(GL_MULTISAMPLE_ARB);*/
|
2010-01-08 09:30:36 +00:00
|
|
|
|
2008-12-18 17:38:21 +00:00
|
|
|
if(v3d->zbuf) {
|
|
|
|
v3d->zbuf= FALSE;
|
|
|
|
glDisable(GL_DEPTH_TEST);
|
|
|
|
}
|
|
|
|
|
2010-03-16 17:49:31 +00:00
|
|
|
if ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) {
|
|
|
|
/* draw grease-pencil stuff (3d-space strokes) */
|
|
|
|
//if (v3d->flag2 & V3D_DISPGP)
|
2010-04-28 07:25:39 +00:00
|
|
|
draw_gpencil_view3d((bContext *)C, 1);
|
2010-03-16 17:49:31 +00:00
|
|
|
|
|
|
|
BDR_drawSketch(C);
|
|
|
|
}
|
|
|
|
|
2008-12-19 14:14:43 +00:00
|
|
|
ED_region_pixelspace(ar);
|
2008-12-18 17:38:21 +00:00
|
|
|
|
|
|
|
// retopo_paint_view_update(v3d);
|
|
|
|
// retopo_draw_paint_lines();
|
|
|
|
|
|
|
|
/* Draw particle edit brush XXX (removed) */
|
|
|
|
|
2010-03-16 17:49:31 +00:00
|
|
|
|
2010-10-02 19:31:23 +00:00
|
|
|
if(rv3d->persp==RV3D_CAMOB)
|
|
|
|
drawviewborder(scene, ar, v3d);
|
2010-03-16 17:49:31 +00:00
|
|
|
|
merge own commits into render branch into trunk since 27560
27562, 27570, 27571, 27574, 27576, 27577, 27579, 27590, 27591, 27594, 27595, 27596, 27599, 27605, 27611, 27612, 27613, 27614, 27623
2010-03-20 16:41:01 +00:00
|
|
|
if ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) {
|
2010-03-16 17:49:31 +00:00
|
|
|
/* draw grease-pencil stuff - needed to get paint-buffer shown too (since it's 2D) */
|
|
|
|
// if (v3d->flag2 & V3D_DISPGP)
|
2010-04-28 07:25:39 +00:00
|
|
|
draw_gpencil_view3d((bContext *)C, 0);
|
2008-12-18 17:38:21 +00:00
|
|
|
|
2010-03-16 17:49:31 +00:00
|
|
|
drawcursor(scene, ar, v3d);
|
|
|
|
}
|
2009-01-13 15:18:41 +00:00
|
|
|
|
2008-12-18 17:38:21 +00:00
|
|
|
if(U.uiflag & USER_SHOW_ROTVIEWICON)
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
draw_view_axis(rv3d);
|
2008-12-18 17:38:21 +00:00
|
|
|
else
|
2.5
View3D has been split now in a local part (RegionView3D) and a
per-area part (old View3D). Currently local is:
- view transform
- camera zoom/offset
- gpencil (todo)
- custom clipping planes
Rest is in Area still, like active camera, draw type, layers,
localview, custom centers, around-settings, transform widget,
gridlines, and so on (mostly stuff as available in header).
To see it work; also added new feature for region split,
press SHIFT+ALT+CTRL+S for four-split.
The idea is to make a preset 4-split, configured to stick
to top/right/front views for three views.
Another cool idea to explore is to then box-clip all drawing
based on these 3 views.
Note about the code:
- currently view3d still stores some depricated settings, to
convert from older files. Not all settings are copied over
though, like custom clip planes or the 'lock view to object'.
- since some view3d ops are now on area level, the operators
for it should keep track of that.
Bugfix in transform: quat initialize in operator-invoke missed
one zero.
Als brought back GE to compile for missing Ipos and channels.
2009-01-19 16:54:41 +00:00
|
|
|
draw_view_icon(rv3d);
|
2008-12-18 17:38:21 +00:00
|
|
|
|
2010-02-12 00:44:26 +00:00
|
|
|
if((U.uiflag & USER_SHOW_FPS) && (CTX_wm_screen(C)->animtimer)) {
|
|
|
|
draw_viewport_fps(scene, ar);
|
|
|
|
}
|
|
|
|
else if(U.uiflag & USER_SHOW_VIEWPORTNAME) {
|
2008-12-18 17:38:21 +00:00
|
|
|
draw_viewport_name(ar, v3d);
|
|
|
|
}
|
2009-08-12 14:11:53 +00:00
|
|
|
if (grid_unit) { /* draw below the viewport name */
|
|
|
|
UI_ThemeColor(TH_TEXT_HI);
|
2010-04-05 05:32:16 +00:00
|
|
|
BLF_draw_default(22, ar->winy-(USER_SHOW_VIEWPORTNAME?40:20), 0.0f, grid_unit);
|
2009-08-12 14:11:53 +00:00
|
|
|
}
|
|
|
|
|
2008-12-18 17:38:21 +00:00
|
|
|
ob= OBACT;
|
|
|
|
if(U.uiflag & USER_DRAWVIEWINFO)
|
|
|
|
draw_selected_name(scene, ob, v3d);
|
|
|
|
|
|
|
|
/* XXX here was the blockhandlers for floating panels */
|
|
|
|
|
2009-12-17 14:38:30 +00:00
|
|
|
v3d->flag |= V3D_INVALID_BACKBUF;
|
2008-12-18 17:38:21 +00:00
|
|
|
}
|