Blender V2.61 - r43446
Classes | Defines | Functions

view3d_view.c File Reference

#include "DNA_camera_types.h"
#include "DNA_scene_types.h"
#include "DNA_object_types.h"
#include "DNA_lamp_types.h"
#include "MEM_guardedalloc.h"
#include "BLI_math.h"
#include "BLI_rect.h"
#include "BLI_listbase.h"
#include "BLI_utildefines.h"
#include "BKE_anim.h"
#include "BKE_action.h"
#include "BKE_camera.h"
#include "BKE_context.h"
#include "BKE_depsgraph.h"
#include "BKE_object.h"
#include "BKE_global.h"
#include "BKE_main.h"
#include "BKE_report.h"
#include "BKE_scene.h"
#include "BKE_screen.h"
#include "BIF_gl.h"
#include "BIF_glutil.h"
#include "GPU_draw.h"
#include "WM_api.h"
#include "WM_types.h"
#include "ED_screen.h"
#include "ED_armature.h"
#include "view3d_intern.h"

Go to the source code of this file.

Classes

struct  SmoothViewStore

Defines

#define QUATSET(a, b, c, d, e)   a[0]=b; a[1]=c; a[2]=d; a[3]=e;

Functions

void view3d_operator_needs_opengl (const bContext *C)
void view3d_region_operator_needs_opengl (wmWindow *win, ARegion *ar)
float * give_cursor (Scene *scene, View3D *v3d)
void smooth_view (bContext *C, View3D *v3d, ARegion *ar, Object *oldcamera, Object *camera, float *ofs, float *quat, float *dist, float *lens)
static int view3d_smoothview_invoke (bContext *C, wmOperator *UNUSED(op), wmEvent *event)
void VIEW3D_OT_smoothview (wmOperatorType *ot)
static int view3d_camera_to_view_exec (bContext *C, wmOperator *UNUSED(op))
static int view3d_camera_to_view_poll (bContext *C)
void VIEW3D_OT_camera_to_view (wmOperatorType *ot)
static int view3d_camera_to_view_selected_exec (bContext *C, wmOperator *UNUSED(op))
static int view3d_camera_to_view_selected_poll (bContext *C)
void VIEW3D_OT_camera_to_view_selected (wmOperatorType *ot)
static int view3d_setobjectascamera_exec (bContext *C, wmOperator *UNUSED(op))
int ED_operator_rv3d_user_region_poll (bContext *C)
void VIEW3D_OT_object_as_camera (wmOperatorType *ot)
void ED_view3d_calc_clipping (BoundBox *bb, float planes[4][4], bglMats *mats, const rcti *rect)
void ED_view3d_win_to_segment_clip (ARegion *ar, View3D *v3d, const float mval[2], float ray_start[3], float ray_end[3])
void ED_view3d_win_to_ray (ARegion *ar, View3D *v3d, const float mval[2], float ray_start[3], float ray_normal[3])
void ED_view3d_global_to_vector (RegionView3D *rv3d, const float coord[3], float vec[3])
int initgrabz (RegionView3D *rv3d, float x, float y, float z)
void ED_view3d_win_to_3d (ARegion *ar, const float depth_pt[3], const float mval[2], float out[3])
void ED_view3d_win_to_delta (ARegion *ar, const float mval[2], float out[3])
void ED_view3d_win_to_vector (ARegion *ar, const float mval[2], float out[3])
float ED_view3d_depth_read_cached (ViewContext *vc, int x, int y)
void ED_view3d_depth_tag_update (RegionView3D *rv3d)
void ED_view3d_ob_project_mat_get (RegionView3D *rv3d, Object *ob, float pmat[4][4])
void ED_view3d_project_float (const ARegion *ar, const float vec[3], float adr[2], float mat[4][4])
void ED_view3d_project_float_v3 (ARegion *ar, float *vec, float *adr, float mat[4][4])
int ED_view3d_boundbox_clip (RegionView3D *rv3d, float obmat[][4], BoundBox *bb)
void project_short (ARegion *ar, const float vec[3], short adr[2])
void project_int (ARegion *ar, const float vec[3], int adr[2])
void project_int_noclip (ARegion *ar, const float vec[3], int adr[2])
void project_short_noclip (ARegion *ar, const float vec[3], short adr[2])
void project_float (ARegion *ar, const float vec[3], float adr[2])
void project_float_noclip (ARegion *ar, const float vec[3], float adr[2])
int ED_view3d_clip_range_get (View3D *v3d, RegionView3D *rv3d, float *clipsta, float *clipend)
int ED_view3d_viewplane_get (View3D *v3d, RegionView3D *rv3d, int winx, int winy, rctf *viewplane, float *clipsta, float *clipend)
void setwinmatrixview3d (ARegion *ar, View3D *v3d, rctf *rect)
static void obmat_to_viewmat (View3D *v3d, RegionView3D *rv3d, Object *ob, short smooth)
int ED_view3d_lock (RegionView3D *rv3d)
void setviewmatrixview3d (Scene *scene, View3D *v3d, RegionView3D *rv3d)
short view3d_opengl_select (ViewContext *vc, unsigned int *buffer, unsigned int bufsize, rcti *input)
static unsigned int free_localbit (Main *bmain)
int ED_view3d_scene_layer_set (int lay, const int *values, int *active)
static void initlocalview (Main *bmain, Scene *scene, ScrArea *sa)
static void restore_localviewdata (ScrArea *sa, int free)
static void endlocalview (Main *bmain, Scene *scene, ScrArea *sa)
static int localview_exec (bContext *C, wmOperator *UNUSED(unused))
void VIEW3D_OT_localview (wmOperatorType *ot)
static int game_engine_poll (bContext *C)
int ED_view3d_context_activate (bContext *C)
static int game_engine_exec (bContext *C, wmOperator *op)
void VIEW3D_OT_game_start (wmOperatorType *ot)
void view3d_align_axis_to_vector (View3D *v3d, RegionView3D *rv3d, int axisidx, float vec[3])
float ED_view3d_pixel_size (struct RegionView3D *rv3d, const float co[3])

