Blender V5.3
wm_xr_location_scouting.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2026 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
12
13#include <fmt/format.h>
14
15#include "BKE_camera.h"
16#include "BKE_context.hh"
17#include "BKE_lib_id.hh"
18
19#include "BLI_listbase.hh"
20#include "BLI_math_matrix_c.hh"
22#include "BLI_math_vector_c.hh"
23#include "BLI_rect.hh"
24#include "BLI_time.hh"
25
26#include "DNA_camera_types.h"
27
29
30#include "GHOST_Types.hh"
31
32#include "GPU_framebuffer.hh"
33#include "GPU_immediate.hh"
34#include "GPU_matrix.hh"
35#include "GPU_state.hh"
36#include "GPU_viewport.hh"
37
38#include "RNA_access.hh"
39#include "RNA_prototypes.hh"
40
41#include "BLF_api.hh"
42
43#include "UI_interface.hh"
45#include "interface_intern.hh"
46
47#include "WM_api.hh"
48
49#include "wm_xr_intern.hh"
50
51namespace blender {
52
53/* -------------------------------------------------------------------- */
56
58{
59 PointerRNA scene_ptr = RNA_id_pointer_create(&scene->id);
60 PropertyRNA *captures_prop = RNA_struct_find_property(&scene_ptr, "vr_captures");
61
62 if (captures_prop == nullptr) {
63 return true;
64 }
65
66 if (RNA_property_collection_is_empty(&scene_ptr, captures_prop)) {
67 /* Empty capture collection. */
68 return true;
69 }
70
71 return false;
72}
73
74std::optional<XrLocationScoutingCapture> wm_xr_location_scouting_get_active_capture(Scene *scene)
75{
76 /* Workaround: To allow for conditionally registering the location scouting capture collection on
77 * the Scene while not polluting the main DNA Scene struct, and generally keep the
78 * definition simple and contained, the VRCapture collection is defined on the Python
79 * add-on side. Values are then obtained back here via RNA introspection.
80 *
81 * NOTE: This functions thus *needs* be kept in sync with the VRCapture Python class. */
82
84 return std::nullopt;
85 }
86
87 PointerRNA scene_ptr = RNA_id_pointer_create(&scene->id);
88 PropertyRNA *captures_prop = RNA_struct_find_property(&scene_ptr, "vr_captures");
89 BLI_assert(captures_prop != nullptr);
90
91 PropertyRNA *idx_prop = RNA_struct_find_property(&scene_ptr, "vr_captures_selected");
92 const int capture_idx = RNA_property_int_get(&scene_ptr, idx_prop);
93
94 PointerRNA current_capture;
95 RNA_property_collection_lookup_int(&scene_ptr, captures_prop, capture_idx, &current_capture);
96
97 /* Captured pose (location / orientation). */
98 PropertyRNA *location_prop = RNA_struct_find_property(&current_capture, "location");
99 PropertyRNA *orientation_prop = RNA_struct_find_property(&current_capture, "orientation");
100
101 float3 capture_location;
102 float4 capture_orientation;
103 RNA_property_float_get_array(&current_capture, location_prop, capture_location);
104 RNA_property_float_get_array(&current_capture, orientation_prop, capture_orientation);
105
106 GHOST_XrPose capture_pose;
107 capture_pose.is_active = true;
108 copy_v3_v3(capture_pose.position, capture_location);
109 copy_qt_qt(capture_pose.orientation_quat, capture_orientation);
110
111 /* Captured view settings (lens / DoF). */
112 PropertyRNA *lens_focal_prop = RNA_struct_find_property(&current_capture, "lens_focal");
113 PropertyRNA *dof_enabled_prop = RNA_struct_find_property(&current_capture, "dof_enabled");
114 PropertyRNA *dof_distance_prop = RNA_struct_find_property(&current_capture, "dof_distance");
115 PropertyRNA *dof_fstop_prop = RNA_struct_find_property(&current_capture, "dof_fstop");
116
117 XrLocationScoutingCapture capture = {
118 .position = capture_location,
119 .orientation_quat = capture_orientation,
120 .lens_focal = RNA_property_float_get(&current_capture, lens_focal_prop),
121 .dof_enabled = RNA_property_boolean_get(&current_capture, dof_enabled_prop),
122 .dof_distance = RNA_property_float_get(&current_capture, dof_distance_prop),
123 .dof_fstop = RNA_property_float_get(&current_capture, dof_fstop_prop)};
124
125 return std::make_optional(capture);
126}
127
129 const XrLocationScoutingCapture &capture)
130{
131 /* Create a GHOST_XrPose from a XrLocationScoutingCapture. Used to prevent storing GHOST types
132 * inside XrLocationScoutingCapture while still being able to use wm_xr_pose_* functions. */
133 GHOST_XrPose pose;
134
135 pose.is_active = true;
136 copy_v3_v3(pose.position, capture.position);
137 copy_qt_qt(pose.orientation_quat, capture.orientation_quat);
138
139 return pose;
140}
141
143
144/* -------------------------------------------------------------------- */
147
149{
150 switch (settings->viewfinder_hand) {
152 return "/user/hand/left";
154 return "/user/hand/right";
155 default:
157 return nullptr;
158 }
159}
160
162 const wmXrSessionState *state)
163{
164 const char *user_path = wm_xr_viewfinder_get_hand_user_path(settings);
165
166 for (wmXrController &controller : state->controllers) {
167 if (STREQ(controller.subaction_path, user_path) && controller.grip_active) {
168 return &controller;
169 }
170 }
171
172 return nullptr;
173}
174
176{
177 switch (state->viewfinder.active_mode) {
179 return "active_action_live";
181 return "active_action_playback";
183 return "active_action_confirm";
184 }
185
186 return "";
187}
188
190{
191 switch (state->viewfinder.active_mode) {
193 return int(state->viewfinder.active_action_live);
195 return int(state->viewfinder.active_action_playback);
197 return int(state->viewfinder.active_action_confirm);
198 }
199
200 return 0;
201}
202
204{
206 wmXrActionData *actiondata = static_cast<wmXrActionData *>(event->customdata);
207
208 if (!settings->viewfinder_enabled) {
209 return false;
210 }
211
212 return STREQ(actiondata->user_path, wm_xr_viewfinder_get_hand_user_path(settings));
213}
214
216{
217 const RenderData *scene_render_settings = &CTX_data_scene(C)->r;
218
219 /* Use scene render aspect ratio. */
220 const float render_x = scene_render_settings->xsch * scene_render_settings->xasp;
221 const float render_y = scene_render_settings->ysch * scene_render_settings->yasp;
222 const float render_aspect_ratio = render_y / render_x;
223
224 constexpr float minimum_width = 4.3f;
225 const float viewfinder_width = minimum_width + settings->viewfinder_scale;
226 const float viewfinder_height = viewfinder_width * render_aspect_ratio;
227
228 rctf viewfinder_rect = {};
229 BLI_rctf_resize(&viewfinder_rect, viewfinder_width, viewfinder_height);
230
231 return viewfinder_rect;
232}
233
235{
236 /* Turn the user-facing 0 -> 1 factor into a 1 -> 1.5 factor. */
237 return (settings->viewfinder_passepartout_overscan * 0.5) + 1.0f;
238}
239
241 const wmXrSessionState *state,
242 const float viewfinder_height,
243 float r_mat[4][4])
244{
245 const wmXrController *viewfinder_controller = wm_xr_viewfinder_get_controller(settings, state);
246
247 if (!viewfinder_controller) {
248 return false;
249 }
250
251 /* Compute vertical offset. */
252 constexpr float base_controller_offset = -0.1f;
253 const float height_offset = (viewfinder_height / 2) * wmXrViewfinderState::xr_ui_unit_fac * -1;
254 const float viewfinder_vertical_offset = base_controller_offset + height_offset;
255
256 /* Obtain viewfinder capture mat from the chosen controller grip mat. */
257 float viewfinder_mat[4][4];
258 copy_m4_m4(viewfinder_mat, viewfinder_controller->grip_mat);
259 translate_m4(viewfinder_mat, 0.0f, 0.0f, viewfinder_vertical_offset);
260 rotate_m4(viewfinder_mat, 'X', -M_PI_2);
261
262 copy_m4_m4(r_mat, viewfinder_mat);
263 return true;
264}
265
267 float raw_capture_mat[4][4],
268 float r_smoothed_mat[4][4])
269{
270 /* Take the raw capture matrix, apply movement smoothing from stored state position/orientation
271 * while also updating them, and return the resulting smoothed viewfinder transform matrix. */
272 float raw_capture_position[3];
273 float raw_capture_orientation_quat[4];
274 mat4_to_loc_quat(raw_capture_position, raw_capture_orientation_quat, raw_capture_mat);
275
276 const double current_time = BLI_time_now_seconds();
277 const double delta_t = current_time - state->viewfinder.smoothing_delta_t;
278
279 /* Delta-T threshold used to reset smoothing when switching between Playback/Live mode. */
280 constexpr double delta_t_threshold = 0.25;
281
282 if (state->viewfinder.smoothing_delta_t != 0.0 && delta_t < delta_t_threshold) {
283 /* Apply exponential movement smoothing. */
284 constexpr float movement_smoothing_speed = 25.0f;
285 const float clamped_delta = min_ff(delta_t, 0.1f);
286 const float factor = 1.0f - exp(-clamped_delta * movement_smoothing_speed);
287
288 interp_v3_v3v3(state->viewfinder.capture_position,
289 state->viewfinder.capture_position,
290 raw_capture_position,
291 factor);
292 interp_qt_qtqt(state->viewfinder.capture_orientation_quat,
293 state->viewfinder.capture_orientation_quat,
294 raw_capture_orientation_quat,
295 factor);
296 }
297 else {
298 /* Initialize smoothing, or reset if delta_t threshold was exceeded. */
299 copy_v3_v3(state->viewfinder.capture_position, raw_capture_position);
300 copy_qt_qt(state->viewfinder.capture_orientation_quat, raw_capture_orientation_quat);
301 }
302
303 state->viewfinder.smoothing_delta_t = current_time;
304
305 quat_to_mat4(r_smoothed_mat, state->viewfinder.capture_orientation_quat);
306 copy_v3_v3(r_smoothed_mat[3], state->viewfinder.capture_position);
307}
308
310
311/* -------------------------------------------------------------------- */
314
316{
318 XrSessionSettings *settings = &xr_data->session_settings;
319
320 if (!settings->viewfinder_enabled) {
321 return;
322 }
323
324 float viewfinder_render_viewmat[4][4] = {};
325
326 Camera *cam_render_data = state->viewfinder.render_cam_data_id; /* Allocated ID. */
327 CameraParams cam_render_params;
328 BKE_camera_params_init(&cam_render_params);
329
330 bContext *xr_context = WM_xr_session_context_get(xr_data);
331 Scene *scene = CTX_data_scene(xr_context);
332
333 switch (state->viewfinder.active_mode) {
335 const rctf viewfinder_rect = wm_xr_viewfinder_get_rect(xr_context, settings);
336 const float viewfinder_height = BLI_rctf_size_y(&viewfinder_rect);
337
338 float raw_capture_mat[4][4];
339 if (!wm_xr_viewfinder_get_capture_mat(settings, state, viewfinder_height, raw_capture_mat)) {
340 /* Invalid viewfinder capture matrix, cannot draw, early return. */
341 return;
342 }
343
344 /* Build final capture camera matrix for rendering, apply movement smoothing over time to
345 * stabilize the Viewfinder Live capture view. */
346 float viewfinder_capture_mat[4][4];
347 wm_xr_viewfinder_transform_update_smoothed(state, raw_capture_mat, viewfinder_capture_mat);
348
349 invert_m4_m4(viewfinder_render_viewmat, viewfinder_capture_mat);
350
351 cam_render_params.lens = state->viewfinder.capture_lens_focal;
353 cam_render_data->dof.flag, state->viewfinder.capture_dof_enabled, CAM_DOF_ENABLED);
354 cam_render_data->dof.aperture_fstop = state->viewfinder.capture_dof_fstop;
355 cam_render_data->dof.focus_distance = state->viewfinder.capture_dof_distance;
356
357 break;
358 }
361 auto capture = wm_xr_location_scouting_get_active_capture(scene);
362 if (!capture.has_value()) {
363 /* Nothing to draw, early return. */
364 return;
365 }
366
367 const GHOST_XrPose capture_pose = wm_xr_location_scouting_capture_to_ghost_pose(*capture);
368 wm_xr_pose_to_imat(&capture_pose, viewfinder_render_viewmat);
369 cam_render_params.lens = capture->lens_focal;
370
371 SET_FLAG_FROM_TEST(cam_render_data->dof.flag, capture->dof_enabled, CAM_DOF_ENABLED);
372 cam_render_data->dof.focus_distance = capture->dof_distance;
373 cam_render_data->dof.aperture_fstop = capture->dof_fstop;
374
375 break;
376 }
377 default:
379 break;
380 }
381
382 /* Compute obtained camera parameter from Live / Playback for render, using scene render
383 * aspect ratio. */
384 const RenderData *render_settings = &scene->r;
385 BKE_camera_params_compute_viewplane(&cam_render_params,
386 render_settings->xsch,
387 render_settings->ysch,
388 render_settings->xasp,
389 render_settings->yasp);
390 /* In Live mode, scale viewplane by passepartout overscan. */
391 if (state->viewfinder.active_mode == XR_VIEWFINDER_MODE_LIVE) {
392 BLI_rctf_mul(&cam_render_params.viewplane, wm_xr_viewfinder_get_pp_overscan(settings));
393 }
394
395 BKE_camera_params_compute_matrix(&cam_render_params);
396
397 float viewfinder_winmat[4][4];
398 copy_m4_m4(viewfinder_winmat, cam_render_params.winmat);
399
400 /* Set viewfinder View3D draw flags, using base XR draw flags with some overridden exceptions. */
401 int viewfinder_draw_flags = V3D_OFSDRAW_OVERRIDE_SCENE_SETTINGS | settings->draw_flags;
402 viewfinder_draw_flags &= ~V3D_OFSDRAW_SHOW_SELECTION; /* Always hide selection outlines. */
403 viewfinder_draw_flags &= ~V3D_OFSDRAW_XR_SHOW_CONTROLLERS; /* Always hide other XR controller. */
404 viewfinder_draw_flags &= ~V3D_OFSDRAW_XR_SHOW_CUSTOM_OVERLAYS; /* Always hide XR overlays. */
405
406 /* Always enable DoF in the View3D settings used by in the viewfinder rendered view
407 * for Workbench. */
408 View3DShading viewfinder_shading_settings = settings->shading;
409 viewfinder_shading_settings.flag |= V3D_SHADING_DEPTH_OF_FIELD;
410
411 /* Shim Viewfinder Camera Object to override the View3D with for rendering and pass it our
412 * cam_render_data ID. */
413 Object viewfinder_cam_ob = {};
414 viewfinder_cam_ob.type = OB_CAMERA;
415 viewfinder_cam_ob.data = id_cast<ID *>(cam_render_data);
416
417 Depsgraph *depsgraph = CTX_data_depsgraph_pointer(xr_context);
419 scene,
420 &viewfinder_shading_settings,
421 xr_context,
422 settings->shading.type,
427 viewfinder_draw_flags,
428 viewfinder_render_viewmat,
429 viewfinder_winmat,
430 settings->clip_start,
431 settings->clip_end,
432 1.0f,
433 true,
434 false,
435 true,
436 nullptr,
437 true,
438 &viewfinder_cam_ob,
439 state->viewfinder.offscreen,
440 state->viewfinder.viewport);
441}
442
444
445/* -------------------------------------------------------------------- */
453
455{
456 ui::Block *block = ui::block_begin(C, nullptr, __func__, emboss);
457
458 /* Since there are no windows in XR, use a dummy constant window size as aspect. */
459 const int2 win_size = {1600 * 2, 900 * 2};
460 const rcti winrct = {0, win_size[0] - 1, 0, win_size[1] - 1};
461
462 wmGetProjectionMatrix(block->winmat, &winrct);
463 block->aspect = 2.0f / fabsf(win_size[0] * block->winmat[0][0]);
464
466 ui::block_theme_style_set(block, ui::BLOCK_THEME_STYLE_POPUP); /* Can also use REGULAR here. */
467
468 return block;
469}
470
472{
473 /* This is a stripped down version of #ui::block_draw without background drawing (which relies
474 * on window coordinates), while also keeping the transform matrix from the outside GPU context
475 * for the block to be positioned in VR space. */
476
477 /* Fake fixed region winrct size values, for drawing to not depend on the window size. Values
478 * obtained from the window region used during development.
479 * TODO(@brainzman): Switch to a uniform size, and resize existing XR UI widgets accordingly.
480 */
481 ARegion region = {};
482 BLI_rcti_init(&region.winrct, 0, 1680, 0, 1760);
483
486
487 uiStyle style = *ui::style_get_dpi();
488 for (ui::Button &but : block->buttons()) {
489 rcti rect;
490 button_to_pixelrect(&rect, &region, block, &but);
491
492 if (rect.xmin < rect.xmax && rect.ymin < rect.ymax) {
493 draw_button(C, &region, &style, &but, &rect);
494 }
495 }
496
499}
500
502{
503 const uiStyle *style = ui::style_get_dpi();
504 const int viewfinder_width = style->widget.points * 50 * UI_SCALE_FAC;
505
506 using namespace blender;
507 return ui::block_layout(block,
510 0,
511 0,
512 viewfinder_width,
513 0,
514 0,
515 style);
516}
517
519 const wmXrSessionState *state)
520{
522
523 const float tab_width = UI_UNIT_X * 10.5f;
524
525 ui::Button *but = uiDefBut(block,
527 "Live Camera View",
528 0,
529 0,
530 tab_width,
531 UI_UNIT_Y,
532 nullptr,
533 0,
534 0,
535 "");
536 button_func_pushed_state_set(but, [&state](const ui::Button &) -> bool {
537 return state->viewfinder.active_mode == XR_VIEWFINDER_MODE_LIVE;
538 });
539
540 but = uiDefBut(block,
542 "Image Playback",
543 tab_width,
544 0,
545 tab_width,
546 UI_UNIT_Y,
547 nullptr,
548 0,
549 0,
550 "");
551 button_func_pushed_state_set(but, [&state](const ui::Button &) -> bool {
552 return state->viewfinder.active_mode == XR_VIEWFINDER_MODE_PLAYBACK;
553 });
554
555 ui::block_end(C, block);
556
557 return block;
558}
559
561 const wmXrSessionState *state)
562{
564 ui::Layout &layout = wm_xr_viewfinder_ui_layout(block);
565
566 if (state->viewfinder.active_mode == XR_VIEWFINDER_MODE_PLAYBACK) {
567 const std::string settings_left_side_label = fmt::format(
568 "Show active capture in space: {}",
569 state->viewfinder.playback_show_active_capture_in_space_enabled ? "on" : "off");
570 layout.label(settings_left_side_label.c_str(), ICON_NONE);
571 }
572 else if (state->viewfinder.active_mode == XR_VIEWFINDER_MODE_CONFIRM) {
573 layout.label("Confirm: Delete this shot?", ICON_NONE);
574 }
575
576 ui::block_end(C, block);
577
578 return block;
579}
580
582 const wmXrSessionState *state)
583{
585 ui::Layout &layout = wm_xr_viewfinder_ui_layout(block);
586
587 Scene *scene = CTX_data_scene(C);
588 PointerRNA scene_ptr = RNA_id_pointer_create(&scene->id);
589
590 /* Note: unsafe, relies on the VR add-on being loaded. */
591 PropertyRNA *captures_len_prop = RNA_struct_find_property(&scene_ptr, "vr_captures");
592 PropertyRNA *captures_idx_prop = RNA_struct_find_property(&scene_ptr, "vr_captures_selected");
593 const int captures_len = RNA_property_collection_length(&scene_ptr, captures_len_prop);
594 const int captures_idx = RNA_property_int_get(&scene_ptr, captures_idx_prop);
595
596 std::string settings_right_side_label;
597 switch (state->viewfinder.active_mode) {
598 /* \xe2\x80\x87 corresponds to a Unicode Figure Space (BLI_STR_UTF8_FIGURE_SPACE). */
600 settings_right_side_label = fmt::format(
601 "{:\xe2\x80\x87>3}mm DoF: {} d: {:\xe2\x80\x87<4.1f} f {:\xe2\x80\x87<3.1f}",
602 state->viewfinder.capture_lens_focal,
603 state->viewfinder.capture_dof_enabled ? "on " : "off",
604 state->viewfinder.capture_dof_distance,
605 state->viewfinder.capture_dof_fstop);
606 break;
609 /* Current capture indicator (`current capture idx / all captures`). */
610 if (captures_len > 0) {
611 const int width = captures_len >= 10 ? 2 : 1;
612 const char *pad_prefix = captures_len < 10 ? " " : "";
613 settings_right_side_label = fmt::format("{}{:\xe2\x80\x87>{}} / {:\xe2\x80\x87>{}}",
614 pad_prefix,
615 captures_idx + 1,
616 width,
617 captures_len,
618 width);
619 }
620 break;
621 default:
623 return nullptr;
624 }
625
626 layout.label(settings_right_side_label.c_str(), ICON_NONE);
627
628 ui::block_end(C, block);
629
630 return block;
631}
632
634 const wmXrSessionState *state)
635{
637 ui::Layout &layout = wm_xr_viewfinder_ui_layout(block);
638
639 const StringRefNull active_action_prop = wm_xr_viewfinder_get_active_mode_str(state);
640 int active_action_idx = wm_xr_viewfinder_get_active_action_idx(state);
641
643 &CTX_wm_manager(C)->id, RNA_XrViewfinderState, (void *)&state->viewfinder);
644 PropertyRNA *prop = RNA_struct_find_property(&ptr, active_action_prop.c_str());
645
646 const char *active_action_label;
647 RNA_property_enum_name(nullptr, &ptr, prop, active_action_idx, &active_action_label);
648 layout.label(active_action_label, ICON_NONE);
649
650 ui::block_end(C, block);
651
652 return block;
653}
654
656 const wmXrSessionState *state)
657{
659 ui::Layout &layout = wm_xr_viewfinder_ui_layout(block);
660 ui::Layout &row = layout.row(true);
661
662 layout.scale_y_set(1.1f);
663
665 &CTX_wm_manager(C)->id, RNA_XrViewfinderState, (void *)&state->viewfinder);
666 PropertyRNA *prop = RNA_struct_find_property(&ptr, "active_action_live");
667
668 if (state->viewfinder.active_mode == XR_VIEWFINDER_MODE_LIVE) {
669 /* Live mode, display each property enum separately for the DoF controls to be marked
670 * as disabled when DoF is disabled. */
671 layout.ui_units_x_set(8.0f); /* Width hack. */
672
673 ui::Layout &sub1 = row.row(true);
674 sub1.prop_enum(&ptr, prop, XR_VIEWFINDER_ACTION_LIVE_LENS, "", ICON_NONE);
675 sub1.prop_enum(&ptr, prop, XR_VIEWFINDER_ACTION_LIVE_DOF, "", ICON_NONE);
676
677 ui::Layout &sub2 = row.row(true);
678 /* Show these controls greyed-out if DoF is disabled. */
679 sub2.enabled_set(state->viewfinder.capture_dof_enabled);
680 sub2.prop_enum(&ptr, prop, XR_VIEWFINDER_ACTION_LIVE_FOCUS, "", ICON_NONE);
681 sub2.prop_enum(&ptr, prop, XR_VIEWFINDER_ACTION_LIVE_APERTURE, "", ICON_NONE);
682 }
683 else {
684 /* Playback and Confirm mode, directly draw the full enum prop. */
685 layout.scale_x_set(15.0f); /* Width hack. */
686
687 const StringRefNull active_action_prop = wm_xr_viewfinder_get_active_mode_str(state);
688 row.prop(
689 &ptr, active_action_prop.c_str(), ui::ITEM_R_EXPAND | ui::ITEM_R_ICON_ONLY, "", ICON_NONE);
690 }
691
692 ui::block_end(C, block);
693
694 return block;
695}
696
698 const wmXrSessionState *state)
699{
700 const bool empty_captures = wm_xr_location_scouting_is_captures_empty(CTX_data_scene(C));
701
703 ui::Layout &layout = wm_xr_viewfinder_ui_layout(block);
704
705 if (state->viewfinder.active_mode == XR_VIEWFINDER_MODE_PLAYBACK && empty_captures) {
706 layout.label("No shots captured yet.", ICON_NONE);
707 }
708
709 ui::block_end(C, block);
710
711 return block;
712}
713
715 const wmXrSessionState *state,
716 const rctf &viewfinder_rect)
717{
718 using BlockFuncPtr = decltype(&wm_xr_viewfinder_ui_mode_tabs_block);
719 const auto draw_block = [&](BlockFuncPtr block_func, float x_off, float y_off) {
721 GPU_matrix_translate_3f(x_off, y_off, 0.0f);
722 GPU_matrix_scale_1f(0.02f);
723
724 ui::Block *block = block_func(C, state);
726
728 };
729
730 const float mode_tabs_x = viewfinder_rect.xmin - 0.15f;
731 const float mode_tabs_y = viewfinder_rect.ymax + 0.45f;
732
733 draw_block(wm_xr_viewfinder_ui_mode_tabs_block, mode_tabs_x, mode_tabs_y);
734
735 const float settings_left_label_x = viewfinder_rect.xmin + 0.05f;
736 const float settings_right_label_x = state->viewfinder.active_mode == XR_VIEWFINDER_MODE_LIVE ?
737 viewfinder_rect.xmax - 3.7f :
738 viewfinder_rect.xmax - 0.8f;
739 const float settings_label_y = viewfinder_rect.ymax + 0.47f;
740
741 draw_block(
742 wm_xr_viewfinder_ui_settings_left_label_block, settings_left_label_x, settings_label_y);
743 draw_block(
744 wm_xr_viewfinder_ui_settings_right_label_block, settings_right_label_x, settings_label_y);
745
746 const float action_label_x = viewfinder_rect.xmin + 0.05f;
747 const float action_label_y = viewfinder_rect.ymin - 0.15f;
748
749 float action_enum_x = 0.0f;
750 switch (state->viewfinder.active_mode) {
752 action_enum_x = viewfinder_rect.xmax - 1.6f;
753 break;
755 action_enum_x = viewfinder_rect.xmax - 1.2f;
756 break;
758 action_enum_x = viewfinder_rect.xmax - 0.8f;
759 break;
760 default:
762 break;
763 }
764 const float action_enum_y = viewfinder_rect.ymin - 0.15f;
765
766 draw_block(wm_xr_viewfinder_ui_action_label_block, action_label_x, action_label_y);
767 draw_block(wm_xr_viewfinder_ui_action_enum_block, action_enum_x, action_enum_y);
768
769 constexpr float missing_label_x = -1.1f;
770 constexpr float missing_label_y = 0.1f;
771
772 draw_block(wm_xr_viewfinder_ui_missing_captures_label_block, missing_label_x, missing_label_y);
773}
774
776
777/* -------------------------------------------------------------------- */
780
782{
783 /* NOTE: This duplicates logic from the Python add-on VIEW3D_GGT_vr_captures gizmo, not ideal. */
784 if (state->viewfinder.active_mode != XR_VIEWFINDER_MODE_PLAYBACK ||
785 state->viewfinder.playback_show_active_capture_in_space_enabled == false)
786 {
787 return;
788 }
789
791 if (!capture.has_value()) {
792 return;
793 }
794
795 float capture_mat[4][4];
796
797 const GHOST_XrPose capture_pose = wm_xr_location_scouting_capture_to_ghost_pose(*capture);
798 wm_xr_pose_to_mat(&capture_pose, capture_mat);
799
800 /* Compute focal. */
801 constexpr float sensor_fit_fac = 36 * 2; /* Twice the default Camera sensor fit (36mm). */
802 const float focal = capture->lens_focal / sensor_fit_fac;
803
804 /* Compute aspect. */
805 const RenderData *render_settings = &CTX_data_scene(C)->r;
806 const float render_x = render_settings->xsch * render_settings->xasp;
807 const float render_y = render_settings->ysch * render_settings->yasp;
808 const float aspect_x = render_x < render_y ? render_x / render_y : 1;
809 const float aspect_y = render_x > render_y ? render_y / render_x : 1;
810 /* Base aspect to match native Blender Camera Gizmo (using Auto Sensor Fit). */
811 constexpr float base_aspect = 1.0f / 4.0f;
812 const float aspect[2] = {aspect_x * base_aspect, aspect_y * base_aspect};
813
814 const float corners[4][3] = {
815 {-aspect[0], -aspect[1], -focal},
816 {aspect[0], -aspect[1], -focal},
817 {aspect[0], aspect[1], -focal},
818 {-aspect[0], aspect[1], -focal},
819 };
820
821 constexpr float color[4] = {0.25f, 0.81f, 1.0f, 1.0f};
822
823 GPUVertFormat *format = immVertexFormat();
824 uint pos = GPU_vertformat_attr_add(format, "pos", gpu::VertAttrType::SFLOAT_32_32_32);
825 uint col = GPU_vertformat_attr_add(format, "color", gpu::VertAttrType::SFLOAT_32_32_32_32);
826
828 GPU_matrix_mul(capture_mat);
829
833
834 float viewport[4];
835 GPU_viewport_size_get_f(viewport);
836 immUniform2fv("viewportSize", &viewport[2]);
837 immUniform1f("lineWidth", 2.0f * U.pixelsize);
838
839 /* Camera frame. */
841 for (int i = 0; i < 4; i++) {
842 immAttr4fv(col, color);
843 immVertex3fv(pos, corners[i]);
844 }
845 immAttr4fv(col, color);
846 immVertex3fv(pos, corners[0]);
847 immEnd();
848
849 /* Camera frustum lines from origin to each corner. */
851 for (int i = 0; i < 4; i++) {
852 immAttr4fv(col, color);
853 immVertex3f(pos, 0.0f, 0.0f, 0.0f);
854 immAttr4fv(col, color);
855 immVertex3fv(pos, corners[i]);
856 }
857 immEnd();
858
862
864}
865
867
868/* -------------------------------------------------------------------- */
871
872static void wm_xr_viewfinder_ui_draw_background(const rctf &viewfinder_rect)
873{
874 float background_col[3];
876
877 rctf background_rect = viewfinder_rect;
878 BLI_rctf_pad(&background_rect, 0.2f, 0.6f);
879 BLI_rctf_translate(&background_rect, 0.0f, -0.1f);
880
881 rctf outline_rect = viewfinder_rect;
882 BLI_rctf_pad(&outline_rect, 0.08f, 0.08f);
883
884 rctf tabs_bg_rect = {.xmin = background_rect.xmin,
885 .xmax = background_rect.xmin + 4.55f,
886 .ymin = background_rect.ymax - 0.3f,
887 .ymax = background_rect.ymax + 0.45f};
888
890 /* Workaround: regain precision on the rect side by a factor of 100. */
891 GPU_matrix_scale_1f(0.01f);
892 BLI_rctf_mul(&background_rect, 100);
893 BLI_rctf_mul(&tabs_bg_rect, 100);
894 BLI_rctf_mul(&outline_rect, 100);
895
897
898 GPU_matrix_translate_3f(0.0f, 0.0f, -1.5f);
899
900 ui::draw_roundbox_3fv_alpha(&tabs_bg_rect, true, 16, background_col, 1.0f);
901 GPU_matrix_translate_3f(0.0f, 0.0f, 0.5f);
902 ui::draw_roundbox_3fv_alpha(&background_rect, true, 16, background_col, 1.0f);
903 GPU_matrix_translate_3f(0.0f, 0.0f, 0.5f);
905
907}
908
910 const rctf &rect,
911 const rctf &uv,
912 const float color[4])
913{
914 GPUVertFormat *format = immVertexFormat();
915 uint pos = GPU_vertformat_attr_add(format, "pos", gpu::VertAttrType::SFLOAT_32_32);
916 uint texco = GPU_vertformat_attr_add(format, "texCoord", gpu::VertAttrType::SFLOAT_32_32);
917
920
922
925
926 immRectf_with_texco(pos, texco, rect, uv);
927
930}
931
933 const wmXrSessionState *state,
934 const rctf &viewfinder_rect)
935{
937 const bool empty_captures = wm_xr_location_scouting_is_captures_empty(CTX_data_scene(C));
938
939 if (state->viewfinder.active_mode == XR_VIEWFINDER_MODE_PLAYBACK && empty_captures) {
940 return;
941 }
942
943 /* Obtain the Viewfinder view texture we computed in #wm_xr_draw_view. */
944 gpu::Texture *view_tex = GPU_offscreen_color_texture(state->viewfinder.offscreen);
945
946 constexpr rctf tex_uv = {0.0f, 1.0f, 0.0f, 1.0f};
947 constexpr float tex_color[4] = {1.0f, 1.0f, 1.0f, 1.0f};
948
949 wm_xr_viewfinder_ui_draw_texture(view_tex, viewfinder_rect, tex_uv, tex_color);
950}
951
953 const rctf &viewfinder_rect)
954{
955 gpu::Texture *logo_tex = state->viewfinder.backside_logo_texture;
956
957 /* Fit logo within viewfinder while maintaining aspect ratio. */
958 const float logo_aspect = GPU_texture_width(logo_tex) / GPU_texture_height(logo_tex);
959 const float logo_width = BLI_rctf_size_x(&viewfinder_rect);
960 const float logo_height = BLI_rctf_size_y(&viewfinder_rect);
961 const float width = min_ff(logo_width, logo_height * logo_aspect);
962
963 rctf logo_rect = viewfinder_rect;
964 BLI_rctf_resize(&logo_rect, width, width / logo_aspect);
965
966 /* Flip UV coords for horizontal mirror to draw on the backside of the viewfinder. */
967 const rctf tex_uv = {1.0f, 0.0f, 0.0f, 1.0f};
968 GPU_matrix_translate_3f(0.0f, 0.0f, -0.05f);
970}
971
973 const wmXrSessionState *state,
974 const rctf &vf_rect)
975{
976 /* Only draw overlays in Live capture mode, early return if there's no overlay to be drawn. */
977 if (state->viewfinder.active_mode != XR_VIEWFINDER_MODE_LIVE) {
978 return;
979 }
980 rctf capture_rect = vf_rect;
981 BLI_rctf_resize(&capture_rect,
984
985 GPUVertFormat *format = immVertexFormat();
986 uint pos = GPU_vertformat_attr_add(format, "pos", gpu::VertAttrType::SFLOAT_32_32);
987
990
991 /* Passepartout. */
992 immUniformColor4f(0.0f, 0.0f, 0.0f, settings->viewfinder_passepartout_opacity);
993
994 /* Main passepartout dark border strips. */
995 immRectf(pos, vf_rect.xmin, capture_rect.ymax, vf_rect.xmax, vf_rect.ymax);
996 immRectf(pos, vf_rect.xmin, vf_rect.ymin, vf_rect.xmax, capture_rect.ymin);
997 immRectf(pos, vf_rect.xmin, capture_rect.ymin, capture_rect.xmin, capture_rect.ymax);
998 immRectf(pos, capture_rect.xmax, capture_rect.ymin, vf_rect.xmax, capture_rect.ymax);
999
1000 /* White wire frame around capture area for the passepartout to be visible at 0 opacity. */
1001 immUniformColor4f(1.0f, 1.0f, 1.0f, 0.2f);
1003 immVertex2f(pos, capture_rect.xmin, capture_rect.ymin);
1004 immVertex2f(pos, capture_rect.xmax, capture_rect.ymin);
1005 immVertex2f(pos, capture_rect.xmax, capture_rect.ymax);
1006 immVertex2f(pos, capture_rect.xmin, capture_rect.ymax);
1007 immEnd();
1008
1009 /* Crosshair. */
1010 if (settings->viewfinder_crosshair_enabled) {
1011 const float center_x = BLI_rctf_cent_x(&capture_rect);
1012 const float center_y = BLI_rctf_cent_y(&capture_rect);
1013 const float crosshair_size = BLI_rctf_size_y(&capture_rect) * 0.1f;
1014
1015 constexpr float base_col[4] = {1.0f, 1.0f, 0.0f, 0.8f};
1016 constexpr float focus_hit_col[4] = {0.0f, 1.0f, 1.0f, 0.8f};
1017 constexpr float focus_miss_col[4] = {1.0f, 0.0f, 0.0f, 0.8f};
1018
1019 /* Interval during which the cursor changes color to indicate focus hit status. */
1020 constexpr double focus_hit_time = 0.15;
1021 const double last_focus_hit_delta = BLI_time_now_seconds() -
1022 state->viewfinder.last_focus_hit_time;
1023
1024 const float *crosshair_col = base_col;
1025
1026 /* Focus hit indicator color. */
1027 if (last_focus_hit_delta < focus_hit_time) {
1028 crosshair_col = state->viewfinder.last_focus_hit_success ? focus_hit_col : focus_miss_col;
1029 }
1030
1031 immUniformColor4fv(crosshair_col);
1033 /* Horizontal line. */
1034 immVertex2f(pos, center_x - crosshair_size, center_y);
1035 immVertex2f(pos, center_x + crosshair_size, center_y);
1036 /* Vertical line. */
1037 immVertex2f(pos, center_x, center_y - crosshair_size);
1038 immVertex2f(pos, center_x, center_y + crosshair_size);
1039 immEnd();
1040 }
1041
1044}
1045
1047 const rctf &viewfinder_rect)
1048{
1049 /* Do not apply the flash effect if we're in playback mode. */
1050 if (state->viewfinder.active_mode == XR_VIEWFINDER_MODE_PLAYBACK) {
1051 state->viewfinder.last_flash_trigger_time = 0.0;
1052 return;
1053 }
1054
1055 constexpr double flash_duration_sec = 0.4;
1056 constexpr float full_flash_alpha = 0.3f;
1057
1058 const double last_flash_delta = BLI_time_now_seconds() -
1059 state->viewfinder.last_flash_trigger_time;
1060
1061 if (last_flash_delta < flash_duration_sec) {
1062 const float flash_progress = last_flash_delta / flash_duration_sec;
1063 const float flash_alpha = interpf(0.0f, full_flash_alpha, flash_progress);
1064
1065 GPUVertFormat *flash_format = immVertexFormat();
1066 uint flash_pos = GPU_vertformat_attr_add(flash_format, "pos", gpu::VertAttrType::SFLOAT_32_32);
1067
1070 immUniformColor4f(1.0f, 1.0f, 1.0f, flash_alpha);
1071 immRectf(flash_pos,
1072 viewfinder_rect.xmin,
1073 viewfinder_rect.ymin,
1074 viewfinder_rect.xmax,
1075 viewfinder_rect.ymax);
1078 }
1079}
1080
1082 const XrSessionSettings *settings,
1084{
1085 if (!settings->viewfinder_enabled) {
1086 return;
1087 }
1088
1089 const rctf viewfinder_rect = wm_xr_viewfinder_get_rect(C, settings);
1090
1091 /* Initial transform setup. */
1092 float viewfinder_mat[4][4];
1093 const float viewfinder_height = BLI_rctf_size_y(&viewfinder_rect);
1094 if (!wm_xr_viewfinder_get_capture_mat(settings, state, viewfinder_height, viewfinder_mat)) {
1095 return;
1096 }
1097
1099 GPU_matrix_mul(viewfinder_mat);
1101
1102 /* Main background elements. */
1103 wm_xr_viewfinder_ui_draw_background(viewfinder_rect);
1104
1106 GPU_depth_mask(false);
1107
1108 /* Viewfinder view, capture flash and overlays. */
1110 wm_xr_viewfinder_ui_draw_capture_overlays(settings, state, viewfinder_rect);
1112
1113 /* UI Widgets. */
1114 wm_xr_viewfinder_ui_draw_widgets(C, state, viewfinder_rect);
1115
1116 /* Logo on the back side of the viewfinder. */
1118
1119 GPU_depth_mask(true);
1122
1123 /* Selected playback capture camera (drawn in world space). */
1125}
1126
1128
1129} // namespace blender
Camera data-block and utility functions.
#define M_PI_2
Platform independent time functions.
#define UI_SCALE_FAC
#define C
Definition RandGen.cpp:29
#define UI_UNIT_Y
#define UI_UNIT_X
#define BLI_assert_unreachable()
#define SET_FLAG_FROM_TEST(value, test, flag)
#define STREQ(a, b)
constexpr const char * c_str() const
#define exp
TEX_TEMPLATE DataVec texture(T, FltCoord, float=0.0f) RET
const int state
void get_color_3fv(int colorid, float col[3])
void widgetbase_draw_cache_begin()
void block_flag_enable(Block *block, int flag)
const uiStyle * style_get_dpi()
void widgetbase_draw_cache_end()
Block * block_begin(const bContext *C, ARegion *region, std::string name, EmbossType emboss)
void block_theme_style_set(Block *block, char theme_style)
void block_end(const bContext *C, Block *block, bool postpone_callbacks=false)
void draw_roundbox_3fv_alpha(const rctf *rect, bool filled, float rad, const float col[3], float alpha)
Layout & block_layout(Block *block, LayoutDirection direction, LayoutType type, int x, int y, int size, int em, int padding, const uiStyle *style)
void draw_roundbox_4fv(const rctf *rect, bool filled, float rad, const float col[4])
BMesh Iterators.
MINLINE float min_ff(float a, float b)
static float wm_xr_viewfinder_get_pp_overscan(const XrSessionSettings *settings)
UserDef U
Definition blender.cc:58
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
static ui::Block * wm_xr_viewfinder_ui_settings_left_label_block(const bContext *C, const wmXrSessionState *state)
static void wm_xr_viewfinder_ui_draw_texture(gpu::Texture *texture, const rctf &rect, const rctf &uv, const float color[4])
void wm_xr_pose_to_mat(const GHOST_XrPose *pose, float r_mat[4][4])
Definition wm_xr_draw.cc:44
void mat4_to_loc_quat(float loc[3], float quat[4], const float wmat[4][4])
void RNA_property_float_get_array(PointerRNA *ptr, PropertyRNA *prop, float *values)
void immEnd()
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
void GPU_matrix_scale_1f(float factor)
MINLINE void copy_v3_v3(float r[3], const float a[3])
unsigned int uint
Definition BKE_text.h:55
PointerRNA RNA_id_pointer_create(ID *id)
Depsgraph * CTX_data_depsgraph_pointer(const bContext *C)
bool wm_xr_viewfinder_operator_event_match_hand(bContext *C, const wmEvent *event)
@ XR_VIEWFINDER_MODE_CONFIRM
@ XR_VIEWFINDER_MODE_PLAYBACK
@ XR_VIEWFINDER_MODE_LIVE
GPUVertFormat * immVertexFormat()
bool RNA_property_enum_name(bContext *C, PointerRNA *ptr, PropertyRNA *prop, const int value, const char **r_name)
static rctf wm_xr_viewfinder_get_rect(const bContext *C, const XrSessionSettings *settings)
bool invert_m4_m4(float inverse[4][4], const float mat[4][4])
static void wm_xr_viewfinder_gizmo_draw_capture_camera(const bContext *C, wmXrSessionState *state)
void BLI_rctf_resize(struct rctf *rect, float x, float y)
Definition rct.cc:671
bContext * WM_xr_session_context_get(const wmXrData *xr)
void immBegin(GPUPrimType, uint vertex_len)
void BKE_camera_params_compute_viewplane(CameraParams *params, int winx, int winy, float aspx, float aspy)
static int wm_xr_viewfinder_get_active_action_idx(const wmXrSessionState *state)
@ V3D_OFSDRAW_SHOW_SELECTION
@ V3D_OFSDRAW_OVERRIDE_SCENE_SETTINGS
@ V3D_OFSDRAW_XR_SHOW_CONTROLLERS
@ V3D_OFSDRAW_XR_SHOW_CUSTOM_OVERLAYS
@ GPU_SAMPLER_EXTEND_MODE_CLAMP_TO_BORDER
@ GPU_PRIM_LINE_STRIP
@ GPU_PRIM_LINE_LOOP
void GPU_depth_mask(bool depth)
Definition gpu_state.cc:107
@ GPU_SAMPLER_FILTERING_LINEAR
void translate_m4(float mat[4][4], float Tx, float Ty, float Tz)
void immUniformColor4fv(const float rgba[4])
int RNA_property_collection_length(PointerRNA *ptr, PropertyRNA *prop)
static void wm_xr_viewfinder_ui_draw_background(const rctf &viewfinder_rect)
static ui::Block * wm_xr_viewfinder_ui_action_label_block(const bContext *C, const wmXrSessionState *state)
@ V3D_SHADING_DEPTH_OF_FIELD
static ui::Block * wm_xr_viewfinder_ui_mode_tabs_block(const bContext *C, const wmXrSessionState *state)
static GHOST_XrPose wm_xr_location_scouting_capture_to_ghost_pose(const XrLocationScoutingCapture &capture)
void immUnbindProgram()
void GPU_matrix_mul(const float m[4][4])
@ GPU_BLEND_NONE
Definition GPU_state.hh:88
@ GPU_BLEND_ALPHA
Definition GPU_state.hh:90
@ GPU_BLEND_ALPHA_PREMULT
Definition GPU_state.hh:91
bool RNA_property_boolean_get(PointerRNA *ptr, PropertyRNA *prop)
static ui::Block * wm_xr_viewfinder_ui_block_begin(const bContext *C, ui::EmbossType emboss)
VecBase< float, 4 > float4
void immBindBuiltinProgram(GPUBuiltinShader shader_id)
@ XR_VIEWFINDER_HAND_LEFT
@ XR_VIEWFINDER_HAND_RIGHT
void BKE_camera_params_compute_matrix(CameraParams *params)
void wm_xr_viewfinder_render_view(wmXrData *xr_data)
void BLI_rctf_mul(struct rctf *rect, float factor)
Definition rct.cc:602
static void wm_xr_viewfinder_ui_draw_capture_flash(wmXrSessionState *state, const rctf &viewfinder_rect)
VecBase< int32_t, 2 > int2
void immUniform1f(const char *name, float x)
@ GPU_DEPTH_NONE
Definition GPU_state.hh:132
@ GPU_DEPTH_LESS_EQUAL
Definition GPU_state.hh:135
bool wm_xr_location_scouting_is_captures_empty(Scene *scene)
void immVertex2f(uint attr_id, float x, float y)
void copy_qt_qt(float q[4], const float a[4])
void GPU_viewport_size_get_f(float coords[4])
Definition gpu_state.cc:258
void immAttr4fv(uint attr_id, const float data[4])
void interp_qt_qtqt(float q[4], const float a[4], const float b[4], float t)
@ GPU_SHADER_3D_POLYLINE_FLAT_COLOR
BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
Definition BLI_rect.hh:215
wmWindowManager * CTX_wm_manager(const bContext *C)
@ XR_VIEWFINDER_ACTION_LIVE_APERTURE
@ XR_VIEWFINDER_ACTION_LIVE_DOF
@ XR_VIEWFINDER_ACTION_LIVE_LENS
@ XR_VIEWFINDER_ACTION_LIVE_FOCUS
static void wm_xr_viewfinder_transform_update_smoothed(wmXrSessionState *state, float raw_capture_mat[4][4], float r_smoothed_mat[4][4])
int GPU_texture_width(const gpu::Texture *texture)
void immUniformColor4f(float r, float g, float b, float a)
PointerRNA RNA_pointer_create_discrete(ID *id, StructRNA *type, void *data)
void ED_view3d_draw_offscreen_simple(Depsgraph *depsgraph, Scene *scene, View3DShading *shading_override, bContext *context, eDrawType drawtype, int object_type_exclude_viewport_override, int object_type_exclude_select_override, int winx, int winy, unsigned int draw_flags, const float viewmat[4][4], const float winmat[4][4], float clip_start, float clip_end, float xr_vignette_aperture, bool is_xr_surface, bool is_image_render, bool draw_background, const char *viewname, bool do_color_management, Object *camera_override, GPUOffScreen *ofs, GPUViewport *viewport)
void interp_v3_v3v3(float r[3], const float a[3], const float b[3], float t)
void immRectf_with_texco(uint pos, uint tex_coord, const rctf &p, const rctf &uv)
uint GPU_vertformat_attr_add(GPUVertFormat *format, StringRef name, gpu::VertAttrType type)
void immBindTextureSampler(const char *name, gpu::Texture *tex, GPUSamplerState state)
void BLI_rcti_init(struct rcti *rect, int xmin, int xmax, int ymin, int ymax)
Definition rct.cc:428
static ui::Block * wm_xr_viewfinder_ui_action_enum_block(const bContext *C, const wmXrSessionState *state)
float RNA_property_float_get(PointerRNA *ptr, PropertyRNA *prop)
bool RNA_property_collection_is_empty(PointerRNA *ptr, PropertyRNA *prop)
void immVertex3fv(uint attr_id, const float data[3])
void rotate_m4(float mat[4][4], char axis, float angle)
gpu::Texture * GPU_offscreen_color_texture(const GPUOffScreen *offscreen)
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
Definition BLI_rect.hh:211
void wm_xr_pose_to_imat(const GHOST_XrPose *pose, float r_imat[4][4])
Definition wm_xr_draw.cc:60
void wm_xr_viewfinder_draw(const bContext *C, const XrSessionSettings *settings, wmXrSessionState *state)
int GPU_texture_height(const gpu::Texture *texture)
static ui::Block * wm_xr_viewfinder_ui_missing_captures_label_block(const bContext *C, const wmXrSessionState *state)
static void wm_xr_viewfinder_ui_draw_capture_overlays(const XrSessionSettings *settings, const wmXrSessionState *state, const rctf &vf_rect)
BLI_INLINE float BLI_rctf_cent_y(const struct rctf *rct)
Definition BLI_rect.hh:198
static void wm_xr_viewfinder_ui_draw_backside_logo_texture(const wmXrSessionState *state, const rctf &viewfinder_rect)
static void wm_xr_viewfinder_ui_draw_view_texture(const bContext *C, const wmXrSessionState *state, const rctf &viewfinder_rect)
bool RNA_property_collection_lookup_int(PointerRNA *ptr, PropertyRNA *prop, int key, PointerRNA *r_ptr)
static void wm_xr_viewfinder_ui_block_draw(const bContext *C, ui::Block *block)
void BLI_rctf_translate(struct rctf *rect, float x, float y)
Definition rct.cc:587
MINLINE float interpf(float target, float origin, float t)
double BLI_time_now_seconds()
Definition time.cc:30
void wmGetProjectionMatrix(float mat[4][4], const rcti *winrct)
static wmXrController * wm_xr_viewfinder_get_controller(const XrSessionSettings *settings, const wmXrSessionState *state)
Scene * CTX_data_scene(const bContext *C)
void immUniform2fv(const char *name, const float data[2])
void immVertex3f(uint attr_id, float x, float y, float z)
void GPU_blend(GPUBlend blend)
Definition gpu_state.cc:44
std::optional< XrLocationScoutingCapture > wm_xr_location_scouting_get_active_capture(Scene *scene)
void copy_m4_m4(float m1[4][4], const float m2[4][4])
void GPU_matrix_translate_3f(float x, float y, float z)
static StringRefNull wm_xr_viewfinder_get_active_mode_str(const wmXrSessionState *state)
VecBase< float, 3 > float3
void BKE_camera_params_init(CameraParams *params)
static void wm_xr_viewfinder_ui_draw_widgets(const bContext *C, const wmXrSessionState *state, const rctf &viewfinder_rect)
int RNA_property_int_get(PointerRNA *ptr, PropertyRNA *prop)
void GPU_matrix_pop()
void GPU_depth_test(GPUDepthTest test)
Definition gpu_state.cc:70
static bool wm_xr_viewfinder_get_capture_mat(const XrSessionSettings *settings, const wmXrSessionState *state, const float viewfinder_height, float r_mat[4][4])
static ui::Layout & wm_xr_viewfinder_ui_layout(ui::Block *block)
void immRectf(uint pos, float x1, float y1, float x2, float y2)
BLI_INLINE float BLI_rctf_cent_x(const struct rctf *rct)
Definition BLI_rect.hh:194
void BLI_rctf_pad(struct rctf *rect, float pad_x, float pad_y)
Definition rct.cc:651
void GPU_matrix_push()
void quat_to_mat4(float m[4][4], const float q[4])
static const char * wm_xr_viewfinder_get_hand_user_path(const XrSessionSettings *settings)
static ui::Block * wm_xr_viewfinder_ui_settings_right_label_block(const bContext *C, const wmXrSessionState *state)
#define fabsf
struct RenderData r
eView3DShading_Flag flag
struct View3DShading shading
std::ranges::transform_view< std::ranges::ref_view< const Vector< std::unique_ptr< Button > > >, Button &(*)(const std::unique_ptr< Button > &)> buttons() const
void enabled_set(bool enabled)
void label(StringRef name, int icon)
void ui_units_x_set(float width)
void scale_x_set(float scale)
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< StringRef > name_opt, int icon, std::optional< StringRef > placeholder=std::nullopt)
void scale_y_set(float scale)
Layout & row(bool align)
void prop_enum(PointerRNA *ptr, PropertyRNA *prop, int value, std::optional< StringRefNull > name, int icon)
XrSessionSettings session_settings
struct wmXrRuntimeData * runtime
wmXrSessionState session_state
static constexpr int view_resolution
static constexpr float accent_color[4]
static constexpr float xr_ui_unit_fac
uiFontStyle widget