Blender V4.3
view3d_view.cc File Reference
#include "MEM_guardedalloc.h"
#include "BLI_linklist.h"
#include "BLI_listbase.h"
#include "BLI_math_matrix.h"
#include "BLI_math_rotation.h"
#include "BLI_math_vector.h"
#include "BLI_rect.h"
#include "BKE_action.hh"
#include "BKE_context.hh"
#include "BKE_global.hh"
#include "BKE_idprop.hh"
#include "BKE_layer.hh"
#include "BKE_lib_id.hh"
#include "BKE_main.hh"
#include "BKE_modifier.hh"
#include "BKE_object.hh"
#include "BKE_report.hh"
#include "BKE_scene.hh"
#include "DEG_depsgraph_query.hh"
#include "UI_resources.hh"
#include "GPU_matrix.hh"
#include "GPU_platform.hh"
#include "GPU_select.hh"
#include "GPU_state.hh"
#include "WM_api.hh"
#include "ED_object.hh"
#include "ED_screen.hh"
#include "DRW_engine.hh"
#include "RNA_access.hh"
#include "RNA_define.hh"
#include "view3d_intern.hh"
#include "view3d_navigate.hh"

Go to the source code of this file.

Classes

struct  DrawSelectLoopUserData
 

Functions

Camera to View Operator
static int view3d_camera_to_view_exec (bContext *C, wmOperator *)
 
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 (const Depsgraph *depsgraph, ARegion *region, const View3D *v3d, const rcti *rect)
 
static void obmat_to_viewmat (RegionView3D *rv3d, Object *ob)
 
