diff options
author | Peter Kim <pk15950@gmail.com> | 2021-10-12 10:18:05 +0300 |
---|---|---|
committer | Peter Kim <pk15950@gmail.com> | 2021-10-12 10:18:05 +0300 |
commit | 9dda65455b54336fe3efef91eba9e41866dac1c1 (patch) | |
tree | 2f8fd6edf8d190e018b63c6b6bdacb38ab7905bd /source/blender/makesdna | |
parent | cfa59b3fabe729e49a57154ce21c5a4b88aa5812 (diff) |
XR Controller Support Step 4: Controller Drawing
Addresses T77127 (Controller Drawing).
Adds VR controller visualization and custom drawing via draw
handlers. Add-ons can draw to the XR surface (headset display) and
mirror window by adding a View3D draw handler of region type 'XR' and
draw type 'POST_VIEW'. Controller drawing and custom overlays can be
toggled individually as XR session options, which will be added in a
future update to the VR Scene Inspection add-on.
For the actual drawing, the OpenXR XR_MSFT_controller_model extension
is used to load a glTF model provided by the XR runtime. The model's
vertex data is then used to create a GPUBatch in the XR session
state. Finally, this batch is drawn via the XR surface draw handler
mentioned above.
For runtimes that do not support the controller model extension, a
a simple fallback shape (sphere) is drawn instead.
Reviewed By: Severin, fclem
Differential Revision: https://developer.blender.org/D10948
Diffstat (limited to 'source/blender/makesdna')
-rw-r--r-- | source/blender/makesdna/DNA_screen_types.h | 5 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_view3d_enums.h | 3 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_view3d_types.h | 3 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_xr_types.h | 11 |
4 files changed, 20 insertions, 2 deletions
diff --git a/source/blender/makesdna/DNA_screen_types.h b/source/blender/makesdna/DNA_screen_types.h index f557890e3e8..86fd6b9744a 100644 --- a/source/blender/makesdna/DNA_screen_types.h +++ b/source/blender/makesdna/DNA_screen_types.h @@ -666,8 +666,11 @@ typedef enum eRegion_Type { RGN_TYPE_EXECUTE = 10, RGN_TYPE_FOOTER = 11, RGN_TYPE_TOOL_HEADER = 12, + /* Region type used exclusively by internal code and add-ons to register draw callbacks to the XR + context (surface, mirror view). Does not represent any real region. */ + RGN_TYPE_XR = 13, -#define RGN_TYPE_LEN (RGN_TYPE_TOOL_HEADER + 1) +#define RGN_TYPE_LEN (RGN_TYPE_XR + 1) } eRegion_Type; /* use for function args */ diff --git a/source/blender/makesdna/DNA_view3d_enums.h b/source/blender/makesdna/DNA_view3d_enums.h index aec52da1bf9..59012a0cd8d 100644 --- a/source/blender/makesdna/DNA_view3d_enums.h +++ b/source/blender/makesdna/DNA_view3d_enums.h @@ -30,6 +30,9 @@ typedef enum eV3DOffscreenDrawFlag { V3D_OFSDRAW_SHOW_ANNOTATION = (1 << 0), V3D_OFSDRAW_OVERRIDE_SCENE_SETTINGS = (1 << 1), V3D_OFSDRAW_SHOW_GRIDFLOOR = (1 << 2), + V3D_OFSDRAW_SHOW_SELECTION = (1 << 3), + V3D_OFSDRAW_XR_SHOW_CONTROLLERS = (1 << 4), + V3D_OFSDRAW_XR_SHOW_CUSTOM_OVERLAYS = (1 << 5), } eV3DOffscreenDrawFlag; /** #View3DShading.light */ diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h index 4d88f6f0c15..fafc470b95a 100644 --- a/source/blender/makesdna/DNA_view3d_types.h +++ b/source/blender/makesdna/DNA_view3d_types.h @@ -373,6 +373,7 @@ typedef struct View3D { #define V3D_HIDE_HELPLINES (1 << 2) #define V3D_FLAG_UNUSED_2 (1 << 3) /* cleared */ #define V3D_XR_SESSION_MIRROR (1 << 4) +#define V3D_XR_SESSION_SURFACE (1 << 5) #define V3D_FLAG_UNUSED_10 (1 << 10) /* cleared */ #define V3D_SELECT_OUTLINE (1 << 11) @@ -465,6 +466,8 @@ enum { #define V3D_FLAG2_UNUSED_13 (1 << 13) /* cleared */ #define V3D_FLAG2_UNUSED_14 (1 << 14) /* cleared */ #define V3D_FLAG2_UNUSED_15 (1 << 15) /* cleared */ +#define V3D_XR_SHOW_CONTROLLERS (1 << 16) +#define V3D_XR_SHOW_CUSTOM_OVERLAYS (1 << 17) /** #View3D.gp_flag (short) */ #define V3D_GP_FADE_OBJECTS (1 << 0) /* Fade all non GP objects */ diff --git a/source/blender/makesdna/DNA_xr_types.h b/source/blender/makesdna/DNA_xr_types.h index a9d427777f7..6f4f7e3e8ae 100644 --- a/source/blender/makesdna/DNA_xr_types.h +++ b/source/blender/makesdna/DNA_xr_types.h @@ -42,7 +42,9 @@ typedef struct XrSessionSettings { /** View3D draw flags (V3D_OFSDRAW_NONE, V3D_OFSDRAW_SHOW_ANNOTATION, ...). */ char draw_flags; - char _pad2[3]; + /** Draw style for controller visualization. */ + char controller_draw_style; + char _pad2[2]; /** Clipping distance. */ float clip_start, clip_end; @@ -61,6 +63,13 @@ typedef enum eXRSessionBasePoseType { XR_BASE_POSE_CUSTOM = 2, } eXRSessionBasePoseType; +typedef enum eXrSessionControllerDrawStyle { + XR_CONTROLLER_DRAW_DARK = 0, + XR_CONTROLLER_DRAW_LIGHT = 1, + XR_CONTROLLER_DRAW_DARK_RAY = 2, + XR_CONTROLLER_DRAW_LIGHT_RAY = 3, +} eXrSessionControllerDrawStyle; + /** XR action type. Enum values match those in GHOST_XrActionType enum for consistency. */ typedef enum eXrActionType { XR_BOOLEAN_INPUT = 1, |