Show a laser-beam pointer while aiming at the menu/keyboard
build / build (push) Successful in 1m40s
build / build (push) Successful in 1m40s
The flat cross-shaped reticle used while aiming at the game quad is drawn directly into the game quad's own texture, so it only ever made sense there - while the menu launcher or keyboard was open, there was no visual feedback at all until the ray was precisely on target, making both panels hard to aim at. Add a second, thin XrCompositionLayerQuad per hand: a billboarded "laser beam" ribbon from the controller to wherever that hand's ray currently crosses the plane of whichever overlay (keyboard, then menu) claims it that frame, oriented via a view-space head pose so it reads as a line from the viewer's eye regardless of angle, colored per hand (cyan left, amber right) and clamped to 2m so grazing angles don't produce an absurdly long beam. Built from data xr_input.c's existing per-hand hit-testing already computes; the game-quad reticle itself is untouched.
This commit is contained in:
@@ -5,13 +5,17 @@
|
||||
// visible, this tests against the game quad xr_session.c submits and draws
|
||||
// a small reticle where each hand's aim ray crosses it; while either
|
||||
// overlay is visible, it tests against that overlay's quad instead (the
|
||||
// keyboard is tried first) and forwards trigger edges as synthetic touches
|
||||
// (no reticle - each overlay's own content comes from its Java view's
|
||||
// rendered Bitmap).
|
||||
// keyboard is tried first), forwards trigger edges as synthetic touches,
|
||||
// and - since neither overlay's own on-quad cursor gives any feedback
|
||||
// while the ray is short of actually landing on it - builds a thin,
|
||||
// billboarded laser-beam quad per hand from the controller to wherever
|
||||
// the ray currently crosses that overlay's plane (see
|
||||
// xr_input_get_beam_layer()).
|
||||
#ifndef QUESTSHOCK_XR_INPUT_H
|
||||
#define QUESTSHOCK_XR_INPUT_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define XR_USE_PLATFORM_ANDROID 1
|
||||
#define XR_USE_GRAPHICS_API_OPENGL_ES 1
|
||||
@@ -24,10 +28,12 @@ extern "C" {
|
||||
// Call once, right after the session is created (see xr_session.c's
|
||||
// xr_create_instance_and_session()) - creates the action set/actions,
|
||||
// suggests Touch controller bindings, creates the per-hand aim action
|
||||
// spaces, and attaches the set to the session. Returns false (logged,
|
||||
// non-fatal - the caller keeps rendering without input) if any of that
|
||||
// fails.
|
||||
bool xr_input_init(XrInstance instance, XrSession session);
|
||||
// spaces and a view-space reference (for the laser-beam billboard math),
|
||||
// creates the two per-hand beam swapchains (swapchain_format - the same
|
||||
// format shared by the game swapchain and both overlays), and attaches
|
||||
// the action set to the session. Returns false (logged, non-fatal - the
|
||||
// caller keeps rendering without input) if any of that fails.
|
||||
bool xr_input_init(XrInstance instance, XrSession session, int64_t swapchain_format);
|
||||
|
||||
// Call once per frame from xr_frame_end(), before releasing the acquired
|
||||
// swapchain image - syncs this frame's action states (always, so edge
|
||||
@@ -40,6 +46,16 @@ bool xr_input_init(XrInstance instance, XrSession session);
|
||||
// xr_frame_begin() used to predict this frame.
|
||||
void xr_input_sync_and_draw(XrSpace baseSpace, XrTime time, bool draw);
|
||||
|
||||
// Call once per hand (hand: 0=left, 1=right) after xr_input_sync_and_draw()
|
||||
// in the same frame - if that hand's ray claimed the keyboard or menu
|
||||
// overlay this frame (see the file comment above), fills *out_quad's
|
||||
// subImage/pose/size for its laser-beam ribbon and returns true.
|
||||
// space/eyeVisibility/layerFlags are left for the caller to set, same
|
||||
// convention as xr_overlay_render_and_build_layer(). Returns false
|
||||
// (out_quad untouched) if no beam should be shown for that hand this
|
||||
// frame.
|
||||
bool xr_input_get_beam_layer(int hand, XrCompositionLayerQuad *out_quad);
|
||||
|
||||
void xr_input_shutdown(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
Reference in New Issue
Block a user