void view3d_viewmatrix_set (const 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 view3d_opengl_select_cache_end ()
 
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_ex (const ViewContext *vc, GPUSelectBuffer *buffer, const rcti *input, eV3DSelectMode select_mode, eV3DSelectObjectFilter select_filter, const bool do_material_slot_selection)
 
int view3d_opengl_select (const ViewContext *vc, GPUSelectBuffer *buffer, const rcti *input, eV3DSelectMode select_mode, eV3DSelectObjectFilter select_filter)
 
int view3d_opengl_select_with_id_filter (const ViewContext *vc, GPUSelectBuffer *buffer, 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, const Scene *scene, ViewLayer *view_layer, ScrArea *area, const bool frame_selected, const int smooth_viewtx, ReportList *reports)
 
static bool view3d_localview_exit (const Depsgraph *depsgraph, wmWindowManager *wm, wmWindow *win, const Scene *scene, ViewLayer *view_layer, ScrArea *area, const bool frame_selected, const int smooth_viewtx)
 
bool ED_localview_exit_if_empty (const Depsgraph *depsgraph, Scene *scene, ViewLayer *view_layer, wmWindowManager *wm, wmWindow *win, View3D *v3d, 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 (const Main *bmain, ushort local_collections_uid, bool *r_reset)
 
static void local_collections_reset_uuid (LayerCollection *layer_collection, const ushort local_view_bit)
 
static void view3d_local_collections_reset (const Main *bmain, const uint local_view_bit)
 
bool ED_view3d_local_collections_set (const Main *bmain, View3D *v3d)
 
void ED_view3d_local_collections_reset (const 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 538 of file view3d_view.cc.

References BLI_linklist_index(), and DEG_get_original_object().

Referenced by view3d_opengl_select_ex().

◆ drw_select_loop_pass()

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

◆ ED_localview_exit_if_empty()

bool ED_localview_exit_if_empty ( const Depsgraph * depsgraph,
Scene * scene,
ViewLayer * view_layer,
wmWindowManager * wm,
wmWindow * win,
View3D * v3d,
ScrArea * area,
bool frame_selected = true,
int smooth_viewtx = 0 )

Exit 'local view' of given View3D editor, if it is active and there is nothing to display in it anymore.

Parameters
depsgraphOptional, only required for #frame_selected.
frame_selectedFrame the newly out-of-local view to show currently visible selected objects. Will only do something if a valid depsgraph pointer is also provided.
smooth_viewtxSmooth transition time (in milliseconds) between current view and final view, if changes are happening. Currently only used if #frame_selected is enabled.
Returns
true if the local view was actually exited.

Definition at line 1038 of file view3d_view.cc.

References BKE_view_layer_object_bases_get(), BKE_view_layer_synced_ensure(), depsgraph, View3D_Runtime::flag, LISTBASE_FOREACH, View3D::local_view_uid, View3D::localvd, View3D::runtime, and view3d_localview_exit().

Referenced by localview_remove_from_exec(), and space_view3d_refresh().

◆ ED_operator_rv3d_user_region_poll()

◆ ED_view3d_local_collections_reset()

◆ ED_view3d_local_collections_set()

bool ED_view3d_local_collections_set ( const Main * bmain,
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 1270 of file view3d_view.cc.

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

◆ ED_view3d_select_filter_from_mode()

◆ free_localcollection_bit()

static uint free_localcollection_bit ( const Main * bmain,
ushort local_collections_uid,
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()

◆ localview_remove_from_exec()

◆ localview_remove_from_poll()

static bool localview_remove_from_poll ( bContext * C)
static

◆ obmat_to_viewmat()

static void obmat_to_viewmat ( RegionView3D * rv3d,
Object * ob )
static

◆ sync_viewport_camera_smoothview()

◆ view3d_camera_to_view_exec()

◆ view3d_camera_to_view_poll()

◆ view3d_camera_to_view_selected_exec()

◆ view3d_local_collections_reset()

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

◆ view3d_localview_exit()

◆ view3d_localview_init()

◆ view3d_opengl_select()

◆ view3d_opengl_select_cache_begin()

void view3d_opengl_select_cache_begin ( )

Optionally cache data for multiple calls to view3d_opengl_select

just avoid GPU_select headers outside this file

Definition at line 469 of file view3d_view.cc.

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 ( )

Definition at line 474 of file view3d_view.cc.

References GPU_select_cache_end().

Referenced by get_nearest_editbonepoint(), and mixed_bones_object_selectbuffer().

◆ view3d_opengl_select_ex()

int view3d_opengl_select_ex ( const ViewContext * vc,
GPUSelectBuffer * buffer,
const rcti * input,
eV3DSelectMode select_mode,
eV3DSelectObjectFilter select_filter,
bool do_material_slot_selection )
Note
(vc->obedit == NULL) can be set to explicitly skip edit-object selection.

Definition at line 544 of file view3d_view.cc.

References BKE_modifiers_get_virtual_modifierlist(), BKE_view_layer_edit_object_get(), BKE_view_layer_synced_ensure(), BLI_assert, BLI_linklist_prepend_alloca, BLI_rcti_init_pt_radius(), DrawSelectLoopUserData::buffer, ViewContext::C, CTX_wm_manager(), depsgraph, ViewContext::depsgraph, DRW_draw_select_loop(), DRW_gpu_context_disable(), DRW_gpu_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(), eModifierType_Armature, G, G_FLAG_PICKSEL, GPU_BACKEND_VULKAN, GPU_DEPTH_LESS_EQUAL, GPU_DEPTH_NONE, GPU_depth_test(), GPU_DEVICE_ATI, GPU_DEVICE_NVIDIA, GPU_DRIVER_OFFICIAL, GPU_OS_ANY, GPU_SELECT_ALL, GPU_select_begin_next(), 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, GPU_type_matches_ex(), DrawSelectLoopUserData::hits, Object::mode, ModifierData::next, OB_MODE_ALL_WEIGHT_PAINT, OB_MODE_OBJECT, OB_MODE_POSE, OB_WIRE, ViewContext::obact, ViewContext::obedit, ArmatureModifierData::object, DrawSelectLoopUserData::pass, DrawSelectLoopUserData::rect, ViewContext::region, RGN_TYPE_WINDOW, ViewContext::rv3d, ViewContext::scene, View3D::shading, SPACE_VIEW3D, ModifierData::type, View3DShading::type, UI_SetTheme(), UI_Theme_Restore(), UI_Theme_Store(), 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, XRAY_ACTIVE, XRAY_ENABLED, and xy.

Referenced by mixed_bones_object_selectbuffer(), and view3d_opengl_select().

◆ view3d_opengl_select_with_id_filter()

◆ VIEW3D_OT_camera_to_view()

◆ VIEW3D_OT_camera_to_view_selected()

◆ VIEW3D_OT_localview()

◆ VIEW3D_OT_localview_remove_from()

◆ VIEW3D_OT_object_as_camera()

◆ view3d_setobjectascamera_exec()

◆ view3d_viewmatrix_set()

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

Sets RegionView3D.viewmat

Parameters
depsgraphDepsgraph.
sceneScene for camera and cursor location.
v3dView 3D space data.
rv3d3D region which stores the final matrices.
rect_scaleOptional 2D scale argument, Use when displaying a sub-region, eg: when view3d_winmatrix_set takes a 'rect' argument.
Note
don't set windows active in here, is used by renderwin too.

Definition at line 380 of file view3d_view.cc.

References BKE_pose_channel_find_name(), View3D::camera, copy_v3_v3(), DEG_get_evaluated_object(), depsgraph, RegionView3D::dist, ED_view3d_lock(), invert_m4_m4(), RegionView3D::is_persp, mul_m4_m4m4(), mul_m4_v3(), mul_mat3_m4_v3(), mul_v2_v2fl(), OB_ARMATURE, View3D::ob_center, View3D::ob_center_bone, View3D::ob_center_cursor, obmat_to_viewmat(), RegionView3D::ofs, RegionView3D::ofs_lock, RegionView3D::persp, Object::pose, bPoseChannel::pose_mat, quat_to_mat4(), RV3D_CAMOB, RV3D_LOCK_FLAGS, RV3D_LOCK_ROTATION, RV3D_PERSP, translate_m4(), Object::type, RegionView3D::viewmat, RegionView3D::viewquat, and RegionView3D::winmat.

Referenced by ED_view3d_update_viewmat().

◆ view3d_winmatrix_set()

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