Blender  V2.93
Classes
view3d_view.c File Reference
#include "DNA_camera_types.h"
#include "DNA_gpencil_modifier_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "MEM_guardedalloc.h"
#include "BLI_linklist.h"
#include "BLI_listbase.h"
#include "BLI_math.h"
#include "BLI_rect.h"
#include "BLI_utildefines.h"
#include "BKE_action.h"
#include "BKE_camera.h"
#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_gpencil_modifier.h"
#include "BKE_idprop.h"
#include "BKE_layer.h"
#include "BKE_main.h"
#include "BKE_modifier.h"
#include "BKE_object.h"
#include "BKE_report.h"
#include "BKE_scene.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_query.h"
#include "UI_resources.h"
#include "GPU_matrix.h"
#include "GPU_select.h"
#include "GPU_state.h"
#include "WM_api.h"
#include "WM_types.h"
#include "ED_object.h"
#include "ED_screen.h"
#include "DRW_engine.h"
#include "RNA_access.h"
#include "RNA_define.h"
#include "view3d_intern.h"

Go to the source code of this file.

Classes

struct  SmoothView3DState
 
struct  SmoothView3DStore
 
struct  DrawSelectLoopUserData
 

Functions

Smooth View Operator & Utilities

Use for view transitions to have smooth (animated) transitions.

static void view3d_smooth_view_state_backup (struct SmoothView3DState *sms_state, const View3D *v3d, const RegionView3D *rv3d)
 
static void view3d_smooth_view_state_restore (const struct SmoothView3DState *sms_state, View3D *v3d, RegionView3D *rv3d)
 
void ED_view3d_smooth_view_ex (const Depsgraph *depsgraph, wmWindowManager *wm, wmWindow *win, ScrArea *area, View3D *v3d, ARegion *region, const int smooth_viewtx, const V3D_SmoothParams *sview)
 
void ED_view3d_smooth_view (bContext *C, View3D *v3d, ARegion *region, const int smooth_viewtx, const struct V3D_SmoothParams *sview)
 
static void view3d_smoothview_apply (bContext *C, View3D *v3d, ARegion *region, bool sync_boxview)
 
