106 ot->
name =
"Align Camera to View";
108 ot->
idname =
"VIEW3D_OT_camera_to_view";
134 if (camera_ob ==
nullptr) {
149 ot->
name =
"Camera Fit Frame to Selected";
150 ot->
description =
"Move the camera so selected objects are framed";
151 ot->
idname =
"VIEW3D_OT_camera_to_view_selected";
170 const int smooth_viewtx)
177 View3D *other_v3d =
reinterpret_cast<View3D *
>(space_link);
178 if (other_v3d == v3d) {
181 if (other_v3d->
camera == ob) {
186 ListBase *lb = (space_link == area->spacedata.first) ? &area->regionbase :
187 &space_link->regionbase;
190 if (other_region->regiondata) {
199 sview_params.
ofs = other_rv3d->
ofs;
201 sview_params.
dist = &other_rv3d->
dist;
202 sview_params.
lens = &other_v3d->
lens;
208 C, other_v3d, other_region, smooth_viewtx, &sview_params);
242 if (v3d->
scenelock && scene->camera != ob) {
249 if (camera_old != ob) {
253 sview_params.
ofs = rv3d->
ofs;
285 ot->
name =
"Set Active Object as Camera";
286 ot->
description =
"Set the active object as the active camera for this view or scene";
287 ot->
idname =
"VIEW3D_OT_object_as_camera";
310 float clipsta, clipend;
325 printf(
"%s: %d %d %f %f %f %f %f %f\n",
341 viewplane.
xmin = full_viewplane.
xmin +
343 viewplane.
ymin = full_viewplane.
ymin +
345 viewplane.
xmax = full_viewplane.
xmin +
347 viewplane.
ymax = full_viewplane.
ymin +
351 viewplane = full_viewplane;
356 viewplane.
xmin, viewplane.
xmax, viewplane.
ymin, viewplane.
ymax, clipsta, clipend);
360 viewplane.
xmin, viewplane.
xmax, viewplane.
ymin, viewplane.
ymax, clipsta, clipend);
384 const float rect_scale[2])
397 bool use_lock_ofs =
false;
412 copy_v3_v3(vec, ob_eval->object_to_world().location());
417 mul_m4_v3(ob_eval->object_to_world().ptr(), vec);
435 float persmat[4][4], persinv[4][4];
452 vec[0] /= rect_scale[0];
453 vec[1] /= rect_scale[1];
489 bool continue_pass =
false;
494 continue_pass =
true;
498 if (data->pass == 0) {
504 continue_pass = (hits > 0);
511 return continue_pass;
530 const Object *obact =
static_cast<const Object *
>(user_data);
549 const bool do_material_slot_selection)
568 const bool do_passes = ((is_pick_select ==
false) &&
571 bool draw_surface =
true;
576 if (input->xmin == input->xmax) {
577 const int xy[2] = {input->xmin, input->ymin};
585 if (is_pick_select) {
610 } object_filter = {
nullptr,
nullptr};
621 switch (select_filter) {
626 object_filter.user_data = obact;
638 &virtual_modifier_data);
639 for (; md; md = md->
next) {
648 object_filter.user_data = ob_pose_list;
678 drw_select_loop_user_data.
pass = 0;
679 drw_select_loop_user_data.
hits = 0;
680 drw_select_loop_user_data.
buffer = buffer;
681 drw_select_loop_user_data.
rect = ▭
684 draw_surface =
false;
691 do_material_slot_selection,
694 &drw_select_loop_user_data,
696 object_filter.user_data);
697 hits = drw_select_loop_user_data.
hits;
707 drw_select_loop_user_data.
pass = 0;
708 drw_select_loop_user_data.
hits = 0;
709 drw_select_loop_user_data.
buffer = buffer;
710 drw_select_loop_user_data.
rect = ▭
721 do_material_slot_selection,
724 &drw_select_loop_user_data,
726 object_filter.user_data);
727 hits = drw_select_loop_user_data.
hits;
730 G.f &= ~G_FLAG_PICKSEL;
785 ushort local_view_bits = 0;
792 for (; sl; sl = sl->
next) {
803 for (
int i = 0; i < 16; i++) {
804 if ((local_view_bits & (1 << i)) == 0) {
819 const bool frame_selected,
820 const int smooth_viewtx,
823 View3D *v3d =
static_cast<View3D *
>(area->spacedata.first);
824 float min[3], max[3], box[3];
827 bool changed =
false;
837 if (local_view_bit == 0) {
849 base->local_view_bits &= ~local_view_bit;
854 base_iter->local_view_bits |= local_view_bit;
865 base->local_view_bits |= local_view_bit;
869 base->local_view_bits &= ~local_view_bit;
875 size =
max_fff(box[0], box[1], box[2]);
878 if (changed ==
false) {
893 *v3d->
localvd = blender::dna::shallow_copy(*v3d);
902 Object *camera_old =
nullptr;
903 float dist_new, ofs_new[3];
909 if (frame_selected) {
920 if (size < 0.0001f) {
937 sview_params.
ofs = ofs_new;
939 sview_params.
dist = ok_dist ? &dist_new :
nullptr;
945 depsgraph, wm, win, area, v3d, region, smooth_viewtx, &sview_params);
959 const bool frame_selected,
960 const int smooth_viewtx)
962 View3D *v3d =
static_cast<View3D *
>(area->spacedata.first);
963 bool changed =
false;
971 base->local_view_bits &= ~v3d->local_view_uid;
979 if (rv3d->
localvd ==
nullptr) {
1002 if (rv3d->
localvd ==
nullptr) {
1007 Object *camera_old_rv3d, *camera_new_rv3d;
1019 sview_params.
camera = camera_new_rv3d;
1027 depsgraph, wm, win, area, v3d, region, smooth_viewtx, &sview_params);
1045 const bool frame_selected,
1046 const int smooth_viewtx)
1048 if (v3d->
localvd ==
nullptr) {
1062 depsgraph, wm, win, scene, view_layer, area, frame_selected, smooth_viewtx);
1081 depsgraph, wm, win, scene, view_layer, area, frame_selected, smooth_viewtx);
1101 if (v3d->
localvd ==
nullptr) {
1118 ot->
description =
"Toggle display of selected object(s) separately and centered in view";
1119 ot->
idname =
"VIEW3D_OT_localview";
1131 "Move the view to frame the selected objects");
1140 bool changed =
false;
1144 base->local_view_bits &= ~v3d->local_view_uid;
1147 if (base == view_layer->
basact) {
1148 view_layer->
basact =
nullptr;
1192 ot->
name =
"Remove from Local View";
1193 ot->
description =
"Move selected objects out of local view";
1194 ot->
idname =
"VIEW3D_OT_localview_remove_from";
1209 ushort local_collections_uid,
1212 ushort local_view_bits = 0;
1229 if (local_collections_uid && ((local_collections_uid & local_view_bits) == 0)) {
1230 return local_collections_uid;
1234 for (
int i = 0; i < 16; i++) {
1235 if ((local_view_bits & (1 << i)) == 0) {
1245 const ushort local_view_bit)
1277 v3d->
flag &= ~V3D_LOCAL_COLLECTIONS;
1280 if (local_view_bit == 0) {
1297 uint local_view_bit = ~(0);
1298 bool do_reset =
false;
1322 else if (reset_all && (do_reset || (local_view_bit != ~(0)))) {
1337#ifdef WITH_XR_OPENXR
1354void ED_view3d_xr_mirror_update(
const ScrArea *area,
const View3D *v3d,
const bool enable)
1392 if (xr_shading->
prop) {
1394 xr_shading->
prop =
nullptr;
1398 const int old_xr_shading_flag = xr_shading->
flag;
1400 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)
bool BKE_object_is_mode_compat(const Object *ob, eObjectMode object_mode)
void BKE_object_minmax(Object *ob, float r_min[3], float r_max[3])
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)
MINLINE float max_ff(float a, float b)
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)
Object * DEG_get_original_object(Object *object)
Object * DEG_get_evaluated_object(const Depsgraph *depsgraph, Object *object)
#define OB_MODE_ALL_WEIGHT_PAINT
#define BASE_SELECTED(v3d, base)
#define V3D_CAMERA_SCENE(scene, v3d)
@ USER_GPU_FLAG_NO_DEPT_PICK
#define RV3D_LOCK_FLAGS(rv3d)
@ V3D_RUNTIME_XR_SESSION_ROOT
@ V3D_SHADING_WORLD_ORIENTATION
@ 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_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
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()
@ GPU_SELECT_NEAREST_SECOND_PASS
@ GPU_SELECT_NEAREST_FIRST_PASS
@ GPU_SELECT_PICK_NEAREST
bool GPU_select_is_cached()
unsigned int GPU_select_end()
void GPU_select_cache_load_id()
void GPU_select_begin_next(GPUSelectBuffer *buffer, const rcti *input, eGPUSelectMode mode, int oldhits)
uint GPU_select_buffer_remove_by_id(blender::MutableSpan< GPUSelectResult > hit_results, uint select_id)
void GPU_select_cache_begin()
void GPU_depth_test(eGPUDepthTest 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)
void reset()
clear internal cached data and reset random seed
void resize(const int64_t new_size)
MutableSpan< T > as_mutable_span()
const Depsgraph * depsgraph
draw_view in_light_buf[] float
void *(* MEM_mallocN)(size_t len, const char *str)
void MEM_freeN(void *vmemh)
void base_select(Base *base, eObjectSelect_Mode mode)
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)
eGPUSelectMode gpu_select_mode
ListBase layer_collections
unsigned short local_collections_bits
struct ModifierData * next
struct SmoothView3DStore * sms
struct RegionView3D * localvd
struct SceneStats * local_stats
unsigned short local_collections_uid
struct Object * ob_center
unsigned short local_view_uid
struct View3DShading shading
bool(* poll)(bContext *C) ATTR_WARN_UNUSED_RESULT
int(* exec)(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
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 view3d_opengl_select_cache_begin()
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])
static int localview_remove_from_exec(bContext *C, wmOperator *op)
void VIEW3D_OT_localview(wmOperatorType *ot)
static void view3d_local_collections_reset(const Main *bmain, const uint local_view_bit)
static uint free_localview_bit(Main *bmain)
static void obmat_to_viewmat(RegionView3D *rv3d, Object *ob)
static int localview_exec(bContext *C, wmOperator *op)
void VIEW3D_OT_localview_remove_from(wmOperatorType *ot)
void VIEW3D_OT_camera_to_view_selected(wmOperatorType *ot)
static int view3d_camera_to_view_selected_exec(bContext *C, wmOperator *op)
static bool drw_select_loop_pass(eDRWSelectStage stage, void *user_data)
static bool drw_select_filter_object_mode_lock(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)
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)
int view3d_opengl_select(const ViewContext *vc, GPUSelectBuffer *buffer, const rcti *input, eV3DSelectMode select_mode, eV3DSelectObjectFilter select_filter)
static bool drw_select_filter_object_mode_lock_for_weight_paint(Object *ob, void *user_data)
static void sync_viewport_camera_smoothview(bContext *C, View3D *v3d, Object *ob, 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 view3d_camera_to_view_exec(bContext *C, wmOperator *)
eV3DSelectObjectFilter ED_view3d_select_filter_from_mode(const Scene *scene, const Object *obact)
static bool localview_remove_from_poll(bContext *C)
void ED_view3d_local_collections_reset(const bContext *C, const bool reset_all)
int view3d_opengl_select_with_id_filter(const ViewContext *vc, GPUSelectBuffer *buffer, const rcti *input, eV3DSelectMode select_mode, eV3DSelectObjectFilter select_filter, uint select_id)
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_opengl_select_cache_end()
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)
static int view3d_setobjectascamera_exec(bContext *C, wmOperator *op)
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)