Detailed Description

Definition in file view3d_view.c.


Define Documentation

#define QUATSET (   a,
  b,
  c,
  d,
 
)    a[0]=b; a[1]=c; a[2]=d; a[3]=e;

Definition at line 1098 of file view3d_view.c.

Referenced by ED_view3d_lock().


Function Documentation

int ED_operator_rv3d_user_region_poll ( bContext C)
int ED_view3d_boundbox_clip ( RegionView3D rv3d,
float  obmat[][4],
BoundBox bb 
)
void ED_view3d_calc_clipping ( BoundBox bb,
float  planes[4][4],
bglMats mats,
const rcti rect 
)
int ED_view3d_clip_range_get ( View3D v3d,
RegionView3D rv3d,
float *  clipsta,
float *  clipend 
)
int ED_view3d_context_activate ( bContext C)
float ED_view3d_depth_read_cached ( ViewContext vc,
int  x,
int  y 
)
void ED_view3d_depth_tag_update ( RegionView3D rv3d)
void ED_view3d_global_to_vector ( struct RegionView3D rv3d,
const float  coord[3],
float  vec[3] 
)

Calculate a normalized 3d direction vector from the viewpoint towards a global location. In orthographic view the resulting vector will match the view vector.

Parameters:
rv3dThe region (used for the window width and height).
coordThe world-space location.
vecThe resulting normalized vector.

Definition at line 617 of file view3d_view.c.

References copy_v3_v3(), RegionView3D::is_persp, mul_m4_v4(), mul_v3_fl(), normalize_v3(), sub_v3_v3v3(), RegionView3D::viewinv, and RegionView3D::viewmat.

Referenced by calc_sculpt_normal(), calc_sculpt_plane(), project_brush_radius(), sculpt_update_cache_invariants(), and test_manipulator_axis().

int ED_view3d_lock ( RegionView3D rv3d)
void ED_view3d_ob_project_mat_get ( RegionView3D rv3d,
Object ob,
float  pmat[4][4] 
)
float ED_view3d_pixel_size ( struct RegionView3D rv3d,
const float  co[3] 
)
void ED_view3d_project_float ( const ARegion ar,
const float  vec[3],
float  adr[2],
float  mat[4][4] 
)

Definition at line 771 of file view3d_view.c.

References copy_v3_v3(), IS_CLIPPED, mul_m4_v4(), ARegion::winx, and ARegion::winy.

void ED_view3d_project_float_v3 ( ARegion ar,
float *  vec,
float *  adr,
float  mat[4][4] 
)

