mirror of
https://github.com/DrBeef/JKXR.git
synced 2024-11-23 20:43:09 +00:00
Merge branch 'main' of https://github.com/DrBeef/JKXR
This commit is contained in:
commit
ee0f69e34b
18 changed files with 2710 additions and 85 deletions
|
@ -28,6 +28,11 @@
|
|||
<!-- META QUEST -->
|
||||
<meta-data android:name="com.oculus.supportedDevices" android:value="quest|quest2"/>
|
||||
<meta-data android:name="com.oculus.ossplash" android:value="true"/>
|
||||
<!-- Set Dual Core mode for Quest 2/Pro -->
|
||||
<meta-data android:name="com.oculus.dualcorecpuset" android:value="true" />
|
||||
<!-- Enabling CPU and GPU level trading: -1 = -1 level to gpu, +1 level to cpu -->
|
||||
<!-- CPU needs all the power it can get!! -->
|
||||
<meta-data android:name="com.oculus.trade_cpu_for_gpu_amount" android:value="-1" />
|
||||
|
||||
<!-- PICO XR -->
|
||||
<meta-data android:name="pvr.app.type" android:value="vr" />
|
||||
|
|
|
@ -295,30 +295,37 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
|
|||
if (offhandGripPushed)
|
||||
{
|
||||
if (!vr.weapon_stabilised && vr.item_selector == 0 &&
|
||||
!vr.misc_camera && !vr.cgzoommode && vr_two_handed_weapons->integer)
|
||||
!vr.misc_camera && !vr.cgzoommode)
|
||||
{
|
||||
if (distance < STABILISATION_DISTANCE &&
|
||||
cl.frame.ps.weapon == WP_SABER) {
|
||||
vr.weapon_stabilised = true;
|
||||
}
|
||||
else {
|
||||
vec3_t dir, weaponposition, offhandposition;
|
||||
VectorSet(weaponposition, pWeapon->Pose.position.z, pWeapon->Pose.position.x, pWeapon->Pose.position.y);
|
||||
VectorSet(offhandposition, pOff->Pose.position.z, pOff->Pose.position.x, pOff->Pose.position.y);
|
||||
VectorSubtract(weaponposition, offhandposition, dir);
|
||||
VectorNormalize(dir);
|
||||
|
||||
vec3_t weaponangles, weaponForward, rotation = { 0 };
|
||||
rotation[PITCH] = vr_weapon_pitchadjust->value;
|
||||
QuatToYawPitchRoll(pWeapon->Pose.orientation, rotation, weaponangles);
|
||||
AngleVectors(weaponangles, weaponForward, NULL, NULL);
|
||||
VectorNormalize(weaponForward);
|
||||
|
||||
if (cl.frame.ps.weapon > WP_SABER &&
|
||||
DotProduct(weaponForward, dir) > 0.8f)
|
||||
if (vr_two_handed_weapons->integer)
|
||||
{
|
||||
if (distance < STABILISATION_DISTANCE &&
|
||||
cl.frame.ps.weapon == WP_SABER)
|
||||
{
|
||||
vr.weapon_stabilised = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
vec3_t dir, weaponposition, offhandposition;
|
||||
VectorSet(weaponposition, pWeapon->Pose.position.z,
|
||||
pWeapon->Pose.position.x, pWeapon->Pose.position.y);
|
||||
VectorSet(offhandposition, pOff->Pose.position.z, pOff->Pose.position.x,
|
||||
pOff->Pose.position.y);
|
||||
VectorSubtract(weaponposition, offhandposition, dir);
|
||||
VectorNormalize(dir);
|
||||
|
||||
vec3_t weaponangles, weaponForward, rotation = {0};
|
||||
rotation[PITCH] = vr_weapon_pitchadjust->value;
|
||||
QuatToYawPitchRoll(pWeapon->Pose.orientation, rotation, weaponangles);
|
||||
AngleVectors(weaponangles, weaponForward, NULL, NULL);
|
||||
VectorNormalize(weaponForward);
|
||||
|
||||
if (cl.frame.ps.weapon > WP_SABER &&
|
||||
DotProduct(weaponForward, dir) > 0.8f)
|
||||
{
|
||||
vr.weapon_stabilised = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!vr.weapon_stabilised)
|
||||
|
|
|
@ -37,8 +37,6 @@ extern float SS_MULTIPLIER ;
|
|||
|
||||
/* global arg_xxx structs */
|
||||
struct arg_dbl *ss;
|
||||
struct arg_int *cpu;
|
||||
struct arg_int *gpu;
|
||||
struct arg_int *msaa;
|
||||
struct arg_end *end;
|
||||
|
||||
|
@ -791,8 +789,6 @@ JNIEXPORT jlong JNICALL Java_com_drbeef_jkxr_GLES3JNILib_onCreate( JNIEnv * env,
|
|||
/* the global arg_xxx structs are initialised within the argtable */
|
||||
void *argtable[] = {
|
||||
ss = arg_dbl0("s", "supersampling", "<double>", "super sampling value (default: Q1: 1.2, Q2: 1.35)"),
|
||||
cpu = arg_int0("c", "cpu", "<int>", "CPU perf index 1-4 (default: 2)"),
|
||||
gpu = arg_int0("g", "gpu", "<int>", "GPU perf index 1-4 (default: 3)"),
|
||||
msaa = arg_int0("m", "msaa", "<int>", "MSAA (default: 1)"),
|
||||
end = arg_end(20)
|
||||
};
|
||||
|
|
|
@ -924,10 +924,10 @@ void ovrApp_HandleSessionStateChanges(ovrApp* app, XrSessionState state) {
|
|||
"xrPerfSettingsSetPerformanceLevelEXT",
|
||||
(PFN_xrVoidFunction * )(&pfnPerfSettingsSetPerformanceLevelEXT)));
|
||||
|
||||
OXR(pfnPerfSettingsSetPerformanceLevelEXT(
|
||||
app->Session, XR_PERF_SETTINGS_DOMAIN_CPU_EXT, cpuPerfLevel));
|
||||
OXR(pfnPerfSettingsSetPerformanceLevelEXT(
|
||||
app->Session, XR_PERF_SETTINGS_DOMAIN_GPU_EXT, gpuPerfLevel));
|
||||
// OXR(pfnPerfSettingsSetPerformanceLevelEXT(
|
||||
// app->Session, XR_PERF_SETTINGS_DOMAIN_CPU_EXT, cpuPerfLevel));
|
||||
// OXR(pfnPerfSettingsSetPerformanceLevelEXT(
|
||||
// app->Session, XR_PERF_SETTINGS_DOMAIN_GPU_EXT, gpuPerfLevel));
|
||||
|
||||
if (strstr(gAppState.OpenXRHMD, "meta") != NULL)
|
||||
{
|
||||
|
|
|
@ -34,9 +34,11 @@ bool VR_UseScreenLayer()
|
|||
vr.misc_camera ||
|
||||
(CL_IsRunningInGameCinematic() || CL_InGameCinematicOnStandBy()) ||
|
||||
(cls.state == CA_DISCONNECTED) ||
|
||||
(cls.state == CA_CHALLENGING) ||
|
||||
(cls.state == CA_CONNECTING) ||
|
||||
(cls.state == CA_CINEMATIC) ||
|
||||
(cls.state == CA_LOADING) ||
|
||||
(cls.state == CA_PRIMED) ||
|
||||
( Key_GetCatcher( ) & KEYCATCH_UI ) ||
|
||||
( Key_GetCatcher( ) & KEYCATCH_CONSOLE ));
|
||||
|
||||
|
|
|
@ -3488,7 +3488,7 @@ void CG_FireWeapon( centity_t *cent, qboolean alt_fire )
|
|||
}
|
||||
|
||||
//Are we the player?
|
||||
if (cent->gent->client->ps.clientNum == 0)
|
||||
if (cent->gent->client && cent->gent->client->ps.clientNum == 0)
|
||||
{
|
||||
/*
|
||||
These are specific to external haptics vest/arms/face combinations
|
||||
|
@ -3555,6 +3555,7 @@ void CG_FireWeapon( centity_t *cent, qboolean alt_fire )
|
|||
break;
|
||||
case WP_DEMP2:
|
||||
case WP_EMPLACED_GUN:
|
||||
case WP_CONCUSSION:
|
||||
cgi_HapticEvent("bfg_fire", position, 0, 100, 0, 0);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1452,7 +1452,7 @@ static inline qboolean G_RagWantsHumanoidsOnly( CGhoul2Info *ghlInfo )
|
|||
{
|
||||
char *GLAName;
|
||||
GLAName = gi.G2API_GetGLAName( ghlInfo );
|
||||
assert(GLAName);
|
||||
//assert(GLAName);
|
||||
|
||||
if ( !Q_stricmp( "models/players/_humanoid/_humanoid", GLAName ) )
|
||||
{//only _humanoid skeleton is expected to have these
|
||||
|
|
|
@ -3293,7 +3293,7 @@ void CG_FireWeapon( centity_t *cent, qboolean alt_fire )
|
|||
}
|
||||
|
||||
//Are we the player?
|
||||
if (cent->gent->client->ps.clientNum == 0)
|
||||
if (cent->gent->client && cent->gent->client->ps.clientNum == 0)
|
||||
{
|
||||
/*
|
||||
These are specific to external haptics vest/arms/face combinations
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
openxr.h
|
||||
openxr_platform.h
|
||||
openxr_reflection.h
|
||||
openxr_reflection_structs.h
|
||||
openxr_reflection_parent_structs.h
|
|
@ -1,4 +1,4 @@
|
|||
Copyright (c) 2017-2022, The Khronos Group Inc.
|
||||
Copyright (c) 2017-2023, The Khronos Group Inc.
|
||||
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright (c) 2017-2022, The Khronos Group Inc.
|
||||
# Copyright (c) 2017-2023, The Khronos Group Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -2,7 +2,7 @@
|
|||
#define OPENXR_PLATFORM_H_ 1
|
||||
|
||||
/*
|
||||
** Copyright 2017-2022 The Khronos Group Inc.
|
||||
** Copyright 2017-2023 The Khronos Group Inc.
|
||||
**
|
||||
** SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*/
|
||||
|
@ -454,9 +454,9 @@ typedef XrSwapchainImageVulkanKHR XrSwapchainImageVulkan2KHR;
|
|||
|
||||
typedef XrGraphicsRequirementsVulkanKHR XrGraphicsRequirementsVulkan2KHR;
|
||||
|
||||
typedef XrResult (XRAPI_PTR *PFN_xrCreateVulkanInstanceKHR)(XrInstance instance, const XrVulkanInstanceCreateInfoKHR* createInfo, VkInstance* vulkanInstance, VkResult* vulkanResult);
|
||||
typedef XrResult (XRAPI_PTR *PFN_xrCreateVulkanDeviceKHR)(XrInstance instance, const XrVulkanDeviceCreateInfoKHR* createInfo, VkDevice* vulkanDevice, VkResult* vulkanResult);
|
||||
typedef XrResult (XRAPI_PTR *PFN_xrGetVulkanGraphicsDevice2KHR)(XrInstance instance, const XrVulkanGraphicsDeviceGetInfoKHR* getInfo, VkPhysicalDevice* vulkanPhysicalDevice);
|
||||
typedef XrResult (XRAPI_PTR *PFN_xrCreateVulkanInstanceKHR)(XrInstance instance, const XrVulkanInstanceCreateInfoKHR* createInfo, VkInstance* vulkanInstance, VkResult* vulkanResult);
|
||||
typedef XrResult (XRAPI_PTR *PFN_xrCreateVulkanDeviceKHR)(XrInstance instance, const XrVulkanDeviceCreateInfoKHR* createInfo, VkDevice* vulkanDevice, VkResult* vulkanResult);
|
||||
typedef XrResult (XRAPI_PTR *PFN_xrGetVulkanGraphicsDevice2KHR)(XrInstance instance, const XrVulkanGraphicsDeviceGetInfoKHR* getInfo, VkPhysicalDevice* vulkanPhysicalDevice);
|
||||
typedef XrResult (XRAPI_PTR *PFN_xrGetVulkanGraphicsRequirements2KHR)(XrInstance instance, XrSystemId systemId, XrGraphicsRequirementsVulkanKHR* graphicsRequirements);
|
||||
|
||||
#ifndef XR_NO_PROTOTYPES
|
||||
|
@ -491,14 +491,15 @@ XRAPI_ATTR XrResult XRAPI_CALL xrGetVulkanGraphicsRequirements2KHR(
|
|||
#define XR_MNDX_egl_enable 1
|
||||
#define XR_MNDX_egl_enable_SPEC_VERSION 1
|
||||
#define XR_MNDX_EGL_ENABLE_EXTENSION_NAME "XR_MNDX_egl_enable"
|
||||
typedef void *(*PFN_xrEglGetProcAddressMNDX)(const char *name);
|
||||
// XrGraphicsBindingEGLMNDX extends XrSessionCreateInfo
|
||||
typedef struct XrGraphicsBindingEGLMNDX {
|
||||
XrStructureType type;
|
||||
const void* XR_MAY_ALIAS next;
|
||||
PFNEGLGETPROCADDRESSPROC getProcAddress;
|
||||
EGLDisplay display;
|
||||
EGLConfig config;
|
||||
EGLContext context;
|
||||
XrStructureType type;
|
||||
const void* XR_MAY_ALIAS next;
|
||||
PFN_xrEglGetProcAddressMNDX getProcAddress;
|
||||
EGLDisplay display;
|
||||
EGLConfig config;
|
||||
EGLContext context;
|
||||
} XrGraphicsBindingEGLMNDX;
|
||||
|
||||
#endif /* XR_USE_PLATFORM_EGL */
|
||||
|
@ -565,6 +566,30 @@ typedef struct XrAndroidSurfaceSwapchainCreateInfoFB {
|
|||
|
||||
#endif /* XR_USE_PLATFORM_ANDROID */
|
||||
|
||||
#ifdef XR_USE_PLATFORM_ML
|
||||
|
||||
#define XR_ML_compat 1
|
||||
#define XR_ML_compat_SPEC_VERSION 1
|
||||
#define XR_ML_COMPAT_EXTENSION_NAME "XR_ML_compat"
|
||||
typedef struct XrCoordinateSpaceCreateInfoML {
|
||||
XrStructureType type;
|
||||
const void* XR_MAY_ALIAS next;
|
||||
MLCoordinateFrameUID cfuid;
|
||||
XrPosef poseInCoordinateSpace;
|
||||
} XrCoordinateSpaceCreateInfoML;
|
||||
|
||||
typedef XrResult (XRAPI_PTR *PFN_xrCreateSpaceFromCoordinateFrameUIDML)(XrSession session, const XrCoordinateSpaceCreateInfoML *createInfo, XrSpace* space);
|
||||
|
||||
#ifndef XR_NO_PROTOTYPES
|
||||
#ifdef XR_EXTENSION_PROTOTYPES
|
||||
XRAPI_ATTR XrResult XRAPI_CALL xrCreateSpaceFromCoordinateFrameUIDML(
|
||||
XrSession session,
|
||||
const XrCoordinateSpaceCreateInfoML * createInfo,
|
||||
XrSpace* space);
|
||||
#endif /* XR_EXTENSION_PROTOTYPES */
|
||||
#endif /* !XR_NO_PROTOTYPES */
|
||||
#endif /* XR_USE_PLATFORM_ML */
|
||||
|
||||
#ifdef XR_USE_PLATFORM_WIN32
|
||||
|
||||
#define XR_OCULUS_audio_device_guid 1
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** Copyright (c) 2017-2022, The Khronos Group Inc.
|
||||
** Copyright (c) 2017-2023, The Khronos Group Inc.
|
||||
**
|
||||
** SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*/
|
||||
|
@ -65,7 +65,7 @@ typedef unsigned __int64 uint64_t;
|
|||
#endif // !defined( XR_NO_STDINT_H )
|
||||
|
||||
// XR_PTR_SIZE (in bytes)
|
||||
#if (defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__) ) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__))
|
||||
#if (defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__) ) || defined(_M_X64) || defined(__ia64) || defined(_M_IA64) || defined(__aarch64__) || defined(__powerpc64__))
|
||||
#define XR_PTR_SIZE 8
|
||||
#else
|
||||
#define XR_PTR_SIZE 4
|
||||
|
@ -103,6 +103,10 @@ typedef unsigned __int64 uint64_t;
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined(XR_CPP_NULLPTR_SUPPORTED)
|
||||
#define XR_CPP_NULLPTR_SUPPORTED 0
|
||||
#endif // !defined(XR_CPP_NULLPTR_SUPPORTED)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -2,7 +2,7 @@
|
|||
#define OPENXR_REFLECTION_PARENT_STRUCTS_H_ 1
|
||||
|
||||
/*
|
||||
** Copyright (c) 2017-2022, The Khronos Group Inc.
|
||||
** Copyright (c) 2017-2023, The Khronos Group Inc.
|
||||
**
|
||||
** SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*/
|
||||
|
@ -62,6 +62,8 @@ This file contains expansion macros (X Macros) for OpenXR structures that have a
|
|||
_avail(XrEventDataSpaceQueryCompleteFB, XR_TYPE_EVENT_DATA_SPACE_QUERY_COMPLETE_FB) \
|
||||
_avail(XrEventDataSpaceSaveCompleteFB, XR_TYPE_EVENT_DATA_SPACE_SAVE_COMPLETE_FB) \
|
||||
_avail(XrEventDataSpaceEraseCompleteFB, XR_TYPE_EVENT_DATA_SPACE_ERASE_COMPLETE_FB) \
|
||||
_avail(XrEventDataSpaceShareCompleteFB, XR_TYPE_EVENT_DATA_SPACE_SHARE_COMPLETE_FB) \
|
||||
_avail(XrEventDataSpaceListSaveCompleteFB, XR_TYPE_EVENT_DATA_SPACE_LIST_SAVE_COMPLETE_FB) \
|
||||
|
||||
|
||||
|
||||
|
@ -75,6 +77,8 @@ This file contains expansion macros (X Macros) for OpenXR structures that have a
|
|||
// Implementation detail of XR_LIST_ALL_CHILD_STRUCTURE_TYPES_XrHapticBaseHeader()
|
||||
#define _impl_XR_LIST_ALL_CHILD_STRUCTURE_TYPES_XrHapticBaseHeader_CORE(_avail, _unavail) \
|
||||
_avail(XrHapticVibration, XR_TYPE_HAPTIC_VIBRATION) \
|
||||
_avail(XrHapticAmplitudeEnvelopeVibrationFB, XR_TYPE_HAPTIC_AMPLITUDE_ENVELOPE_VIBRATION_FB) \
|
||||
_avail(XrHapticPcmVibrationFB, XR_TYPE_HAPTIC_PCM_VIBRATION_FB) \
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#define OPENXR_REFLECTION_STRUCTS_H_ 1
|
||||
|
||||
/*
|
||||
** Copyright (c) 2017-2022, The Khronos Group Inc.
|
||||
** Copyright (c) 2017-2023, The Khronos Group Inc.
|
||||
**
|
||||
** SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*/
|
||||
|
@ -37,6 +37,7 @@ This file contains expansion macros (X Macros) for OpenXR structures.
|
|||
_impl_XR_LIST_ALL_STRUCTURE_TYPES_XR_USE_GRAPHICS_API_VULKAN(_avail, _unavail) \
|
||||
_impl_XR_LIST_ALL_STRUCTURE_TYPES_XR_USE_PLATFORM_ANDROID(_avail, _unavail) \
|
||||
_impl_XR_LIST_ALL_STRUCTURE_TYPES_XR_USE_PLATFORM_EGL(_avail, _unavail) \
|
||||
_impl_XR_LIST_ALL_STRUCTURE_TYPES_XR_USE_PLATFORM_ML(_avail, _unavail) \
|
||||
_impl_XR_LIST_ALL_STRUCTURE_TYPES_XR_USE_PLATFORM_WIN32(_avail, _unavail) \
|
||||
|
||||
|
||||
|
@ -143,6 +144,11 @@ This file contains expansion macros (X Macros) for OpenXR structures.
|
|||
_avail(XrCompositionLayerReprojectionInfoMSFT, XR_TYPE_COMPOSITION_LAYER_REPROJECTION_INFO_MSFT) \
|
||||
_avail(XrCompositionLayerReprojectionPlaneOverrideMSFT, XR_TYPE_COMPOSITION_LAYER_REPROJECTION_PLANE_OVERRIDE_MSFT) \
|
||||
_avail(XrCompositionLayerSecureContentFB, XR_TYPE_COMPOSITION_LAYER_SECURE_CONTENT_FB) \
|
||||
_avail(XrSystemBodyTrackingPropertiesFB, XR_TYPE_SYSTEM_BODY_TRACKING_PROPERTIES_FB) \
|
||||
_avail(XrBodyTrackerCreateInfoFB, XR_TYPE_BODY_TRACKER_CREATE_INFO_FB) \
|
||||
_avail(XrBodySkeletonFB, XR_TYPE_BODY_SKELETON_FB) \
|
||||
_avail(XrBodyJointsLocateInfoFB, XR_TYPE_BODY_JOINTS_LOCATE_INFO_FB) \
|
||||
_avail(XrBodyJointLocationsFB, XR_TYPE_BODY_JOINT_LOCATIONS_FB) \
|
||||
_avail(XrInteractionProfileDpadBindingEXT, XR_TYPE_INTERACTION_PROFILE_DPAD_BINDING_EXT) \
|
||||
_avail(XrInteractionProfileAnalogThresholdVALVE, XR_TYPE_INTERACTION_PROFILE_ANALOG_THRESHOLD_VALVE) \
|
||||
_avail(XrHandJointsMotionRangeInfoEXT, XR_TYPE_HAND_JOINTS_MOTION_RANGE_INFO_EXT) \
|
||||
|
@ -217,6 +223,8 @@ This file contains expansion macros (X Macros) for OpenXR structures.
|
|||
_avail(XrSystemMarkerTrackingPropertiesVARJO, XR_TYPE_SYSTEM_MARKER_TRACKING_PROPERTIES_VARJO) \
|
||||
_avail(XrEventDataMarkerTrackingUpdateVARJO, XR_TYPE_EVENT_DATA_MARKER_TRACKING_UPDATE_VARJO) \
|
||||
_avail(XrMarkerSpaceCreateInfoVARJO, XR_TYPE_MARKER_SPACE_CREATE_INFO_VARJO) \
|
||||
_avail(XrFrameEndInfoML, XR_TYPE_FRAME_END_INFO_ML) \
|
||||
_avail(XrGlobalDimmerFrameEndInfoML, XR_TYPE_GLOBAL_DIMMER_FRAME_END_INFO_ML) \
|
||||
_avail(XrSpatialAnchorPersistenceInfoMSFT, XR_TYPE_SPATIAL_ANCHOR_PERSISTENCE_INFO_MSFT) \
|
||||
_avail(XrSpatialAnchorFromPersistedAnchorCreateInfoMSFT, XR_TYPE_SPATIAL_ANCHOR_FROM_PERSISTED_ANCHOR_CREATE_INFO_MSFT) \
|
||||
_avail(XrSpaceQueryInfoFB, XR_TYPE_SPACE_QUERY_INFO_FB) \
|
||||
|
@ -230,18 +238,64 @@ This file contains expansion macros (X Macros) for OpenXR structures.
|
|||
_avail(XrSpaceEraseInfoFB, XR_TYPE_SPACE_ERASE_INFO_FB) \
|
||||
_avail(XrEventDataSpaceSaveCompleteFB, XR_TYPE_EVENT_DATA_SPACE_SAVE_COMPLETE_FB) \
|
||||
_avail(XrEventDataSpaceEraseCompleteFB, XR_TYPE_EVENT_DATA_SPACE_ERASE_COMPLETE_FB) \
|
||||
_avail(XrSpaceShareInfoFB, XR_TYPE_SPACE_SHARE_INFO_FB) \
|
||||
_avail(XrEventDataSpaceShareCompleteFB, XR_TYPE_EVENT_DATA_SPACE_SHARE_COMPLETE_FB) \
|
||||
_avail(XrCompositionLayerSpaceWarpInfoFB, XR_TYPE_COMPOSITION_LAYER_SPACE_WARP_INFO_FB) \
|
||||
_avail(XrSystemSpaceWarpPropertiesFB, XR_TYPE_SYSTEM_SPACE_WARP_PROPERTIES_FB) \
|
||||
_avail(XrHapticAmplitudeEnvelopeVibrationFB, XR_TYPE_HAPTIC_AMPLITUDE_ENVELOPE_VIBRATION_FB) \
|
||||
_avail(XrSemanticLabelsFB, XR_TYPE_SEMANTIC_LABELS_FB) \
|
||||
_avail(XrRoomLayoutFB, XR_TYPE_ROOM_LAYOUT_FB) \
|
||||
_avail(XrBoundary2DFB, XR_TYPE_BOUNDARY_2D_FB) \
|
||||
_avail(XrSemanticLabelsSupportInfoFB, XR_TYPE_SEMANTIC_LABELS_SUPPORT_INFO_FB) \
|
||||
_avail(XrDigitalLensControlALMALENCE, XR_TYPE_DIGITAL_LENS_CONTROL_ALMALENCE) \
|
||||
_avail(XrEventDataSceneCaptureCompleteFB, XR_TYPE_EVENT_DATA_SCENE_CAPTURE_COMPLETE_FB) \
|
||||
_avail(XrSceneCaptureRequestInfoFB, XR_TYPE_SCENE_CAPTURE_REQUEST_INFO_FB) \
|
||||
_avail(XrSpaceContainerFB, XR_TYPE_SPACE_CONTAINER_FB) \
|
||||
_avail(XrFoveationEyeTrackedProfileCreateInfoMETA, XR_TYPE_FOVEATION_EYE_TRACKED_PROFILE_CREATE_INFO_META) \
|
||||
_avail(XrFoveationEyeTrackedStateMETA, XR_TYPE_FOVEATION_EYE_TRACKED_STATE_META) \
|
||||
_avail(XrSystemFoveationEyeTrackedPropertiesMETA, XR_TYPE_SYSTEM_FOVEATION_EYE_TRACKED_PROPERTIES_META) \
|
||||
_avail(XrSystemFaceTrackingPropertiesFB, XR_TYPE_SYSTEM_FACE_TRACKING_PROPERTIES_FB) \
|
||||
_avail(XrFaceTrackerCreateInfoFB, XR_TYPE_FACE_TRACKER_CREATE_INFO_FB) \
|
||||
_avail(XrFaceExpressionInfoFB, XR_TYPE_FACE_EXPRESSION_INFO_FB) \
|
||||
_avail(XrFaceExpressionWeightsFB, XR_TYPE_FACE_EXPRESSION_WEIGHTS_FB) \
|
||||
_avail(XrEyeTrackerCreateInfoFB, XR_TYPE_EYE_TRACKER_CREATE_INFO_FB) \
|
||||
_avail(XrEyeGazesInfoFB, XR_TYPE_EYE_GAZES_INFO_FB) \
|
||||
_avail(XrSystemEyeTrackingPropertiesFB, XR_TYPE_SYSTEM_EYE_TRACKING_PROPERTIES_FB) \
|
||||
_avail(XrEyeGazesFB, XR_TYPE_EYE_GAZES_FB) \
|
||||
_avail(XrPassthroughKeyboardHandsIntensityFB, XR_TYPE_PASSTHROUGH_KEYBOARD_HANDS_INTENSITY_FB) \
|
||||
_avail(XrCompositionLayerSettingsFB, XR_TYPE_COMPOSITION_LAYER_SETTINGS_FB) \
|
||||
_avail(XrHapticPcmVibrationFB, XR_TYPE_HAPTIC_PCM_VIBRATION_FB) \
|
||||
_avail(XrDevicePcmSampleRateStateFB, XR_TYPE_DEVICE_PCM_SAMPLE_RATE_STATE_FB) \
|
||||
_avail(XrCompositionLayerDepthTestFB, XR_TYPE_COMPOSITION_LAYER_DEPTH_TEST_FB) \
|
||||
_avail(XrLocalDimmingFrameEndInfoMETA, XR_TYPE_LOCAL_DIMMING_FRAME_END_INFO_META) \
|
||||
_avail(XrPassthroughPreferencesMETA, XR_TYPE_PASSTHROUGH_PREFERENCES_META) \
|
||||
_avail(XrSystemVirtualKeyboardPropertiesMETA, XR_TYPE_SYSTEM_VIRTUAL_KEYBOARD_PROPERTIES_META) \
|
||||
_avail(XrVirtualKeyboardCreateInfoMETA, XR_TYPE_VIRTUAL_KEYBOARD_CREATE_INFO_META) \
|
||||
_avail(XrVirtualKeyboardSpaceCreateInfoMETA, XR_TYPE_VIRTUAL_KEYBOARD_SPACE_CREATE_INFO_META) \
|
||||
_avail(XrVirtualKeyboardLocationInfoMETA, XR_TYPE_VIRTUAL_KEYBOARD_LOCATION_INFO_META) \
|
||||
_avail(XrVirtualKeyboardModelVisibilitySetInfoMETA, XR_TYPE_VIRTUAL_KEYBOARD_MODEL_VISIBILITY_SET_INFO_META) \
|
||||
_avail(XrVirtualKeyboardAnimationStateMETA, XR_TYPE_VIRTUAL_KEYBOARD_ANIMATION_STATE_META) \
|
||||
_avail(XrVirtualKeyboardModelAnimationStatesMETA, XR_TYPE_VIRTUAL_KEYBOARD_MODEL_ANIMATION_STATES_META) \
|
||||
_avail(XrVirtualKeyboardTextureDataMETA, XR_TYPE_VIRTUAL_KEYBOARD_TEXTURE_DATA_META) \
|
||||
_avail(XrVirtualKeyboardInputInfoMETA, XR_TYPE_VIRTUAL_KEYBOARD_INPUT_INFO_META) \
|
||||
_avail(XrVirtualKeyboardTextContextChangeInfoMETA, XR_TYPE_VIRTUAL_KEYBOARD_TEXT_CONTEXT_CHANGE_INFO_META) \
|
||||
_avail(XrEventDataVirtualKeyboardCommitTextMETA, XR_TYPE_EVENT_DATA_VIRTUAL_KEYBOARD_COMMIT_TEXT_META) \
|
||||
_avail(XrEventDataVirtualKeyboardBackspaceMETA, XR_TYPE_EVENT_DATA_VIRTUAL_KEYBOARD_BACKSPACE_META) \
|
||||
_avail(XrEventDataVirtualKeyboardEnterMETA, XR_TYPE_EVENT_DATA_VIRTUAL_KEYBOARD_ENTER_META) \
|
||||
_avail(XrEventDataVirtualKeyboardShownMETA, XR_TYPE_EVENT_DATA_VIRTUAL_KEYBOARD_SHOWN_META) \
|
||||
_avail(XrEventDataVirtualKeyboardHiddenMETA, XR_TYPE_EVENT_DATA_VIRTUAL_KEYBOARD_HIDDEN_META) \
|
||||
_avail(XrExternalCameraOCULUS, XR_TYPE_EXTERNAL_CAMERA_OCULUS) \
|
||||
_avail(XrPerformanceMetricsStateMETA, XR_TYPE_PERFORMANCE_METRICS_STATE_META) \
|
||||
_avail(XrPerformanceMetricsCounterMETA, XR_TYPE_PERFORMANCE_METRICS_COUNTER_META) \
|
||||
_avail(XrSpaceListSaveInfoFB, XR_TYPE_SPACE_LIST_SAVE_INFO_FB) \
|
||||
_avail(XrEventDataSpaceListSaveCompleteFB, XR_TYPE_EVENT_DATA_SPACE_LIST_SAVE_COMPLETE_FB) \
|
||||
_avail(XrSpaceUserCreateInfoFB, XR_TYPE_SPACE_USER_CREATE_INFO_FB) \
|
||||
_avail(XrSystemHeadsetIdPropertiesMETA, XR_TYPE_SYSTEM_HEADSET_ID_PROPERTIES_META) \
|
||||
_avail(XrPassthroughColorLutCreateInfoMETA, XR_TYPE_PASSTHROUGH_COLOR_LUT_CREATE_INFO_META) \
|
||||
_avail(XrPassthroughColorLutUpdateInfoMETA, XR_TYPE_PASSTHROUGH_COLOR_LUT_UPDATE_INFO_META) \
|
||||
_avail(XrPassthroughColorMapLutMETA, XR_TYPE_PASSTHROUGH_COLOR_MAP_LUT_META) \
|
||||
_avail(XrPassthroughColorMapInterpolatedLutMETA, XR_TYPE_PASSTHROUGH_COLOR_MAP_INTERPOLATED_LUT_META) \
|
||||
_avail(XrSystemPassthroughColorLutPropertiesMETA, XR_TYPE_SYSTEM_PASSTHROUGH_COLOR_LUT_PROPERTIES_META) \
|
||||
_avail(XrPassthroughCreateInfoHTC, XR_TYPE_PASSTHROUGH_CREATE_INFO_HTC) \
|
||||
_avail(XrPassthroughColorHTC, XR_TYPE_PASSTHROUGH_COLOR_HTC) \
|
||||
_avail(XrPassthroughMeshTransformInfoHTC, XR_TYPE_PASSTHROUGH_MESH_TRANSFORM_INFO_HTC) \
|
||||
|
@ -250,6 +304,17 @@ This file contains expansion macros (X Macros) for OpenXR structures.
|
|||
_avail(XrFoveationDynamicModeInfoHTC, XR_TYPE_FOVEATION_DYNAMIC_MODE_INFO_HTC) \
|
||||
_avail(XrFoveationCustomModeInfoHTC, XR_TYPE_FOVEATION_CUSTOM_MODE_INFO_HTC) \
|
||||
_avail(XrActiveActionSetPrioritiesEXT, XR_TYPE_ACTIVE_ACTION_SET_PRIORITIES_EXT) \
|
||||
_avail(XrSystemForceFeedbackCurlPropertiesMNDX, XR_TYPE_SYSTEM_FORCE_FEEDBACK_CURL_PROPERTIES_MNDX) \
|
||||
_avail(XrForceFeedbackCurlApplyLocationsMNDX, XR_TYPE_FORCE_FEEDBACK_CURL_APPLY_LOCATIONS_MNDX) \
|
||||
_avail(XrHandTrackingDataSourceInfoEXT, XR_TYPE_HAND_TRACKING_DATA_SOURCE_INFO_EXT) \
|
||||
_avail(XrHandTrackingDataSourceStateEXT, XR_TYPE_HAND_TRACKING_DATA_SOURCE_STATE_EXT) \
|
||||
_avail(XrSystemPlaneDetectionPropertiesEXT, XR_TYPE_SYSTEM_PLANE_DETECTION_PROPERTIES_EXT) \
|
||||
_avail(XrPlaneDetectorCreateInfoEXT, XR_TYPE_PLANE_DETECTOR_CREATE_INFO_EXT) \
|
||||
_avail(XrPlaneDetectorBeginInfoEXT, XR_TYPE_PLANE_DETECTOR_BEGIN_INFO_EXT) \
|
||||
_avail(XrPlaneDetectorGetInfoEXT, XR_TYPE_PLANE_DETECTOR_GET_INFO_EXT) \
|
||||
_avail(XrPlaneDetectorLocationEXT, XR_TYPE_PLANE_DETECTOR_LOCATION_EXT) \
|
||||
_avail(XrPlaneDetectorLocationsEXT, XR_TYPE_PLANE_DETECTOR_LOCATIONS_EXT) \
|
||||
_avail(XrPlaneDetectorPolygonBufferEXT, XR_TYPE_PLANE_DETECTOR_POLYGON_BUFFER_EXT) \
|
||||
|
||||
|
||||
#if defined(XR_USE_GRAPHICS_API_D3D11)
|
||||
|
@ -410,6 +475,16 @@ This file contains expansion macros (X Macros) for OpenXR structures.
|
|||
|
||||
#endif
|
||||
|
||||
#if defined(XR_USE_PLATFORM_ML)
|
||||
#define _impl_XR_LIST_ALL_STRUCTURE_TYPES_XR_USE_PLATFORM_ML(_avail, _unavail) \
|
||||
_avail(XrCoordinateSpaceCreateInfoML, XR_TYPE_COORDINATE_SPACE_CREATE_INFO_ML) \
|
||||
|
||||
#else
|
||||
#define _impl_XR_LIST_ALL_STRUCTURE_TYPES_XR_USE_PLATFORM_ML(_avail, _unavail) \
|
||||
_unavail(XrCoordinateSpaceCreateInfoML, XR_TYPE_COORDINATE_SPACE_CREATE_INFO_ML) \
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(XR_USE_PLATFORM_WIN32)
|
||||
#define _impl_XR_LIST_ALL_STRUCTURE_TYPES_XR_USE_PLATFORM_WIN32(_avail, _unavail) \
|
||||
_avail(XrHolographicWindowAttachmentMSFT, XR_TYPE_HOLOGRAPHIC_WINDOW_ATTACHMENT_MSFT) \
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
// Copyright (c) 2016 Oculus VR, LLC.
|
||||
// Copyright (c) 2017-2023, The Khronos Group Inc.
|
||||
// Copyright (c) 2016, Oculus VR, LLC.
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
@ -21,22 +21,19 @@
|
|||
#ifndef XR_LINEAR_H_
|
||||
#define XR_LINEAR_H_
|
||||
|
||||
#if defined(OS_LINUX_XCB) || defined(OS_LINUX_XCB_GLX) || defined(OS_LINUX_WAYLAND)
|
||||
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||
#pragma clang diagnostic ignored "-Wunused-function"
|
||||
#endif
|
||||
|
||||
#include <openxr/openxr.h>
|
||||
|
||||
/* REUSE-IgnoreStart */
|
||||
/* The following has copyright notices that duplicate the header above */
|
||||
|
||||
/*
|
||||
================================================================================================
|
||||
|
||||
Description : Vector, matrix and quaternion math.
|
||||
Author : J.M.P. van Waveren
|
||||
Date : 12/10/2016
|
||||
Language : C99
|
||||
Format : Indent 4 spaces - no tabs.
|
||||
Copyright : Copyright (c) 2016 Oculus VR, LLC. All Rights reserved.
|
||||
Description : Vector, matrix and quaternion math.
|
||||
Orig. Author : J.M.P. van Waveren
|
||||
Orig. Date : 12/10/2016
|
||||
Language : C99
|
||||
Copyright : Copyright (c) 2016 Oculus VR, LLC. All Rights reserved.
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
|
@ -51,6 +48,7 @@ XrVector2f
|
|||
XrVector3f
|
||||
XrVector4f
|
||||
XrQuaternionf
|
||||
XrPosef
|
||||
XrMatrix4x4f
|
||||
|
||||
inline static void XrVector3f_Set(XrVector3f* v, const float value);
|
||||
|
@ -64,8 +62,18 @@ inline static void XrVector3f_Scale(XrVector3f* result, const XrVector3f* a, con
|
|||
inline static void XrVector3f_Normalize(XrVector3f* v);
|
||||
inline static float XrVector3f_Length(const XrVector3f* v);
|
||||
|
||||
inline static void XrQuaternionf_CreateIdentity(XrQuaternionf* q);
|
||||
inline static void XrQuaternionf_CreateFromAxisAngle(XrQuaternionf* result, const XrVector3f* axis, const float angleInRadians);
|
||||
inline static void XrQuaternionf_Lerp(XrQuaternionf* result, const XrQuaternionf* a, const XrQuaternionf* b, const float fraction);
|
||||
inline static void XrQuaternionf_Multiply(XrQuaternionf* result, const XrQuaternionf* a, const XrQuaternionf* b;
|
||||
inline static void XrQuaternionf_Multiply(XrQuaternionf* result, const XrQuaternionf* a, const XrQuaternionf* b);
|
||||
inline static void XrQuaternionf_Invert(XrQuaternionf* result, const XrQuaternionf* q);
|
||||
inline static void XrQuaternionf_Normalize(XrQuaternionf* q);
|
||||
inline static void XrQuaternionf_RotateVector3f(XrVector3f* result, const XrQuaternionf* a, const XrVector3f* v);
|
||||
|
||||
inline static void XrPosef_CreateIdentity(XrPosef* result);
|
||||
inline static void XrPosef_TransformVector3f(XrVector3f* result, const XrPosef* a, const XrVector3f* v);
|
||||
inline static void XrPosef_Multiply(XrPosef* result, const XrPosef* a, const XrPosef* b);
|
||||
inline static void XrPosef_Invert(XrPosef* result, const XrPosef* a);
|
||||
|
||||
inline static void XrMatrix4x4f_CreateIdentity(XrMatrix4x4f* result);
|
||||
inline static void XrMatrix4x4f_CreateTranslation(XrMatrix4x4f* result, const float x, const float y, const float z);
|
||||
|
@ -74,13 +82,13 @@ inline static void XrMatrix4x4f_CreateRotation(XrMatrix4x4f* result, const float
|
|||
inline static void XrMatrix4x4f_CreateScale(XrMatrix4x4f* result, const float x, const float y, const float z);
|
||||
inline static void XrMatrix4x4f_CreateTranslationRotationScale(XrMatrix4x4f* result, const XrVector3f* translation,
|
||||
const XrQuaternionf* rotation, const XrVector3f* scale);
|
||||
inline static void XrMatrix4x4f_CreateProjection(XrMatrix4x4f* result, const float tanAngleLeft, const float tanAngleRight,
|
||||
const float tanAngleUp, float const tanAngleDown, const float nearZ,
|
||||
const float farZ);
|
||||
inline static void XrMatrix4x4f_CreateProjectionFov(XrMatrix4x4f* result, const float fovDegreesLeft, const float fovDegreesRight,
|
||||
const float fovDegreeUp, const float fovDegreesDown, const float nearZ,
|
||||
const float farZ);
|
||||
inline static void XrMatrix4x4f_CreateFromQuaternion(XrMatrix4x4f* result, const XrQuaternionf* src);
|
||||
inline static void XrMatrix4x4f_CreateFromRigidTransform(XrMatrix4x4f* result, const XrPosef* s);
|
||||
inline static void XrMatrix4x4f_CreateProjection(XrMatrix4x4f* result, GraphicsAPI graphicsApi, const float tanAngleLeft,
|
||||
const float tanAngleRight, const float tanAngleUp, float const tanAngleDown,
|
||||
const float nearZ, const float farZ);
|
||||
inline static void XrMatrix4x4f_CreateProjectionFov(XrMatrix4x4f* result, GraphicsAPI graphicsApi, const XrFovf fov,
|
||||
const float nearZ, const float farZ);
|
||||
inline static void XrMatrix4x4f_CreateFromQuaternion(XrMatrix4x4f* result, const XrQuaternionf* quat);
|
||||
inline static void XrMatrix4x4f_CreateOffsetScaleForBounds(XrMatrix4x4f* result, const XrMatrix4x4f* matrix, const XrVector3f* mins,
|
||||
const XrVector3f* maxs);
|
||||
|
||||
|
@ -139,6 +147,8 @@ inline static float XrRcpSqrt(const float x) {
|
|||
return rcp;
|
||||
}
|
||||
|
||||
inline static float XrVector2f_Length(const XrVector2f* v) { return sqrtf(v->x * v->x + v->y * v->y); }
|
||||
|
||||
inline static void XrVector3f_Set(XrVector3f* v, const float value) {
|
||||
v->x = value;
|
||||
v->y = value;
|
||||
|
@ -207,6 +217,13 @@ inline static void XrVector3f_Normalize(XrVector3f* v) {
|
|||
|
||||
inline static float XrVector3f_Length(const XrVector3f* v) { return sqrtf(v->x * v->x + v->y * v->y + v->z * v->z); }
|
||||
|
||||
inline static void XrQuaternionf_CreateIdentity(XrQuaternionf* q) {
|
||||
q->x = 0.0f;
|
||||
q->y = 0.0f;
|
||||
q->z = 0.0f;
|
||||
q->w = 1.0f;
|
||||
}
|
||||
|
||||
inline static void XrQuaternionf_CreateFromAxisAngle(XrQuaternionf* result, const XrVector3f* axis, const float angleInRadians) {
|
||||
float s = sinf(angleInRadians / 2.0f);
|
||||
float lengthRcp = XrRcpSqrt(axis->x * axis->x + axis->y * axis->y + axis->z * axis->z);
|
||||
|
@ -238,6 +255,58 @@ inline static void XrQuaternionf_Multiply(XrQuaternionf* result, const XrQuatern
|
|||
result->w = (b->w * a->w) - (b->x * a->x) - (b->y * a->y) - (b->z * a->z);
|
||||
}
|
||||
|
||||
inline static void XrQuaternionf_Invert(XrQuaternionf* result, const XrQuaternionf* q) {
|
||||
result->x = -q->x;
|
||||
result->y = -q->y;
|
||||
result->z = -q->z;
|
||||
result->w = q->w;
|
||||
}
|
||||
|
||||
inline static void XrQuaternionf_Normalize(XrQuaternionf* q) {
|
||||
const float lengthRcp = XrRcpSqrt(q->x * q->x + q->y * q->y + q->z * q->z + q->w * q->w);
|
||||
q->x *= lengthRcp;
|
||||
q->y *= lengthRcp;
|
||||
q->z *= lengthRcp;
|
||||
q->w *= lengthRcp;
|
||||
}
|
||||
|
||||
inline static void XrQuaternionf_RotateVector3f(XrVector3f* result, const XrQuaternionf* a, const XrVector3f* v) {
|
||||
XrQuaternionf q = {v->x, v->y, v->z, 0.0f};
|
||||
XrQuaternionf aq;
|
||||
XrQuaternionf_Multiply(&aq, &q, a);
|
||||
XrQuaternionf aInv;
|
||||
XrQuaternionf_Invert(&aInv, a);
|
||||
XrQuaternionf aqaInv;
|
||||
XrQuaternionf_Multiply(&aqaInv, &aInv, &aq);
|
||||
|
||||
result->x = aqaInv.x;
|
||||
result->y = aqaInv.y;
|
||||
result->z = aqaInv.z;
|
||||
}
|
||||
|
||||
inline static void XrPosef_CreateIdentity(XrPosef* result) {
|
||||
XrQuaternionf_CreateIdentity(&result->orientation);
|
||||
XrVector3f_Set(&result->position, 0);
|
||||
}
|
||||
|
||||
inline static void XrPosef_TransformVector3f(XrVector3f* result, const XrPosef* a, const XrVector3f* v) {
|
||||
XrVector3f r0;
|
||||
XrQuaternionf_RotateVector3f(&r0, &a->orientation, v);
|
||||
XrVector3f_Add(result, &r0, &a->position);
|
||||
}
|
||||
|
||||
inline static void XrPosef_Multiply(XrPosef* result, const XrPosef* a, const XrPosef* b) {
|
||||
XrQuaternionf_Multiply(&result->orientation, &b->orientation, &a->orientation);
|
||||
XrPosef_TransformVector3f(&result->position, a, &b->position);
|
||||
}
|
||||
|
||||
inline static void XrPosef_Invert(XrPosef* result, const XrPosef* a) {
|
||||
XrQuaternionf_Invert(&result->orientation, &a->orientation);
|
||||
XrVector3f aPosNeg;
|
||||
XrVector3f_Scale(&aPosNeg, &a->position, -1.0f);
|
||||
XrQuaternionf_RotateVector3f(&result->position, &result->orientation, &aPosNeg);
|
||||
}
|
||||
|
||||
// Use left-multiplication to accumulate transformations.
|
||||
inline static void XrMatrix4x4f_Multiply(XrMatrix4x4f* result, const XrMatrix4x4f* a, const XrMatrix4x4f* b) {
|
||||
result->m[0] = a->m[0] * b->m[0] + a->m[4] * b->m[1] + a->m[8] * b->m[2] + a->m[12] * b->m[3];
|
||||
|
@ -379,23 +448,31 @@ inline static void XrMatrix4x4f_CreateTranslation(XrMatrix4x4f* result, const fl
|
|||
}
|
||||
|
||||
// Creates a rotation matrix.
|
||||
// If -Z=forward, +Y=up, +X=right, then degreesX=pitch, degreesY=yaw, degreesZ=roll.
|
||||
inline static void XrMatrix4x4f_CreateRotation(XrMatrix4x4f* result, const float degreesX, const float degreesY,
|
||||
const float degreesZ) {
|
||||
const float sinX = sinf(degreesX * (MATH_PI / 180.0f));
|
||||
const float cosX = cosf(degreesX * (MATH_PI / 180.0f));
|
||||
// If -Z=forward, +Y=up, +X=right, then radiansX=pitch, radiansY=yaw, radiansZ=roll.
|
||||
inline static void XrMatrix4x4f_CreateRotationRadians(XrMatrix4x4f* result, const float radiansX, const float radiansY,
|
||||
const float radiansZ) {
|
||||
const float sinX = sinf(radiansX);
|
||||
const float cosX = cosf(radiansX);
|
||||
const XrMatrix4x4f rotationX = {{1, 0, 0, 0, 0, cosX, sinX, 0, 0, -sinX, cosX, 0, 0, 0, 0, 1}};
|
||||
const float sinY = sinf(degreesY * (MATH_PI / 180.0f));
|
||||
const float cosY = cosf(degreesY * (MATH_PI / 180.0f));
|
||||
const float sinY = sinf(radiansY);
|
||||
const float cosY = cosf(radiansY);
|
||||
const XrMatrix4x4f rotationY = {{cosY, 0, -sinY, 0, 0, 1, 0, 0, sinY, 0, cosY, 0, 0, 0, 0, 1}};
|
||||
const float sinZ = sinf(degreesZ * (MATH_PI / 180.0f));
|
||||
const float cosZ = cosf(degreesZ * (MATH_PI / 180.0f));
|
||||
const float sinZ = sinf(radiansZ);
|
||||
const float cosZ = cosf(radiansZ);
|
||||
const XrMatrix4x4f rotationZ = {{cosZ, sinZ, 0, 0, -sinZ, cosZ, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}};
|
||||
XrMatrix4x4f rotationXY;
|
||||
XrMatrix4x4f_Multiply(&rotationXY, &rotationY, &rotationX);
|
||||
XrMatrix4x4f_Multiply(result, &rotationZ, &rotationXY);
|
||||
}
|
||||
|
||||
// Creates a rotation matrix.
|
||||
// If -Z=forward, +Y=up, +X=right, then degreesX=pitch, degreesY=yaw, degreesZ=roll.
|
||||
inline static void XrMatrix4x4f_CreateRotation(XrMatrix4x4f* result, const float degreesX, const float degreesY,
|
||||
const float degreesZ) {
|
||||
XrMatrix4x4f_CreateRotationRadians(result, degreesX * (MATH_PI / 180.0f), degreesY * (MATH_PI / 180.0f),
|
||||
degreesZ * (MATH_PI / 180.0f));
|
||||
}
|
||||
|
||||
// Creates a scale matrix.
|
||||
inline static void XrMatrix4x4f_CreateScale(XrMatrix4x4f* result, const float x, const float y, const float z) {
|
||||
result->m[0] = x;
|
||||
|
@ -471,6 +548,11 @@ inline static void XrMatrix4x4f_CreateTranslationRotationScale(XrMatrix4x4f* res
|
|||
XrMatrix4x4f_Multiply(result, &translationMatrix, &combinedMatrix);
|
||||
}
|
||||
|
||||
inline static void XrMatrix4x4f_CreateFromRigidTransform(XrMatrix4x4f* result, const XrPosef* s) {
|
||||
const XrVector3f identityScale = {1.0f, 1.0f, 1.0f};
|
||||
XrMatrix4x4f_CreateTranslationRotationScale(result, &s->position, &s->orientation, &identityScale);
|
||||
}
|
||||
|
||||
// Creates a projection matrix based on the specified dimensions.
|
||||
// The projection matrix transforms -Z=forward, +Y=up, +X=right to the appropriate clip space for the graphics API.
|
||||
// The far plane is placed at infinity if farZ <= nearZ.
|
||||
|
|
Loading…
Reference in a new issue