static int view3d_smoothview_invoke (bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
 
void ED_view3d_smooth_view_force_finish (bContext *C, View3D *v3d, ARegion *region)
 
void VIEW3D_OT_smoothview (wmOperatorType *ot)
 
Camera to View Operator
static int view3d_camera_to_view_exec (bContext *C, wmOperator *UNUSED(op))
 
static bool view3d_camera_to_view_poll (bContext *C)
 
void VIEW3D_OT_camera_to_view (wmOperatorType *ot)
 
Camera Fit Frame to Selected Operator
static int view3d_camera_to_view_selected_exec (bContext *C, wmOperator *op)
 
void VIEW3D_OT_camera_to_view_selected (wmOperatorType *ot)
 
Object as Camera Operator
static void sync_viewport_camera_smoothview (bContext *C, View3D *v3d, Object *ob, const int smooth_viewtx)
 
static int view3d_setobjectascamera_exec (bContext *C, wmOperator *op)
 
bool ED_operator_rv3d_user_region_poll (bContext *C)
 
void VIEW3D_OT_object_as_camera (wmOperatorType *ot)
 
Window and View Matrix Calculation
void view3d_winmatrix_set (Depsgraph *depsgraph, ARegion *region, const View3D *v3d, const rcti *rect)
 
static void obmat_to_viewmat (RegionView3D *rv3d, Object *ob)
 
void view3d_viewmatrix_set (Depsgraph *depsgraph, const Scene *scene, const View3D *v3d, RegionView3D *rv3d, const float rect_scale[2])
 
OpenGL Select Utilities
void view3d_opengl_select_cache_begin (void)
 
void view3d_opengl_select_cache_end (void)
 
static bool drw_select_loop_pass (eDRWSelectStage stage, void *user_data)
 
eV3DSelectObjectFilter ED_view3d_select_filter_from_mode (const Scene *scene, const Object *obact)
 
static bool drw_select_filter_object_mode_lock (Object *ob, void *user_data)
 
static bool drw_select_filter_object_mode_lock_for_weight_paint (Object *ob, void *user_data)
 
int view3d_opengl_select (ViewContext *vc, uint *buffer, uint bufsize, const rcti *input, eV3DSelectMode select_mode, eV3DSelectObjectFilter select_filter)
 
int view3d_opengl_select_with_id_filter (ViewContext *vc, uint *buffer, uint bufsize, const rcti *input, eV3DSelectMode select_mode, eV3DSelectObjectFilter select_filter, uint select_id)
 
Local View Operators
static uint free_localview_bit (Main *bmain)
 
static bool view3d_localview_init (const Depsgraph *depsgraph, wmWindowManager *wm, wmWindow *win, Main *bmain, ViewLayer *view_layer, ScrArea *area, const bool frame_selected, const int smooth_viewtx, ReportList *reports)
 
static void view3d_localview_exit (const Depsgraph *depsgraph, wmWindowManager *wm, wmWindow *win, ViewLayer *view_layer, ScrArea *area, const bool frame_selected, const int smooth_viewtx)
 
static int localview_exec (bContext *C, wmOperator *op)
 
void VIEW3D_OT_localview (wmOperatorType *ot)
 
static int localview_remove_from_exec (bContext *C, wmOperator *op)
 
static bool localview_remove_from_poll (bContext *C)
 
void VIEW3D_OT_localview_remove_from (wmOperatorType *ot)
 
Local Collections
static uint free_localcollection_bit (Main *bmain, ushort local_collections_uuid, bool *r_reset)
 
static void local_collections_reset_uuid (LayerCollection *layer_collection, const ushort local_view_bit)
 
static void view3d_local_collections_reset (Main *bmain, const uint local_view_bit)
 
bool ED_view3d_local_collections_set (Main *bmain, struct View3D *v3d)
 
void ED_view3d_local_collections_reset (struct bContext *C, const bool reset_all)
 

Function Documentation

◆ drw_select_filter_object_mode_lock()

static bool drw_select_filter_object_mode_lock ( Object ob,
void *  user_data 
)
static

◆ drw_select_filter_object_mode_lock_for_weight_paint()

static bool drw_select_filter_object_mode_lock_for_weight_paint ( Object ob,
void *  user_data 
)
static

Implement VIEW3D_SELECT_FILTER_WPAINT_POSE_MODE_LOCK for special case when we want to select pose bones (this doesn't switch modes).

Definition at line 962 of file view3d_view.c.

References BLI_linklist_index(), DEG_get_original_object(), and user_data.

Referenced by view3d_opengl_select().

◆ drw_select_loop_pass()

static bool drw_select_loop_pass ( eDRWSelectStage  stage,
void *  user_data 
)
static

◆ ED_operator_rv3d_user_region_poll()

bool ED_operator_rv3d_user_region_poll ( bContext C)

◆ ED_view3d_local_collections_reset()

void ED_view3d_local_collections_reset ( struct bContext C,
const bool  reset_all 
)

◆ ED_view3d_local_collections_set()

bool ED_view3d_local_collections_set ( Main bmain,
struct View3D v3d 
)

See if current uuid is valid, otherwise set a valid uuid to v3d, Try to keep the same uuid previously used to allow users to quickly toggle back and forth.

Definition at line 1637 of file view3d_view.c.

References View3D::flag, free_localcollection_bit(), View3D::local_collections_uuid, reset(), V3D_LOCAL_COLLECTIONS, and view3d_local_collections_reset().

◆ ED_view3d_select_filter_from_mode()

eV3DSelectObjectFilter ED_view3d_select_filter_from_mode ( const Scene scene,
const Object obact 
)

◆ ED_view3d_smooth_view()

void ED_view3d_smooth_view ( bContext C,
View3D v3d,
ARegion region,
const int  smooth_viewtx,
const struct V3D_SmoothParams sview 
)

◆ ED_view3d_smooth_view_ex()

void ED_view3d_smooth_view_ex ( const Depsgraph depsgraph,
wmWindowManager wm,
wmWindow win,
ScrArea area,
View3D v3d,
ARegion region,
const int  smooth_viewtx,
const V3D_SmoothParams sview 
)

Definition at line 127 of file view3d_view.c.

References angle_signed_normalized_qtqt(), blender::compositor::area(), BLI_assert, CAM_ORTHO, V3D_SmoothParams::camera, V3D_SmoothParams::camera_old, copy_qt_qt(), copy_v3_v3(), Object::data, DEG_get_evaluated_object(), depsgraph, V3D_SmoothParams::dist, SmoothView3DState::dist, RegionView3D::dist, double(), SmoothView3DStore::dst, V3D_SmoothParams::dyn_ofs, SmoothView3DStore::dyn_ofs, ED_region_tag_redraw(), ED_view3d_camera_lock_init(), ED_view3d_camera_lock_sync(), ED_view3d_from_object(), ED_view3d_offset_distance(), equals_v3v3(), equals_v4v4(), fabsf, RegionView3D::is_persp, V3D_SmoothParams::lens, SmoothView3DState::lens, View3D::lens, M_PI, MEM_mallocN, NULL, OB_CAMERA, OB_RENDER, Object::obmat, V3D_SmoothParams::ofs, SmoothView3DState::ofs, RegionView3D::ofs, SmoothView3DStore::org, SmoothView3DStore::org_view, RegionView3D::persp, V3D_SmoothParams::quat, SmoothView3DState::quat, ARegion::regiondata, RegionView3D::render_engine, RegionView3D::rflag, RV3D_BOXVIEW, RV3D_LOCK_FLAGS, RV3D_LOCK_ROTATION, RV3D_NAVIGATING, RV3D_ORTHO, RV3D_PERSP, RV3D_VIEW_USER, View3D::shading, RegionView3D::smooth_timer, RegionView3D::sms, SmoothView3DStore::src, SmoothView3DStore::time_allowed, TIMER1, SmoothView3DStore::to_camera, Object::type, View3DShading::type, SmoothView3DStore::use_dyn_ofs, RegionView3D::view, view3d_boxview_copy(), VIEW3D_DIST_FALLBACK, view3d_orbit_apply_dyn_ofs(), view3d_smooth_view_state_backup(), view3d_smooth_view_state_restore(), RegionView3D::viewquat, WM_event_add_timer(), and WM_event_remove_timer().

Referenced by ED_view3d_smooth_view(), view3d_localview_exit(), and view3d_localview_init().

◆ ED_view3d_smooth_view_force_finish()

void ED_view3d_smooth_view_force_finish ( bContext C,
View3D v3d,
ARegion region 
)

◆ free_localcollection_bit()

static uint free_localcollection_bit ( Main bmain,
ushort  local_collections_uuid,
bool *  r_reset 
)
static

◆ free_localview_bit()

static uint free_localview_bit ( Main bmain)
static

◆ local_collections_reset_uuid()

static void local_collections_reset_uuid ( LayerCollection layer_collection,
const ushort  local_view_bit 
)
static

◆ localview_exec()

static int localview_exec ( bContext C,
wmOperator op 
)
static

◆ localview_remove_from_exec()

static int localview_remove_from_exec ( bContext C,
wmOperator op 
)
static

◆ localview_remove_from_poll()

static bool localview_remove_from_poll ( bContext C)
static

Definition at line 1538 of file view3d_view.c.

References C, CTX_data_edit_object(), CTX_wm_view3d(), View3D::localvd, and NULL.

Referenced by VIEW3D_OT_localview_remove_from().

◆ obmat_to_viewmat()

static void obmat_to_viewmat ( RegionView3D rv3d,
Object ob 
)
static

◆ sync_viewport_camera_smoothview()

static void sync_viewport_camera_smoothview ( bContext C,
View3D v3d,
Object ob,
const int  smooth_viewtx 
)
static

◆ view3d_camera_to_view_exec()

static int view3d_camera_to_view_exec ( bContext C,
wmOperator UNUSEDop 
)
static

◆ view3d_camera_to_view_poll()

static bool view3d_camera_to_view_poll ( bContext C)
static

◆ view3d_camera_to_view_selected_exec()

static int view3d_camera_to_view_selected_exec ( bContext C,
wmOperator op 
)
static

◆ view3d_local_collections_reset()

static void view3d_local_collections_reset ( Main bmain,
const uint  local_view_bit 
)
static

◆ view3d_localview_exit()

static void view3d_localview_exit ( const Depsgraph depsgraph,
wmWindowManager wm,
wmWindow win,
ViewLayer view_layer,
ScrArea area,
const bool  frame_selected,
const int  smooth_viewtx 
)
static

◆ view3d_localview_init()

static bool view3d_localview_init ( const Depsgraph depsgraph,
wmWindowManager wm,
wmWindow win,
Main bmain,
ViewLayer view_layer,
ScrArea area,
const bool  frame_selected,
const int  smooth_viewtx,
ReportList reports 
)
static

◆ view3d_opengl_select()

int view3d_opengl_select ( ViewContext vc,
uint buffer,
uint  bufsize,
const rcti input,
eV3DSelectMode  select_mode,
eV3DSelectObjectFilter  select_filter 
)
Warning
be sure to account for a negative return value This is an error, "Too many objects in select buffer" and no action should be taken (can crash blender) if this happens
Note
(vc->obedit == NULL) can be set to explicitly skip edit-object selection.

Definition at line 975 of file view3d_view.c.

References BKE_gpencil_modifiers_get_virtual_modifierlist(), BKE_modifiers_get_virtual_modifierlist(), BLI_assert, BLI_linklist_prepend_alloca, BLI_rcti_init_pt_radius(), buffer, ViewContext::C, CTX_wm_manager(), depsgraph, ViewContext::depsgraph, DRW_draw_select_loop(), DRW_opengl_context_disable(), DRW_opengl_context_enable(), drw_select_filter_object_mode_lock(), drw_select_filter_object_mode_lock_for_weight_paint(), drw_select_loop_pass(), ED_view3d_draw_setup_view(), eGpencilModifierType_Armature, eModifierType_Armature, G, G_FLAG_PICKSEL, GPU_DEPTH_LESS_EQUAL, GPU_DEPTH_NONE, GPU_depth_test(), GPU_SELECT_ALL, GPU_select_begin(), GPU_select_cache_end(), GPU_select_cache_load_id(), GPU_select_end(), GPU_select_is_cached(), DrawSelectLoopUserData::gpu_select_mode, GPU_SELECT_NEAREST_FIRST_PASS, GPU_SELECT_PICK_ALL, GPU_SELECT_PICK_NEAREST, DrawSelectLoopUserData::hits, Object::mode, GpencilModifierData::next, ModifierData::next, NULL, OB_GPENCIL, OB_MODE_ALL_WEIGHT_PAINT, OB_MODE_OBJECT, OB_MODE_POSE, OB_WIRE, ViewContext::obact, ViewContext::obedit, OBEDIT_FROM_VIEW_LAYER, ArmatureGpencilModifierData::object, ArmatureModifierData::object, DrawSelectLoopUserData::pass, DrawSelectLoopUserData::rect, ViewContext::region, RGN_TYPE_WINDOW, ViewContext::rv3d, scene, ViewContext::scene, View3D::shading, SPACE_VIEW3D, GpencilModifierData::type, ModifierData::type, Object::type, View3DShading::type, UI_SetTheme(), UI_Theme_Restore(), UI_Theme_Store(), user_data, USER_GPU_FLAG_NO_DEPT_PICK, ViewContext::v3d, VIEW3D_SELECT_FILTER_NOP, VIEW3D_SELECT_FILTER_OBJECT_MODE_LOCK, VIEW3D_SELECT_FILTER_WPAINT_POSE_MODE_LOCK, VIEW3D_SELECT_PICK_ALL, VIEW3D_SELECT_PICK_NEAREST, ViewContext::view_layer, RegionView3D::viewmat, ViewContext::win, rcti::xmax, rcti::xmin, XRAY_ACTIVE, XRAY_ENABLED, and rcti::ymin.

Referenced by view3d_opengl_select_with_id_filter().

◆ view3d_opengl_select_cache_begin()

void view3d_opengl_select_cache_begin ( void  )

Optionally cache data for multiple calls to view3d_opengl_select

just avoid GPU_select headers outside this file

Definition at line 892 of file view3d_view.c.

References GPU_select_cache_begin().

Referenced by get_nearest_editbonepoint(), and mixed_bones_object_selectbuffer().

◆ view3d_opengl_select_cache_end()

void view3d_opengl_select_cache_end ( void  )

Definition at line 897 of file view3d_view.c.

References GPU_select_cache_end().

Referenced by get_nearest_editbonepoint(), and mixed_bones_object_selectbuffer().

◆ view3d_opengl_select_with_id_filter()

int view3d_opengl_select_with_id_filter ( ViewContext vc,
uint buffer,
uint  bufsize,
const rcti input,
eV3DSelectMode  select_mode,
eV3DSelectObjectFilter  select_filter,
uint  select_id 
)

◆ VIEW3D_OT_camera_to_view()

void VIEW3D_OT_camera_to_view ( wmOperatorType ot)

◆ VIEW3D_OT_camera_to_view_selected()

void VIEW3D_OT_camera_to_view_selected ( wmOperatorType ot)

◆ VIEW3D_OT_localview()

void VIEW3D_OT_localview ( wmOperatorType ot)

◆ VIEW3D_OT_localview_remove_from()

void VIEW3D_OT_localview_remove_from ( wmOperatorType ot)

◆ VIEW3D_OT_object_as_camera()

void VIEW3D_OT_object_as_camera ( wmOperatorType ot)

◆ VIEW3D_OT_smoothview()

void VIEW3D_OT_smoothview ( wmOperatorType ot)

◆ view3d_setobjectascamera_exec()

static int view3d_setobjectascamera_exec ( bContext C,
wmOperator op 
)
static

◆ view3d_smooth_view_state_backup()

static void view3d_smooth_view_state_backup ( struct SmoothView3DState sms_state,
const View3D v3d,
const RegionView3D rv3d 
)
static

◆ view3d_smooth_view_state_restore()

static void view3d_smooth_view_state_restore ( const struct SmoothView3DState sms_state,
View3D v3d,
RegionView3D rv3d 
)
static

◆ view3d_smoothview_apply()

static void view3d_smoothview_apply ( bContext C,
View3D v3d,
ARegion region,
bool  sync_boxview 
)
static

◆ view3d_smoothview_invoke()

static int view3d_smoothview_invoke ( bContext C,
wmOperator UNUSEDop,
const wmEvent event 
)
static

◆ view3d_viewmatrix_set()

void view3d_viewmatrix_set ( Depsgraph depsgraph,
const Scene scene,
const View3D v3d,
RegionView3D rv3d,
const float  rect_scale[2] 
)

◆ view3d_winmatrix_set()

void view3d_winmatrix_set ( Depsgraph depsgraph,
ARegion region,
const View3D v3d,
const rcti rect 
)