2008-12-19 12:14:58 +00:00
|
|
|
/**
|
|
|
|
|
* $Id:
|
|
|
|
|
*
|
|
|
|
|
* ***** 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
|
2008-12-26 10:31:44 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
2008-12-19 12:14:58 +00:00
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
|
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
*
|
|
|
|
|
* The Original Code is Copyright (C) 2008 Blender Foundation.
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
2008-12-26 10:31:44 +00:00
|
|
|
*
|
2008-12-19 12:14:58 +00:00
|
|
|
* Contributor(s): Blender Foundation
|
|
|
|
|
*
|
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <math.h>
|
|
|
|
|
#include <float.h>
|
|
|
|
|
|
|
|
|
|
#include "DNA_action_types.h"
|
2008-12-20 11:33:16 +00:00
|
|
|
#include "DNA_armature_types.h"
|
2008-12-19 12:14:58 +00:00
|
|
|
#include "DNA_camera_types.h"
|
|
|
|
|
#include "DNA_lamp_types.h"
|
|
|
|
|
#include "DNA_object_types.h"
|
|
|
|
|
#include "DNA_space_types.h"
|
|
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
|
#include "DNA_screen_types.h"
|
|
|
|
|
#include "DNA_userdef_types.h"
|
|
|
|
|
#include "DNA_view3d_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-19 12:14:58 +00:00
|
|
|
#include "BLI_rand.h"
|
|
|
|
|
|
|
|
|
|
#include "BKE_action.h"
|
2008-12-19 17:14:02 +00:00
|
|
|
#include "BKE_context.h"
|
2008-12-20 15:42:48 +00:00
|
|
|
#include "BKE_depsgraph.h"
|
2008-12-19 12:14:58 +00:00
|
|
|
#include "BKE_object.h"
|
|
|
|
|
#include "BKE_global.h"
|
2009-08-15 19:48:50 +00:00
|
|
|
#include "BKE_paint.h"
|
2009-01-21 02:24:12 +00:00
|
|
|
#include "BKE_report.h"
|
2008-12-19 12:14:58 +00:00
|
|
|
#include "BKE_scene.h"
|
|
|
|
|
#include "BKE_screen.h"
|
|
|
|
|
#include "BKE_utildefines.h"
|
|
|
|
|
|
|
|
|
|
#include "RE_pipeline.h" // make_stars
|
|
|
|
|
|
|
|
|
|
#include "BIF_gl.h"
|
|
|
|
|
|
|
|
|
|
#include "WM_api.h"
|
2008-12-19 17:14:02 +00:00
|
|
|
#include "WM_types.h"
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2008-12-19 19:27:41 +00:00
|
|
|
#include "RNA_access.h"
|
|
|
|
|
#include "RNA_define.h"
|
|
|
|
|
|
2009-02-20 20:39:27 +00:00
|
|
|
#include "ED_particle.h"
|
2009-07-08 16:17:47 +00:00
|
|
|
#include "ED_retopo.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"
|
2008-12-19 12:14:58 +00:00
|
|
|
#include "ED_screen.h"
|
2009-07-08 16:17:47 +00:00
|
|
|
#include "ED_transform.h"
|
2008-12-19 17:14:02 +00:00
|
|
|
#include "ED_types.h"
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
#include "UI_interface.h"
|
|
|
|
|
#include "UI_resources.h"
|
|
|
|
|
#include "UI_view2d.h"
|
|
|
|
|
|
|
|
|
|
#include "PIL_time.h" /* smoothview */
|
|
|
|
|
|
|
|
|
|
#include "view3d_intern.h" // own include
|
|
|
|
|
|
|
|
|
|
/* ********************** view3d_edit: view manipulations ********************* */
|
|
|
|
|
|
2009-01-20 18:31:11 +00:00
|
|
|
/* ********************* box view support ***************** */
|
|
|
|
|
|
|
|
|
|
static void view3d_boxview_clip(ScrArea *sa)
|
|
|
|
|
{
|
|
|
|
|
ARegion *ar;
|
|
|
|
|
BoundBox *bb = MEM_callocN(sizeof(BoundBox), "clipbb");
|
|
|
|
|
float clip[6][4];
|
2009-10-21 17:56:26 +00:00
|
|
|
float x1= 0.0f, y1= 0.0f, z1= 0.0f, ofs[3] = {0.0f, 0.0f, 0.0f};
|
2009-01-20 18:31:11 +00:00
|
|
|
int val;
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2009-01-20 18:31:11 +00:00
|
|
|
/* create bounding box */
|
|
|
|
|
for(ar= sa->regionbase.first; ar; ar= ar->next) {
|
|
|
|
|
if(ar->regiontype==RGN_TYPE_WINDOW) {
|
|
|
|
|
RegionView3D *rv3d= ar->regiondata;
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2.5
Smaller jobs, all in one commit!
- Moved object_do_update out of view3d drawing, into
the event system (currently after notifiers).
Depsgraph calls for setting update flags will have to
keep track of each Screen's needs, so a UI showing only
a Sequencer doesn't do objects.
- Added button in "Properties region" in 3D window to set
or disable 4-split, including the 3 options it has.
(lock, box, clip)
- Restored legacy code for UI, to make things work like
bone rename, autocomplete.
- Node editor now shows Curves widgets again
- Bugfix: composite job increased Viewer user id count
- Bugfix: Node editor, not "Enable nodes" still called
a Job, which didn't do anything
- Various code cleaning, unused vars and prototypes.
2009-02-11 16:54:55 +00:00
|
|
|
if(rv3d->viewlock & RV3D_BOXCLIP) {
|
2009-10-27 02:54:25 +00:00
|
|
|
if(ELEM(rv3d->view, RV3D_VIEW_TOP, RV3D_VIEW_BOTTOM)) {
|
2009-01-20 18:31:11 +00:00
|
|
|
if(ar->winx>ar->winy) x1= rv3d->dist;
|
|
|
|
|
else x1= ar->winx*rv3d->dist/ar->winy;
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2009-01-20 18:31:11 +00:00
|
|
|
if(ar->winx>ar->winy) y1= ar->winy*rv3d->dist/ar->winx;
|
|
|
|
|
else y1= rv3d->dist;
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2009-01-20 18:31:11 +00:00
|
|
|
ofs[0]= rv3d->ofs[0];
|
|
|
|
|
ofs[1]= rv3d->ofs[1];
|
|
|
|
|
}
|
2009-10-27 02:54:25 +00:00
|
|
|
else if(ELEM(rv3d->view, RV3D_VIEW_FRONT, RV3D_VIEW_BACK)) {
|
2009-01-20 18:31:11 +00:00
|
|
|
ofs[2]= rv3d->ofs[2];
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2009-01-20 18:31:11 +00:00
|
|
|
if(ar->winx>ar->winy) z1= ar->winy*rv3d->dist/ar->winx;
|
|
|
|
|
else z1= rv3d->dist;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2009-01-20 18:31:11 +00:00
|
|
|
for(val=0; val<8; val++) {
|
|
|
|
|
if(ELEM4(val, 0, 3, 4, 7))
|
|
|
|
|
bb->vec[val][0]= -x1 - ofs[0];
|
|
|
|
|
else
|
|
|
|
|
bb->vec[val][0]= x1 - ofs[0];
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2009-01-20 18:31:11 +00:00
|
|
|
if(ELEM4(val, 0, 1, 4, 5))
|
|
|
|
|
bb->vec[val][1]= -y1 - ofs[1];
|
|
|
|
|
else
|
|
|
|
|
bb->vec[val][1]= y1 - ofs[1];
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2009-01-20 18:31:11 +00:00
|
|
|
if(val > 3)
|
|
|
|
|
bb->vec[val][2]= -z1 - ofs[2];
|
|
|
|
|
else
|
|
|
|
|
bb->vec[val][2]= z1 - ofs[2];
|
2009-07-09 02:45:48 +00:00
|
|
|
}
|
|
|
|
|
|
2009-01-20 18:31:11 +00:00
|
|
|
/* normals for plane equations */
|
2009-11-10 20:43:45 +00:00
|
|
|
normal_tri_v3( clip[0],bb->vec[0], bb->vec[1], bb->vec[4]);
|
|
|
|
|
normal_tri_v3( clip[1],bb->vec[1], bb->vec[2], bb->vec[5]);
|
|
|
|
|
normal_tri_v3( clip[2],bb->vec[2], bb->vec[3], bb->vec[6]);
|
|
|
|
|
normal_tri_v3( clip[3],bb->vec[3], bb->vec[0], bb->vec[7]);
|
|
|
|
|
normal_tri_v3( clip[4],bb->vec[4], bb->vec[5], bb->vec[6]);
|
|
|
|
|
normal_tri_v3( clip[5],bb->vec[0], bb->vec[2], bb->vec[1]);
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2009-01-20 18:31:11 +00:00
|
|
|
/* then plane equations */
|
|
|
|
|
for(val=0; val<5; val++) {
|
|
|
|
|
clip[val][3]= - clip[val][0]*bb->vec[val][0] - clip[val][1]*bb->vec[val][1] - clip[val][2]*bb->vec[val][2];
|
|
|
|
|
}
|
|
|
|
|
clip[5][3]= - clip[5][0]*bb->vec[0][0] - clip[5][1]*bb->vec[0][1] - clip[5][2]*bb->vec[0][2];
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2009-01-20 18:31:11 +00:00
|
|
|
/* create bounding box */
|
|
|
|
|
for(ar= sa->regionbase.first; ar; ar= ar->next) {
|
|
|
|
|
if(ar->regiontype==RGN_TYPE_WINDOW) {
|
|
|
|
|
RegionView3D *rv3d= ar->regiondata;
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2.5
Smaller jobs, all in one commit!
- Moved object_do_update out of view3d drawing, into
the event system (currently after notifiers).
Depsgraph calls for setting update flags will have to
keep track of each Screen's needs, so a UI showing only
a Sequencer doesn't do objects.
- Added button in "Properties region" in 3D window to set
or disable 4-split, including the 3 options it has.
(lock, box, clip)
- Restored legacy code for UI, to make things work like
bone rename, autocomplete.
- Node editor now shows Curves widgets again
- Bugfix: composite job increased Viewer user id count
- Bugfix: Node editor, not "Enable nodes" still called
a Job, which didn't do anything
- Various code cleaning, unused vars and prototypes.
2009-02-11 16:54:55 +00:00
|
|
|
if(rv3d->viewlock & RV3D_BOXCLIP) {
|
2009-01-20 18:31:11 +00:00
|
|
|
rv3d->rflag |= RV3D_CLIPPING;
|
|
|
|
|
memcpy(rv3d->clip, clip, sizeof(clip));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
MEM_freeN(bb);
|
|
|
|
|
}
|
|
|
|
|
|
2.5
Smaller jobs, all in one commit!
- Moved object_do_update out of view3d drawing, into
the event system (currently after notifiers).
Depsgraph calls for setting update flags will have to
keep track of each Screen's needs, so a UI showing only
a Sequencer doesn't do objects.
- Added button in "Properties region" in 3D window to set
or disable 4-split, including the 3 options it has.
(lock, box, clip)
- Restored legacy code for UI, to make things work like
bone rename, autocomplete.
- Node editor now shows Curves widgets again
- Bugfix: composite job increased Viewer user id count
- Bugfix: Node editor, not "Enable nodes" still called
a Job, which didn't do anything
- Various code cleaning, unused vars and prototypes.
2009-02-11 16:54:55 +00:00
|
|
|
/* sync center/zoom view of region to others, for view transforms */
|
2009-01-20 14:23:32 +00:00
|
|
|
static void view3d_boxview_sync(ScrArea *sa, ARegion *ar)
|
|
|
|
|
{
|
|
|
|
|
ARegion *artest;
|
|
|
|
|
RegionView3D *rv3d= ar->regiondata;
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2009-01-20 14:23:32 +00:00
|
|
|
for(artest= sa->regionbase.first; artest; artest= artest->next) {
|
|
|
|
|
if(artest!=ar && artest->regiontype==RGN_TYPE_WINDOW) {
|
|
|
|
|
RegionView3D *rv3dtest= artest->regiondata;
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2009-01-20 14:23:32 +00:00
|
|
|
if(rv3dtest->viewlock) {
|
|
|
|
|
rv3dtest->dist= rv3d->dist;
|
|
|
|
|
|
2009-10-27 02:54:25 +00:00
|
|
|
if( ELEM(rv3d->view, RV3D_VIEW_TOP, RV3D_VIEW_BOTTOM) ) {
|
|
|
|
|
if( ELEM(rv3dtest->view, RV3D_VIEW_FRONT, RV3D_VIEW_BACK))
|
2009-01-20 14:23:32 +00:00
|
|
|
rv3dtest->ofs[0]= rv3d->ofs[0];
|
2009-10-27 02:54:25 +00:00
|
|
|
else if( ELEM(rv3dtest->view, RV3D_VIEW_RIGHT, RV3D_VIEW_LEFT))
|
2009-01-20 14:23:32 +00:00
|
|
|
rv3dtest->ofs[1]= rv3d->ofs[1];
|
|
|
|
|
}
|
2009-10-27 02:54:25 +00:00
|
|
|
else if( ELEM(rv3d->view, RV3D_VIEW_FRONT, RV3D_VIEW_BACK) ) {
|
|
|
|
|
if( ELEM(rv3dtest->view, RV3D_VIEW_TOP, RV3D_VIEW_BOTTOM))
|
2009-01-20 14:23:32 +00:00
|
|
|
rv3dtest->ofs[0]= rv3d->ofs[0];
|
2009-10-27 02:54:25 +00:00
|
|
|
else if( ELEM(rv3dtest->view, RV3D_VIEW_RIGHT, RV3D_VIEW_LEFT))
|
2009-01-20 14:23:32 +00:00
|
|
|
rv3dtest->ofs[2]= rv3d->ofs[2];
|
|
|
|
|
}
|
2009-10-27 02:54:25 +00:00
|
|
|
else if( ELEM(rv3d->view, RV3D_VIEW_RIGHT, RV3D_VIEW_LEFT) ) {
|
|
|
|
|
if( ELEM(rv3dtest->view, RV3D_VIEW_TOP, RV3D_VIEW_BOTTOM))
|
2009-01-20 14:23:32 +00:00
|
|
|
rv3dtest->ofs[1]= rv3d->ofs[1];
|
2009-10-27 02:54:25 +00:00
|
|
|
if( ELEM(rv3dtest->view, RV3D_VIEW_FRONT, RV3D_VIEW_BACK))
|
2009-01-20 14:23:32 +00:00
|
|
|
rv3dtest->ofs[2]= rv3d->ofs[2];
|
|
|
|
|
}
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2009-01-20 14:23:32 +00:00
|
|
|
ED_region_tag_redraw(artest);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-01-20 18:31:11 +00:00
|
|
|
view3d_boxview_clip(sa);
|
2009-01-20 14:23:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* for home, center etc */
|
2.5
Smaller jobs, all in one commit!
- Moved object_do_update out of view3d drawing, into
the event system (currently after notifiers).
Depsgraph calls for setting update flags will have to
keep track of each Screen's needs, so a UI showing only
a Sequencer doesn't do objects.
- Added button in "Properties region" in 3D window to set
or disable 4-split, including the 3 options it has.
(lock, box, clip)
- Restored legacy code for UI, to make things work like
bone rename, autocomplete.
- Node editor now shows Curves widgets again
- Bugfix: composite job increased Viewer user id count
- Bugfix: Node editor, not "Enable nodes" still called
a Job, which didn't do anything
- Various code cleaning, unused vars and prototypes.
2009-02-11 16:54:55 +00:00
|
|
|
void view3d_boxview_copy(ScrArea *sa, ARegion *ar)
|
2009-01-20 14:23:32 +00:00
|
|
|
{
|
|
|
|
|
ARegion *artest;
|
|
|
|
|
RegionView3D *rv3d= ar->regiondata;
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2009-01-20 14:23:32 +00:00
|
|
|
for(artest= sa->regionbase.first; artest; artest= artest->next) {
|
|
|
|
|
if(artest!=ar && artest->regiontype==RGN_TYPE_WINDOW) {
|
|
|
|
|
RegionView3D *rv3dtest= artest->regiondata;
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2009-01-20 14:23:32 +00:00
|
|
|
if(rv3dtest->viewlock) {
|
|
|
|
|
rv3dtest->dist= rv3d->dist;
|
|
|
|
|
VECCOPY(rv3dtest->ofs, rv3d->ofs);
|
|
|
|
|
ED_region_tag_redraw(artest);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-01-20 18:31:11 +00:00
|
|
|
view3d_boxview_clip(sa);
|
2009-01-20 14:23:32 +00:00
|
|
|
}
|
|
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
/* ************************** init for view ops **********************************/
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
typedef struct ViewOpsData {
|
2009-01-20 14:23:32 +00:00
|
|
|
ScrArea *sa;
|
2008-12-19 17:14:02 +00:00
|
|
|
ARegion *ar;
|
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;
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
float oldquat[4];
|
|
|
|
|
float trackvec[3];
|
|
|
|
|
float ofs[3], obofs[3];
|
|
|
|
|
float reverse, dist0;
|
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
|
|
|
float grid, far;
|
2009-09-25 10:24:42 +00:00
|
|
|
short axis_snap; /* view rotate only */
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
int origx, origy, oldx, oldy;
|
2009-09-25 10:24:42 +00:00
|
|
|
int origkey; /* the key that triggered the operator */
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
} ViewOpsData;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
#define TRACKBALLSIZE (1.1)
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
static void calctrackballvec(rcti *rect, int mx, int my, float *vec)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
|
|
|
|
float x, y, radius, d, z, t;
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
radius= TRACKBALLSIZE;
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
/* normalize x and y */
|
2008-12-19 17:14:02 +00:00
|
|
|
x= (rect->xmax + rect->xmin)/2 - mx;
|
|
|
|
|
x/= (float)((rect->xmax - rect->xmin)/4);
|
|
|
|
|
y= (rect->ymax + rect->ymin)/2 - my;
|
|
|
|
|
y/= (float)((rect->ymax - rect->ymin)/2);
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
d = sqrt(x*x + y*y);
|
|
|
|
|
if (d < radius*M_SQRT1_2) /* Inside sphere */
|
|
|
|
|
z = sqrt(radius*radius - d*d);
|
|
|
|
|
else
|
|
|
|
|
{ /* On hyperbola */
|
|
|
|
|
t = radius / M_SQRT2;
|
|
|
|
|
z = t*t / d;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
vec[0]= x;
|
|
|
|
|
vec[1]= y;
|
|
|
|
|
vec[2]= -z; /* yah yah! */
|
2008-12-19 17:14:02 +00:00
|
|
|
}
|
|
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
static void viewops_data(bContext *C, wmOperator *op, wmEvent *event)
|
|
|
|
|
{
|
2009-10-15 15:58:12 +00:00
|
|
|
static float lastofs[3] = {0,0,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
|
|
|
View3D *v3d = CTX_wm_view3d(C);
|
|
|
|
|
RegionView3D *rv3d;
|
2008-12-19 17:14:02 +00:00
|
|
|
ViewOpsData *vod= MEM_callocN(sizeof(ViewOpsData), "viewops data");
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
/* store data */
|
|
|
|
|
op->customdata= vod;
|
2009-01-20 14:23:32 +00:00
|
|
|
vod->sa= CTX_wm_area(C);
|
2008-12-19 17:14:02 +00:00
|
|
|
vod->ar= CTX_wm_region(C);
|
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
|
|
|
vod->rv3d= rv3d= vod->ar->regiondata;
|
|
|
|
|
vod->dist0= rv3d->dist;
|
|
|
|
|
QUATCOPY(vod->oldquat, rv3d->viewquat);
|
2008-12-19 17:14:02 +00:00
|
|
|
vod->origx= vod->oldx= event->x;
|
|
|
|
|
vod->origy= vod->oldy= event->y;
|
2009-09-25 10:24:42 +00:00
|
|
|
vod->origkey= event->type; /* the key that triggered the operator. */
|
2009-10-15 15:58:12 +00:00
|
|
|
|
|
|
|
|
if (U.uiflag & USER_ORBIT_SELECTION)
|
|
|
|
|
{
|
|
|
|
|
VECCOPY(vod->ofs, rv3d->ofs);
|
|
|
|
|
/* If there's no selection, lastofs is unmodified and last value since static */
|
|
|
|
|
calculateTransformCenter(C, event, V3D_CENTROID, lastofs);
|
|
|
|
|
VECCOPY(vod->obofs, lastofs);
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_v3_fl(vod->obofs, -1.0f);
|
2009-10-15 15:58:12 +00:00
|
|
|
}
|
2009-07-09 02:45:48 +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
|
|
|
/* lookup, we dont pass on v3d to prevent confusement */
|
|
|
|
|
vod->grid= v3d->grid;
|
|
|
|
|
vod->far= v3d->far;
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
calctrackballvec(&vod->ar->winrct, event->x, event->y, vod->trackvec);
|
2008-12-26 10:31:44 +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
|
|
|
initgrabz(rv3d, -rv3d->ofs[0], -rv3d->ofs[1], -rv3d->ofs[2]);
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
vod->reverse= 1.0f;
|
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->persmat[2][1] < 0.0f)
|
2008-12-19 17:14:02 +00:00
|
|
|
vod->reverse= -1.0f;
|
2008-12-26 10:31:44 +00:00
|
|
|
|
|
|
|
|
}
|
2008-12-19 17:14:02 +00:00
|
|
|
|
|
|
|
|
/* ************************** viewrotate **********************************/
|
|
|
|
|
|
|
|
|
|
static const float thres = 0.93f; //cos(20 deg);
|
|
|
|
|
|
|
|
|
|
#define COS45 0.70710678118654746
|
|
|
|
|
#define SIN45 COS45
|
|
|
|
|
|
|
|
|
|
static float snapquats[39][6] = {
|
|
|
|
|
/*{q0, q1, q3, q4, view, oposite_direction}*/
|
2009-10-27 02:54:25 +00:00
|
|
|
{COS45, -SIN45, 0.0, 0.0, RV3D_VIEW_FRONT, 0}, //front
|
|
|
|
|
{0.0, 0.0, -SIN45, -SIN45, RV3D_VIEW_BACK, 0}, //back
|
|
|
|
|
{1.0, 0.0, 0.0, 0.0, RV3D_VIEW_TOP, 0}, //top
|
|
|
|
|
{0.0, -1.0, 0.0, 0.0, RV3D_VIEW_BOTTOM, 0}, //bottom
|
|
|
|
|
{0.5, -0.5, -0.5, -0.5, RV3D_VIEW_LEFT, 0}, //left
|
|
|
|
|
{0.5, -0.5, 0.5, 0.5, RV3D_VIEW_RIGHT, 0}, //right
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
/* some more 45 deg snaps */
|
|
|
|
|
{0.65328145027160645, -0.65328145027160645, 0.27059805393218994, 0.27059805393218994, 0, 0},
|
|
|
|
|
{0.92387950420379639, 0.0, 0.0, 0.38268342614173889, 0, 0},
|
|
|
|
|
{0.0, -0.92387950420379639, 0.38268342614173889, 0.0, 0, 0},
|
|
|
|
|
{0.35355335474014282, -0.85355335474014282, 0.35355338454246521, 0.14644660055637360, 0, 0},
|
|
|
|
|
{0.85355335474014282, -0.35355335474014282, 0.14644660055637360, 0.35355338454246521, 0, 0},
|
|
|
|
|
{0.49999994039535522, -0.49999994039535522, 0.49999997019767761, 0.49999997019767761, 0, 0},
|
|
|
|
|
{0.27059802412986755, -0.65328145027160645, 0.65328145027160645, 0.27059802412986755, 0, 0},
|
|
|
|
|
{0.65328145027160645, -0.27059802412986755, 0.27059802412986755, 0.65328145027160645, 0, 0},
|
|
|
|
|
{0.27059799432754517, -0.27059799432754517, 0.65328139066696167, 0.65328139066696167, 0, 0},
|
|
|
|
|
{0.38268336653709412, 0.0, 0.0, 0.92387944459915161, 0, 0},
|
|
|
|
|
{0.0, -0.38268336653709412, 0.92387944459915161, 0.0, 0, 0},
|
|
|
|
|
{0.14644658565521240, -0.35355335474014282, 0.85355335474014282, 0.35355335474014282, 0, 0},
|
|
|
|
|
{0.35355335474014282, -0.14644658565521240, 0.35355335474014282, 0.85355335474014282, 0, 0},
|
|
|
|
|
{0.0, 0.0, 0.92387944459915161, 0.38268336653709412, 0, 0},
|
|
|
|
|
{-0.0, 0.0, 0.38268336653709412, 0.92387944459915161, 0, 0},
|
|
|
|
|
{-0.27059802412986755, 0.27059802412986755, 0.65328133106231689, 0.65328133106231689, 0, 0},
|
|
|
|
|
{-0.38268339633941650, 0.0, 0.0, 0.92387938499450684, 0, 0},
|
|
|
|
|
{0.0, 0.38268339633941650, 0.92387938499450684, 0.0, 0, 0},
|
|
|
|
|
{-0.14644658565521240, 0.35355338454246521, 0.85355329513549805, 0.35355332493782043, 0, 0},
|
|
|
|
|
{-0.35355338454246521, 0.14644658565521240, 0.35355332493782043, 0.85355329513549805, 0, 0},
|
|
|
|
|
{-0.49999991059303284, 0.49999991059303284, 0.49999985098838806, 0.49999985098838806, 0, 0},
|
|
|
|
|
{-0.27059799432754517, 0.65328145027160645, 0.65328139066696167, 0.27059799432754517, 0, 0},
|
|
|
|
|
{-0.65328145027160645, 0.27059799432754517, 0.27059799432754517, 0.65328139066696167, 0, 0},
|
|
|
|
|
{-0.65328133106231689, 0.65328133106231689, 0.27059793472290039, 0.27059793472290039, 0, 0},
|
|
|
|
|
{-0.92387932538986206, 0.0, 0.0, 0.38268333673477173, 0, 0},
|
|
|
|
|
{0.0, 0.92387932538986206, 0.38268333673477173, 0.0, 0, 0},
|
|
|
|
|
{-0.35355329513549805, 0.85355329513549805, 0.35355329513549805, 0.14644657075405121, 0, 0},
|
|
|
|
|
{-0.85355329513549805, 0.35355329513549805, 0.14644657075405121, 0.35355329513549805, 0, 0},
|
|
|
|
|
{-0.38268330693244934, 0.92387938499450684, 0.0, 0.0, 0, 0},
|
|
|
|
|
{-0.92387938499450684, 0.38268330693244934, 0.0, 0.0, 0, 0},
|
|
|
|
|
{-COS45, 0.0, 0.0, SIN45, 0, 0},
|
|
|
|
|
{COS45, 0.0, 0.0, SIN45, 0, 0},
|
|
|
|
|
{0.0, 0.0, 0.0, 1.0, 0, 0}
|
|
|
|
|
};
|
|
|
|
|
|
2009-09-25 10:24:42 +00:00
|
|
|
enum {
|
|
|
|
|
VIEW_PASS= 0,
|
|
|
|
|
VIEW_APPLY,
|
|
|
|
|
VIEW_CONFIRM
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* NOTE: these defines are saved in keymap files, do not change values but just add new ones */
|
|
|
|
|
#define VIEW_MODAL_CONFIRM 1 /* used for all view operations */
|
|
|
|
|
#define VIEWROT_MODAL_AXIS_SNAP_ENABLE 2
|
|
|
|
|
#define VIEWROT_MODAL_AXIS_SNAP_DISABLE 3
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* called in transform_ops.c, on each regeneration of keymaps */
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
void viewrotate_modal_keymap(wmKeyConfig *keyconf)
|
2009-09-25 10:24:42 +00:00
|
|
|
{
|
|
|
|
|
static EnumPropertyItem modal_items[] = {
|
|
|
|
|
{VIEW_MODAL_CONFIRM, "CONFIRM", 0, "Cancel", ""},
|
|
|
|
|
|
|
|
|
|
{VIEWROT_MODAL_AXIS_SNAP_ENABLE, "AXIS_SNAP_ENABLE", 0, "Enable Axis Snap", ""},
|
|
|
|
|
{VIEWROT_MODAL_AXIS_SNAP_DISABLE, "AXIS_SNAP_DISABLE", 0, "Enable Axis Snap", ""},
|
|
|
|
|
|
|
|
|
|
{0, NULL, 0, NULL, NULL}};
|
|
|
|
|
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
wmKeyMap *keymap= WM_modalkeymap_get(keyconf, "View3D Rotate Modal");
|
2009-09-25 10:24:42 +00:00
|
|
|
|
|
|
|
|
/* this function is called for each spacetype, only needs to add map once */
|
|
|
|
|
if(keymap) return;
|
|
|
|
|
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
keymap= WM_modalkeymap_add(keyconf, "View3D Rotate Modal", modal_items);
|
2009-09-25 10:24:42 +00:00
|
|
|
|
|
|
|
|
/* items for modal map */
|
|
|
|
|
WM_modalkeymap_add_item(keymap, MIDDLEMOUSE, KM_RELEASE, KM_ANY, 0, VIEW_MODAL_CONFIRM);
|
|
|
|
|
WM_modalkeymap_add_item(keymap, ESCKEY, KM_PRESS, KM_ANY, 0, VIEW_MODAL_CONFIRM);
|
|
|
|
|
|
|
|
|
|
WM_modalkeymap_add_item(keymap, LEFTCTRLKEY, KM_PRESS, KM_ANY, 0, VIEWROT_MODAL_AXIS_SNAP_ENABLE);
|
|
|
|
|
WM_modalkeymap_add_item(keymap, LEFTCTRLKEY, KM_RELEASE, KM_ANY, 0, VIEWROT_MODAL_AXIS_SNAP_DISABLE);
|
|
|
|
|
|
|
|
|
|
/* assign map to operators */
|
|
|
|
|
WM_modalkeymap_assign(keymap, "VIEW3D_OT_rotate");
|
|
|
|
|
|
|
|
|
|
}
|
2008-12-19 17:14:02 +00:00
|
|
|
|
2009-09-25 10:24:42 +00:00
|
|
|
static void viewrotate_apply(ViewOpsData *vod, int x, int y)
|
2008-12-19 17:14:02 +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= vod->rv3d;
|
2009-09-25 10:24:42 +00:00
|
|
|
int use_sel= U.uiflag & USER_ORBIT_SELECTION;
|
2008-12-26 10:31:44 +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
|
|
|
rv3d->view= 0; /* need to reset everytime because of view snapping */
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
if (U.flag & USER_TRACKBALL) {
|
|
|
|
|
float phi, si, q1[4], dvec[3], newvec[3];
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
calctrackballvec(&vod->ar->winrct, x, y, newvec);
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
sub_v3_v3v3(dvec, newvec, vod->trackvec);
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
si= sqrt(dvec[0]*dvec[0]+ dvec[1]*dvec[1]+ dvec[2]*dvec[2]);
|
|
|
|
|
si/= (2.0*TRACKBALLSIZE);
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
cross_v3_v3v3(q1+1, vod->trackvec, newvec);
|
|
|
|
|
normalize_v3(q1+1);
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
/* Allow for rotation beyond the interval
|
|
|
|
|
* [-pi, pi] */
|
|
|
|
|
while (si > 1.0)
|
|
|
|
|
si -= 2.0;
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
/* This relation is used instead of
|
|
|
|
|
* phi = asin(si) so that the angle
|
|
|
|
|
* of rotation is linearly proportional
|
|
|
|
|
* to the distance that the mouse is
|
|
|
|
|
* dragged. */
|
|
|
|
|
phi = si * M_PI / 2.0;
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
si= sin(phi);
|
|
|
|
|
q1[0]= cos(phi);
|
|
|
|
|
q1[1]*= si;
|
|
|
|
|
q1[2]*= si;
|
2008-12-26 10:31:44 +00:00
|
|
|
q1[3]*= si;
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_qt_qtqt(rv3d->viewquat, q1, vod->oldquat);
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
if (use_sel) {
|
|
|
|
|
/* compute the post multiplication quat, to rotate the offset correctly */
|
|
|
|
|
QUATCOPY(q1, vod->oldquat);
|
2009-11-10 20:43:45 +00:00
|
|
|
conjugate_qt(q1);
|
|
|
|
|
mul_qt_qtqt(q1, q1, rv3d->viewquat);
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
conjugate_qt(q1); /* conj == inv for unit quat */
|
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
|
|
|
VECCOPY(rv3d->ofs, vod->ofs);
|
2009-11-10 20:43:45 +00:00
|
|
|
sub_v3_v3v3(rv3d->ofs, rv3d->ofs, vod->obofs);
|
|
|
|
|
mul_qt_v3(q1, rv3d->ofs);
|
|
|
|
|
add_v3_v3v3(rv3d->ofs, rv3d->ofs, vod->obofs);
|
2008-12-19 17:14:02 +00:00
|
|
|
}
|
2008-12-26 10:31:44 +00:00
|
|
|
}
|
2008-12-19 17:14:02 +00:00
|
|
|
else {
|
|
|
|
|
/* New turntable view code by John Aughey */
|
|
|
|
|
float si, phi, q1[4];
|
|
|
|
|
float m[3][3];
|
|
|
|
|
float m_inv[3][3];
|
|
|
|
|
float xvec[3] = {1,0,0};
|
|
|
|
|
/* Sensitivity will control how fast the viewport rotates. 0.0035 was
|
|
|
|
|
obtained experimentally by looking at viewport rotation sensitivities
|
|
|
|
|
on other modeling programs. */
|
|
|
|
|
/* Perhaps this should be a configurable user parameter. */
|
|
|
|
|
const float sensitivity = 0.0035;
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
/* Get the 3x3 matrix and its inverse from the quaternion */
|
2009-11-10 20:43:45 +00:00
|
|
|
quat_to_mat3( m,rv3d->viewquat);
|
|
|
|
|
invert_m3_m3(m_inv,m);
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
/* Determine the direction of the x vector (for rotating up and down) */
|
|
|
|
|
/* This can likely be compuated directly from the quaternion. */
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_m3_v3(m_inv,xvec);
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
/* Perform the up/down rotation */
|
|
|
|
|
phi = sensitivity * -(y - vod->oldy);
|
|
|
|
|
si = sin(phi);
|
|
|
|
|
q1[0] = cos(phi);
|
|
|
|
|
q1[1] = si * xvec[0];
|
|
|
|
|
q1[2] = si * xvec[1];
|
|
|
|
|
q1[3] = si * xvec[2];
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, q1);
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
if (use_sel) {
|
2009-11-10 20:43:45 +00:00
|
|
|
conjugate_qt(q1); /* conj == inv for unit quat */
|
|
|
|
|
sub_v3_v3v3(rv3d->ofs, rv3d->ofs, vod->obofs);
|
|
|
|
|
mul_qt_v3(q1, rv3d->ofs);
|
|
|
|
|
add_v3_v3v3(rv3d->ofs, rv3d->ofs, vod->obofs);
|
2008-12-19 17:14:02 +00:00
|
|
|
}
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
/* Perform the orbital rotation */
|
|
|
|
|
phi = sensitivity * vod->reverse * (x - vod->oldx);
|
|
|
|
|
q1[0] = cos(phi);
|
|
|
|
|
q1[1] = q1[2] = 0.0;
|
|
|
|
|
q1[3] = sin(phi);
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, q1);
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
if (use_sel) {
|
2009-11-10 20:43:45 +00:00
|
|
|
conjugate_qt(q1);
|
|
|
|
|
sub_v3_v3v3(rv3d->ofs, rv3d->ofs, vod->obofs);
|
|
|
|
|
mul_qt_v3(q1, rv3d->ofs);
|
|
|
|
|
add_v3_v3v3(rv3d->ofs, rv3d->ofs, vod->obofs);
|
2008-12-19 17:14:02 +00:00
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
/* check for view snap */
|
2009-09-25 10:24:42 +00:00
|
|
|
if (vod->axis_snap){
|
2008-12-19 17:14:02 +00:00
|
|
|
int i;
|
|
|
|
|
float viewmat[3][3];
|
2008-12-26 10:31:44 +00:00
|
|
|
|
|
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
quat_to_mat3( viewmat,rv3d->viewquat);
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
for (i = 0 ; i < 39; i++){
|
|
|
|
|
float snapmat[3][3];
|
|
|
|
|
float view = (int)snapquats[i][4];
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
quat_to_mat3( snapmat,snapquats[i]);
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
if ((dot_v3v3(snapmat[0], viewmat[0]) > thres) &&
|
|
|
|
|
(dot_v3v3(snapmat[1], viewmat[1]) > thres) &&
|
|
|
|
|
(dot_v3v3(snapmat[2], viewmat[2]) > thres)){
|
2008-12-26 10:31:44 +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
|
|
|
QUATCOPY(rv3d->viewquat, snapquats[i]);
|
2008-12-26 10:31:44 +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
|
|
|
rv3d->view = view;
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2008-12-19 17:14:02 +00:00
|
|
|
vod->oldx= x;
|
|
|
|
|
vod->oldy= y;
|
|
|
|
|
|
|
|
|
|
ED_region_tag_redraw(vod->ar);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int viewrotate_modal(bContext *C, wmOperator *op, wmEvent *event)
|
|
|
|
|
{
|
2008-12-19 19:27:41 +00:00
|
|
|
ViewOpsData *vod= op->customdata;
|
2009-09-25 10:24:42 +00:00
|
|
|
short event_code= VIEW_PASS;
|
2008-12-19 17:14:02 +00:00
|
|
|
|
|
|
|
|
/* execute the events */
|
2009-09-25 10:24:42 +00:00
|
|
|
if(event->type==MOUSEMOVE) {
|
|
|
|
|
event_code= VIEW_APPLY;
|
|
|
|
|
}
|
|
|
|
|
else if(event->type==EVT_MODAL_MAP) {
|
|
|
|
|
switch (event->val) {
|
|
|
|
|
case VIEW_MODAL_CONFIRM:
|
|
|
|
|
event_code= VIEW_CONFIRM;
|
|
|
|
|
break;
|
|
|
|
|
case VIEWROT_MODAL_AXIS_SNAP_ENABLE:
|
|
|
|
|
vod->axis_snap= TRUE;
|
|
|
|
|
event_code= VIEW_APPLY;
|
|
|
|
|
break;
|
|
|
|
|
case VIEWROT_MODAL_AXIS_SNAP_DISABLE:
|
|
|
|
|
vod->axis_snap= FALSE;
|
|
|
|
|
event_code= VIEW_APPLY;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(event->type==vod->origkey && event->val==KM_RELEASE) {
|
|
|
|
|
event_code= VIEW_CONFIRM;
|
|
|
|
|
}
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2009-09-25 10:24:42 +00:00
|
|
|
if(event_code==VIEW_APPLY) {
|
|
|
|
|
viewrotate_apply(vod, event->x, event->y);
|
|
|
|
|
}
|
|
|
|
|
else if (event_code==VIEW_CONFIRM) {
|
|
|
|
|
request_depth_update(CTX_wm_region_view3d(C));
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2009-09-25 10:24:42 +00:00
|
|
|
MEM_freeN(vod);
|
|
|
|
|
op->customdata= NULL;
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2009-09-25 10:24:42 +00:00
|
|
|
return OPERATOR_FINISHED;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
return OPERATOR_RUNNING_MODAL;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
static int viewrotate_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
2008-12-19 12:14:58 +00:00
|
|
|
{
|
2009-01-20 14:23:32 +00:00
|
|
|
RegionView3D *rv3d= CTX_wm_region_view3d(C);
|
2008-12-19 17:14:02 +00:00
|
|
|
ViewOpsData *vod;
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2009-01-20 14:23:32 +00:00
|
|
|
if(rv3d->viewlock)
|
|
|
|
|
return OPERATOR_CANCELLED;
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
/* makes op->customdata */
|
|
|
|
|
viewops_data(C, op, event);
|
|
|
|
|
vod= op->customdata;
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
/* switch from camera view when: */
|
2009-10-27 02:54:25 +00:00
|
|
|
if(vod->rv3d->persp != RV3D_PERSP) {
|
2008-12-26 10:31:44 +00:00
|
|
|
|
|
|
|
|
if (U.uiflag & USER_AUTOPERSP)
|
2009-10-27 02:54:25 +00:00
|
|
|
vod->rv3d->persp= RV3D_PERSP;
|
|
|
|
|
else if(vod->rv3d->persp==RV3D_CAMOB)
|
|
|
|
|
vod->rv3d->persp= RV3D_PERSP;
|
2008-12-19 17:14:02 +00:00
|
|
|
ED_region_tag_redraw(vod->ar);
|
|
|
|
|
}
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
/* add temp handler */
|
2009-09-18 12:43:36 +00:00
|
|
|
WM_event_add_modal_handler(C, op);
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
return OPERATOR_RUNNING_MODAL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2009-09-25 10:24:42 +00:00
|
|
|
void VIEW3D_OT_rotate(wmOperatorType *ot)
|
2008-12-19 17:14:02 +00:00
|
|
|
{
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
/* identifiers */
|
|
|
|
|
ot->name= "Rotate view";
|
2009-03-24 12:16:58 +00:00
|
|
|
ot->description = "Rotate the view.";
|
2009-09-25 10:24:42 +00:00
|
|
|
ot->idname= "VIEW3D_OT_rotate";
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
/* api callbacks */
|
|
|
|
|
ot->invoke= viewrotate_invoke;
|
|
|
|
|
ot->modal= viewrotate_modal;
|
2008-12-26 19:07:31 +00:00
|
|
|
ot->poll= ED_operator_view3d_active;
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2009-01-31 19:40:40 +00:00
|
|
|
/* flags */
|
2009-10-10 17:19:49 +00:00
|
|
|
ot->flag= OPTYPE_BLOCKING|OPTYPE_GRAB_POINTER;
|
2008-12-19 17:14:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ************************ viewmove ******************************** */
|
|
|
|
|
|
2009-09-25 10:24:42 +00:00
|
|
|
|
|
|
|
|
/* NOTE: these defines are saved in keymap files, do not change values but just add new ones */
|
|
|
|
|
|
|
|
|
|
/* called in transform_ops.c, on each regeneration of keymaps */
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
void viewmove_modal_keymap(wmKeyConfig *keyconf)
|
2009-09-25 10:24:42 +00:00
|
|
|
{
|
|
|
|
|
static EnumPropertyItem modal_items[] = {
|
|
|
|
|
{VIEW_MODAL_CONFIRM, "CONFIRM", 0, "Confirm", ""},
|
|
|
|
|
|
|
|
|
|
{0, NULL, 0, NULL, NULL}};
|
|
|
|
|
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
wmKeyMap *keymap= WM_modalkeymap_get(keyconf, "View3D Move Modal");
|
2009-09-25 10:24:42 +00:00
|
|
|
|
|
|
|
|
/* this function is called for each spacetype, only needs to add map once */
|
|
|
|
|
if(keymap) return;
|
|
|
|
|
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
keymap= WM_modalkeymap_add(keyconf, "View3D Move Modal", modal_items);
|
2009-09-25 10:24:42 +00:00
|
|
|
|
|
|
|
|
/* items for modal map */
|
|
|
|
|
WM_modalkeymap_add_item(keymap, MIDDLEMOUSE, KM_RELEASE, KM_ANY, 0, VIEW_MODAL_CONFIRM);
|
|
|
|
|
WM_modalkeymap_add_item(keymap, ESCKEY, KM_PRESS, KM_ANY, 0, VIEW_MODAL_CONFIRM);
|
|
|
|
|
|
|
|
|
|
/* assign map to operators */
|
|
|
|
|
WM_modalkeymap_assign(keymap, "VIEW3D_OT_move");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
static void viewmove_apply(ViewOpsData *vod, int x, int y)
|
|
|
|
|
{
|
2009-10-27 02:54:25 +00:00
|
|
|
if(vod->rv3d->persp==RV3D_CAMOB) {
|
2008-12-19 17:14:02 +00:00
|
|
|
float max= (float)MAX2(vod->ar->winx, vod->ar->winy);
|
2008-12-26 10:31:44 +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
|
|
|
vod->rv3d->camdx += (vod->oldx - x)/(max);
|
|
|
|
|
vod->rv3d->camdy += (vod->oldy - y)/(max);
|
|
|
|
|
CLAMP(vod->rv3d->camdx, -1.0f, 1.0f);
|
|
|
|
|
CLAMP(vod->rv3d->camdy, -1.0f, 1.0f);
|
2008-12-19 17:14:02 +00:00
|
|
|
// XXX preview3d_event= 0;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
2008-12-19 17:14:02 +00:00
|
|
|
else {
|
|
|
|
|
float dvec[3];
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2009-01-20 18:31:11 +00:00
|
|
|
window_to_3d_delta(vod->ar, dvec, x-vod->oldx, y-vod->oldy);
|
2009-11-10 20:43:45 +00:00
|
|
|
add_v3_v3v3(vod->rv3d->ofs, vod->rv3d->ofs, dvec);
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2.5
Smaller jobs, all in one commit!
- Moved object_do_update out of view3d drawing, into
the event system (currently after notifiers).
Depsgraph calls for setting update flags will have to
keep track of each Screen's needs, so a UI showing only
a Sequencer doesn't do objects.
- Added button in "Properties region" in 3D window to set
or disable 4-split, including the 3 options it has.
(lock, box, clip)
- Restored legacy code for UI, to make things work like
bone rename, autocomplete.
- Node editor now shows Curves widgets again
- Bugfix: composite job increased Viewer user id count
- Bugfix: Node editor, not "Enable nodes" still called
a Job, which didn't do anything
- Various code cleaning, unused vars and prototypes.
2009-02-11 16:54:55 +00:00
|
|
|
if(vod->rv3d->viewlock & RV3D_BOXVIEW)
|
2009-01-20 14:23:32 +00:00
|
|
|
view3d_boxview_sync(vod->sa, vod->ar);
|
2008-12-19 17:14:02 +00:00
|
|
|
}
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
vod->oldx= x;
|
|
|
|
|
vod->oldy= y;
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
ED_region_tag_redraw(vod->ar);
|
|
|
|
|
}
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
static int viewmove_modal(bContext *C, wmOperator *op, wmEvent *event)
|
2008-12-26 10:31:44 +00:00
|
|
|
{
|
2009-09-25 10:24:42 +00:00
|
|
|
|
2008-12-19 19:27:41 +00:00
|
|
|
ViewOpsData *vod= op->customdata;
|
2009-09-25 10:24:42 +00:00
|
|
|
short event_code= VIEW_PASS;
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
/* execute the events */
|
2009-09-25 10:24:42 +00:00
|
|
|
if(event->type==MOUSEMOVE) {
|
|
|
|
|
event_code= VIEW_APPLY;
|
|
|
|
|
}
|
|
|
|
|
else if(event->type==EVT_MODAL_MAP) {
|
|
|
|
|
switch (event->val) {
|
|
|
|
|
case VIEW_MODAL_CONFIRM:
|
|
|
|
|
event_code= VIEW_CONFIRM;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(event->type==vod->origkey && event->val==KM_RELEASE) {
|
|
|
|
|
event_code= VIEW_CONFIRM;
|
|
|
|
|
}
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2009-09-25 10:24:42 +00:00
|
|
|
if(event_code==VIEW_APPLY) {
|
|
|
|
|
viewmove_apply(vod, event->x, event->y);
|
|
|
|
|
}
|
|
|
|
|
else if (event_code==VIEW_CONFIRM) {
|
|
|
|
|
request_depth_update(CTX_wm_region_view3d(C));
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2009-09-25 10:24:42 +00:00
|
|
|
MEM_freeN(vod);
|
|
|
|
|
op->customdata= NULL;
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2009-09-25 10:24:42 +00:00
|
|
|
return OPERATOR_FINISHED;
|
2008-12-19 17:14:02 +00:00
|
|
|
}
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
return OPERATOR_RUNNING_MODAL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int viewmove_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
|
|
|
|
{
|
|
|
|
|
/* makes op->customdata */
|
|
|
|
|
viewops_data(C, op, event);
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
/* add temp handler */
|
2009-09-18 12:43:36 +00:00
|
|
|
WM_event_add_modal_handler(C, op);
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
return OPERATOR_RUNNING_MODAL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2009-09-25 10:24:42 +00:00
|
|
|
void VIEW3D_OT_move(wmOperatorType *ot)
|
2008-12-19 17:14:02 +00:00
|
|
|
{
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
/* identifiers */
|
2009-03-23 03:14:56 +00:00
|
|
|
ot->name= "Move view";
|
2009-03-24 12:16:58 +00:00
|
|
|
ot->description = "Move the view.";
|
2009-09-25 10:24:42 +00:00
|
|
|
ot->idname= "VIEW3D_OT_move";
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
/* api callbacks */
|
|
|
|
|
ot->invoke= viewmove_invoke;
|
|
|
|
|
ot->modal= viewmove_modal;
|
2008-12-26 19:07:31 +00:00
|
|
|
ot->poll= ED_operator_view3d_active;
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2009-01-31 19:40:40 +00:00
|
|
|
/* flags */
|
2009-10-10 17:19:49 +00:00
|
|
|
ot->flag= OPTYPE_BLOCKING|OPTYPE_GRAB_POINTER;
|
2008-12-19 17:14:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ************************ viewzoom ******************************** */
|
|
|
|
|
|
2009-09-25 10:24:42 +00:00
|
|
|
/* called in transform_ops.c, on each regeneration of keymaps */
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
void viewzoom_modal_keymap(wmKeyConfig *keyconf)
|
2009-09-25 10:24:42 +00:00
|
|
|
{
|
|
|
|
|
static EnumPropertyItem modal_items[] = {
|
|
|
|
|
{VIEW_MODAL_CONFIRM, "CONFIRM", 0, "Confirm", ""},
|
|
|
|
|
|
|
|
|
|
{0, NULL, 0, NULL, NULL}};
|
|
|
|
|
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
wmKeyMap *keymap= WM_modalkeymap_get(keyconf, "View3D Zoom Modal");
|
2009-09-25 10:24:42 +00:00
|
|
|
|
|
|
|
|
/* this function is called for each spacetype, only needs to add map once */
|
|
|
|
|
if(keymap) return;
|
|
|
|
|
|
Key Configuration
Keymaps are now saveable and configurable from the user preferences, note
that editing one item in a keymap means the whole keymap is now defined by
the user and will not be updated by Blender, an option for syncing might be
added later. The outliner interface is still there, but I will probably
remove it.
There's actually 3 levels now:
* Default builtin key configuration.
* Key configuration loaded from .py file, for configs like Blender 2.4x
or other 3D applications.
* Keymaps edited by the user and saved in .B.blend. These can be saved
to .py files as well to make creating distributable configurations
easier.
Also, user preferences sections were reorganized a bit, now there is:
Interface, Editing, Input, Files and System.
Implementation notes:
* wmKeyConfig was added which represents a key configuration containing
keymaps.
* wmKeymapItem was renamed to wmKeyMapItem for consistency with wmKeyMap.
* Modal maps are not wrapped yet.
* User preferences DNA file reading did not support newdataadr() yet,
added this now for reading keymaps.
* Key configuration related settings are now RNA wrapped.
* is_property_set and is_property_hidden python methods were added.
2009-10-08 18:40:03 +00:00
|
|
|
keymap= WM_modalkeymap_add(keyconf, "View3D Zoom Modal", modal_items);
|
2009-09-25 10:24:42 +00:00
|
|
|
|
|
|
|
|
/* items for modal map */
|
|
|
|
|
WM_modalkeymap_add_item(keymap, MIDDLEMOUSE, KM_RELEASE, KM_ANY, 0, VIEW_MODAL_CONFIRM);
|
|
|
|
|
WM_modalkeymap_add_item(keymap, ESCKEY, KM_PRESS, KM_ANY, 0, VIEW_MODAL_CONFIRM);
|
|
|
|
|
|
|
|
|
|
/* assign map to operators */
|
|
|
|
|
WM_modalkeymap_assign(keymap, "VIEW3D_OT_zoom");
|
|
|
|
|
}
|
|
|
|
|
|
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 view_zoom_mouseloc(ARegion *ar, float dfac, int mx, int my)
|
2008-12-19 17:14:02 +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-07-09 02:45:48 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
if(U.uiflag & USER_ZOOM_TO_MOUSEPOS) {
|
|
|
|
|
float dvec[3];
|
|
|
|
|
float tvec[3];
|
|
|
|
|
float tpos[3];
|
|
|
|
|
float new_dist;
|
|
|
|
|
short vb[2], mouseloc[2];
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
mouseloc[0]= mx - ar->winrct.xmin;
|
|
|
|
|
mouseloc[1]= my - ar->winrct.ymin;
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
/* find the current window width and height */
|
|
|
|
|
vb[0] = ar->winx;
|
|
|
|
|
vb[1] = ar->winy;
|
2008-12-26 10:31:44 +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
|
|
|
tpos[0] = -rv3d->ofs[0];
|
|
|
|
|
tpos[1] = -rv3d->ofs[1];
|
|
|
|
|
tpos[2] = -rv3d->ofs[2];
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
/* Project cursor position into 3D space */
|
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
|
|
|
initgrabz(rv3d, tpos[0], tpos[1], tpos[2]);
|
2009-01-20 18:31:11 +00:00
|
|
|
window_to_3d_delta(ar, dvec, mouseloc[0]-vb[0]/2, mouseloc[1]-vb[1]/2);
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
/* Calculate view target position for dolly */
|
|
|
|
|
tvec[0] = -(tpos[0] + dvec[0]);
|
|
|
|
|
tvec[1] = -(tpos[1] + dvec[1]);
|
|
|
|
|
tvec[2] = -(tpos[2] + dvec[2]);
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
/* Offset to target position and dolly */
|
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
|
|
|
new_dist = rv3d->dist * dfac;
|
2008-12-26 10:31:44 +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
|
|
|
VECCOPY(rv3d->ofs, tvec);
|
|
|
|
|
rv3d->dist = new_dist;
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
/* Calculate final offset */
|
|
|
|
|
dvec[0] = tvec[0] + dvec[0] * dfac;
|
|
|
|
|
dvec[1] = tvec[1] + dvec[1] * dfac;
|
|
|
|
|
dvec[2] = tvec[2] + dvec[2] * dfac;
|
2008-12-26 10:31:44 +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
|
|
|
VECCOPY(rv3d->ofs, dvec);
|
2008-12-19 17:14:02 +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
|
|
|
rv3d->dist *= dfac;
|
2008-12-19 17:14:02 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void viewzoom_apply(ViewOpsData *vod, int x, int y)
|
|
|
|
|
{
|
|
|
|
|
float zfac=1.0;
|
|
|
|
|
|
|
|
|
|
if(U.viewzoom==USER_ZOOM_CONT) {
|
|
|
|
|
// oldstyle zoom
|
|
|
|
|
zfac = 1.0+(float)(vod->origx - x + vod->origy - y)/1000.0;
|
|
|
|
|
}
|
|
|
|
|
else if(U.viewzoom==USER_ZOOM_SCALE) {
|
|
|
|
|
int ctr[2], len1, len2;
|
|
|
|
|
// method which zooms based on how far you move the mouse
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
ctr[0] = (vod->ar->winrct.xmax + vod->ar->winrct.xmin)/2;
|
|
|
|
|
ctr[1] = (vod->ar->winrct.ymax + vod->ar->winrct.ymin)/2;
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
len1 = (int)sqrt((ctr[0] - x)*(ctr[0] - x) + (ctr[1] - y)*(ctr[1] - y)) + 5;
|
|
|
|
|
len2 = (int)sqrt((ctr[0] - vod->origx)*(ctr[0] - vod->origx) + (ctr[1] - vod->origy)*(ctr[1] - vod->origy)) + 5;
|
2008-12-26 10:31:44 +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
|
|
|
zfac = vod->dist0 * ((float)len2/len1) / vod->rv3d->dist;
|
2008-12-19 17:14:02 +00:00
|
|
|
}
|
|
|
|
|
else { /* USER_ZOOM_DOLLY */
|
|
|
|
|
float len1 = (vod->ar->winrct.ymax - y) + 5;
|
|
|
|
|
float len2 = (vod->ar->winrct.ymax - vod->origy) + 5;
|
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
|
|
|
zfac = vod->dist0 * (2.0*((len2/len1)-1.0) + 1.0) / vod->rv3d->dist;
|
2008-12-19 17:14:02 +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(zfac != 1.0 && zfac*vod->rv3d->dist > 0.001*vod->grid &&
|
|
|
|
|
zfac*vod->rv3d->dist < 10.0*vod->far)
|
|
|
|
|
view_zoom_mouseloc(vod->ar, zfac, vod->oldx, vod->oldy);
|
2008-12-19 17:14:02 +00:00
|
|
|
|
|
|
|
|
|
2009-10-27 02:54:25 +00:00
|
|
|
if ((U.uiflag & USER_ORBIT_ZBUF) && (U.viewzoom==USER_ZOOM_CONT) && (vod->rv3d->persp==RV3D_PERSP)) {
|
2008-12-19 17:14:02 +00:00
|
|
|
float upvec[3], mat[3][3];
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
/* Secret apricot feature, translate the view when in continues mode */
|
|
|
|
|
upvec[0] = upvec[1] = 0.0f;
|
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
|
|
|
upvec[2] = (vod->dist0 - vod->rv3d->dist) * vod->grid;
|
|
|
|
|
vod->rv3d->dist = vod->dist0;
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_m3_m4(mat, vod->rv3d->viewinv);
|
|
|
|
|
mul_m3_v3(mat, upvec);
|
|
|
|
|
add_v3_v3v3(vod->rv3d->ofs, vod->rv3d->ofs, upvec);
|
2008-12-19 17:14:02 +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
|
|
|
/* these limits were in old code too */
|
|
|
|
|
if(vod->rv3d->dist<0.001*vod->grid) vod->rv3d->dist= 0.001*vod->grid;
|
|
|
|
|
if(vod->rv3d->dist>10.0*vod->far) vod->rv3d->dist=10.0*vod->far;
|
2008-12-19 17:14:02 +00:00
|
|
|
}
|
|
|
|
|
|
2009-10-27 02:54:25 +00:00
|
|
|
// XXX if(vod->rv3d->persp==RV3D_ORTHO || vod->rv3d->persp==RV3D_CAMOB) preview3d_event= 0;
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2.5
Smaller jobs, all in one commit!
- Moved object_do_update out of view3d drawing, into
the event system (currently after notifiers).
Depsgraph calls for setting update flags will have to
keep track of each Screen's needs, so a UI showing only
a Sequencer doesn't do objects.
- Added button in "Properties region" in 3D window to set
or disable 4-split, including the 3 options it has.
(lock, box, clip)
- Restored legacy code for UI, to make things work like
bone rename, autocomplete.
- Node editor now shows Curves widgets again
- Bugfix: composite job increased Viewer user id count
- Bugfix: Node editor, not "Enable nodes" still called
a Job, which didn't do anything
- Various code cleaning, unused vars and prototypes.
2009-02-11 16:54:55 +00:00
|
|
|
if(vod->rv3d->viewlock & RV3D_BOXVIEW)
|
2009-01-20 14:23:32 +00:00
|
|
|
view3d_boxview_sync(vod->sa, vod->ar);
|
|
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
ED_region_tag_redraw(vod->ar);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int viewzoom_modal(bContext *C, wmOperator *op, wmEvent *event)
|
2008-12-26 10:31:44 +00:00
|
|
|
{
|
2008-12-19 19:27:41 +00:00
|
|
|
ViewOpsData *vod= op->customdata;
|
2009-09-25 10:24:42 +00:00
|
|
|
short event_code= VIEW_PASS;
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
/* execute the events */
|
2009-09-25 10:24:42 +00:00
|
|
|
if(event->type==MOUSEMOVE) {
|
|
|
|
|
event_code= VIEW_APPLY;
|
|
|
|
|
}
|
|
|
|
|
else if(event->type==EVT_MODAL_MAP) {
|
|
|
|
|
switch (event->val) {
|
|
|
|
|
case VIEW_MODAL_CONFIRM:
|
|
|
|
|
event_code= VIEW_CONFIRM;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(event->type==vod->origkey && event->val==KM_RELEASE) {
|
|
|
|
|
event_code= VIEW_CONFIRM;
|
|
|
|
|
}
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2009-09-25 10:24:42 +00:00
|
|
|
if(event_code==VIEW_APPLY) {
|
|
|
|
|
viewzoom_apply(vod, event->x, event->y);
|
|
|
|
|
}
|
|
|
|
|
else if (event_code==VIEW_CONFIRM) {
|
|
|
|
|
request_depth_update(CTX_wm_region_view3d(C));
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2009-09-25 10:24:42 +00:00
|
|
|
MEM_freeN(vod);
|
|
|
|
|
op->customdata= NULL;
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2009-09-25 10:24:42 +00:00
|
|
|
return OPERATOR_FINISHED;
|
2008-12-19 17:14:02 +00:00
|
|
|
}
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
return OPERATOR_RUNNING_MODAL;
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-19 19:27:41 +00:00
|
|
|
static int viewzoom_exec(bContext *C, wmOperator *op)
|
2008-12-19 17:14:02 +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
|
|
|
View3D *v3d = CTX_wm_view3d(C);
|
|
|
|
|
RegionView3D *rv3d= CTX_wm_region_view3d(C);
|
2008-12-19 19:27:41 +00:00
|
|
|
int delta= RNA_int_get(op->ptr, "delta");
|
2009-10-16 00:23:40 +00:00
|
|
|
int mx = RNA_int_get(op->ptr, "mx");
|
|
|
|
|
int my = RNA_int_get(op->ptr, "my");
|
2008-12-19 19:27:41 +00:00
|
|
|
|
|
|
|
|
if(delta < 0) {
|
|
|
|
|
/* this min and max is also in viewmove() */
|
2009-10-27 02:54:25 +00:00
|
|
|
if(rv3d->persp==RV3D_CAMOB) {
|
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-= 10;
|
|
|
|
|
if(rv3d->camzoom<-30) rv3d->camzoom= -30;
|
2008-12-19 19:27:41 +00:00
|
|
|
}
|
2009-10-16 00:23:40 +00:00
|
|
|
else if(rv3d->dist<10.0*v3d->far) {
|
|
|
|
|
view_zoom_mouseloc(CTX_wm_region(C), 1.2f, mx, my);
|
|
|
|
|
}
|
2008-12-19 19:27:41 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2009-10-27 02:54:25 +00:00
|
|
|
if(rv3d->persp==RV3D_CAMOB) {
|
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+= 10;
|
|
|
|
|
if(rv3d->camzoom>300) rv3d->camzoom= 300;
|
2008-12-19 19:27:41 +00:00
|
|
|
}
|
2009-10-16 00:23:40 +00:00
|
|
|
else if(rv3d->dist> 0.001*v3d->grid) {
|
|
|
|
|
view_zoom_mouseloc(CTX_wm_region(C), .83333f, mx, my);
|
|
|
|
|
}
|
2008-12-19 19:27:41 +00:00
|
|
|
}
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2.5
Smaller jobs, all in one commit!
- Moved object_do_update out of view3d drawing, into
the event system (currently after notifiers).
Depsgraph calls for setting update flags will have to
keep track of each Screen's needs, so a UI showing only
a Sequencer doesn't do objects.
- Added button in "Properties region" in 3D window to set
or disable 4-split, including the 3 options it has.
(lock, box, clip)
- Restored legacy code for UI, to make things work like
bone rename, autocomplete.
- Node editor now shows Curves widgets again
- Bugfix: composite job increased Viewer user id count
- Bugfix: Node editor, not "Enable nodes" still called
a Job, which didn't do anything
- Various code cleaning, unused vars and prototypes.
2009-02-11 16:54:55 +00:00
|
|
|
if(rv3d->viewlock & RV3D_BOXVIEW)
|
2009-01-20 14:23:32 +00:00
|
|
|
view3d_boxview_sync(CTX_wm_area(C), CTX_wm_region(C));
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2009-01-30 18:27:25 +00:00
|
|
|
request_depth_update(CTX_wm_region_view3d(C));
|
2008-12-19 19:27:41 +00:00
|
|
|
ED_region_tag_redraw(CTX_wm_region(C));
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 19:27:41 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int viewzoom_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
|
|
|
|
{
|
|
|
|
|
int delta= RNA_int_get(op->ptr, "delta");
|
2009-10-16 00:23:40 +00:00
|
|
|
|
|
|
|
|
/* if one or the other zoom position aren't set, set from event */
|
|
|
|
|
if (!RNA_property_is_set(op->ptr, "mx") || !RNA_property_is_set(op->ptr, "my"))
|
|
|
|
|
{
|
|
|
|
|
RNA_int_set(op->ptr, "mx", event->x);
|
|
|
|
|
RNA_int_set(op->ptr, "my", event->y);
|
|
|
|
|
}
|
2008-12-19 19:27:41 +00:00
|
|
|
|
|
|
|
|
if(delta) {
|
|
|
|
|
viewzoom_exec(C, op);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* makes op->customdata */
|
|
|
|
|
viewops_data(C, op, event);
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 19:27:41 +00:00
|
|
|
/* add temp handler */
|
2009-09-18 12:43:36 +00:00
|
|
|
WM_event_add_modal_handler(C, op);
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 19:27:41 +00:00
|
|
|
return OPERATOR_RUNNING_MODAL;
|
|
|
|
|
}
|
|
|
|
|
return OPERATOR_FINISHED;
|
2008-12-19 17:14:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2009-03-29 02:15:13 +00:00
|
|
|
void VIEW3D_OT_zoom(wmOperatorType *ot)
|
2008-12-19 17:14:02 +00:00
|
|
|
{
|
|
|
|
|
/* identifiers */
|
2009-01-31 19:40:40 +00:00
|
|
|
ot->name= "Zoom view";
|
2009-03-24 12:16:58 +00:00
|
|
|
ot->description = "Zoom in/out in the view.";
|
2009-03-29 02:15:13 +00:00
|
|
|
ot->idname= "VIEW3D_OT_zoom";
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
/* api callbacks */
|
|
|
|
|
ot->invoke= viewzoom_invoke;
|
2008-12-19 19:27:41 +00:00
|
|
|
ot->exec= viewzoom_exec;
|
2008-12-19 17:14:02 +00:00
|
|
|
ot->modal= viewzoom_modal;
|
2008-12-26 19:07:31 +00:00
|
|
|
ot->poll= ED_operator_view3d_active;
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2009-01-31 19:40:40 +00:00
|
|
|
/* flags */
|
2009-10-10 17:19:49 +00:00
|
|
|
ot->flag= OPTYPE_BLOCKING|OPTYPE_GRAB_POINTER;
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2009-10-16 00:23:40 +00:00
|
|
|
RNA_def_int(ot->srna, "delta", 0, 0, INT_MAX, "Delta", "", 0, INT_MAX);
|
|
|
|
|
RNA_def_int(ot->srna, "mx", 0, 0, INT_MAX, "Zoom Position X", "", 0, INT_MAX);
|
|
|
|
|
RNA_def_int(ot->srna, "my", 0, 0, INT_MAX, "Zoom Position Y", "", 0, INT_MAX);
|
2008-12-19 17:14:02 +00:00
|
|
|
}
|
|
|
|
|
|
2008-12-20 11:33:16 +00:00
|
|
|
static int viewhome_exec(bContext *C, wmOperator *op) /* was view3d_home() in 2.4x */
|
|
|
|
|
{
|
|
|
|
|
ARegion *ar= CTX_wm_region(C);
|
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
|
|
|
View3D *v3d = CTX_wm_view3d(C);
|
|
|
|
|
RegionView3D *rv3d= CTX_wm_region_view3d(C);
|
2008-12-20 11:33:16 +00:00
|
|
|
Scene *scene= CTX_data_scene(C);
|
|
|
|
|
Base *base;
|
2009-08-20 21:09:48 +00:00
|
|
|
float *curs;
|
2008-12-20 11:33:16 +00:00
|
|
|
|
|
|
|
|
int center= RNA_boolean_get(op->ptr, "center");
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-20 11:33:16 +00:00
|
|
|
float size, min[3], max[3], afm[3];
|
|
|
|
|
int ok= 1, onedone=0;
|
|
|
|
|
|
|
|
|
|
if(center) {
|
|
|
|
|
min[0]= min[1]= min[2]= 0.0f;
|
|
|
|
|
max[0]= max[1]= max[2]= 0.0f;
|
2009-08-20 21:09:48 +00:00
|
|
|
|
|
|
|
|
/* in 2.4x this also move the cursor to (0, 0, 0) (with shift+c). */
|
|
|
|
|
curs= give_cursor(scene, v3d);
|
|
|
|
|
curs[0]= curs[1]= curs[2]= 0.0;
|
2008-12-20 11:33:16 +00:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
INIT_MINMAX(min, max);
|
|
|
|
|
}
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-20 11:33:16 +00:00
|
|
|
for(base= scene->base.first; base; base= base->next) {
|
|
|
|
|
if(base->lay & v3d->lay) {
|
|
|
|
|
onedone= 1;
|
|
|
|
|
minmax_object(base->object, min, max);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(!onedone) return OPERATOR_FINISHED; /* TODO - should this be cancel? */
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-20 11:33:16 +00:00
|
|
|
afm[0]= (max[0]-min[0]);
|
|
|
|
|
afm[1]= (max[1]-min[1]);
|
|
|
|
|
afm[2]= (max[2]-min[2]);
|
|
|
|
|
size= 0.7f*MAX3(afm[0], afm[1], afm[2]);
|
|
|
|
|
if(size==0.0) ok= 0;
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-20 11:33:16 +00:00
|
|
|
if(ok) {
|
|
|
|
|
float new_dist;
|
|
|
|
|
float new_ofs[3];
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-20 11:33:16 +00:00
|
|
|
new_dist = size;
|
|
|
|
|
new_ofs[0]= -(min[0]+max[0])/2.0f;
|
|
|
|
|
new_ofs[1]= -(min[1]+max[1])/2.0f;
|
|
|
|
|
new_ofs[2]= -(min[2]+max[2])/2.0f;
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-20 11:33:16 +00:00
|
|
|
// correction for window aspect ratio
|
|
|
|
|
if(ar->winy>2 && ar->winx>2) {
|
|
|
|
|
size= (float)ar->winx/(float)ar->winy;
|
|
|
|
|
if(size<1.0) size= 1.0f/size;
|
|
|
|
|
new_dist*= size;
|
|
|
|
|
}
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2009-10-27 02:54:25 +00:00
|
|
|
if (rv3d->persp==RV3D_CAMOB) {
|
|
|
|
|
rv3d->persp= RV3D_PERSP;
|
2009-07-09 02:45:48 +00:00
|
|
|
smooth_view(C, NULL, v3d->camera, new_ofs, NULL, &new_dist, NULL);
|
2008-12-20 11:33:16 +00:00
|
|
|
}
|
2009-08-15 14:37:40 +00:00
|
|
|
else {
|
|
|
|
|
smooth_view(C, NULL, NULL, new_ofs, NULL, &new_dist, NULL);
|
|
|
|
|
}
|
2008-12-20 11:33:16 +00:00
|
|
|
}
|
|
|
|
|
// XXX BIF_view3d_previewrender_signal(curarea, PR_DBASE|PR_DISPRECT);
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2.5
Smaller jobs, all in one commit!
- Moved object_do_update out of view3d drawing, into
the event system (currently after notifiers).
Depsgraph calls for setting update flags will have to
keep track of each Screen's needs, so a UI showing only
a Sequencer doesn't do objects.
- Added button in "Properties region" in 3D window to set
or disable 4-split, including the 3 options it has.
(lock, box, clip)
- Restored legacy code for UI, to make things work like
bone rename, autocomplete.
- Node editor now shows Curves widgets again
- Bugfix: composite job increased Viewer user id count
- Bugfix: Node editor, not "Enable nodes" still called
a Job, which didn't do anything
- Various code cleaning, unused vars and prototypes.
2009-02-11 16:54:55 +00:00
|
|
|
if(rv3d->viewlock & RV3D_BOXVIEW)
|
2009-01-20 14:23:32 +00:00
|
|
|
view3d_boxview_copy(CTX_wm_area(C), ar);
|
2008-12-20 11:33:16 +00:00
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-09 08:39:58 +00:00
|
|
|
void VIEW3D_OT_view_all(wmOperatorType *ot)
|
2008-12-20 11:33:16 +00:00
|
|
|
{
|
|
|
|
|
/* identifiers */
|
2009-09-26 16:43:20 +00:00
|
|
|
ot->name= "View All";
|
2009-03-23 03:14:56 +00:00
|
|
|
ot->description = "View all objects in scene.";
|
2009-07-09 08:39:58 +00:00
|
|
|
ot->idname= "VIEW3D_OT_view_all";
|
2008-12-20 11:33:16 +00:00
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
|
ot->exec= viewhome_exec;
|
2008-12-26 19:07:31 +00:00
|
|
|
ot->poll= ED_operator_view3d_active;
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2009-01-31 19:40:40 +00:00
|
|
|
/* flags */
|
2.5
Operator goodies!
--- Macro operators
Operators now can consist of multiple operators. Such a macro operator
is identical and behaves identical to other opererators. Macros can
also be constructed of macros even! Currently only hardcoded macros are
implemented, this to solve combined operators such as 'add duplicate' or
'extrude' (both want a transform appended).
Usage is simple:
- WM_operatortype_append_macro() : add new operatortype, name, flags
- WM_operatortype_macro_define() : add existing operator to macro
(Note: macro_define will also allow properties to be set, doesnt work
right now)
On converting the macro wmOperatorType to a real operator, it makes a
list of all operators, and the standard macro callbacks (exec, invoke,
modal, poll) just will use all.
Important note; switching to a modal operator only works as last in the
chain now!
Macros implemented for duplicate, extrude and rip. Tool menu works fine
for it, also the redo hotkey F4 works properly.
--- Operator redo fix
The operators use the undo system to switch back, but this could give
errors if other actions added undo pushes (buttons, outliner). Now the
redo for operator searches back for the correct undo level.
This fixes issues with many redos.
Note for brecht: removed the ED_undo_push for buttons... it was called
on *every* button now, which is probably too much? For example, using
the 'toolbar' redo also caused this...
2009-07-29 17:56:38 +00:00
|
|
|
ot->flag= 0;
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2009-01-16 23:53:11 +00:00
|
|
|
RNA_def_boolean(ot->srna, "center", 0, "Center", "");
|
2008-12-20 11:33:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int viewcenter_exec(bContext *C, wmOperator *op) /* like a localview without local!, was centerview() in 2.4x */
|
2008-12-26 10:31:44 +00:00
|
|
|
{
|
2008-12-20 11:33:16 +00:00
|
|
|
ARegion *ar= CTX_wm_region(C);
|
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
|
|
|
View3D *v3d = CTX_wm_view3d(C);
|
|
|
|
|
RegionView3D *rv3d= CTX_wm_region_view3d(C);
|
2008-12-20 11:33:16 +00:00
|
|
|
Scene *scene= CTX_data_scene(C);
|
|
|
|
|
Object *ob= OBACT;
|
2009-01-02 19:10:35 +00:00
|
|
|
Object *obedit= CTX_data_edit_object(C);
|
2008-12-20 11:33:16 +00:00
|
|
|
float size, min[3], max[3], afm[3];
|
|
|
|
|
int ok=0;
|
|
|
|
|
|
|
|
|
|
/* SMOOTHVIEW */
|
|
|
|
|
float new_ofs[3];
|
|
|
|
|
float new_dist;
|
|
|
|
|
|
|
|
|
|
INIT_MINMAX(min, max);
|
|
|
|
|
|
2009-08-15 21:46:25 +00:00
|
|
|
if (ob && ob->mode & OB_MODE_WEIGHT_PAINT) {
|
2008-12-20 11:33:16 +00:00
|
|
|
/* hardcoded exception, we look for the one selected armature */
|
|
|
|
|
/* this is weak code this way, we should make a generic active/selection callback interface once... */
|
|
|
|
|
Base *base;
|
|
|
|
|
for(base=scene->base.first; base; base= base->next) {
|
|
|
|
|
if(TESTBASELIB(v3d, base)) {
|
|
|
|
|
if(base->object->type==OB_ARMATURE)
|
2009-08-16 03:24:23 +00:00
|
|
|
if(base->object->mode & OB_MODE_POSE)
|
2008-12-20 11:33:16 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(base)
|
|
|
|
|
ob= base->object;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2009-01-02 19:10:35 +00:00
|
|
|
if(obedit) {
|
2009-02-14 13:07:09 +00:00
|
|
|
ok = minmax_verts(obedit, min, max); /* only selected */
|
2008-12-20 11:33:16 +00:00
|
|
|
}
|
2009-08-16 03:24:23 +00:00
|
|
|
else if(ob && (ob->mode & OB_MODE_POSE)) {
|
2008-12-20 11:33:16 +00:00
|
|
|
if(ob->pose) {
|
|
|
|
|
bArmature *arm= ob->data;
|
|
|
|
|
bPoseChannel *pchan;
|
|
|
|
|
float vec[3];
|
|
|
|
|
|
|
|
|
|
for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
|
|
|
|
|
if(pchan->bone->flag & BONE_SELECTED) {
|
|
|
|
|
if(pchan->bone->layer & arm->layer) {
|
|
|
|
|
ok= 1;
|
|
|
|
|
VECCOPY(vec, pchan->pose_head);
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_m4_v3(ob->obmat, vec);
|
2008-12-20 11:33:16 +00:00
|
|
|
DO_MINMAX(vec, min, max);
|
|
|
|
|
VECCOPY(vec, pchan->pose_tail);
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_m4_v3(ob->obmat, vec);
|
2008-12-20 11:33:16 +00:00
|
|
|
DO_MINMAX(vec, min, max);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-08-15 19:48:50 +00:00
|
|
|
else if (paint_facesel_test(ob)) {
|
2008-12-20 11:33:16 +00:00
|
|
|
// XXX ok= minmax_tface(min, max);
|
|
|
|
|
}
|
2009-08-16 02:35:44 +00:00
|
|
|
else if (ob && (ob->mode & OB_MODE_PARTICLE_EDIT)) {
|
2009-01-24 13:45:24 +00:00
|
|
|
ok= PE_minmax(scene, min, max);
|
2008-12-20 11:33:16 +00:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
Base *base= FIRSTBASE;
|
|
|
|
|
while(base) {
|
2008-12-20 18:43:21 +00:00
|
|
|
if(TESTBASE(v3d, base)) {
|
2008-12-20 11:33:16 +00:00
|
|
|
minmax_object(base->object, min, max);
|
|
|
|
|
/* account for duplis */
|
2009-01-04 14:14:06 +00:00
|
|
|
minmax_object_duplis(scene, base->object, min, max);
|
2008-12-20 11:33:16 +00:00
|
|
|
|
|
|
|
|
ok= 1;
|
|
|
|
|
}
|
|
|
|
|
base= base->next;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(ok==0) return OPERATOR_FINISHED;
|
|
|
|
|
|
|
|
|
|
afm[0]= (max[0]-min[0]);
|
|
|
|
|
afm[1]= (max[1]-min[1]);
|
|
|
|
|
afm[2]= (max[2]-min[2]);
|
2009-02-14 10:03:24 +00:00
|
|
|
size= MAX3(afm[0], afm[1], afm[2]);
|
|
|
|
|
/* perspective should be a bit farther away to look nice */
|
2009-10-27 02:54:25 +00:00
|
|
|
if(rv3d->persp==RV3D_ORTHO)
|
2009-02-14 10:03:24 +00:00
|
|
|
size*= 0.7;
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2008-12-20 11:33:16 +00:00
|
|
|
if(size <= v3d->near*1.5f) size= v3d->near*1.5f;
|
|
|
|
|
|
|
|
|
|
new_ofs[0]= -(min[0]+max[0])/2.0f;
|
|
|
|
|
new_ofs[1]= -(min[1]+max[1])/2.0f;
|
|
|
|
|
new_ofs[2]= -(min[2]+max[2])/2.0f;
|
|
|
|
|
|
|
|
|
|
new_dist = size;
|
|
|
|
|
|
|
|
|
|
/* correction for window aspect ratio */
|
|
|
|
|
if(ar->winy>2 && ar->winx>2) {
|
|
|
|
|
size= (float)ar->winx/(float)ar->winy;
|
|
|
|
|
if(size<1.0f) size= 1.0f/size;
|
|
|
|
|
new_dist*= size;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
v3d->cursor[0]= -new_ofs[0];
|
|
|
|
|
v3d->cursor[1]= -new_ofs[1];
|
|
|
|
|
v3d->cursor[2]= -new_ofs[2];
|
|
|
|
|
|
2009-10-27 02:54:25 +00:00
|
|
|
if (rv3d->persp==RV3D_CAMOB) {
|
|
|
|
|
rv3d->persp= RV3D_PERSP;
|
2008-12-26 18:15:46 +00:00
|
|
|
smooth_view(C, v3d->camera, NULL, new_ofs, NULL, &new_dist, NULL);
|
2009-07-09 02:45:48 +00:00
|
|
|
}
|
2008-12-26 18:15:46 +00:00
|
|
|
else {
|
|
|
|
|
smooth_view(C, NULL, NULL, new_ofs, NULL, &new_dist, NULL);
|
2008-12-20 11:33:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// XXX BIF_view3d_previewrender_signal(curarea, PR_DBASE|PR_DISPRECT);
|
2.5
Smaller jobs, all in one commit!
- Moved object_do_update out of view3d drawing, into
the event system (currently after notifiers).
Depsgraph calls for setting update flags will have to
keep track of each Screen's needs, so a UI showing only
a Sequencer doesn't do objects.
- Added button in "Properties region" in 3D window to set
or disable 4-split, including the 3 options it has.
(lock, box, clip)
- Restored legacy code for UI, to make things work like
bone rename, autocomplete.
- Node editor now shows Curves widgets again
- Bugfix: composite job increased Viewer user id count
- Bugfix: Node editor, not "Enable nodes" still called
a Job, which didn't do anything
- Various code cleaning, unused vars and prototypes.
2009-02-11 16:54:55 +00:00
|
|
|
if(rv3d->viewlock & RV3D_BOXVIEW)
|
2009-01-20 14:23:32 +00:00
|
|
|
view3d_boxview_copy(CTX_wm_area(C), ar);
|
2008-12-20 11:33:16 +00:00
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
2009-02-14 13:07:09 +00:00
|
|
|
|
2009-07-09 08:39:58 +00:00
|
|
|
void VIEW3D_OT_view_center(wmOperatorType *ot)
|
2008-12-20 11:33:16 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
|
|
/* identifiers */
|
2009-09-26 16:43:20 +00:00
|
|
|
ot->name= "View Selected";
|
2009-03-24 12:16:58 +00:00
|
|
|
ot->description = "Move the view to the selection center.";
|
2009-07-09 08:39:58 +00:00
|
|
|
ot->idname= "VIEW3D_OT_view_center";
|
2008-12-20 11:33:16 +00:00
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
|
ot->exec= viewcenter_exec;
|
2008-12-26 19:07:31 +00:00
|
|
|
ot->poll= ED_operator_view3d_active;
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2009-01-31 19:40:40 +00:00
|
|
|
/* flags */
|
2.5
Operator goodies!
--- Macro operators
Operators now can consist of multiple operators. Such a macro operator
is identical and behaves identical to other opererators. Macros can
also be constructed of macros even! Currently only hardcoded macros are
implemented, this to solve combined operators such as 'add duplicate' or
'extrude' (both want a transform appended).
Usage is simple:
- WM_operatortype_append_macro() : add new operatortype, name, flags
- WM_operatortype_macro_define() : add existing operator to macro
(Note: macro_define will also allow properties to be set, doesnt work
right now)
On converting the macro wmOperatorType to a real operator, it makes a
list of all operators, and the standard macro callbacks (exec, invoke,
modal, poll) just will use all.
Important note; switching to a modal operator only works as last in the
chain now!
Macros implemented for duplicate, extrude and rip. Tool menu works fine
for it, also the redo hotkey F4 works properly.
--- Operator redo fix
The operators use the undo system to switch back, but this could give
errors if other actions added undo pushes (buttons, outliner). Now the
redo for operator searches back for the correct undo level.
This fixes issues with many redos.
Note for brecht: removed the ED_undo_push for buttons... it was called
on *every* button now, which is probably too much? For example, using
the 'toolbar' redo also caused this...
2009-07-29 17:56:38 +00:00
|
|
|
ot->flag= 0;
|
2008-12-20 11:33:16 +00:00
|
|
|
}
|
|
|
|
|
|
2008-12-27 01:29:56 +00:00
|
|
|
/* ********************* Set render border operator ****************** */
|
|
|
|
|
|
|
|
|
|
static int render_border_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
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
|
|
|
View3D *v3d = CTX_wm_view3d(C);
|
2008-12-27 01:29:56 +00:00
|
|
|
ARegion *ar= CTX_wm_region(C);
|
|
|
|
|
Scene *scene= CTX_data_scene(C);
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2008-12-27 01:29:56 +00:00
|
|
|
rcti rect;
|
|
|
|
|
rctf vb;
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2008-12-27 01:29:56 +00:00
|
|
|
/* get border select values using rna */
|
|
|
|
|
rect.xmin= RNA_int_get(op->ptr, "xmin");
|
|
|
|
|
rect.ymin= RNA_int_get(op->ptr, "ymin");
|
|
|
|
|
rect.xmax= RNA_int_get(op->ptr, "xmax");
|
|
|
|
|
rect.ymax= RNA_int_get(op->ptr, "ymax");
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2008-12-27 01:29:56 +00:00
|
|
|
/* calculate range */
|
|
|
|
|
calc_viewborder(scene, ar, v3d, &vb);
|
|
|
|
|
|
|
|
|
|
scene->r.border.xmin= ((float)rect.xmin-vb.xmin)/(vb.xmax-vb.xmin);
|
|
|
|
|
scene->r.border.ymin= ((float)rect.ymin-vb.ymin)/(vb.ymax-vb.ymin);
|
|
|
|
|
scene->r.border.xmax= ((float)rect.xmax-vb.xmin)/(vb.xmax-vb.xmin);
|
|
|
|
|
scene->r.border.ymax= ((float)rect.ymax-vb.ymin)/(vb.ymax-vb.ymin);
|
2009-07-09 02:45:48 +00:00
|
|
|
|
|
|
|
|
/* actually set border */
|
2008-12-27 01:29:56 +00:00
|
|
|
CLAMP(scene->r.border.xmin, 0.0, 1.0);
|
|
|
|
|
CLAMP(scene->r.border.ymin, 0.0, 1.0);
|
|
|
|
|
CLAMP(scene->r.border.xmax, 0.0, 1.0);
|
|
|
|
|
CLAMP(scene->r.border.ymax, 0.0, 1.0);
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2008-12-27 01:29:56 +00:00
|
|
|
/* drawing a border surrounding the entire camera view switches off border rendering
|
|
|
|
|
* or the border covers no pixels */
|
|
|
|
|
if ((scene->r.border.xmin <= 0.0 && scene->r.border.xmax >= 1.0 &&
|
|
|
|
|
scene->r.border.ymin <= 0.0 && scene->r.border.ymax >= 1.0) ||
|
|
|
|
|
(scene->r.border.xmin == scene->r.border.xmax ||
|
|
|
|
|
scene->r.border.ymin == scene->r.border.ymax ))
|
|
|
|
|
{
|
|
|
|
|
scene->r.mode &= ~R_BORDER;
|
|
|
|
|
} else {
|
|
|
|
|
scene->r.mode |= R_BORDER;
|
|
|
|
|
}
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2008-12-27 01:29:56 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int view3d_render_border_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
|
|
|
|
{
|
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= CTX_wm_region_view3d(C);
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2008-12-27 01:29:56 +00:00
|
|
|
/* if not in camera view do not exec the operator*/
|
2009-10-27 02:54:25 +00:00
|
|
|
if (rv3d->persp == RV3D_CAMOB) return WM_border_select_invoke(C, op, event);
|
2008-12-27 01:29:56 +00:00
|
|
|
else return OPERATOR_PASS_THROUGH;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void VIEW3D_OT_render_border(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
|
|
|
|
ot->name= "Set Render Border";
|
2009-03-24 12:16:58 +00:00
|
|
|
ot->description = "Set the boundries of the border render and enables border render .";
|
2008-12-27 01:29:56 +00:00
|
|
|
ot->idname= "VIEW3D_OT_render_border";
|
|
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
|
ot->invoke= view3d_render_border_invoke;
|
|
|
|
|
ot->exec= render_border_exec;
|
|
|
|
|
ot->modal= WM_border_select_modal;
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2008-12-27 01:29:56 +00:00
|
|
|
ot->poll= ED_operator_view3d_active;
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2009-01-31 19:40:40 +00:00
|
|
|
/* flags */
|
|
|
|
|
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2008-12-27 01:29:56 +00:00
|
|
|
/* rna */
|
2009-01-16 23:53:11 +00:00
|
|
|
RNA_def_int(ot->srna, "xmin", 0, INT_MIN, INT_MAX, "X Min", "", INT_MIN, INT_MAX);
|
|
|
|
|
RNA_def_int(ot->srna, "xmax", 0, INT_MIN, INT_MAX, "X Max", "", INT_MIN, INT_MAX);
|
|
|
|
|
RNA_def_int(ot->srna, "ymin", 0, INT_MIN, INT_MAX, "Y Min", "", INT_MIN, INT_MAX);
|
|
|
|
|
RNA_def_int(ot->srna, "ymax", 0, INT_MIN, INT_MAX, "Y Max", "", INT_MIN, INT_MAX);
|
2008-12-27 01:29:56 +00:00
|
|
|
|
2009-01-16 00:58:33 +00:00
|
|
|
}
|
|
|
|
|
/* ********************* Border Zoom operator ****************** */
|
|
|
|
|
|
2009-07-24 23:07:18 +00:00
|
|
|
static int view3d_zoom_border_exec(bContext *C, wmOperator *op)
|
2009-01-16 00:58:33 +00:00
|
|
|
{
|
|
|
|
|
ARegion *ar= CTX_wm_region(C);
|
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
|
|
|
View3D *v3d = CTX_wm_view3d(C);
|
|
|
|
|
RegionView3D *rv3d= CTX_wm_region_view3d(C);
|
2009-01-16 00:58:33 +00:00
|
|
|
Scene *scene= CTX_data_scene(C);
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2009-01-16 00:58:33 +00:00
|
|
|
/* Zooms in on a border drawn by the user */
|
|
|
|
|
rcti rect;
|
|
|
|
|
float dvec[3], vb[2], xscale, yscale, scale;
|
|
|
|
|
|
|
|
|
|
/* SMOOTHVIEW */
|
|
|
|
|
float new_dist;
|
|
|
|
|
float new_ofs[3];
|
|
|
|
|
|
|
|
|
|
/* ZBuffer depth vars */
|
|
|
|
|
bglMats mats;
|
|
|
|
|
float depth, depth_close= MAXFLOAT;
|
|
|
|
|
int had_depth = 0;
|
|
|
|
|
double cent[2], p[3];
|
|
|
|
|
int xs, ys;
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2009-01-16 00:58:33 +00:00
|
|
|
/* note; otherwise opengl won't work */
|
|
|
|
|
view3d_operator_needs_opengl(C);
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2009-01-16 00:58:33 +00:00
|
|
|
/* get border select values using rna */
|
|
|
|
|
rect.xmin= RNA_int_get(op->ptr, "xmin");
|
|
|
|
|
rect.ymin= RNA_int_get(op->ptr, "ymin");
|
|
|
|
|
rect.xmax= RNA_int_get(op->ptr, "xmax");
|
|
|
|
|
rect.ymax= RNA_int_get(op->ptr, "ymax");
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2009-01-16 00:58:33 +00:00
|
|
|
/* Get Z Depths, needed for perspective, nice for ortho */
|
|
|
|
|
bgl_get_mats(&mats);
|
|
|
|
|
draw_depth(scene, ar, v3d, NULL);
|
|
|
|
|
|
|
|
|
|
/* force updating */
|
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) {
|
2009-01-16 00:58:33 +00:00
|
|
|
had_depth = 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
|
|
|
rv3d->depths->damaged = 1;
|
2009-01-16 00:58:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
view3d_update_depths(ar, v3d);
|
|
|
|
|
|
|
|
|
|
/* Constrain rect to depth bounds */
|
|
|
|
|
if (rect.xmin < 0) rect.xmin = 0;
|
|
|
|
|
if (rect.ymin < 0) rect.ymin = 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
|
|
|
if (rect.xmax >= rv3d->depths->w) rect.xmax = rv3d->depths->w-1;
|
|
|
|
|
if (rect.ymax >= rv3d->depths->h) rect.ymax = rv3d->depths->h-1;
|
2009-01-16 00:58:33 +00:00
|
|
|
|
|
|
|
|
/* Find the closest Z pixel */
|
|
|
|
|
for (xs=rect.xmin; xs < rect.xmax; xs++) {
|
|
|
|
|
for (ys=rect.ymin; ys < rect.ymax; ys++) {
|
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
|
|
|
depth= rv3d->depths->depths[ys*rv3d->depths->w+xs];
|
|
|
|
|
if(depth < rv3d->depths->depth_range[1] && depth > rv3d->depths->depth_range[0]) {
|
2009-01-16 00:58:33 +00:00
|
|
|
if (depth_close > depth) {
|
|
|
|
|
depth_close = depth;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (had_depth==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
|
|
|
MEM_freeN(rv3d->depths->depths);
|
|
|
|
|
rv3d->depths->depths = NULL;
|
2009-01-16 00:58:33 +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
|
|
|
rv3d->depths->damaged = 1;
|
2009-01-16 00:58:33 +00:00
|
|
|
|
|
|
|
|
cent[0] = (((double)rect.xmin)+((double)rect.xmax)) / 2;
|
|
|
|
|
cent[1] = (((double)rect.ymin)+((double)rect.ymax)) / 2;
|
|
|
|
|
|
2009-10-27 02:54:25 +00:00
|
|
|
if (rv3d->persp==RV3D_PERSP) {
|
2009-01-16 00:58:33 +00:00
|
|
|
double p_corner[3];
|
|
|
|
|
|
|
|
|
|
/* no depths to use, we cant do anything! */
|
2009-01-21 02:24:12 +00:00
|
|
|
if (depth_close==MAXFLOAT){
|
|
|
|
|
BKE_report(op->reports, RPT_ERROR, "Depth Too Large");
|
2009-01-16 00:58:33 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
2009-01-21 02:24:12 +00:00
|
|
|
}
|
2009-01-16 00:58:33 +00:00
|
|
|
/* convert border to 3d coordinates */
|
|
|
|
|
if (( !gluUnProject(cent[0], cent[1], depth_close, mats.modelview, mats.projection, (GLint *)mats.viewport, &p[0], &p[1], &p[2])) ||
|
|
|
|
|
( !gluUnProject((double)rect.xmin, (double)rect.ymin, depth_close, mats.modelview, mats.projection, (GLint *)mats.viewport, &p_corner[0], &p_corner[1], &p_corner[2])))
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
|
|
|
|
dvec[0] = p[0]-p_corner[0];
|
|
|
|
|
dvec[1] = p[1]-p_corner[1];
|
|
|
|
|
dvec[2] = p[2]-p_corner[2];
|
|
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
new_dist = len_v3(dvec);
|
2009-01-16 00:58:33 +00:00
|
|
|
if(new_dist <= v3d->near*1.5) new_dist= v3d->near*1.5;
|
|
|
|
|
|
|
|
|
|
new_ofs[0] = -p[0];
|
|
|
|
|
new_ofs[1] = -p[1];
|
|
|
|
|
new_ofs[2] = -p[2];
|
|
|
|
|
|
|
|
|
|
} else { /* othographic */
|
|
|
|
|
/* find the current window width and height */
|
|
|
|
|
vb[0] = ar->winx;
|
|
|
|
|
vb[1] = ar->winy;
|
|
|
|
|
|
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
|
|
|
new_dist = rv3d->dist;
|
2009-01-16 00:58:33 +00:00
|
|
|
|
|
|
|
|
/* convert the drawn rectangle into 3d space */
|
|
|
|
|
if (depth_close!=MAXFLOAT && gluUnProject(cent[0], cent[1], depth_close, mats.modelview, mats.projection, (GLint *)mats.viewport, &p[0], &p[1], &p[2])) {
|
|
|
|
|
new_ofs[0] = -p[0];
|
|
|
|
|
new_ofs[1] = -p[1];
|
|
|
|
|
new_ofs[2] = -p[2];
|
|
|
|
|
} else {
|
|
|
|
|
/* We cant use the depth, fallback to the old way that dosnt set the center depth */
|
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
|
|
|
new_ofs[0] = rv3d->ofs[0];
|
|
|
|
|
new_ofs[1] = rv3d->ofs[1];
|
|
|
|
|
new_ofs[2] = rv3d->ofs[2];
|
2009-01-16 00:58:33 +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
|
|
|
initgrabz(rv3d, -new_ofs[0], -new_ofs[1], -new_ofs[2]);
|
2009-01-16 00:58:33 +00:00
|
|
|
|
2009-01-20 18:31:11 +00:00
|
|
|
window_to_3d_delta(ar, dvec, (rect.xmin+rect.xmax-vb[0])/2, (rect.ymin+rect.ymax-vb[1])/2);
|
2009-01-16 00:58:33 +00:00
|
|
|
/* center the view to the center of the rectangle */
|
2009-11-10 20:43:45 +00:00
|
|
|
sub_v3_v3v3(new_ofs, new_ofs, dvec);
|
2009-01-16 00:58:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* work out the ratios, so that everything selected fits when we zoom */
|
|
|
|
|
xscale = ((rect.xmax-rect.xmin)/vb[0]);
|
|
|
|
|
yscale = ((rect.ymax-rect.ymin)/vb[1]);
|
|
|
|
|
scale = (xscale >= yscale)?xscale:yscale;
|
|
|
|
|
|
|
|
|
|
/* zoom in as required, or as far as we can go */
|
|
|
|
|
new_dist = ((new_dist*scale) >= 0.001*v3d->grid)? new_dist*scale:0.001*v3d->grid;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
smooth_view(C, NULL, NULL, new_ofs, NULL, &new_dist, NULL);
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2.5
Smaller jobs, all in one commit!
- Moved object_do_update out of view3d drawing, into
the event system (currently after notifiers).
Depsgraph calls for setting update flags will have to
keep track of each Screen's needs, so a UI showing only
a Sequencer doesn't do objects.
- Added button in "Properties region" in 3D window to set
or disable 4-split, including the 3 options it has.
(lock, box, clip)
- Restored legacy code for UI, to make things work like
bone rename, autocomplete.
- Node editor now shows Curves widgets again
- Bugfix: composite job increased Viewer user id count
- Bugfix: Node editor, not "Enable nodes" still called
a Job, which didn't do anything
- Various code cleaning, unused vars and prototypes.
2009-02-11 16:54:55 +00:00
|
|
|
if(rv3d->viewlock & RV3D_BOXVIEW)
|
2009-01-20 14:23:32 +00:00
|
|
|
view3d_boxview_sync(CTX_wm_area(C), ar);
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2009-01-16 00:58:33 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
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
|
|
|
|
2009-07-24 23:07:18 +00:00
|
|
|
static int view3d_zoom_border_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
2009-01-16 00:58:33 +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= CTX_wm_region_view3d(C);
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2009-01-16 00:58:33 +00:00
|
|
|
/* if in camera view do not exec the operator so we do not conflict with set render border*/
|
2009-10-27 02:54:25 +00:00
|
|
|
if (rv3d->persp != RV3D_CAMOB)
|
2009-07-09 02:45:48 +00:00
|
|
|
return WM_border_select_invoke(C, op, event);
|
|
|
|
|
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
|
|
|
return OPERATOR_PASS_THROUGH;
|
2009-01-16 00:58:33 +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
|
|
|
|
2009-03-29 02:15:13 +00:00
|
|
|
void VIEW3D_OT_zoom_border(wmOperatorType *ot)
|
2009-01-16 00:58:33 +00:00
|
|
|
{
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2009-01-16 00:58:33 +00:00
|
|
|
/* identifiers */
|
|
|
|
|
ot->name= "Border Zoom";
|
2009-03-24 12:16:58 +00:00
|
|
|
ot->description = "Zoom in the view to the nearest object contained in the border.";
|
2009-03-29 02:15:13 +00:00
|
|
|
ot->idname= "VIEW3D_OT_zoom_border";
|
2009-01-16 00:58:33 +00:00
|
|
|
|
|
|
|
|
/* api callbacks */
|
2009-07-24 23:07:18 +00:00
|
|
|
ot->invoke= view3d_zoom_border_invoke;
|
|
|
|
|
ot->exec= view3d_zoom_border_exec;
|
2009-01-16 00:58:33 +00:00
|
|
|
ot->modal= WM_border_select_modal;
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2009-01-16 00:58:33 +00:00
|
|
|
ot->poll= ED_operator_view3d_active;
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2009-01-31 19:40:40 +00:00
|
|
|
/* flags */
|
2.5
Operator goodies!
--- Macro operators
Operators now can consist of multiple operators. Such a macro operator
is identical and behaves identical to other opererators. Macros can
also be constructed of macros even! Currently only hardcoded macros are
implemented, this to solve combined operators such as 'add duplicate' or
'extrude' (both want a transform appended).
Usage is simple:
- WM_operatortype_append_macro() : add new operatortype, name, flags
- WM_operatortype_macro_define() : add existing operator to macro
(Note: macro_define will also allow properties to be set, doesnt work
right now)
On converting the macro wmOperatorType to a real operator, it makes a
list of all operators, and the standard macro callbacks (exec, invoke,
modal, poll) just will use all.
Important note; switching to a modal operator only works as last in the
chain now!
Macros implemented for duplicate, extrude and rip. Tool menu works fine
for it, also the redo hotkey F4 works properly.
--- Operator redo fix
The operators use the undo system to switch back, but this could give
errors if other actions added undo pushes (buttons, outliner). Now the
redo for operator searches back for the correct undo level.
This fixes issues with many redos.
Note for brecht: removed the ED_undo_push for buttons... it was called
on *every* button now, which is probably too much? For example, using
the 'toolbar' redo also caused this...
2009-07-29 17:56:38 +00:00
|
|
|
ot->flag= 0;
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2009-01-16 00:58:33 +00:00
|
|
|
/* rna */
|
2009-01-16 23:53:11 +00:00
|
|
|
RNA_def_int(ot->srna, "xmin", 0, INT_MIN, INT_MAX, "X Min", "", INT_MIN, INT_MAX);
|
|
|
|
|
RNA_def_int(ot->srna, "xmax", 0, INT_MIN, INT_MAX, "X Max", "", INT_MIN, INT_MAX);
|
|
|
|
|
RNA_def_int(ot->srna, "ymin", 0, INT_MIN, INT_MAX, "Y Min", "", INT_MIN, INT_MAX);
|
|
|
|
|
RNA_def_int(ot->srna, "ymax", 0, INT_MIN, INT_MAX, "Y Max", "", INT_MIN, INT_MAX);
|
2009-01-16 00:58:33 +00:00
|
|
|
|
2008-12-27 01:29:56 +00:00
|
|
|
}
|
2008-12-26 10:31:44 +00:00
|
|
|
/* ********************* Changing view operator ****************** */
|
|
|
|
|
|
2008-12-23 09:59:02 +00:00
|
|
|
static EnumPropertyItem prop_view_items[] = {
|
2009-10-27 02:54:25 +00:00
|
|
|
{RV3D_VIEW_FRONT, "FRONT", 0, "Front", "View From the Front"},
|
|
|
|
|
{RV3D_VIEW_BACK, "BACK", 0, "Back", "View From the Back"},
|
|
|
|
|
{RV3D_VIEW_LEFT, "LEFT", 0, "Left", "View From the Left"},
|
|
|
|
|
{RV3D_VIEW_RIGHT, "RIGHT", 0, "Right", "View From the Right"},
|
|
|
|
|
{RV3D_VIEW_TOP, "TOP", 0, "Top", "View From the Top"},
|
|
|
|
|
{RV3D_VIEW_BOTTOM, "BOTTOM", 0, "Bottom", "View From the Bottom"},
|
|
|
|
|
{RV3D_VIEW_CAMERA, "CAMERA", 0, "Camera", "View From the active amera"},
|
2009-06-16 00:52:21 +00:00
|
|
|
{0, NULL, 0, NULL, NULL}};
|
2008-12-23 09:59:02 +00:00
|
|
|
|
2009-11-06 10:38:00 +00:00
|
|
|
|
|
|
|
|
/* would like to make this a generic function - outside of transform */
|
|
|
|
|
|
|
|
|
|
static void axis_set_view(bContext *C, float q1, float q2, float q3, float q4, short view, int perspo, int align_active)
|
2008-12-23 09:59:02 +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
|
|
|
View3D *v3d = CTX_wm_view3d(C);
|
|
|
|
|
RegionView3D *rv3d= CTX_wm_region_view3d(C);
|
2008-12-23 09:59:02 +00:00
|
|
|
float new_quat[4];
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2008-12-23 09:59:02 +00:00
|
|
|
new_quat[0]= q1; new_quat[1]= q2;
|
|
|
|
|
new_quat[2]= q3; new_quat[3]= q4;
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2009-11-06 10:38:00 +00:00
|
|
|
if(align_active) {
|
|
|
|
|
/* align to active object */
|
|
|
|
|
Object *obact= CTX_data_active_object(C);
|
|
|
|
|
if (obact==NULL) {
|
|
|
|
|
/* no active object, ignore this option */
|
|
|
|
|
align_active= FALSE;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
float obact_quat[4];
|
2009-11-06 22:10:08 +00:00
|
|
|
float twmat[3][3];
|
2009-11-06 10:38:00 +00:00
|
|
|
|
|
|
|
|
/* same as transform manipulator when normal is set */
|
2009-11-06 22:10:08 +00:00
|
|
|
ED_getTransformOrientationMatrix(C, twmat, TRUE);
|
2009-11-06 10:38:00 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
mat3_to_quat( obact_quat,twmat);
|
|
|
|
|
invert_qt(obact_quat);
|
|
|
|
|
mul_qt_qtqt(new_quat, new_quat, obact_quat);
|
2009-11-06 10:38:00 +00:00
|
|
|
|
|
|
|
|
rv3d->view= view= 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(align_active==FALSE) {
|
|
|
|
|
/* normal operation */
|
|
|
|
|
if(rv3d->viewlock) {
|
|
|
|
|
/* only pass on if */
|
|
|
|
|
if(rv3d->view==RV3D_VIEW_FRONT && view==RV3D_VIEW_BACK);
|
|
|
|
|
else if(rv3d->view==RV3D_VIEW_BACK && view==RV3D_VIEW_FRONT);
|
|
|
|
|
else if(rv3d->view==RV3D_VIEW_RIGHT && view==RV3D_VIEW_LEFT);
|
|
|
|
|
else if(rv3d->view==RV3D_VIEW_LEFT && view==RV3D_VIEW_RIGHT);
|
|
|
|
|
else if(rv3d->view==RV3D_VIEW_BOTTOM && view==RV3D_VIEW_TOP);
|
|
|
|
|
else if(rv3d->view==RV3D_VIEW_TOP && view==RV3D_VIEW_BOTTOM);
|
|
|
|
|
else return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rv3d->view= view;
|
|
|
|
|
}
|
2009-01-20 14:23:32 +00:00
|
|
|
|
|
|
|
|
if(rv3d->viewlock) {
|
|
|
|
|
ED_region_tag_redraw(CTX_wm_region(C));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2009-10-27 02:54:25 +00:00
|
|
|
if (rv3d->persp==RV3D_CAMOB && v3d->camera) {
|
2008-12-23 09:59:02 +00:00
|
|
|
|
2009-10-27 02:54:25 +00:00
|
|
|
if (U.uiflag & USER_AUTOPERSP) rv3d->persp= RV3D_ORTHO;
|
|
|
|
|
else if(rv3d->persp==RV3D_CAMOB) rv3d->persp= perspo;
|
2008-12-23 09:59:02 +00:00
|
|
|
|
2009-07-09 02:45:48 +00:00
|
|
|
smooth_view(C, v3d->camera, NULL, rv3d->ofs, new_quat, NULL, NULL);
|
|
|
|
|
}
|
2008-12-26 18:15:46 +00:00
|
|
|
else {
|
2008-12-23 09:59:02 +00:00
|
|
|
|
2009-10-27 02:54:25 +00:00
|
|
|
if (U.uiflag & USER_AUTOPERSP) rv3d->persp= RV3D_ORTHO;
|
|
|
|
|
else if(rv3d->persp==RV3D_CAMOB) rv3d->persp= perspo;
|
2008-12-23 09:59:02 +00:00
|
|
|
|
2008-12-26 18:15:46 +00:00
|
|
|
smooth_view(C, NULL, NULL, NULL, new_quat, NULL, NULL);
|
2008-12-23 09:59:02 +00:00
|
|
|
}
|
2008-12-26 18:15:46 +00:00
|
|
|
|
2008-12-23 09:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int viewnumpad_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
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
|
|
|
View3D *v3d = CTX_wm_view3d(C);
|
|
|
|
|
RegionView3D *rv3d= CTX_wm_region_view3d(C);
|
2008-12-23 09:59:02 +00:00
|
|
|
Scene *scene= CTX_data_scene(C);
|
2009-10-27 02:54:25 +00:00
|
|
|
static int perspo=RV3D_PERSP;
|
2009-11-06 10:38:00 +00:00
|
|
|
int viewnum, align_active;
|
2008-12-23 09:59:02 +00:00
|
|
|
|
2009-02-04 05:15:39 +00:00
|
|
|
viewnum = RNA_enum_get(op->ptr, "type");
|
2009-11-06 10:38:00 +00:00
|
|
|
align_active = RNA_boolean_get(op->ptr, "align_active");
|
2008-12-23 09:59:02 +00:00
|
|
|
|
|
|
|
|
/* Use this to test if we started out with a camera */
|
|
|
|
|
|
|
|
|
|
switch (viewnum) {
|
2009-10-27 02:54:25 +00:00
|
|
|
case RV3D_VIEW_BOTTOM :
|
2009-11-06 10:38:00 +00:00
|
|
|
axis_set_view(C, 0.0, -1.0, 0.0, 0.0, viewnum, perspo, align_active);
|
2008-12-23 09:59:02 +00:00
|
|
|
break;
|
|
|
|
|
|
2009-10-27 02:54:25 +00:00
|
|
|
case RV3D_VIEW_BACK:
|
2009-11-06 10:38:00 +00:00
|
|
|
axis_set_view(C, 0.0, 0.0, (float)-cos(M_PI/4.0), (float)-cos(M_PI/4.0), viewnum, perspo, align_active);
|
2008-12-23 09:59:02 +00:00
|
|
|
break;
|
|
|
|
|
|
2009-10-27 02:54:25 +00:00
|
|
|
case RV3D_VIEW_LEFT:
|
2009-11-06 10:38:00 +00:00
|
|
|
axis_set_view(C, 0.5, -0.5, 0.5, 0.5, viewnum, perspo, align_active);
|
2008-12-23 09:59:02 +00:00
|
|
|
break;
|
|
|
|
|
|
2009-10-27 02:54:25 +00:00
|
|
|
case RV3D_VIEW_TOP:
|
2009-11-06 10:38:00 +00:00
|
|
|
axis_set_view(C, 1.0, 0.0, 0.0, 0.0, viewnum, perspo, align_active);
|
2008-12-23 09:59:02 +00:00
|
|
|
break;
|
|
|
|
|
|
2009-10-27 02:54:25 +00:00
|
|
|
case RV3D_VIEW_FRONT:
|
2009-11-06 10:38:00 +00:00
|
|
|
axis_set_view(C, (float)cos(M_PI/4.0), (float)-sin(M_PI/4.0), 0.0, 0.0, viewnum, perspo, align_active);
|
2008-12-23 09:59:02 +00:00
|
|
|
break;
|
|
|
|
|
|
2009-10-27 02:54:25 +00:00
|
|
|
case RV3D_VIEW_RIGHT:
|
2009-11-06 10:38:00 +00:00
|
|
|
axis_set_view(C, 0.5, -0.5, -0.5, -0.5, viewnum, perspo, align_active);
|
2008-12-23 09:59:02 +00:00
|
|
|
break;
|
|
|
|
|
|
2009-10-27 02:54:25 +00:00
|
|
|
case RV3D_VIEW_CAMERA:
|
2009-01-20 14:23:32 +00:00
|
|
|
if(rv3d->viewlock==0) {
|
|
|
|
|
/* lastview - */
|
|
|
|
|
|
2009-10-27 02:54:25 +00:00
|
|
|
if(rv3d->persp != RV3D_CAMOB) {
|
2009-01-20 14:23:32 +00:00
|
|
|
/* store settings of current view before allowing overwriting with camera view */
|
|
|
|
|
QUATCOPY(rv3d->lviewquat, rv3d->viewquat);
|
|
|
|
|
rv3d->lview= rv3d->view;
|
|
|
|
|
rv3d->lpersp= rv3d->persp;
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2009-01-20 14:23:32 +00:00
|
|
|
#if 0
|
|
|
|
|
if(G.qual==LR_ALTKEY) {
|
|
|
|
|
if(oldcamera && is_an_active_object(oldcamera)) {
|
|
|
|
|
v3d->camera= oldcamera;
|
|
|
|
|
}
|
|
|
|
|
handle_view3d_lock();
|
2008-12-26 18:15:46 +00:00
|
|
|
}
|
2009-01-20 14:23:32 +00:00
|
|
|
#endif
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2009-01-20 14:23:32 +00:00
|
|
|
if(BASACT) {
|
|
|
|
|
/* check both G.vd as G.scene cameras */
|
|
|
|
|
if((v3d->camera==NULL || scene->camera==NULL) && OBACT->type==OB_CAMERA) {
|
|
|
|
|
v3d->camera= OBACT;
|
|
|
|
|
/*handle_view3d_lock();*/
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2009-01-20 14:23:32 +00:00
|
|
|
if(v3d->camera==NULL) {
|
|
|
|
|
v3d->camera= scene_find_camera(scene);
|
2008-12-26 18:15:46 +00:00
|
|
|
/*handle_view3d_lock();*/
|
|
|
|
|
}
|
2009-10-27 02:54:25 +00:00
|
|
|
rv3d->persp= RV3D_CAMOB;
|
2009-01-20 14:23:32 +00:00
|
|
|
smooth_view(C, NULL, v3d->camera, rv3d->ofs, rv3d->viewquat, &rv3d->dist, &v3d->lens);
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2008-12-26 18:15:46 +00:00
|
|
|
}
|
2009-01-20 14:23:32 +00:00
|
|
|
else{
|
|
|
|
|
/* return to settings of last view */
|
|
|
|
|
/* does smooth_view too */
|
2009-11-06 10:38:00 +00:00
|
|
|
axis_set_view(C, rv3d->lviewquat[0], rv3d->lviewquat[1], rv3d->lviewquat[2], rv3d->lviewquat[3], rv3d->lview, rv3d->lpersp, 0);
|
2008-12-23 09:59:02 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default :
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2009-10-27 02:54:25 +00:00
|
|
|
if(rv3d->persp != RV3D_CAMOB) perspo= rv3d->persp;
|
2008-12-23 09:59:02 +00:00
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
2008-12-26 11:11:21 +00:00
|
|
|
void VIEW3D_OT_viewnumpad(wmOperatorType *ot)
|
2008-12-23 09:59:02 +00:00
|
|
|
{
|
|
|
|
|
/* identifiers */
|
|
|
|
|
ot->name= "View numpad";
|
2009-03-24 12:16:58 +00:00
|
|
|
ot->description = "Set the view.";
|
2008-12-26 11:11:21 +00:00
|
|
|
ot->idname= "VIEW3D_OT_viewnumpad";
|
2008-12-23 09:59:02 +00:00
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
|
ot->exec= viewnumpad_exec;
|
2008-12-26 19:07:31 +00:00
|
|
|
ot->poll= ED_operator_view3d_active;
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2009-01-31 19:40:40 +00:00
|
|
|
/* flags */
|
2.5
Operator goodies!
--- Macro operators
Operators now can consist of multiple operators. Such a macro operator
is identical and behaves identical to other opererators. Macros can
also be constructed of macros even! Currently only hardcoded macros are
implemented, this to solve combined operators such as 'add duplicate' or
'extrude' (both want a transform appended).
Usage is simple:
- WM_operatortype_append_macro() : add new operatortype, name, flags
- WM_operatortype_macro_define() : add existing operator to macro
(Note: macro_define will also allow properties to be set, doesnt work
right now)
On converting the macro wmOperatorType to a real operator, it makes a
list of all operators, and the standard macro callbacks (exec, invoke,
modal, poll) just will use all.
Important note; switching to a modal operator only works as last in the
chain now!
Macros implemented for duplicate, extrude and rip. Tool menu works fine
for it, also the redo hotkey F4 works properly.
--- Operator redo fix
The operators use the undo system to switch back, but this could give
errors if other actions added undo pushes (buttons, outliner). Now the
redo for operator searches back for the correct undo level.
This fixes issues with many redos.
Note for brecht: removed the ED_undo_push for buttons... it was called
on *every* button now, which is probably too much? For example, using
the 'toolbar' redo also caused this...
2009-07-29 17:56:38 +00:00
|
|
|
ot->flag= 0;
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2009-02-04 05:15:39 +00:00
|
|
|
RNA_def_enum(ot->srna, "type", prop_view_items, 0, "View", "The Type of view");
|
2009-11-06 10:38:00 +00:00
|
|
|
RNA_def_boolean(ot->srna, "align_active", 0, "Align Active", "Align to the active objects axis");
|
2008-12-23 09:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
2009-02-03 03:54:03 +00:00
|
|
|
static EnumPropertyItem prop_view_orbit_items[] = {
|
2009-06-16 00:52:21 +00:00
|
|
|
{V3D_VIEW_STEPLEFT, "ORBITLEFT", 0, "Orbit Left", "Orbit the view around to the Left"},
|
|
|
|
|
{V3D_VIEW_STEPRIGHT, "ORBITRIGHT", 0, "Orbit Right", "Orbit the view around to the Right"},
|
|
|
|
|
{V3D_VIEW_STEPUP, "ORBITUP", 0, "Orbit Up", "Orbit the view Up"},
|
|
|
|
|
{V3D_VIEW_STEPDOWN, "ORBITDOWN", 0, "Orbit Down", "Orbit the view Down"},
|
|
|
|
|
{0, NULL, 0, NULL, NULL}};
|
2009-02-03 03:54:03 +00:00
|
|
|
|
|
|
|
|
static int vieworbit_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
|
|
|
|
ARegion *ar= CTX_wm_region(C);
|
|
|
|
|
RegionView3D *rv3d= CTX_wm_region_view3d(C);
|
2009-07-09 02:45:48 +00:00
|
|
|
float phi, si, q1[4];
|
2009-02-03 03:54:03 +00:00
|
|
|
int orbitdir;
|
|
|
|
|
|
|
|
|
|
orbitdir = RNA_enum_get(op->ptr, "type");
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2009-02-03 03:54:03 +00:00
|
|
|
if(rv3d->viewlock==0) {
|
|
|
|
|
|
2009-10-27 02:54:25 +00:00
|
|
|
if(rv3d->persp != RV3D_CAMOB) {
|
2009-02-03 03:54:03 +00:00
|
|
|
if(orbitdir == V3D_VIEW_STEPLEFT || orbitdir == V3D_VIEW_STEPRIGHT) {
|
|
|
|
|
/* z-axis */
|
|
|
|
|
phi= (float)(M_PI/360.0)*U.pad_rot_angle;
|
|
|
|
|
if(orbitdir == V3D_VIEW_STEPRIGHT) phi= -phi;
|
|
|
|
|
si= (float)sin(phi);
|
|
|
|
|
q1[0]= (float)cos(phi);
|
|
|
|
|
q1[1]= q1[2]= 0.0;
|
|
|
|
|
q1[3]= si;
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, q1);
|
2009-02-03 03:54:03 +00:00
|
|
|
rv3d->view= 0;
|
|
|
|
|
}
|
|
|
|
|
if(orbitdir == V3D_VIEW_STEPDOWN || orbitdir == V3D_VIEW_STEPUP) {
|
|
|
|
|
/* horizontal axis */
|
|
|
|
|
VECCOPY(q1+1, rv3d->viewinv[0]);
|
|
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
normalize_v3(q1+1);
|
2009-02-03 03:54:03 +00:00
|
|
|
phi= (float)(M_PI/360.0)*U.pad_rot_angle;
|
|
|
|
|
if(orbitdir == V3D_VIEW_STEPDOWN) phi= -phi;
|
|
|
|
|
si= (float)sin(phi);
|
|
|
|
|
q1[0]= (float)cos(phi);
|
|
|
|
|
q1[1]*= si;
|
|
|
|
|
q1[2]*= si;
|
|
|
|
|
q1[3]*= si;
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, q1);
|
2009-02-03 03:54:03 +00:00
|
|
|
rv3d->view= 0;
|
|
|
|
|
}
|
|
|
|
|
ED_region_tag_redraw(ar);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-09 02:45:48 +00:00
|
|
|
return OPERATOR_FINISHED;
|
2009-02-03 03:54:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void VIEW3D_OT_view_orbit(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
|
|
|
|
ot->name= "View Orbit";
|
2009-03-24 12:16:58 +00:00
|
|
|
ot->description = "Orbit the view.";
|
2009-02-03 03:54:03 +00:00
|
|
|
ot->idname= "VIEW3D_OT_view_orbit";
|
|
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
|
ot->exec= vieworbit_exec;
|
|
|
|
|
ot->poll= ED_operator_view3d_active;
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2009-02-03 03:54:03 +00:00
|
|
|
/* flags */
|
2.5
Operator goodies!
--- Macro operators
Operators now can consist of multiple operators. Such a macro operator
is identical and behaves identical to other opererators. Macros can
also be constructed of macros even! Currently only hardcoded macros are
implemented, this to solve combined operators such as 'add duplicate' or
'extrude' (both want a transform appended).
Usage is simple:
- WM_operatortype_append_macro() : add new operatortype, name, flags
- WM_operatortype_macro_define() : add existing operator to macro
(Note: macro_define will also allow properties to be set, doesnt work
right now)
On converting the macro wmOperatorType to a real operator, it makes a
list of all operators, and the standard macro callbacks (exec, invoke,
modal, poll) just will use all.
Important note; switching to a modal operator only works as last in the
chain now!
Macros implemented for duplicate, extrude and rip. Tool menu works fine
for it, also the redo hotkey F4 works properly.
--- Operator redo fix
The operators use the undo system to switch back, but this could give
errors if other actions added undo pushes (buttons, outliner). Now the
redo for operator searches back for the correct undo level.
This fixes issues with many redos.
Note for brecht: removed the ED_undo_push for buttons... it was called
on *every* button now, which is probably too much? For example, using
the 'toolbar' redo also caused this...
2009-07-29 17:56:38 +00:00
|
|
|
ot->flag= 0;
|
2009-02-03 03:54:03 +00:00
|
|
|
RNA_def_enum(ot->srna, "type", prop_view_orbit_items, 0, "Orbit", "Direction of View Orbit");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static EnumPropertyItem prop_view_pan_items[] = {
|
2009-06-16 00:52:21 +00:00
|
|
|
{V3D_VIEW_PANLEFT, "PANLEFT", 0, "Pan Left", "Pan the view to the Left"},
|
|
|
|
|
{V3D_VIEW_PANRIGHT, "PANRIGHT", 0, "Pan Right", "Pan the view to the Right"},
|
|
|
|
|
{V3D_VIEW_PANUP, "PANUP", 0, "Pan Up", "Pan the view Up"},
|
|
|
|
|
{V3D_VIEW_PANDOWN, "PANDOWN", 0, "Pan Down", "Pan the view Down"},
|
|
|
|
|
{0, NULL, 0, NULL, NULL}};
|
2009-02-03 03:54:03 +00:00
|
|
|
|
|
|
|
|
static int viewpan_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
|
|
|
|
ARegion *ar= CTX_wm_region(C);
|
2009-07-09 02:45:48 +00:00
|
|
|
RegionView3D *rv3d= CTX_wm_region_view3d(C);
|
|
|
|
|
float vec[3];
|
2009-02-03 03:54:03 +00:00
|
|
|
int pandir;
|
|
|
|
|
|
|
|
|
|
pandir = RNA_enum_get(op->ptr, "type");
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2009-02-03 03:54:03 +00:00
|
|
|
initgrabz(rv3d, 0.0, 0.0, 0.0);
|
|
|
|
|
|
|
|
|
|
if(pandir == V3D_VIEW_PANRIGHT) window_to_3d_delta(ar, vec, -32, 0);
|
|
|
|
|
else if(pandir == V3D_VIEW_PANLEFT) window_to_3d_delta(ar, vec, 32, 0);
|
|
|
|
|
else if(pandir == V3D_VIEW_PANUP) window_to_3d_delta(ar, vec, 0, -25);
|
|
|
|
|
else if(pandir == V3D_VIEW_PANDOWN) window_to_3d_delta(ar, vec, 0, 25);
|
|
|
|
|
rv3d->ofs[0]+= vec[0];
|
|
|
|
|
rv3d->ofs[1]+= vec[1];
|
|
|
|
|
rv3d->ofs[2]+= vec[2];
|
|
|
|
|
|
2.5
Smaller jobs, all in one commit!
- Moved object_do_update out of view3d drawing, into
the event system (currently after notifiers).
Depsgraph calls for setting update flags will have to
keep track of each Screen's needs, so a UI showing only
a Sequencer doesn't do objects.
- Added button in "Properties region" in 3D window to set
or disable 4-split, including the 3 options it has.
(lock, box, clip)
- Restored legacy code for UI, to make things work like
bone rename, autocomplete.
- Node editor now shows Curves widgets again
- Bugfix: composite job increased Viewer user id count
- Bugfix: Node editor, not "Enable nodes" still called
a Job, which didn't do anything
- Various code cleaning, unused vars and prototypes.
2009-02-11 16:54:55 +00:00
|
|
|
if(rv3d->viewlock & RV3D_BOXVIEW)
|
2009-02-03 03:54:03 +00:00
|
|
|
view3d_boxview_sync(CTX_wm_area(C), ar);
|
|
|
|
|
|
|
|
|
|
ED_region_tag_redraw(ar);
|
|
|
|
|
|
2009-07-09 02:45:48 +00:00
|
|
|
return OPERATOR_FINISHED;
|
2009-02-03 03:54:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void VIEW3D_OT_view_pan(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
|
|
|
|
ot->name= "View Pan";
|
2009-03-24 12:16:58 +00:00
|
|
|
ot->description = "Pan the view.";
|
2009-02-03 03:54:03 +00:00
|
|
|
ot->idname= "VIEW3D_OT_view_pan";
|
|
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
|
ot->exec= viewpan_exec;
|
|
|
|
|
ot->poll= ED_operator_view3d_active;
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2009-02-03 03:54:03 +00:00
|
|
|
/* flags */
|
2.5
Operator goodies!
--- Macro operators
Operators now can consist of multiple operators. Such a macro operator
is identical and behaves identical to other opererators. Macros can
also be constructed of macros even! Currently only hardcoded macros are
implemented, this to solve combined operators such as 'add duplicate' or
'extrude' (both want a transform appended).
Usage is simple:
- WM_operatortype_append_macro() : add new operatortype, name, flags
- WM_operatortype_macro_define() : add existing operator to macro
(Note: macro_define will also allow properties to be set, doesnt work
right now)
On converting the macro wmOperatorType to a real operator, it makes a
list of all operators, and the standard macro callbacks (exec, invoke,
modal, poll) just will use all.
Important note; switching to a modal operator only works as last in the
chain now!
Macros implemented for duplicate, extrude and rip. Tool menu works fine
for it, also the redo hotkey F4 works properly.
--- Operator redo fix
The operators use the undo system to switch back, but this could give
errors if other actions added undo pushes (buttons, outliner). Now the
redo for operator searches back for the correct undo level.
This fixes issues with many redos.
Note for brecht: removed the ED_undo_push for buttons... it was called
on *every* button now, which is probably too much? For example, using
the 'toolbar' redo also caused this...
2009-07-29 17:56:38 +00:00
|
|
|
ot->flag= 0;
|
2009-02-03 03:54:03 +00:00
|
|
|
RNA_def_enum(ot->srna, "type", prop_view_pan_items, 0, "Pan", "Direction of View Pan");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int viewpersportho_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
|
|
|
|
ARegion *ar= CTX_wm_region(C);
|
2009-07-09 02:45:48 +00:00
|
|
|
RegionView3D *rv3d= CTX_wm_region_view3d(C);
|
|
|
|
|
|
2009-02-03 03:54:03 +00:00
|
|
|
if(rv3d->viewlock==0) {
|
2009-10-27 02:54:25 +00:00
|
|
|
if(rv3d->persp!=RV3D_ORTHO)
|
|
|
|
|
rv3d->persp=RV3D_ORTHO;
|
|
|
|
|
else rv3d->persp=RV3D_PERSP;
|
2009-02-03 03:54:03 +00:00
|
|
|
ED_region_tag_redraw(ar);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2009-02-03 03:54:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void VIEW3D_OT_view_persportho(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
2009-09-20 05:05:16 +00:00
|
|
|
ot->name= "View Persp/Ortho";
|
2009-03-24 12:16:58 +00:00
|
|
|
ot->description = "Switch the current view from perspective/orthographic.";
|
2009-02-03 03:54:03 +00:00
|
|
|
ot->idname= "VIEW3D_OT_view_persportho";
|
|
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
|
ot->exec= viewpersportho_exec;
|
|
|
|
|
ot->poll= ED_operator_view3d_active;
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2009-02-03 03:54:03 +00:00
|
|
|
/* flags */
|
2.5
Operator goodies!
--- Macro operators
Operators now can consist of multiple operators. Such a macro operator
is identical and behaves identical to other opererators. Macros can
also be constructed of macros even! Currently only hardcoded macros are
implemented, this to solve combined operators such as 'add duplicate' or
'extrude' (both want a transform appended).
Usage is simple:
- WM_operatortype_append_macro() : add new operatortype, name, flags
- WM_operatortype_macro_define() : add existing operator to macro
(Note: macro_define will also allow properties to be set, doesnt work
right now)
On converting the macro wmOperatorType to a real operator, it makes a
list of all operators, and the standard macro callbacks (exec, invoke,
modal, poll) just will use all.
Important note; switching to a modal operator only works as last in the
chain now!
Macros implemented for duplicate, extrude and rip. Tool menu works fine
for it, also the redo hotkey F4 works properly.
--- Operator redo fix
The operators use the undo system to switch back, but this could give
errors if other actions added undo pushes (buttons, outliner). Now the
redo for operator searches back for the correct undo level.
This fixes issues with many redos.
Note for brecht: removed the ED_undo_push for buttons... it was called
on *every* button now, which is probably too much? For example, using
the 'toolbar' redo also caused this...
2009-07-29 17:56:38 +00:00
|
|
|
ot->flag= 0;
|
2009-02-03 03:54:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-12-21 12:43:34 +00:00
|
|
|
/* ********************* set clipping operator ****************** */
|
|
|
|
|
|
2009-11-21 16:44:05 +00:00
|
|
|
static void calc_clipping_plane(float clip[6][4], BoundBox *clipbb)
|
|
|
|
|
{
|
|
|
|
|
int val;
|
|
|
|
|
|
|
|
|
|
for(val=0; val<4; val++) {
|
|
|
|
|
|
|
|
|
|
normal_tri_v3( clip[val],clipbb->vec[val], clipbb->vec[val==3?0:val+1], clipbb->vec[val+4]);
|
|
|
|
|
|
|
|
|
|
clip[val][3]=
|
|
|
|
|
- clip[val][0]*clipbb->vec[val][0]
|
|
|
|
|
- clip[val][1]*clipbb->vec[val][1]
|
|
|
|
|
- clip[val][2]*clipbb->vec[val][2];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void calc_local_clipping(float clip_local[][4], BoundBox *clipbb, float mat[][4])
|
|
|
|
|
{
|
|
|
|
|
BoundBox clipbb_local;
|
|
|
|
|
float imat[4][4];
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
invert_m4_m4(imat, mat);
|
|
|
|
|
|
|
|
|
|
for(i=0; i<8; i++) {
|
|
|
|
|
mul_v3_m4v3(clipbb_local.vec[i], imat, clipbb->vec[i]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
calc_clipping_plane(clip_local, &clipbb_local);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ED_view3d_local_clipping(RegionView3D *rv3d, float mat[][4])
|
|
|
|
|
{
|
|
|
|
|
if(rv3d->rflag & RV3D_CLIPPING)
|
|
|
|
|
calc_local_clipping(rv3d->clip_local, rv3d->clipbb, mat);
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-21 12:43:34 +00:00
|
|
|
static int view3d_clipping_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
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= CTX_wm_region_view3d(C);
|
2008-12-21 12:43:34 +00:00
|
|
|
rcti rect;
|
|
|
|
|
double mvmatrix[16];
|
|
|
|
|
double projmatrix[16];
|
|
|
|
|
double xs, ys, p[3];
|
|
|
|
|
GLint viewport[4];
|
|
|
|
|
short val;
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-21 12:43:34 +00:00
|
|
|
rect.xmin= RNA_int_get(op->ptr, "xmin");
|
|
|
|
|
rect.ymin= RNA_int_get(op->ptr, "ymin");
|
|
|
|
|
rect.xmax= RNA_int_get(op->ptr, "xmax");
|
|
|
|
|
rect.ymax= RNA_int_get(op->ptr, "ymax");
|
2008-12-26 10:31:44 +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
|
|
|
rv3d->rflag |= RV3D_CLIPPING;
|
|
|
|
|
rv3d->clipbb= MEM_callocN(sizeof(BoundBox), "clipbb");
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-21 12:43:34 +00:00
|
|
|
/* note; otherwise opengl won't work */
|
|
|
|
|
view3d_operator_needs_opengl(C);
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-21 12:43:34 +00:00
|
|
|
/* Get the matrices needed for gluUnProject */
|
|
|
|
|
glGetIntegerv(GL_VIEWPORT, viewport);
|
|
|
|
|
glGetDoublev(GL_MODELVIEW_MATRIX, mvmatrix);
|
|
|
|
|
glGetDoublev(GL_PROJECTION_MATRIX, projmatrix);
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-21 12:43:34 +00:00
|
|
|
/* near zero floating point values can give issues with gluUnProject
|
|
|
|
|
in side view on some implementations */
|
|
|
|
|
if(fabs(mvmatrix[0]) < 1e-6) mvmatrix[0]= 0.0;
|
|
|
|
|
if(fabs(mvmatrix[5]) < 1e-6) mvmatrix[5]= 0.0;
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-21 12:43:34 +00:00
|
|
|
/* Set up viewport so that gluUnProject will give correct values */
|
|
|
|
|
viewport[0] = 0;
|
|
|
|
|
viewport[1] = 0;
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-21 12:43:34 +00:00
|
|
|
/* four clipping planes and bounding volume */
|
|
|
|
|
/* first do the bounding volume */
|
|
|
|
|
for(val=0; val<4; val++) {
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-21 12:43:34 +00:00
|
|
|
xs= (val==0||val==3)?rect.xmin:rect.xmax;
|
|
|
|
|
ys= (val==0||val==1)?rect.ymin:rect.ymax;
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-21 12:43:34 +00:00
|
|
|
gluUnProject(xs, ys, 0.0, mvmatrix, projmatrix, viewport, &p[0], &p[1], &p[2]);
|
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
|
|
|
VECCOPY(rv3d->clipbb->vec[val], p);
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-21 12:43:34 +00:00
|
|
|
gluUnProject(xs, ys, 1.0, mvmatrix, projmatrix, viewport, &p[0], &p[1], &p[2]);
|
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
|
|
|
VECCOPY(rv3d->clipbb->vec[4+val], p);
|
2008-12-21 12:43:34 +00:00
|
|
|
}
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-21 12:43:34 +00:00
|
|
|
/* then plane equations */
|
2009-11-21 16:44:05 +00:00
|
|
|
calc_clipping_plane(rv3d->clip, rv3d->clipbb);
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-21 12:43:34 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int view3d_clipping_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
|
|
|
|
{
|
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= CTX_wm_region_view3d(C);
|
|
|
|
|
ARegion *ar= CTX_wm_region(C);
|
|
|
|
|
|
|
|
|
|
if(rv3d->rflag & RV3D_CLIPPING) {
|
|
|
|
|
rv3d->rflag &= ~RV3D_CLIPPING;
|
|
|
|
|
ED_region_tag_redraw(ar);
|
|
|
|
|
if(rv3d->clipbb) MEM_freeN(rv3d->clipbb);
|
|
|
|
|
rv3d->clipbb= NULL;
|
2008-12-21 12:43:34 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return WM_border_select_invoke(C, op, event);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* toggles */
|
2009-07-09 08:39:58 +00:00
|
|
|
void VIEW3D_OT_clip_border(wmOperatorType *ot)
|
2008-12-21 12:43:34 +00:00
|
|
|
{
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-21 12:43:34 +00:00
|
|
|
/* identifiers */
|
2009-02-03 03:54:03 +00:00
|
|
|
ot->name= "Clipping Border";
|
2009-03-23 03:14:56 +00:00
|
|
|
ot->description = "Set the view clipping border.";
|
2009-07-09 08:39:58 +00:00
|
|
|
ot->idname= "VIEW3D_OT_clip_border";
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-21 12:43:34 +00:00
|
|
|
/* api callbacks */
|
|
|
|
|
ot->invoke= view3d_clipping_invoke;
|
|
|
|
|
ot->exec= view3d_clipping_exec;
|
|
|
|
|
ot->modal= WM_border_select_modal;
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-26 19:07:31 +00:00
|
|
|
ot->poll= ED_operator_view3d_active;
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2009-01-31 19:40:40 +00:00
|
|
|
/* flags */
|
2.5
Operator goodies!
--- Macro operators
Operators now can consist of multiple operators. Such a macro operator
is identical and behaves identical to other opererators. Macros can
also be constructed of macros even! Currently only hardcoded macros are
implemented, this to solve combined operators such as 'add duplicate' or
'extrude' (both want a transform appended).
Usage is simple:
- WM_operatortype_append_macro() : add new operatortype, name, flags
- WM_operatortype_macro_define() : add existing operator to macro
(Note: macro_define will also allow properties to be set, doesnt work
right now)
On converting the macro wmOperatorType to a real operator, it makes a
list of all operators, and the standard macro callbacks (exec, invoke,
modal, poll) just will use all.
Important note; switching to a modal operator only works as last in the
chain now!
Macros implemented for duplicate, extrude and rip. Tool menu works fine
for it, also the redo hotkey F4 works properly.
--- Operator redo fix
The operators use the undo system to switch back, but this could give
errors if other actions added undo pushes (buttons, outliner). Now the
redo for operator searches back for the correct undo level.
This fixes issues with many redos.
Note for brecht: removed the ED_undo_push for buttons... it was called
on *every* button now, which is probably too much? For example, using
the 'toolbar' redo also caused this...
2009-07-29 17:56:38 +00:00
|
|
|
ot->flag= 0;
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2008-12-21 12:43:34 +00:00
|
|
|
/* rna */
|
2009-01-16 23:53:11 +00:00
|
|
|
RNA_def_int(ot->srna, "xmin", 0, INT_MIN, INT_MAX, "X Min", "", INT_MIN, INT_MAX);
|
|
|
|
|
RNA_def_int(ot->srna, "xmax", 0, INT_MIN, INT_MAX, "X Max", "", INT_MIN, INT_MAX);
|
|
|
|
|
RNA_def_int(ot->srna, "ymin", 0, INT_MIN, INT_MAX, "Y Min", "", INT_MIN, INT_MAX);
|
|
|
|
|
RNA_def_int(ot->srna, "ymax", 0, INT_MIN, INT_MAX, "Y Max", "", INT_MIN, INT_MAX);
|
2008-12-21 12:43:34 +00:00
|
|
|
}
|
|
|
|
|
|
2008-12-26 19:07:31 +00:00
|
|
|
/* ***************** 3d cursor cursor op ******************* */
|
|
|
|
|
|
|
|
|
|
/* mx my in region coords */
|
|
|
|
|
static int set_3dcursor_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
|
|
|
|
{
|
|
|
|
|
Scene *scene= CTX_data_scene(C);
|
|
|
|
|
ARegion *ar= CTX_wm_region(C);
|
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
|
|
|
View3D *v3d = CTX_wm_view3d(C);
|
|
|
|
|
RegionView3D *rv3d= CTX_wm_region_view3d(C);
|
2008-12-26 19:07:31 +00:00
|
|
|
float dx, dy, fz, *fp = NULL, dvec[3], oldcurs[3];
|
2009-01-02 19:10:35 +00:00
|
|
|
short mx, my, mval[2];
|
|
|
|
|
// short ctrl= 0; // XXX
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2008-12-26 19:07:31 +00:00
|
|
|
fp= give_cursor(scene, v3d);
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2009-01-02 19:10:35 +00:00
|
|
|
// if(obedit && ctrl) lr_click= 1;
|
2008-12-26 19:07:31 +00:00
|
|
|
VECCOPY(oldcurs, fp);
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2008-12-26 19:07:31 +00:00
|
|
|
mx= event->x - ar->winrct.xmin;
|
|
|
|
|
my= event->y - ar->winrct.ymin;
|
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_noclip(ar, fp, mval);
|
2009-07-09 02:45:48 +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
|
|
|
initgrabz(rv3d, fp[0], fp[1], fp[2]);
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2008-12-26 19:07:31 +00:00
|
|
|
if(mval[0]!=IS_CLIPPED) {
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2009-01-20 18:31:11 +00:00
|
|
|
window_to_3d_delta(ar, dvec, mval[0]-mx, mval[1]-my);
|
2009-11-10 20:43:45 +00:00
|
|
|
sub_v3_v3v3(fp, fp, dvec);
|
2008-12-26 19:07:31 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2009-07-09 02:45:48 +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
|
|
|
dx= ((float)(mx-(ar->winx/2)))*rv3d->zfac/(ar->winx/2);
|
|
|
|
|
dy= ((float)(my-(ar->winy/2)))*rv3d->zfac/(ar->winy/2);
|
2009-07-09 02:45:48 +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
|
|
|
fz= rv3d->persmat[0][3]*fp[0]+ rv3d->persmat[1][3]*fp[1]+ rv3d->persmat[2][3]*fp[2]+ rv3d->persmat[3][3];
|
|
|
|
|
fz= fz/rv3d->zfac;
|
2009-07-09 02:45:48 +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
|
|
|
fp[0]= (rv3d->persinv[0][0]*dx + rv3d->persinv[1][0]*dy+ rv3d->persinv[2][0]*fz)-rv3d->ofs[0];
|
|
|
|
|
fp[1]= (rv3d->persinv[0][1]*dx + rv3d->persinv[1][1]*dy+ rv3d->persinv[2][1]*fz)-rv3d->ofs[1];
|
|
|
|
|
fp[2]= (rv3d->persinv[0][2]*dx + rv3d->persinv[1][2]*dy+ rv3d->persinv[2][2]*fz)-rv3d->ofs[2];
|
2008-12-26 19:07:31 +00:00
|
|
|
}
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2009-01-02 19:10:35 +00:00
|
|
|
// if(lr_click) {
|
|
|
|
|
// XXX if(obedit->type==OB_MESH) add_click_mesh();
|
|
|
|
|
// else if ELEM(obedit->type, OB_CURVE, OB_SURF) addvert_Nurb(0);
|
|
|
|
|
// else if (obedit->type==OB_ARMATURE) addvert_armature();
|
|
|
|
|
// VECCOPY(fp, oldcurs);
|
|
|
|
|
// }
|
2008-12-26 19:07:31 +00:00
|
|
|
// XXX notifier for scene */
|
2009-02-10 15:38:00 +00:00
|
|
|
ED_area_tag_redraw(CTX_wm_area(C));
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2009-09-18 15:48:49 +00:00
|
|
|
return OPERATOR_FINISHED;
|
2008-12-26 19:07:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void VIEW3D_OT_cursor3d(wmOperatorType *ot)
|
|
|
|
|
{
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2008-12-26 19:07:31 +00:00
|
|
|
/* identifiers */
|
|
|
|
|
ot->name= "Set 3D Cursor";
|
2009-03-23 03:14:56 +00:00
|
|
|
ot->description = "Set the location of the 3D cursor.";
|
2008-12-26 19:07:31 +00:00
|
|
|
ot->idname= "VIEW3D_OT_cursor3d";
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2008-12-26 19:07:31 +00:00
|
|
|
/* api callbacks */
|
|
|
|
|
ot->invoke= set_3dcursor_invoke;
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2008-12-26 19:07:31 +00:00
|
|
|
ot->poll= ED_operator_view3d_active;
|
2009-11-02 16:07:49 +00:00
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
|
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
|
|
|
|
|
2008-12-26 19:07:31 +00:00
|
|
|
/* rna later */
|
|
|
|
|
|
|
|
|
|
}
|
2008-12-21 12:43:34 +00:00
|
|
|
|
2009-07-08 15:01:28 +00:00
|
|
|
/* ***************** manipulator op ******************* */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int manipulator_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
|
|
|
|
{
|
|
|
|
|
View3D *v3d = CTX_wm_view3d(C);
|
|
|
|
|
|
|
|
|
|
if(!(v3d->twflag & V3D_USE_MANIPULATOR)) return OPERATOR_PASS_THROUGH;
|
|
|
|
|
if(!(v3d->twflag & V3D_DRAW_MANIPULATOR)) return OPERATOR_PASS_THROUGH;
|
|
|
|
|
|
2009-11-12 19:42:53 +00:00
|
|
|
/* only no modifier or shift */
|
|
|
|
|
if(event->keymodifier != 0 && event->keymodifier != KM_SHIFT) return OPERATOR_PASS_THROUGH;
|
|
|
|
|
|
2009-07-08 15:01:28 +00:00
|
|
|
/* note; otherwise opengl won't work */
|
|
|
|
|
view3d_operator_needs_opengl(C);
|
2009-07-09 02:45:48 +00:00
|
|
|
|
|
|
|
|
if(0==BIF_do_manipulator(C, event, op))
|
2009-07-08 15:01:28 +00:00
|
|
|
return OPERATOR_PASS_THROUGH;
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2009-07-08 15:01:28 +00:00
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void VIEW3D_OT_manipulator(wmOperatorType *ot)
|
|
|
|
|
{
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2009-07-08 15:01:28 +00:00
|
|
|
/* identifiers */
|
|
|
|
|
ot->name= "3D Manipulator";
|
2009-09-07 04:52:42 +00:00
|
|
|
ot->description = "Manipulate selected item by axis.";
|
2009-07-08 15:01:28 +00:00
|
|
|
ot->idname= "VIEW3D_OT_manipulator";
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2009-07-08 15:01:28 +00:00
|
|
|
/* api callbacks */
|
|
|
|
|
ot->invoke= manipulator_invoke;
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2009-07-08 15:01:28 +00:00
|
|
|
ot->poll= ED_operator_view3d_active;
|
2009-07-09 02:45:48 +00:00
|
|
|
|
2009-07-08 15:01:28 +00:00
|
|
|
/* rna later */
|
2009-07-09 02:45:48 +00:00
|
|
|
RNA_def_boolean_vector(ot->srna, "constraint_axis", 3, NULL, "Constraint Axis", "");
|
2009-07-08 15:01:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-12-20 11:33:16 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
/* ************************* below the line! *********************** */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* XXX todo Zooms in on a border drawn by the user */
|
|
|
|
|
int view_autodist(Scene *scene, ARegion *ar, View3D *v3d, short *mval, float mouse_worldloc[3] ) //, float *autodist )
|
|
|
|
|
{
|
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;
|
|
|
|
|
bglMats mats; /* ZBuffer depth vars */
|
2008-12-19 17:14:02 +00:00
|
|
|
rcti rect;
|
|
|
|
|
float depth, depth_close= MAXFLOAT;
|
|
|
|
|
int had_depth = 0;
|
|
|
|
|
double cent[2], p[3];
|
|
|
|
|
int xs, ys;
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
rect.xmax = mval[0] + 4;
|
|
|
|
|
rect.ymax = mval[1] + 4;
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
rect.xmin = mval[0] - 4;
|
|
|
|
|
rect.ymin = mval[1] - 4;
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
/* Get Z Depths, needed for perspective, nice for ortho */
|
|
|
|
|
bgl_get_mats(&mats);
|
|
|
|
|
draw_depth(scene, ar, v3d, NULL);
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
/* force updating */
|
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) {
|
2008-12-19 17:14:02 +00:00
|
|
|
had_depth = 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
|
|
|
rv3d->depths->damaged = 1;
|
2008-12-19 17:14:02 +00:00
|
|
|
}
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
view3d_update_depths(ar, v3d);
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
/* Constrain rect to depth bounds */
|
|
|
|
|
if (rect.xmin < 0) rect.xmin = 0;
|
|
|
|
|
if (rect.ymin < 0) rect.ymin = 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
|
|
|
if (rect.xmax >= rv3d->depths->w) rect.xmax = rv3d->depths->w-1;
|
|
|
|
|
if (rect.ymax >= rv3d->depths->h) rect.ymax = rv3d->depths->h-1;
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
/* Find the closest Z pixel */
|
|
|
|
|
for (xs=rect.xmin; xs < rect.xmax; xs++) {
|
|
|
|
|
for (ys=rect.ymin; ys < rect.ymax; ys++) {
|
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
|
|
|
depth= rv3d->depths->depths[ys*rv3d->depths->w+xs];
|
|
|
|
|
if(depth < rv3d->depths->depth_range[1] && depth > rv3d->depths->depth_range[0]) {
|
2008-12-19 17:14:02 +00:00
|
|
|
if (depth_close > depth) {
|
|
|
|
|
depth_close = depth;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
if (depth_close==MAXFLOAT)
|
|
|
|
|
return 0;
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
if (had_depth==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
|
|
|
MEM_freeN(rv3d->depths->depths);
|
|
|
|
|
rv3d->depths->depths = NULL;
|
2008-12-19 17:14:02 +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
|
|
|
rv3d->depths->damaged = 1;
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
cent[0] = (double)mval[0];
|
|
|
|
|
cent[1] = (double)mval[1];
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
if (!gluUnProject(cent[0], cent[1], depth_close, mats.modelview, mats.projection, (GLint *)mats.viewport, &p[0], &p[1], &p[2]))
|
|
|
|
|
return 0;
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
mouse_worldloc[0] = (float)p[0];
|
|
|
|
|
mouse_worldloc[1] = (float)p[1];
|
|
|
|
|
mouse_worldloc[2] = (float)p[2];
|
|
|
|
|
return 1;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-12-19 17:14:02 +00:00
|
|
|
|
|
|
|
|
/* ********************* NDOF ************************ */
|
|
|
|
|
/* note: this code is confusing and unclear... (ton) */
|
|
|
|
|
/* **************************************************** */
|
|
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
// ndof scaling will be moved to user setting.
|
|
|
|
|
// In the mean time this is just a place holder.
|
|
|
|
|
|
|
|
|
|
// Note: scaling in the plugin and ghostwinlay.c
|
|
|
|
|
// should be removed. With driver default setting,
|
|
|
|
|
// each axis returns approx. +-200 max deflection.
|
|
|
|
|
|
|
|
|
|
// The values I selected are based on the older
|
|
|
|
|
// polling i/f. With event i/f, the sensistivity
|
|
|
|
|
// can be increased for improved response from
|
|
|
|
|
// small deflections of the device input.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// lukep notes : i disagree on the range.
|
|
|
|
|
// the normal 3Dconnection driver give +/-400
|
|
|
|
|
// on defaut range in other applications
|
|
|
|
|
// and up to +/- 1000 if set to maximum
|
|
|
|
|
// because i remove the scaling by delta,
|
|
|
|
|
// which was a bad idea as it depend of the system
|
2008-12-26 10:31:44 +00:00
|
|
|
// speed and os, i changed the scaling values, but
|
2008-12-19 12:14:58 +00:00
|
|
|
// those are still not ok
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float ndof_axis_scale[6] = {
|
|
|
|
|
+0.01, // Tx
|
|
|
|
|
+0.01, // Tz
|
|
|
|
|
+0.01, // Ty
|
|
|
|
|
+0.0015, // Rx
|
|
|
|
|
+0.0015, // Rz
|
|
|
|
|
+0.0015 // Ry
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void filterNDOFvalues(float *sbval)
|
|
|
|
|
{
|
|
|
|
|
int i=0;
|
|
|
|
|
float max = 0.0;
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
for (i =0; i<6;i++)
|
|
|
|
|
if (fabs(sbval[i]) > max)
|
|
|
|
|
max = fabs(sbval[i]);
|
|
|
|
|
for (i =0; i<6;i++)
|
|
|
|
|
if (fabs(sbval[i]) != max )
|
|
|
|
|
sbval[i]=0.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
|
|
|
// statics for controlling rv3d->dist corrections.
|
|
|
|
|
// viewmoveNDOF zeros and adjusts rv3d->ofs.
|
2008-12-19 12:14:58 +00:00
|
|
|
// viewmove restores based on dz_flag state.
|
|
|
|
|
|
|
|
|
|
int dz_flag = 0;
|
|
|
|
|
float m_dist;
|
|
|
|
|
|
|
|
|
|
void viewmoveNDOFfly(ARegion *ar, View3D *v3d, int mode)
|
|
|
|
|
{
|
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
|
|
|
int i;
|
|
|
|
|
float phi;
|
|
|
|
|
float dval[7];
|
|
|
|
|
// static fval[6] for low pass filter; device input vector is dval[6]
|
|
|
|
|
static float fval[6];
|
|
|
|
|
float tvec[3],rvec[3];
|
|
|
|
|
float q1[4];
|
|
|
|
|
float mat[3][3];
|
|
|
|
|
float upvec[3];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------
|
|
|
|
|
* sometimes this routine is called from headerbuttons
|
|
|
|
|
* viewmove needs to refresh the screen
|
|
|
|
|
*/
|
|
|
|
|
// XXX areawinset(ar->win);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// fetch the current state of the ndof device
|
|
|
|
|
// XXX getndof(dval);
|
|
|
|
|
|
|
|
|
|
if (v3d->ndoffilter)
|
|
|
|
|
filterNDOFvalues(fval);
|
|
|
|
|
|
|
|
|
|
// Scale input values
|
|
|
|
|
|
|
|
|
|
// if(dval[6] == 0) return; // guard against divide by zero
|
|
|
|
|
|
|
|
|
|
for(i=0;i<6;i++) {
|
|
|
|
|
|
|
|
|
|
// user scaling
|
|
|
|
|
dval[i] = dval[i] * ndof_axis_scale[i];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// low pass filter with zero crossing reset
|
|
|
|
|
|
|
|
|
|
for(i=0;i<6;i++) {
|
|
|
|
|
if((dval[i] * fval[i]) >= 0)
|
|
|
|
|
dval[i] = (fval[i] * 15 + dval[i]) / 16;
|
|
|
|
|
else
|
|
|
|
|
fval[i] = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// force perspective mode. This is a hack and is
|
|
|
|
|
// incomplete. It doesn't actually effect the view
|
|
|
|
|
// until the first draw and doesn't update the menu
|
|
|
|
|
// to reflect persp mode.
|
|
|
|
|
|
2009-10-27 02:54:25 +00:00
|
|
|
rv3d->persp = RV3D_PERSP;
|
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
|
|
|
// Correct the distance jump if rv3d->dist != 0
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
// This is due to a side effect of the original
|
|
|
|
|
// mouse view rotation code. The rotation point is
|
|
|
|
|
// set a distance in front of the viewport to
|
|
|
|
|
// make rotating with the mouse look better.
|
|
|
|
|
// The distance effect is written at a low level
|
|
|
|
|
// in the view management instead of the mouse
|
|
|
|
|
// view function. This means that all other view
|
|
|
|
|
// movement devices must subtract this from their
|
|
|
|
|
// view transformations.
|
|
|
|
|
|
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->dist != 0.0) {
|
2008-12-19 12:14:58 +00:00
|
|
|
dz_flag = 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
|
|
|
m_dist = rv3d->dist;
|
2008-12-19 12:14:58 +00:00
|
|
|
upvec[0] = upvec[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
|
|
|
upvec[2] = rv3d->dist;
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_m3_m4(mat, rv3d->viewinv);
|
|
|
|
|
mul_m3_v3(mat, upvec);
|
|
|
|
|
sub_v3_v3v3(rv3d->ofs, rv3d->ofs, upvec);
|
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->dist = 0.0;
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Apply rotation
|
|
|
|
|
// Rotations feel relatively faster than translations only in fly mode, so
|
|
|
|
|
// we have no choice but to fix that here (not in the plugins)
|
|
|
|
|
rvec[0] = -0.5 * dval[3];
|
|
|
|
|
rvec[1] = -0.5 * dval[4];
|
|
|
|
|
rvec[2] = -0.5 * dval[5];
|
|
|
|
|
|
|
|
|
|
// rotate device x and y by view z
|
|
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_m3_m4(mat, rv3d->viewinv);
|
2008-12-19 12:14:58 +00:00
|
|
|
mat[2][2] = 0.0f;
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_m3_v3(mat, rvec);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
// rotate the view
|
|
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
phi = normalize_v3(rvec);
|
2008-12-19 12:14:58 +00:00
|
|
|
if(phi != 0) {
|
2009-11-10 20:43:45 +00:00
|
|
|
axis_angle_to_quat(q1,rvec,phi);
|
|
|
|
|
mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, q1);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Apply translation
|
|
|
|
|
|
|
|
|
|
tvec[0] = dval[0];
|
|
|
|
|
tvec[1] = dval[1];
|
|
|
|
|
tvec[2] = -dval[2];
|
|
|
|
|
|
|
|
|
|
// the next three lines rotate the x and y translation coordinates
|
|
|
|
|
// by the current z axis angle
|
|
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_m3_m4(mat, rv3d->viewinv);
|
2008-12-19 12:14:58 +00:00
|
|
|
mat[2][2] = 0.0f;
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_m3_v3(mat, tvec);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
// translate the view
|
|
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
sub_v3_v3v3(rv3d->ofs, rv3d->ofs, tvec);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------
|
|
|
|
|
* refresh the screen XXX
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
// update render preview window
|
|
|
|
|
|
|
|
|
|
// XXX BIF_view3d_previewrender_signal(ar, PR_DBASE|PR_DISPRECT);
|
|
|
|
|
}
|
|
|
|
|
|
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 viewmoveNDOF(Scene *scene, ARegion *ar, View3D *v3d, int mode)
|
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;
|
|
|
|
|
float fval[7];
|
|
|
|
|
float dvec[3];
|
|
|
|
|
float sbadjust = 1.0f;
|
|
|
|
|
float len;
|
2008-12-19 12:14:58 +00:00
|
|
|
short use_sel = 0;
|
|
|
|
|
Object *ob = OBACT;
|
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
|
|
|
float m[3][3];
|
|
|
|
|
float m_inv[3][3];
|
|
|
|
|
float xvec[3] = {1,0,0};
|
|
|
|
|
float yvec[3] = {0,-1,0};
|
|
|
|
|
float zvec[3] = {0,0,1};
|
2008-12-19 12:14:58 +00:00
|
|
|
float phi, si;
|
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
|
|
|
float q1[4];
|
|
|
|
|
float obofs[3];
|
|
|
|
|
float reverse;
|
|
|
|
|
//float diff[4];
|
|
|
|
|
float d, curareaX, curareaY;
|
|
|
|
|
float mat[3][3];
|
|
|
|
|
float upvec[3];
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
/* Sensitivity will control how fast the view rotates. The value was
|
|
|
|
|
* obtained experimentally by tweaking until the author didn't get dizzy watching.
|
2008-12-26 10:31:44 +00:00
|
|
|
* Perhaps this should be a configurable user parameter.
|
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
|
|
|
float psens = 0.005f * (float) U.ndof_pan; /* pan sensitivity */
|
|
|
|
|
float rsens = 0.005f * (float) U.ndof_rotate; /* rotate sensitivity */
|
|
|
|
|
float zsens = 0.3f; /* zoom sensitivity */
|
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
|
|
|
const float minZoom = -30.0f;
|
|
|
|
|
const float maxZoom = 300.0f;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
//reset view type
|
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->view = 0;
|
2008-12-19 12:14:58 +00:00
|
|
|
//printf("passing here \n");
|
|
|
|
|
//
|
2009-08-16 03:24:23 +00:00
|
|
|
if (scene->obedit==NULL && ob && !(ob->mode & OB_MODE_POSE)) {
|
2008-12-19 12:14:58 +00:00
|
|
|
use_sel = 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
|
|
|
if((dz_flag)||rv3d->dist==0) {
|
2008-12-19 12:14:58 +00:00
|
|
|
dz_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
|
|
|
rv3d->dist = m_dist;
|
2008-12-19 12:14:58 +00:00
|
|
|
upvec[0] = upvec[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
|
|
|
upvec[2] = rv3d->dist;
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_m3_m4(mat, rv3d->viewinv);
|
|
|
|
|
mul_m3_v3(mat, upvec);
|
|
|
|
|
add_v3_v3v3(rv3d->ofs, rv3d->ofs, upvec);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------
|
|
|
|
|
* sometimes this routine is called from headerbuttons
|
|
|
|
|
* viewmove needs to refresh the screen
|
|
|
|
|
*/
|
|
|
|
|
// XXX areawinset(curarea->win);
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------
|
|
|
|
|
* record how much time has passed. clamp at 10 Hz
|
2008-12-26 10:31:44 +00:00
|
|
|
* pretend the previous frame occured at the clamped time
|
2008-12-19 12:14:58 +00:00
|
|
|
*/
|
|
|
|
|
// now = PIL_check_seconds_timer();
|
|
|
|
|
// frametime = (now - prevTime);
|
|
|
|
|
// if (frametime > 0.1f){ /* if more than 1/10s */
|
|
|
|
|
// frametime = 1.0f/60.0; /* clamp at 1/60s so no jumps when starting to move */
|
|
|
|
|
// }
|
|
|
|
|
// prevTime = now;
|
|
|
|
|
// sbadjust *= 60 * frametime; /* normalize ndof device adjustments to 100Hz for framerate independence */
|
|
|
|
|
|
|
|
|
|
/* fetch the current state of the ndof device & enforce dominant mode if selected */
|
|
|
|
|
// XXX getndof(fval);
|
|
|
|
|
if (v3d->ndoffilter)
|
|
|
|
|
filterNDOFvalues(fval);
|
2008-12-26 10:31:44 +00:00
|
|
|
|
|
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
// put scaling back here, was previously in ghostwinlay
|
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
|
|
|
fval[0] = fval[0] * (1.0f/600.0f);
|
|
|
|
|
fval[1] = fval[1] * (1.0f/600.0f);
|
|
|
|
|
fval[2] = fval[2] * (1.0f/1100.0f);
|
|
|
|
|
fval[3] = fval[3] * 0.00005f;
|
|
|
|
|
fval[4] =-fval[4] * 0.00005f;
|
|
|
|
|
fval[5] = fval[5] * 0.00005f;
|
|
|
|
|
fval[6] = fval[6] / 1000000.0f;
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
// scale more if not in perspective mode
|
2009-10-27 02:54:25 +00:00
|
|
|
if (rv3d->persp == RV3D_ORTHO) {
|
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
|
|
|
fval[0] = fval[0] * 0.05f;
|
|
|
|
|
fval[1] = fval[1] * 0.05f;
|
|
|
|
|
fval[2] = fval[2] * 0.05f;
|
|
|
|
|
fval[3] = fval[3] * 0.9f;
|
|
|
|
|
fval[4] = fval[4] * 0.9f;
|
|
|
|
|
fval[5] = fval[5] * 0.9f;
|
|
|
|
|
zsens *= 8;
|
|
|
|
|
}
|
2008-12-26 10:31:44 +00:00
|
|
|
|
2008-12-19 12:14:58 +00:00
|
|
|
/* set object offset */
|
|
|
|
|
if (ob) {
|
|
|
|
|
obofs[0] = -ob->obmat[3][0];
|
|
|
|
|
obofs[1] = -ob->obmat[3][1];
|
|
|
|
|
obofs[2] = -ob->obmat[3][2];
|
|
|
|
|
}
|
|
|
|
|
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
|
|
|
VECCOPY(obofs, rv3d->ofs);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* calc an adjustment based on distance from camera
|
|
|
|
|
disabled per patch 14402 */
|
|
|
|
|
d = 1.0f;
|
|
|
|
|
|
|
|
|
|
/* if (ob) {
|
2009-11-10 20:43:45 +00:00
|
|
|
sub_v3_v3v3(diff, obofs, rv3d->ofs);
|
|
|
|
|
d = len_v3(diff);
|
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
|
|
|
reverse = (rv3d->persmat[2][1] < 0.0f) ? -1.0f : 1.0f;
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
/*----------------------------------------------------
|
2008-12-26 10:31:44 +00:00
|
|
|
* ndof device pan
|
2008-12-19 12:14:58 +00:00
|
|
|
*/
|
|
|
|
|
psens *= 1.0f + d;
|
|
|
|
|
curareaX = sbadjust * psens * fval[0];
|
|
|
|
|
curareaY = sbadjust * psens * fval[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
|
|
|
dvec[0] = curareaX * rv3d->persinv[0][0] + curareaY * rv3d->persinv[1][0];
|
|
|
|
|
dvec[1] = curareaX * rv3d->persinv[0][1] + curareaY * rv3d->persinv[1][1];
|
|
|
|
|
dvec[2] = curareaX * rv3d->persinv[0][2] + curareaY * rv3d->persinv[1][2];
|
2009-11-10 20:43:45 +00:00
|
|
|
add_v3_v3v3(rv3d->ofs, rv3d->ofs, dvec);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
/*----------------------------------------------------
|
2008-12-26 10:31:44 +00:00
|
|
|
* ndof device dolly
|
2008-12-19 12:14:58 +00:00
|
|
|
*/
|
|
|
|
|
len = zsens * sbadjust * fval[2];
|
|
|
|
|
|
2009-10-27 02:54:25 +00:00
|
|
|
if (rv3d->persp==RV3D_CAMOB) {
|
|
|
|
|
if(rv3d->persp==RV3D_CAMOB) { /* This is stupid, please fix - TODO */
|
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+= 10.0f * -len;
|
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
|
|
|
if (rv3d->camzoom < minZoom) rv3d->camzoom = minZoom;
|
|
|
|
|
else if (rv3d->camzoom > maxZoom) rv3d->camzoom = maxZoom;
|
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
|
|
|
else if ((rv3d->dist> 0.001*v3d->grid) && (rv3d->dist<10.0*v3d->far)) {
|
|
|
|
|
rv3d->dist*=(1.0 + len);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------
|
|
|
|
|
* ndof device turntable
|
|
|
|
|
* derived from the turntable code in viewmove
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* Get the 3x3 matrix and its inverse from the quaternion */
|
2009-11-10 20:43:45 +00:00
|
|
|
quat_to_mat3( m,rv3d->viewquat);
|
|
|
|
|
invert_m3_m3(m_inv,m);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
/* Determine the direction of the x vector (for rotating up and down) */
|
|
|
|
|
/* This can likely be compuated directly from the quaternion. */
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_m3_v3(m_inv,xvec);
|
|
|
|
|
mul_m3_v3(m_inv,yvec);
|
|
|
|
|
mul_m3_v3(m_inv,zvec);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
/* Perform the up/down rotation */
|
|
|
|
|
phi = sbadjust * rsens * /*0.5f * */ fval[3]; /* spin vertically half as fast as horizontally */
|
|
|
|
|
si = sin(phi);
|
|
|
|
|
q1[0] = cos(phi);
|
|
|
|
|
q1[1] = si * xvec[0];
|
|
|
|
|
q1[2] = si * xvec[1];
|
|
|
|
|
q1[3] = si * xvec[2];
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, q1);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
if (use_sel) {
|
2009-11-10 20:43:45 +00:00
|
|
|
conjugate_qt(q1); /* conj == inv for unit quat */
|
|
|
|
|
sub_v3_v3v3(rv3d->ofs, rv3d->ofs, obofs);
|
|
|
|
|
mul_qt_v3(q1, rv3d->ofs);
|
|
|
|
|
add_v3_v3v3(rv3d->ofs, rv3d->ofs, obofs);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Perform the orbital rotation */
|
2008-12-26 10:31:44 +00:00
|
|
|
/* Perform the orbital rotation
|
2008-12-19 12:14:58 +00:00
|
|
|
If the seen Up axis is parallel to the zoom axis, rotation should be
|
2008-12-26 10:31:44 +00:00
|
|
|
achieved with a pure Roll motion (no Spin) on the device. When you start
|
|
|
|
|
to tilt, moving from Top to Side view, Spinning will increasingly become
|
|
|
|
|
more relevant while the Roll component will decrease. When a full
|
2008-12-19 12:14:58 +00:00
|
|
|
Side view is reached, rotations around the world's Up axis are achieved
|
|
|
|
|
with a pure Spin-only motion. In other words the control of the spinning
|
|
|
|
|
around the world's Up axis should move from the device's Spin axis to the
|
2008-12-26 10:31:44 +00:00
|
|
|
device's Roll axis depending on the orientation of the world's Up axis
|
2008-12-19 12:14:58 +00:00
|
|
|
relative to the screen. */
|
|
|
|
|
//phi = sbadjust * rsens * reverse * fval[4]; /* spin the knob, y axis */
|
|
|
|
|
phi = sbadjust * rsens * (yvec[2] * fval[4] + zvec[2] * fval[5]);
|
|
|
|
|
q1[0] = cos(phi);
|
|
|
|
|
q1[1] = q1[2] = 0.0;
|
|
|
|
|
q1[3] = sin(phi);
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, q1);
|
2008-12-19 12:14:58 +00:00
|
|
|
|
|
|
|
|
if (use_sel) {
|
2009-11-10 20:43:45 +00:00
|
|
|
conjugate_qt(q1);
|
|
|
|
|
sub_v3_v3v3(rv3d->ofs, rv3d->ofs, obofs);
|
|
|
|
|
mul_qt_v3(q1, rv3d->ofs);
|
|
|
|
|
add_v3_v3v3(rv3d->ofs, rv3d->ofs, obofs);
|
2008-12-19 12:14:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------
|
|
|
|
|
* refresh the screen
|
|
|
|
|
*/
|
|
|
|
|
// XXX scrarea_do_windraw(curarea);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|