112 ot->name =
"Align Camera to View";
113 ot->description =
"Set camera view to active view";
114 ot->idname =
"VIEW3D_OT_camera_to_view";
142 if (camera_ob ==
nullptr) {
157 ot->name =
"Camera Fit Frame to Selected";
158 ot->description =
"Move the camera so selected objects are framed";
159 ot->idname =
"VIEW3D_OT_camera_to_view_selected";
178 const int smooth_viewtx)
185 View3D *other_v3d =
reinterpret_cast<View3D *
>(space_link);
186 if (other_v3d == v3d) {
189 if (other_v3d->
camera == ob) {
194 ListBase *lb = (space_link == area->spacedata.first) ? &area->regionbase :
195 &space_link->regionbase;
198 if (other_region->regiondata) {
207 sview_params.
ofs = other_rv3d->
ofs;
209 sview_params.
dist = &other_rv3d->
dist;
210 sview_params.
lens = &other_v3d->
lens;
216 C, other_v3d, other_region, smooth_viewtx, &sview_params);
259 if (camera_old != ob) {
263 sview_params.
ofs = rv3d->
ofs;
295 ot->name =
"Set Active Object as Camera";
296 ot->description =
"Set the active object as the active camera for this view or scene";
297 ot->idname =
"VIEW3D_OT_object_as_camera";
320 float clipsta, clipend;
335 printf(
"%s: %d %d %f %f %f %f %f %f\n",
351 viewplane.
xmin = full_viewplane.
xmin +
353 viewplane.
ymin = full_viewplane.
ymin +
355 viewplane.
xmax = full_viewplane.
xmin +
357 viewplane.
ymax = full_viewplane.
ymin +
361 viewplane = full_viewplane;
366 viewplane.
xmin, viewplane.
xmax, viewplane.
ymin, viewplane.
ymax, clipsta, clipend);
370 viewplane.
xmin, viewplane.
xmax, viewplane.
ymin, viewplane.
ymax, clipsta, clipend);
394 const float rect_scale[2])
407 bool use_lock_ofs =
false;
422 copy_v3_v3(vec, ob_eval->object_to_world().location());
427 mul_m4_v3(ob_eval->object_to_world().ptr(), vec);
445 float persmat[4][4], persinv[4][4];
462 vec[0] /= rect_scale[0];
463 vec[1] /= rect_scale[1];
499 bool continue_pass =
false;
504 continue_pass =
true;
508 if (
data->pass == 0) {
517 return continue_pass;
536 const Object *obact =
static_cast<const Object *
>(user_data);
555 const bool do_material_slot_selection)
569 bool draw_surface =
true;
598 } object_filter = {
nullptr,
nullptr};
609 switch (select_filter) {
614 object_filter.user_data = obact;
626 for (; md; md = md->
next) {
642 object_filter.user_data = ob_pose_list;
672 drw_select_loop_user_data.
pass = 0;
673 drw_select_loop_user_data.
hits = 0;
674 drw_select_loop_user_data.
buffer = buffer;
675 drw_select_loop_user_data.
rect = ▭
678 draw_surface =
false;
685 do_material_slot_selection,
688 &drw_select_loop_user_data,
690 object_filter.user_data);
691 hits = drw_select_loop_user_data.
hits;
701 drw_select_loop_user_data.
pass = 0;
702 drw_select_loop_user_data.
hits = 0;
703 drw_select_loop_user_data.
buffer = buffer;
704 drw_select_loop_user_data.
rect = ▭
715 do_material_slot_selection,
718 &drw_select_loop_user_data,
720 object_filter.user_data);
721 hits = drw_select_loop_user_data.
hits;
778 ushort local_view_bits = 0;
785 for (; sl; sl = sl->
next) {
796 for (
int i = 0;
i < 16;
i++) {
797 if ((local_view_bits & (1 <<
i)) == 0) {
812 const bool frame_selected,
813 const int smooth_viewtx,
820 bool changed =
false;
830 if (local_view_bit == 0) {
842 base->local_view_bits &= ~local_view_bit;
847 base_iter->local_view_bits |= local_view_bit;
858 base->local_view_bits |= local_view_bit;
862 base->local_view_bits &= ~local_view_bit;
871 if (changed ==
false) {
886 *v3d->
localvd = blender::dna::shallow_copy(*v3d);
895 Object *camera_old =
nullptr;
896 float dist_new, ofs_new[3];
901 if (frame_selected) {
913 if (
size < 0.0001f) {
931 sview_params.
ofs = ofs_new;
933 sview_params.
dist = ok_dist ? &dist_new :
nullptr;
939 depsgraph, wm, win, area, v3d, region, smooth_viewtx, &sview_params);
953 const bool frame_selected,
954 const int smooth_viewtx)
957 bool changed =
false;
965 base->local_view_bits &= ~v3d->local_view_uid;
973 if (rv3d->
localvd ==
nullptr) {
996 if (rv3d->
localvd ==
nullptr) {
1001 Object *camera_old_rv3d, *camera_new_rv3d;
1013 sview_params.
camera = camera_new_rv3d;
1021 depsgraph, wm, win, area, v3d, region, smooth_viewtx, &sview_params);
1039 const bool frame_selected,
1040 const int smooth_viewtx)
1042 if (v3d->
localvd ==
nullptr) {
1056 depsgraph, wm, win, scene, view_layer, area, frame_selected, smooth_viewtx);
1075 depsgraph, wm, win, scene, view_layer, area, frame_selected, smooth_viewtx);
1095 if (v3d->
localvd ==
nullptr) {
1111 ot->name =
"Local View";
1112 ot->description =
"Toggle display of selected object(s) separately and centered in view";
1113 ot->idname =
"VIEW3D_OT_localview";
1126 "Move the view to frame the selected objects");
1135 bool changed =
false;
1139 base->local_view_bits &= ~v3d->local_view_uid;
1142 if (base == view_layer->
basact) {
1143 view_layer->
basact =
nullptr;
1187 ot->name =
"Remove from Local View";
1188 ot->description =
"Move selected objects out of local view";
1189 ot->idname =
"VIEW3D_OT_localview_remove_from";
1204 ushort local_collections_uid,
1207 ushort local_view_bits = 0;
1224 if (local_collections_uid && ((local_collections_uid & local_view_bits) == 0)) {
1225 return local_collections_uid;
1229 for (
int i = 0;
i < 16;
i++) {
1230 if ((local_view_bits & (1 <<
i)) == 0) {
1240 const ushort local_view_bit)
1275 if (local_view_bit == 0) {
1292 uint local_view_bit = ~0;
1293 bool do_reset =
false;
1303 local_view_bit &= ~v3d->local_collections_uid;
1317 else if (reset_all && (do_reset || (local_view_bit != ~0))) {
1332#ifdef WITH_XR_OPENXR
1349void ED_view3d_xr_mirror_update(
const ScrArea *area,
const View3D *v3d,
const bool enable)
1387 if (xr_shading->
prop) {
1389 xr_shading->
prop =
nullptr;
1393 const int old_xr_shading_flag = xr_shading->
flag;
1395 xr_shading->
flag = (xr_shading->
flag & ~flag_copy) | (old_xr_shading_flag & flag_copy);
Blender kernel action and pose functionality.
bPoseChannel * BKE_pose_channel_find_name(const bPose *pose, const char *name)
Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
ScrArea * CTX_wm_area(const bContext *C)
wmWindow * CTX_wm_window(const bContext *C)
Object * CTX_data_active_object(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
Object * CTX_data_edit_object(const bContext *C)
Main * CTX_data_main(const bContext *C)
wmWindowManager * CTX_wm_manager(const bContext *C)
View3D * CTX_wm_view3d(const bContext *C)
ViewLayer * CTX_data_view_layer(const bContext *C)
void IDP_FreeProperty(IDProperty *prop)
IDProperty * IDP_CopyProperty(const IDProperty *prop) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
void BKE_view_layer_synced_ensure(const Scene *scene, ViewLayer *view_layer)
void BKE_layer_collection_local_sync(const Scene *scene, ViewLayer *view_layer, const View3D *v3d)
#define FOREACH_BASE_IN_EDIT_MODE_BEGIN(_scene, _view_layer, _v3d, _instance)
#define FOREACH_BASE_IN_EDIT_MODE_END
ListBase * BKE_view_layer_object_bases_get(ViewLayer *view_layer)
Object * BKE_view_layer_edit_object_get(const ViewLayer *view_layer)
bool BKE_id_is_editable(const Main *bmain, const ID *id)
ModifierData * BKE_modifiers_get_virtual_modifierlist(const Object *ob, VirtualModifierData *data)
General operations, lookup, etc. for blender objects.
void BKE_object_tfm_protected_backup(const Object *ob, ObjectTfmProtectedChannels *obtfm)
Object * BKE_object_pose_armature_get(Object *ob)
void BKE_object_tfm_protected_restore(Object *ob, const ObjectTfmProtectedChannels *obtfm, short protectflag)
void BKE_object_minmax(Object *ob, blender::float3 &r_min, blender::float3 &r_max)
bool BKE_object_is_mode_compat(const Object *ob, eObjectMode object_mode)
void BKE_report(ReportList *reports, eReportType type, const char *message)
bool BKE_scene_uses_blender_workbench(const Scene *scene)
bool BKE_scene_uses_blender_eevee(const Scene *scene)
int BLI_linklist_index(const LinkNode *list, const void *ptr) ATTR_WARN_UNUSED_RESULT
#define BLI_linklist_prepend_alloca(listp, ptr)
#define LISTBASE_FOREACH(type, var, list)
MINLINE float max_fff(float a, float b, float c)
void mul_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
void normalize_m4_m4(float rmat[4][4], const float mat[4][4]) ATTR_NONNULL()
void translate_m4(float mat[4][4], float Tx, float Ty, float Tz)
void mul_m4_v3(const float M[4][4], float r[3])
bool invert_m4_m4(float inverse[4][4], const float mat[4][4])
void mul_mat3_m4_v3(const float mat[4][4], float r[3])
void quat_to_mat4(float m[4][4], const float q[4])
void mat4_normalized_to_quat(float q[4], const float mat[4][4])
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void negate_v3_v3(float r[3], const float a[3])
void mid_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void mul_v2_v2fl(float r[2], const float a[2], float f)
void BLI_rcti_init_pt_radius(struct rcti *rect, const int xy[2], int size)
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
#define INIT_MINMAX(min, max)
void DEG_id_tag_update(ID *id, unsigned int flags)
void DEG_id_type_tag(Main *bmain, short id_type)
void DEG_tag_on_visible_update(Main *bmain, bool do_time)
void DEG_relations_tag_update(Main *bmain)
T * DEG_get_original(T *id)
T * DEG_get_evaluated(const Depsgraph *depsgraph, T *id)
@ eModifierType_GreasePencilArmature
#define OB_MODE_ALL_WEIGHT_PAINT
#define BASE_SELECTED(v3d, base)
#define V3D_CAMERA_SCENE(scene, v3d)
@ V3D_SHADING_WORLD_ORIENTATION
#define RV3D_LOCK_FLAGS(rv3d)
@ V3D_RUNTIME_LOCAL_MAYBE_EMPTY
@ V3D_RUNTIME_XR_SESSION_ROOT
@ RV3D_LOCK_ANY_TRANSFORM
void DRW_gpu_context_disable()
bool(*)(Object *ob, void *user_data) DRW_ObjectFilterFn
void DRW_gpu_context_enable()
void DRW_draw_select_loop(Depsgraph *depsgraph, ARegion *region, View3D *v3d, bool use_obedit_skip, bool draw_surface, bool use_nearest, bool do_material_sub_selection, const rcti *rect, DRW_SelectPassFn select_pass_fn, void *select_pass_user_data, DRW_ObjectFilterFn object_filter_fn, void *object_filter_user_data)
void ED_view3d_local_stats_free(View3D *v3d)
void ED_area_tag_redraw(ScrArea *area)
bool ED_operator_scene_editable(bContext *C)
bool ED_operator_view3d_active(bContext *C)
#define XRAY_ENABLED(v3d)
void ED_view3d_to_object(const Depsgraph *depsgraph, Object *ob, const float ofs[3], const float quat[4], float dist)
bool ED_view3d_context_user_region(bContext *C, View3D **r_v3d, ARegion **r_region)
bool ED_view3d_lock(RegionView3D *rv3d)
void ED_view3d_lastview_store(RegionView3D *rv3d)
float ED_view3d_radius_to_dist(const View3D *v3d, const ARegion *region, const Depsgraph *depsgraph, char persp, bool use_aspect, float radius)
void ED_view3d_draw_setup_view(const wmWindowManager *wm, wmWindow *win, Depsgraph *depsgraph, Scene *scene, ARegion *region, View3D *v3d, const float viewmat[4][4], const float winmat[4][4], const rcti *rect)
bool ED_view3d_viewplane_get(const Depsgraph *depsgraph, const View3D *v3d, const RegionView3D *rv3d, int winx, int winy, rctf *r_viewplane, float *r_clip_start, float *r_clip_end, float *r_pixsize)
@ VIEW3D_SELECT_PICK_NEAREST
bool ED_view3d_camera_to_view_selected(Main *bmain, Depsgraph *depsgraph, const Scene *scene, Object *camera_ob)
@ VIEW3D_SELECT_FILTER_NOP
@ VIEW3D_SELECT_FILTER_OBJECT_MODE_LOCK
@ VIEW3D_SELECT_FILTER_WPAINT_POSE_MODE_LOCK
float ED_view3d_dist_soft_min_get(const View3D *v3d, bool use_persp_range)
bool ED_operator_rv3d_user_region_poll(bContext *C)
bool ED_view3d_area_user_region(const ScrArea *area, const View3D *v3d, ARegion **r_region)
void GPU_matrix_ortho_set(float left, float right, float bottom, float top, float near, float far)
void GPU_matrix_frustum_set(float left, float right, float bottom, float top, float near, float far)
#define GPU_matrix_projection_get(x)
void GPU_select_cache_end()
bool GPU_select_is_cached()
unsigned int GPU_select_end()
void GPU_select_begin_next(GPUSelectBuffer *buffer, const rcti *input, GPUSelectMode mode, int oldhits)
void GPU_select_cache_load_id()
uint GPU_select_buffer_remove_by_id(blender::MutableSpan< GPUSelectResult > hit_results, uint select_id)
void GPU_select_cache_begin()
@ GPU_SELECT_PICK_NEAREST
void GPU_depth_test(GPUDepthTest test)
Read Guarded memory(de)allocation.
void UI_Theme_Store(bThemeState *theme_state)
void UI_Theme_Restore(const bThemeState *theme_state)
void UI_SetTheme(int spacetype, int regionid)
BMesh const char void * data
BPy_StructRNA * depsgraph
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
void reset()
clear internal cached data and reset random seed
void resize(const int64_t new_size)
MutableSpan< T > as_mutable_span()
void * MEM_mallocN(size_t len, const char *str)
void MEM_freeN(void *vmemh)
void base_select(Base *base, eObjectSelect_Mode mode)
VecBase< float, 3 > float3
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
GPUSelectMode gpu_select_mode
ListBase layer_collections
unsigned short local_collections_bits
struct ModifierData * next
struct SmoothView3DStore * sms
struct RegionView3D * localvd
struct ToolSettings * toolsettings
unsigned short local_collections_uid
struct Object * ob_center
unsigned short local_view_uid
struct View3DShading shading
struct ReportList * reports
XrSessionSettings session_settings
void ED_view3d_smooth_view(bContext *C, View3D *v3d, ARegion *region, int smooth_viewtx, const V3D_SmoothParams *sview)
void ED_view3d_smooth_view_force_finish_no_camera_lock(const Depsgraph *depsgraph, wmWindowManager *wm, wmWindow *win, const Scene *scene, View3D *v3d, ARegion *region)
void ED_view3d_smooth_view_ex(const Depsgraph *depsgraph, wmWindowManager *wm, wmWindow *win, ScrArea *area, View3D *v3d, ARegion *region, int smooth_viewtx, const V3D_SmoothParams *sview)
void ED_view3d_smooth_view_force_finish(bContext *C, View3D *v3d, ARegion *region)
static void local_collections_reset_uuid(LayerCollection *layer_collection, const ushort local_view_bit)
void view3d_viewmatrix_set(const Depsgraph *depsgraph, const Scene *scene, const View3D *v3d, RegionView3D *rv3d, const float rect_scale[2])
void VIEW3D_OT_localview(wmOperatorType *ot)
int view3d_gpu_select(const ViewContext *vc, GPUSelectBuffer *buffer, const rcti *input, eV3DSelectMode select_mode, eV3DSelectObjectFilter select_filter)
static void view3d_local_collections_reset(const Main *bmain, const uint local_view_bit)
static wmOperatorStatus view3d_setobjectascamera_exec(bContext *C, wmOperator *op)
static uint free_localview_bit(Main *bmain)
void view3d_gpu_select_cache_end()
static void obmat_to_viewmat(RegionView3D *rv3d, Object *ob)
void VIEW3D_OT_localview_remove_from(wmOperatorType *ot)
void VIEW3D_OT_camera_to_view_selected(wmOperatorType *ot)
static bool drw_select_loop_pass(eDRWSelectStage stage, void *user_data)
static wmOperatorStatus view3d_camera_to_view_selected_exec(bContext *C, wmOperator *op)
static bool drw_select_filter_object_mode_lock(Object *ob, void *user_data)
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)
static bool drw_select_filter_object_mode_lock_for_weight_paint(Object *ob, void *user_data)
static wmOperatorStatus localview_remove_from_exec(bContext *C, wmOperator *op)
int view3d_gpu_select_ex(const ViewContext *vc, GPUSelectBuffer *buffer, const rcti *input, eV3DSelectMode select_mode, eV3DSelectObjectFilter select_filter, const bool do_material_slot_selection)
static void sync_viewport_camera_smoothview(bContext *C, View3D *v3d, Object *ob, const int smooth_viewtx)
static wmOperatorStatus view3d_camera_to_view_exec(bContext *C, wmOperator *)
int view3d_gpu_select_with_id_filter(const ViewContext *vc, GPUSelectBuffer *buffer, const rcti *input, eV3DSelectMode select_mode, eV3DSelectObjectFilter select_filter, uint select_id)
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 wmOperatorStatus localview_exec(bContext *C, wmOperator *op)
eV3DSelectObjectFilter ED_view3d_select_filter_from_mode(const Scene *scene, const Object *obact)
static bool localview_remove_from_poll(bContext *C)
void view3d_gpu_select_cache_begin()
void ED_view3d_local_collections_reset(const bContext *C, const bool reset_all)
bool ED_view3d_local_collections_set(const Main *bmain, View3D *v3d)
static uint free_localcollection_bit(const Main *bmain, ushort local_collections_uid, bool *r_reset)
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)
void view3d_winmatrix_set(const Depsgraph *depsgraph, ARegion *region, const View3D *v3d, const rcti *rect)
void VIEW3D_OT_camera_to_view(wmOperatorType *ot)
static bool view3d_camera_to_view_poll(bContext *C)
bool ED_operator_rv3d_user_region_poll(bContext *C)
void VIEW3D_OT_object_as_camera(wmOperatorType *ot)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
int WM_operator_smooth_viewtx_get(const wmOperator *op)
bool WM_xr_session_is_ready(const wmXrData *xr)
bool WM_xr_session_exists(const wmXrData *xr)