Definition at line 790 of file view3d_view.c.

References copy_v3_v3(), IS_CLIPPED, mul_m4_v4(), ARegion::winx, and ARegion::winy.

int ED_view3d_scene_layer_set ( int  lay,
const int *  values,
int *  active 
)

Definition at line 1337 of file view3d_view.c.

References i.

int ED_view3d_viewplane_get ( View3D v3d,
RegionView3D rv3d,
int  winx,
int  winy,
rctf viewplane,
float *  clipsta,
float *  clipend 
)
void ED_view3d_win_to_3d ( struct ARegion ar,
const float  depth_pt[3],
const float  mval[2],
float  out[3] 
)

Calculate a 3d location from 2d window coordinates.

Parameters:
arThe region (used for the window width and height).
depth_ptThe reference location used to calculate the Z depth.
mvalThe area relative location (such as event->mval converted to floats).
outThe resulting world-space location.

Definition at line 663 of file view3d_view.c.

References add_v3_v3v3(), closest_to_line_v3(), copy_v3_v3(), ED_view3d_win_to_vector(), RegionView3D::is_persp, isect_line_plane_v3(), RegionView3D::persinv, ARegion::regiondata, TRUE, RegionView3D::viewinv, ARegion::winx, ARegion::winy, and zero_v3().

Referenced by armature_click_extrude_invoke(), and gp_strokepoint_convertcoords().

void ED_view3d_win_to_delta ( struct ARegion ar,
const float  mval[2],
float  out[3] 
)

Calculate a 3d difference vector from 2d window offset. note that initgrabz() must be called first to determine the depth used to calculate the delta.

Parameters:
arThe region (used for the window width and height).
mvalThe area relative 2d difference (such as event->mval[0] - other_x).
outThe resulting world-space delta.

Definition at line 695 of file view3d_view.c.

References RegionView3D::persinv, ARegion::regiondata, ARegion::winx, ARegion::winy, and RegionView3D::zfac.

Referenced by brush_edit_apply(), convertViewVec(), draw_bgpic(), gp_stroke_convertcoords(), paint_calc_object_space_radius(), sculpt_update_brush_delta(), set_3dcursor_invoke(), sk_projectDrawPoint(), view3d_get_view_aligned_coordinate(), view3d_zoom_border_exec(), view_zoom_mouseloc(), viewmove_apply(), and viewpan_exec().

void ED_view3d_win_to_ray ( struct ARegion ar,
struct View3D v3d,
const float  mval[2],
float  ray_start[3],
float  ray_normal[3] 
)

Calculate a 3d viewpoint and direction vector from 2d window coordinates. This ray_start is located at the viewpoint, ray_normal is the direction towards mval. ray_start is clipped by the view near limit so points in front of it are always in view. In orthographic view the resulting ray_normal will match the view vector.

Parameters:
arThe region (used for the window width and height).
v3dThe 3d viewport (used for near clipping value).
mvalThe area relative 2d location (such as event->mval, converted into float[2]).
ray_startThe world-space starting point of the segment.
ray_normalThe normalized world-space direction of towards mval.

Definition at line 608 of file view3d_view.c.

References ED_view3d_win_to_segment_clip(), normalize_v3(), and sub_v3_v3v3().

Referenced by peelObjects(), sk_interpolateDepth(), and snapObjects().

void ED_view3d_win_to_segment_clip ( struct ARegion ar,
struct View3D v3d,
const float  mval[2],
float  ray_start[3],
float  ray_end[3] 
)

Calculate a 3d segment from 2d window coordinates. This ray_start is located at the viewpoint, ray_end is a far point. ray_start and ray_end are clipped by the view near and far limits so points along this line are always in view. In orthographic view all resulting segments will be parallel.

Parameters:
arThe region (used for the window width and height).
v3dThe 3d viewport (used for near and far clipping range).
mvalThe area relative 2d location (such as event->mval, converted into float[2]).
ray_startThe world-space starting point of the segment.
ray_endThe world-space end point of the segment.

Definition at line 573 of file view3d_view.c.

References RegionView3D::clip, clip_line_plane(), copy_v3_v3(), ED_view3d_win_to_vector(), View3D::far, RegionView3D::is_persp, madd_v3_v3v3fl(), mul_m4_v4(), View3D::near, RegionView3D::persinv, ARegion::regiondata, RegionView3D::rflag, RV3D_CLIPPING, RegionView3D::viewinv, ARegion::winx, and ARegion::winy.

