116 ot->
name =
"Align Camera to View";
117 ot->
description =
"Set camera view to active view";
118 ot->
idname =
"VIEW3D_OT_camera_to_view";
146 if (camera_ob ==
nullptr) {
161 ot->
name =
"Camera Fit Frame to Selected";
162 ot->
description =
"Move the camera so selected objects are framed";
163 ot->
idname =
"VIEW3D_OT_camera_to_view_selected";
182 const int smooth_viewtx)
189 View3D *other_v3d =
reinterpret_cast<View3D *
>(&space_link);
190 if (other_v3d == v3d) {
193 if (other_v3d->
camera == ob) {
198 ListBaseT<ARegion> *lb = (&space_link == area.
spacedata.first_) ?
201 for (
ARegion &other_region : *lb) {
203 if (other_region.regiondata) {
212 sview_params.
ofs = other_rv3d->
ofs;
214 sview_params.
dist = &other_rv3d->
dist;
215 sview_params.
lens = &other_v3d->
lens;
221 C, other_v3d, &other_region, smooth_viewtx, &sview_params);
264 if (camera_old != ob) {
268 sview_params.
ofs = rv3d->
ofs;
300 ot->
name =
"Set Active Object as Camera";
301 ot->
description =
"Set the active object as the active camera for this view or scene";
302 ot->
idname =
"VIEW3D_OT_object_as_camera";
325 float clipsta, clipend;
340 printf(
"%s: %d %d %f %f %f %f %f %f\n",
356 viewplane.
xmin = full_viewplane.
xmin +
358 viewplane.
ymin = full_viewplane.
ymin +
360 viewplane.
xmax = full_viewplane.
xmin +
362 viewplane.
ymax = full_viewplane.
ymin +
366 viewplane = full_viewplane;
371 viewplane.
xmin, viewplane.
xmax, viewplane.
ymin, viewplane.
ymax, clipsta, clipend);
375 viewplane.
xmin, viewplane.
xmax, viewplane.
ymin, viewplane.
ymax, clipsta, clipend);
409 const float rect_scale[2])
422 bool use_lock_ofs =
false;
437 copy_v3_v3(vec, ob_eval->object_to_world().location());
442 mul_m4_v3(ob_eval->object_to_world().ptr(), vec);
460 float persmat[4][4], persinv[4][4];
477 vec[0] /= rect_scale[0];
478 vec[1] /= rect_scale[1];
515 bool continue_pass =
false;
521 continue_pass =
true;
525 if (
data->pass == 0) {
534 return continue_pass;
567 const_cast<Object *
>(obweight)))
585 if (std::optional<eV3DSelectObjectFilter> filter_override =
588 return *filter_override;
599 const Object *obact =
static_cast<const Object *
>(user_data);
606 const Object *obact =
static_cast<const Object *
>(user_data);
626 const bool do_material_slot_selection)
638 bool draw_surface =
true;
644 const int xy[2] = {input->
xmin, input->
ymin};
667 } object_filter = {
nullptr,
nullptr};
680 switch (select_filter) {
685 object_filter.user_data = obact;
693 object_filter.user_data = obact;
705 for (; md; md = md->
next) {
721 object_filter.user_data = ob_pose_list;
740 wm, vc->
win, depsgraph, scene, region, v3d, vc->
rv3d->
viewmat,
nullptr, &rect);
751 drw_select_loop_user_data.
pass = 0;
752 drw_select_loop_user_data.
hits = 0;
753 drw_select_loop_user_data.
buffer = buffer;
754 drw_select_loop_user_data.
rect = ▭
755 drw_select_loop_user_data.
radius = select_radius;
758 draw_surface =
false;
764 do_material_slot_selection,
767 &drw_select_loop_user_data,
769 object_filter.user_data);
770 hits = drw_select_loop_user_data.
hits;
780 drw_select_loop_user_data.
pass = 0;
781 drw_select_loop_user_data.
hits = 0;
782 drw_select_loop_user_data.
buffer = buffer;
783 drw_select_loop_user_data.
rect = ▭
784 drw_select_loop_user_data.
radius = select_radius;
794 do_material_slot_selection,
797 &drw_select_loop_user_data,
799 object_filter.user_data);
800 hits = drw_select_loop_user_data.
hits;
805 wm, vc->
win, depsgraph, scene, region, v3d, vc->
rv3d->
viewmat,
nullptr,
nullptr);
825 return view3d_gpu_select_ex(vc, buffer, input, select_mode, select_filter, select_shape,
false);
859 ushort local_view_bits = 0;
866 for (; sl; sl = sl->
next) {
877 for (
int i = 0; i < 16; i++) {
878 if ((local_view_bits & (1 << i)) == 0) {
893 const bool frame_selected,
894 const int smooth_viewtx,
901 bool changed =
false;
911 if (local_view_bit == 0) {
923 base.local_view_bits &= ~local_view_bit;
928 base_iter->local_view_bits |= local_view_bit;
939 base.local_view_bits |= local_view_bit;
943 base.local_view_bits &= ~local_view_bit;
949 size = std::max({box[0], box[1], box[2]});
952 if (changed ==
false) {
966 v3d->
localvd = MEM_new<View3D>(
"localview");
976 Object *camera_old =
nullptr;
977 float dist_new, ofs_new[3];
981 if (frame_selected) {
998 if (size < 0.0001f) {
1016 sview_params.
ofs = ofs_new;
1018 sview_params.
dist = ok_dist ? &dist_new :
nullptr;
1024 depsgraph,
wm, win, area, v3d, ®ion, smooth_viewtx, &sview_params);
1038 const bool frame_selected,
1039 const int smooth_viewtx)
1042 bool changed =
false;
1044 if (v3d->
localvd ==
nullptr) {
1050 base.local_view_bits &= ~v3d->local_view_uid;
1058 if (rv3d->
localvd ==
nullptr) {
1081 if (rv3d->
localvd ==
nullptr) {
1085 if (frame_selected && depsgraph) {
1086 Object *camera_old_rv3d, *camera_new_rv3d;
1098 sview_params.
camera = camera_new_rv3d;
1106 depsgraph,
wm, win, area, v3d, ®ion, smooth_viewtx, &sview_params);
1124 const bool frame_selected,
1125 const int smooth_viewtx)
1127 if (v3d->
localvd ==
nullptr) {
1141 depsgraph,
wm, win, scene, view_layer, area, frame_selected, smooth_viewtx);
1160 depsgraph,
wm, win, scene, view_layer, area, frame_selected, smooth_viewtx);
1180 if (v3d->
localvd ==
nullptr) {
1196 ot->
name =
"Local View";
1197 ot->
description =
"Toggle display of selected object(s) separately and centered in view";
1198 ot->
idname =
"VIEW3D_OT_localview";
1211 "Move the view to frame the selected objects");
1220 bool changed =
false;
1224 base.local_view_bits &= ~v3d->local_view_uid;
1227 if (&base == view_layer->
basact) {
1228 view_layer->
basact =
nullptr;
1272 ot->
name =
"Remove from Local View";
1273 ot->
description =
"Move selected objects out of local view";
1274 ot->
idname =
"VIEW3D_OT_localview_remove_from";
1289 ushort local_collections_uid,
1292 ushort local_view_bits = 0;
1309 if (local_collections_uid && ((local_collections_uid & local_view_bits) == 0)) {
1310 return local_collections_uid;
1314 for (
int i = 0; i < 16; i++) {
1315 if ((local_view_bits & (1 << i)) == 0) {
1325 const ushort local_view_bit)
1360 if (local_view_bit == 0) {
1377 uint local_view_bit = ~0;
1378 bool do_reset =
false;
1388 local_view_bit &= ~v3d->local_collections_uid;
1402 else if (reset_all && (do_reset || (local_view_bit != ~0))) {
1417#ifdef WITH_XR_OPENXR
1419static void view3d_xr_mirror_begin(RegionView3D *rv3d)
1434void ED_view3d_xr_mirror_update(
const ScrArea *area,
const View3D *v3d,
const bool enable)
1442 view3d_xr_mirror_begin(
static_cast<RegionView3D *
>(region_rv3d->regiondata));
1445 view3d_xr_mirror_end(
static_cast<RegionView3D *
>(region_rv3d->regiondata));
1456 if (v3d->shading.type !=
OB_SOLID) {
1472 if (xr_shading->prop) {
1474 xr_shading->prop =
nullptr;
1479 *xr_shading = v3d->shading;
1480 xr_shading->flag = (xr_shading->flag & ~flag_copy) | (old_xr_shading_flag & flag_copy);
1481 if (v3d->shading.prop) {
Blender kernel action and pose functionality.
#define FOREACH_BASE_IN_EDIT_MODE_BEGIN(_bmain, _scene, _view_layer, _v3d, _instance)
#define FOREACH_BASE_IN_EDIT_MODE_END
General operations, lookup, etc. for blender objects.
#define BLI_linklist_prepend_alloca(listp, ptr)
#define OB_MODE_ALL_WEIGHT_PAINT
#define OBPOSE_FROM_OBACT(ob)
#define V3D_CAMERA_SCENE(scene, v3d)
#define OBWEIGHTPAINT_ALL_FROM_OBACT(ob)
#define RV3D_LOCK_FLAGS(rv3d)
#define XRAY_ENABLED(v3d)
Read Blender memory allocation and freeing.
#define INIT_MINMAX(min, max)
void resize(const int64_t new_size)
MutableSpan< T > as_mutable_span()
void camera(KernelGlobals &kg, const ShadingData &sd, float3 &outview, float &outdepth, float &outdist)
internal::ShallowDataConstRef< T > shallow_copy(const T &other)
void base_select(Base *base, eObjectSelect_Mode mode)
void theme_store(bThemeState *theme_state)
void theme_set(int spacetype, int regionid)
void theme_restore(const bThemeState *theme_state)
void DRW_gpu_context_enable()
static bool drw_select_loop_pass(eDRWSelectStage stage, void *user_data)
@ V3D_OVERLAY_BONE_SELECT
void GPU_matrix_frustum_set(float left, float right, float bottom, float top, float near, float far)
bool ED_view3d_context_user_region(bContext *C, View3D **r_v3d, ARegion **r_region)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
static uint free_localview_bit(Main *bmain)
void view3d_viewmatrix_set(const Depsgraph *depsgraph, const Scene *scene, const View3D *v3d, RegionView3D *rv3d, const float rect_scale[2])
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)
MINLINE void negate_v3_v3(float r[3], const float a[3])
void DRW_draw_select_loop(Depsgraph *depsgraph, ARegion *region, View3D *v3d, 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)
@ V3D_RUNTIME_LOCAL_MAYBE_EMPTY
@ V3D_RUNTIME_XR_SESSION_ROOT
bool ED_operator_scene_editable(bContext *C)
bool ED_view3d_camera_to_view_selected(Main *bmain, Depsgraph *depsgraph, const Scene *scene, Object *camera_ob)
ScrArea * CTX_wm_area(const bContext *C)
static void sync_viewport_camera_smoothview(bContext *C, View3D *v3d, Object *ob, const int smooth_viewtx)
static wmOperatorStatus view3d_camera_to_view_selected_exec(bContext *C, wmOperator *op)
void VIEW3D_OT_object_as_camera(wmOperatorType *ot)
void view3d_gpu_select_cache_end()
void BKE_object_tfm_protected_backup(const Object *ob, ObjectTfmProtectedChannels *obtfm)
bool ED_view3d_local_collections_set(const Main *bmain, View3D *v3d)
bool ED_operator_rv3d_user_region_poll(bContext *C)
static void local_collections_reset_uuid(LayerCollection *layer_collection, const ushort local_view_bit)
MINLINE void copy_v3_v3(float r[3], const float a[3])
void VIEW3D_OT_localview(wmOperatorType *ot)
void VIEW3D_OT_localview_remove_from(wmOperatorType *ot)
@ GPU_SELECT_PICK_NEAREST
bool WM_xr_session_exists(const wmXrData *xr)
float ED_view3d_radius_to_dist(const View3D *v3d, const ARegion *region, const Depsgraph *depsgraph, eRegionView3D_Persp persp, bool use_aspect, float radius)
bool(*)(Object *ob, void *user_data) DRW_ObjectFilterFn
IDProperty * IDP_CopyProperty(const IDProperty *prop) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
void mat4_normalized_to_quat(float q[4], const float mat[4][4])
bool invert_m4_m4(float inverse[4][4], const float mat[4][4])
@ eModifierType_GreasePencilArmature
Object * BKE_modifiers_is_deformed_by_armature(Object *ob)
int WM_operator_smooth_viewtx_get(const wmOperator *op)
void GPU_select_cache_load_id()
static wmOperatorStatus view3d_setobjectascamera_exec(bContext *C, wmOperator *op)
static bool drw_select_filter_object_mode_lock_same_type(Object *ob, void *user_data)
void mul_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
wmWindow * CTX_wm_window(const bContext *C)
static bool drw_select_filter_object_mode_lock_for_weight_paint(Object *ob, void *user_data)
static void obmat_to_viewmat(RegionView3D *rv3d, Object *ob)
void GPU_select_begin_next(GPUSelectBuffer *buffer, const rcti *input, int radius, GPUSelectMode mode, int oldhits)
void translate_m4(float mat[4][4], float Tx, float Ty, float Tz)
void VIEW3D_OT_camera_to_view_selected(wmOperatorType *ot)
static std::optional< eV3DSelectObjectFilter > view3d_select_filter_from_mode_lock_override(const View3D *v3d, const Object *obact)
@ RV3D_LOCK_ANY_TRANSFORM
unsigned int GPU_select_end()
static bool localview_remove_from_poll(bContext *C)
@ V3D_SHADING_WORLD_ORIENTATION
ViewLayer * CTX_data_view_layer(const bContext *C)
void view3d_gpu_select_cache_begin()
uint GPU_select_buffer_remove_by_id(MutableSpan< GPUSelectResult > hit_results, uint select_id)
void DEG_tag_on_visible_update(Main *bmain, bool do_time)
float ED_view3d_dist_soft_min_get(const View3D *v3d, bool use_persp_range)
@ VIEW3D_SELECT_FILTER_NOP
@ VIEW3D_SELECT_FILTER_WPAINT_POSE_MODE_LOCK
@ VIEW3D_SELECT_FILTER_OBJECT_MODE_LOCK
@ VIEW3D_SELECT_FILTER_OBJECT_MODE_LOCK_SAME_TYPE
void GPU_select_cache_end()
int BLI_linklist_index(const LinkNode *list, const void *ptr) ATTR_WARN_UNUSED_RESULT
void mul_m4_v3(const float M[4][4], float r[3])
static uint free_localcollection_bit(const Main *bmain, ushort local_collections_uid, bool *r_reset)
void DRW_gpu_context_disable()
void BKE_object_minmax(Object *ob, float3 &r_min, float3 &r_max)
bool BKE_scene_uses_blender_eevee(const Scene *scene)
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)
Object * BKE_view_layer_edit_object_get(const ViewLayer *view_layer)
Main * DEG_get_bmain(const Depsgraph *graph)
void DEG_id_tag_update(ID *id, unsigned int flags)
void BKE_report(ReportList *reports, eReportType type, const char *message)
BMesh const char void * data
T * DEG_get_evaluated(const Depsgraph *depsgraph, T *id)
void ED_view3d_local_stats_free(View3D *v3d)
eV3DSelectObjectFilter ED_view3d_select_filter_from_mode(const Scene *scene, const View3D *v3d, const Object *obact)
BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
wmWindowManager * CTX_wm_manager(const bContext *C)
Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C, bool rna_write_check=false)
@ VIEW3D_SELECT_PICK_NEAREST
Object * CTX_data_edit_object(const bContext *C)
void DEG_id_type_tag(Main *bmain, short id_type)
ModifierData * BKE_modifiers_get_virtual_modifierlist(const Object *ob, VirtualModifierData *data)
void ED_view3d_smooth_view_force_finish_no_camera_lock(const Depsgraph *depsgraph, wmWindowManager *wm, wmWindow *win, const Scene *scene, View3D *v3d, ARegion *region)
bool GPU_select_is_cached()
bool BKE_layer_collection_local_sync(const Main &bmain, const Scene *scene, ViewLayer *view_layer, const View3D *v3d)
bool BKE_view_layer_synced_ensure(const Main &bmain, const Scene *scene, ViewLayer *view_layer)
bool WM_xr_session_is_ready(const wmXrData *xr)
bool ED_operator_view3d_active(bContext *C)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
static wmOperatorStatus view3d_camera_to_view_exec(bContext *C, wmOperator *)
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)
MINLINE void mul_v2_v2fl(float r[2], const float a[2], float f)
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
static bool view3d_camera_to_view_poll(bContext *C)
int view3d_gpu_select_with_id_filter(const ViewContext *vc, GPUSelectBuffer *buffer, const rcti *input, eV3DSelectMode select_mode, eV3DSelectObjectFilter select_filter, uint select_id)
void mul_mat3_m4_v3(const float mat[4][4], float r[3])
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)
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 wmOperatorStatus localview_remove_from_exec(bContext *C, wmOperator *op)
void view3d_winmatrix_set(const Depsgraph *depsgraph, ARegion *region, const View3D *v3d, const rcti *rect)
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
void mid_v3_v3v3(float r[3], const float a[3], const float b[3])
bool ED_view3d_lock(RegionView3D *rv3d)
T * DEG_get_original(T *id)
static bool drw_select_filter_object_mode_lock(Object *ob, void *user_data)
void rotate_m4(float mat[4][4], char axis, float angle)
bool BKE_scene_uses_blender_workbench(const Scene *scene)
void transpose_m4(float R[4][4])
Main * CTX_data_main(const bContext *C)
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
void VIEW3D_OT_camera_to_view(wmOperatorType *ot)
void IDP_FreeProperty(IDProperty *prop)
void GPU_matrix_ortho_set(float left, float right, float bottom, float top, float near, float far)
void ED_view3d_smooth_view_force_finish(bContext *C, View3D *v3d, ARegion *region)
MINLINE void negate_v4(float r[4])
void ED_view3d_lastview_store(RegionView3D *rv3d)
void DEG_relations_tag_update(Main *bmain)
Scene * CTX_data_scene(const bContext *C)
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)
int view3d_gpu_select_ex(const ViewContext *vc, GPUSelectBuffer *buffer, const rcti *input, eV3DSelectMode select_mode, eV3DSelectObjectFilter select_filter, eV3DSelectShape select_shape, bool do_material_slot_selection)
VecBase< float, 3 > float3
bool ED_view3d_area_user_region(const ScrArea *area, const View3D *v3d, ARegion **r_region)
void ED_view3d_to_object(const Depsgraph *depsgraph, Object *ob, const float ofs[3], const float quat[4], float dist, float roll)
static void view3d_local_collections_reset(const Main *bmain, const uint local_view_bit)
void GPU_select_cache_begin()
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
const float(* GPU_matrix_projection_get(float m[4][4]))[4]
void normalize_m4_m4(float rmat[4][4], const float mat[4][4]) ATTR_NONNULL()
bool BKE_id_is_editable(const Main *bmain, const ID *id)
void BLI_rcti_init_pt_radius(struct rcti *rect, const int xy[2], int size)
bool BKE_object_is_mode_compat(const Object *ob, eObjectMode object_mode)
void GPU_depth_test(GPUDepthTest test)
int view3d_gpu_select(const ViewContext *vc, GPUSelectBuffer *buffer, const rcti *input, eV3DSelectMode select_mode, eV3DSelectObjectFilter select_filter, eV3DSelectShape select_shape)
Object * CTX_data_active_object(const bContext *C)
void ED_view3d_local_collections_reset(const bContext *C, bool reset_all)
void ED_view3d_smooth_view(bContext *C, View3D *v3d, ARegion *region, int smooth_viewtx, const V3D_SmoothParams *sview)
ListBaseT< Base > * BKE_view_layer_object_bases_get(ViewLayer *view_layer)
bPoseChannel * BKE_pose_channel_find_name(const bPose *pose, const char *name)
void BKE_object_tfm_protected_restore(Object *ob, const ObjectTfmProtectedChannels *obtfm, short protectflag)
View3D * CTX_wm_view3d(const bContext *C)
void quat_to_mat4(float m[4][4], const float q[4])
void ED_area_tag_redraw(ScrArea *area)
static wmOperatorStatus localview_exec(bContext *C, wmOperator *op)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
GPUSelectMode gpu_select_mode
eLayerCollection_Flag flag
ListBaseT< LayerCollection > layer_collections
unsigned short local_collections_bits
ListBaseT< Scene > scenes
ListBaseT< bScreen > screens
struct ModifierData * next
eObject_ProtectFlag protectflag
struct RegionView3D * localvd
eRegionView3D_ViewAxisRoll view_axis_roll
eRegionView3D_Persp persp
struct SmoothView3DStore * sms
ListBaseT< ViewLayer > view_layers
struct ToolSettings * toolsettings
ListBaseT< ARegion > regionbase
ListBaseT< SpaceLink > spacedata
ListBaseT< ARegion > regionbase
struct Object * ob_center
unsigned short local_collections_uid
unsigned short local_view_uid
ListBaseT< LayerCollection > layer_collections
ListBaseT< struct ScrArea > areabase
wmOperatorStatus(*) exec(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
bool(*) poll(bContext *C) ATTR_WARN_UNUSED_RESULT
struct ReportList * reports