The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

d/ns: Tidy code

+37 -51
+5 -6
src/xrt/drivers/north_star/distortion/deformation_northstar.cpp
··· 4 4 5 5 #include "deformation_northstar.h" 6 6 7 + 7 8 OpticalSystem::OpticalSystem(const OpticalSystem &_in) 8 9 { 9 10 ellipseMinorAxis = _in.ellipseMinorAxis; ··· 107 108 } 108 109 } 109 110 110 - 111 111 Vector2 112 112 OpticalSystem::RenderUVToDisplayUV(Vector2 inputUV) 113 113 { ··· 186 186 187 187 return ScreenUV_Real; 188 188 } 189 - 190 189 191 190 Vector2 192 191 OpticalSystem::SolveDisplayUVToRenderUV(Vector2 inputUV, ··· 294 293 } 295 294 296 295 297 - extern "C" ns_optical_system * 296 + extern "C" struct ns_optical_system * 298 297 ns_create_optical_system(struct ns_eye *eye) 299 298 { 300 299 OpticalSystem *opticalSystem = new OpticalSystem(); 301 300 opticalSystem->LoadOpticalData(eye); 302 301 opticalSystem->setiters(50, 50); 303 302 opticalSystem->RegenerateMesh(); 304 - return (ns_optical_system *)opticalSystem; 303 + return (struct ns_optical_system *)opticalSystem; 305 304 } 306 305 307 306 extern "C" void 308 307 ns_display_uv_to_render_uv(struct ns_uv in, 309 308 struct ns_uv *out, 310 - struct ns_eye eye) 309 + struct ns_eye *eye) 311 310 { 312 - OpticalSystem *opticalSystem = (OpticalSystem *)eye.optical_system; 311 + OpticalSystem *opticalSystem = (OpticalSystem *)eye->optical_system; 313 312 Vector2 inUV = Vector2(in.u, 1.f - in.v); 314 313 Vector2 outUV = opticalSystem->DisplayUVToRenderUVPreviousSeed(inUV); 315 314 out->u = outUV.x;
+6 -18
src/xrt/drivers/north_star/ns_hmd.c
··· 9 9 * @ingroup drv_ns 10 10 */ 11 11 12 - 13 12 #include <math.h> 14 13 #include <stdio.h> 15 14 #include <unistd.h> ··· 37 36 * 38 37 */ 39 38 40 - struct ns_hmd * 41 - get_ns_hmd(struct xrt_device *xdev) 42 - { 43 - return (struct ns_hmd *)xdev; 44 - } 45 - 46 - static inline struct ns_mesh * 47 - ns_mesh(struct u_uv_generator *gen) 48 - { 49 - return (struct ns_mesh *)gen; 50 - } 51 - 52 39 static void 53 40 ns_hmd_destroy(struct xrt_device *xdev) 54 41 { 55 - struct ns_hmd *ns = get_ns_hmd(xdev); 42 + struct ns_hmd *ns = ns_hmd(xdev); 56 43 57 44 // Remove the variable tracking. 58 45 u_var_remove_root(ns); ··· 63 50 static void 64 51 ns_hmd_update_inputs(struct xrt_device *xdev, struct time_state *timekeeping) 65 52 { 66 - struct ns_hmd *ns = get_ns_hmd(xdev); 53 + struct ns_hmd *ns = ns_hmd(xdev); 67 54 68 55 if (ns->tracker != NULL) { 69 56 ns->tracker->update_inputs(ns->tracker, timekeeping); ··· 77 64 int64_t *out_timestamp, 78 65 struct xrt_space_relation *out_relation) 79 66 { 80 - struct ns_hmd *ns = get_ns_hmd(xdev); 67 + struct ns_hmd *ns = ns_hmd(xdev); 81 68 82 69 83 70 // If the tracking device is created use it. ··· 107 94 uint32_t view_index, 108 95 struct xrt_pose *out_pose) 109 96 { 110 - struct ns_hmd *ns = get_ns_hmd(xdev); 97 + struct ns_hmd *ns = ns_hmd(xdev); 111 98 *out_pose = ns->eye_configs[view_index].eye_pose; 112 99 } 113 100 ··· 129 116 130 117 struct ns_uv uv = {u, v}; 131 118 struct ns_uv warped_uv = {0.0f, 0.0f}; 132 - ns_display_uv_to_render_uv(uv, &warped_uv, mesh->ns->eye_configs[view]); 119 + ns_display_uv_to_render_uv(uv, &warped_uv, 120 + &mesh->ns->eye_configs[view]); 133 121 134 122 result->r.x = warped_uv.u; 135 123 result->r.y = warped_uv.v;
+25 -27
src/xrt/drivers/north_star/ns_hmd.h
··· 16 16 #include "xrt/xrt_defines.h" 17 17 #include "xrt/xrt_device.h" 18 18 19 + 19 20 #ifdef __cplusplus 20 21 extern "C" { 21 22 #endif 22 23 23 - /*! 24 - * @defgroup drv_ns North Star Driver 25 - * @ingroup drv 26 - * 27 - * @brief Driver for the North Star HMD. 28 - */ 29 24 30 25 /* 31 26 * ··· 65 60 * 66 61 */ 67 62 68 - 69 63 /*! 70 64 * Opaque struct for optical system C++ integration 71 65 * 72 66 * @ingroup drv_ns 73 67 */ 74 - typedef struct _ns_optical_system ns_optical_system; 75 - 68 + struct ns_optical_system; 76 69 77 70 /*! 78 71 * Simple UV struct. ··· 84 77 float u; 85 78 float v; 86 79 }; 87 - 88 80 89 81 /*! 90 82 * Configuration information about the LMC or Rigel sensor according to the ··· 98 90 const char *serial; 99 91 struct xrt_pose pose; 100 92 }; 101 - 102 93 103 94 /*! 104 95 * Distortion information about an eye parsed from the configuration file. ··· 120 111 struct xrt_matrix_4x4 sphere_to_world_space; 121 112 struct xrt_matrix_4x4 world_to_screen_space; 122 113 123 - ns_optical_system *optical_system; 114 + struct ns_optical_system *optical_system; 124 115 }; 125 116 126 117 /*! ··· 155 146 struct ns_hmd *ns; 156 147 }; 157 148 158 - /*! 159 - * @dir drivers/north_star 160 - * 161 - * @brief @ref drv_ns files. 162 - */ 163 - 164 149 165 150 /* 166 151 * ··· 169 154 */ 170 155 171 156 /*! 172 - * Convert the display UV to the render UV using the distortion mesh. 157 + * Get the North Star HMD information from a @ref xrt_device. 173 158 * 174 159 * @ingroup drv_ns 175 160 */ 176 - void 177 - ns_display_uv_to_render_uv(struct ns_uv display_uv, 178 - struct ns_uv *render_uv, 179 - struct ns_eye eye); 161 + XRT_MAYBE_UNUSED static inline struct ns_hmd * 162 + ns_hmd(struct xrt_device *xdev) 163 + { 164 + return (struct ns_hmd *)xdev; 165 + } 180 166 181 167 /*! 182 - * Get the North Star HMD information from the xrt_device. 168 + * Get the North Star mesh generator from a @ref u_uv_generator. 183 169 * 184 170 * @ingroup drv_ns 185 171 */ 186 - struct ns_hmd * 187 - get_ns_hmd(struct xrt_device *xdev); 172 + XRT_MAYBE_UNUSED static inline struct ns_mesh * 173 + ns_mesh(struct u_uv_generator *gen) 174 + { 175 + return (struct ns_mesh *)gen; 176 + } 188 177 178 + /*! 179 + * Convert the display UV to the render UV using the distortion mesh. 180 + * 181 + * @ingroup drv_ns 182 + */ 183 + void 184 + ns_display_uv_to_render_uv(struct ns_uv display_uv, 185 + struct ns_uv *render_uv, 186 + struct ns_eye *eye); 189 187 190 - ns_optical_system * 188 + struct ns_optical_system * 191 189 ns_create_optical_system(struct ns_eye *eye); 192 190 193 191
+1
src/xrt/drivers/north_star/ns_interface.h
··· 14 14 extern "C" { 15 15 #endif 16 16 17 + 17 18 /*! 18 19 * @defgroup drv_ns North Star Driver 19 20 * @ingroup drv