Referenced by brush_add(), ED_view3d_win_to_ray(), sculpt_stroke_get_location(), and sk_getIntersections().

void ED_view3d_win_to_vector ( struct ARegion ar,
const float  mval[2],
float  out[3] 
)

Calculate a 3d direction vector from 2d window coordinates. This direction vector starts and the view in the direction of the 2d window coordinates. In orthographic view all window coordinates yield the same vector.

Parameters:
arThe region (used for the window width and height).
mvalThe area relative 2d location (such as event->mval converted to floats).
outThe resulting normalized world-space direction vector.

Definition at line 711 of file view3d_view.c.

References copy_v3_v3(), RegionView3D::is_persp, mul_project_m4_v3(), normalize_v3(), RegionView3D::persinv, ARegion::regiondata, sub_v3_v3(), RegionView3D::viewinv, ARegion::winx, and ARegion::winy.

Referenced by ED_view3d_win_to_3d(), ED_view3d_win_to_segment_clip(), and viewops_data_create().

static void endlocalview ( Main bmain,
Scene scene,
ScrArea sa 
) [static]
static unsigned int free_localbit ( Main bmain) [static]
static int game_engine_exec ( bContext C,
wmOperator op 
) [static]
static int game_engine_poll ( bContext C) [static]
float* give_cursor ( Scene scene,
View3D v3d 
)
int initgrabz ( RegionView3D rv3d,
float  x,
float  y,
float  z 
)
static void initlocalview ( Main bmain,
Scene scene,
ScrArea sa 
) [static]
static int localview_exec ( bContext C,
wmOperator UNUSEDunused 
) [static]
static void obmat_to_viewmat ( View3D v3d,
RegionView3D rv3d,
Object ob,
short  smooth 
) [static]
void project_float ( ARegion ar,
const float  vec[3],
float  adr[2] 
)
void project_float_noclip ( ARegion ar,
const float  vec[3],
float  adr[2] 
)
void project_int ( ARegion ar,
const float  vec[3],
int  adr[2] 
)
void project_int_noclip ( ARegion ar,
const float  vec[3],
int  adr[2] 
)
void project_short ( ARegion ar,
const float  vec[3],
short  adr[2] 
)
void project_short_noclip ( ARegion ar,
const float  vec[3],
short  adr[2] 
)
static void restore_localviewdata ( ScrArea sa,
int  free 
) [static]
void setviewmatrixview3d ( Scene scene,
View3D v3d,
RegionView3D rv3d 
)
void setwinmatrixview3d ( ARegion ar,
View3D v3d,
rctf rect 
)
void smooth_view ( bContext C,
View3D v3d,
ARegion ar,
Object oldcamera,
Object camera,
float *  ofs,
float *  quat,
float *  dist,
float *  lens 
)
void view3d_align_axis_to_vector ( View3D v3d,
RegionView3D rv3d,
int  axisidx,
float  vec[3] 
)
static int view3d_camera_to_view_exec ( bContext C,
wmOperator UNUSEDop 
) [static]
static int view3d_camera_to_view_poll ( bContext C) [static]
static int view3d_camera_to_view_selected_exec ( bContext C,
wmOperator UNUSEDop 
) [static]
static int view3d_camera_to_view_selected_poll ( bContext C) [static]
short view3d_opengl_select ( ViewContext vc,
unsigned int *  buffer,
unsigned int  bufsize,
rcti input 
)
void view3d_operator_needs_opengl ( const bContext C)
void VIEW3D_OT_camera_to_view ( wmOperatorType ot)
void VIEW3D_OT_camera_to_view_selected ( wmOperatorType ot)
void VIEW3D_OT_game_start ( wmOperatorType ot)
void VIEW3D_OT_localview ( wmOperatorType ot)
void VIEW3D_OT_object_as_camera ( wmOperatorType ot)
void VIEW3D_OT_smoothview ( wmOperatorType ot)
void view3d_region_operator_needs_opengl ( wmWindow win,
ARegion ar 
)
static int view3d_setobjectascamera_exec ( bContext C,
wmOperator UNUSEDop 
) [static]
static int view3d_smoothview_invoke ( bContext C,
wmOperator UNUSEDop,
wmEvent event 
) [static]