The open source OpenXR runtime
0
fork

Configure Feed

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

a/util: Resolve warnings

+50 -53
+45 -45
src/xrt/auxiliary/util/u_distortion_mesh.c
··· 27 27 typedef bool (*func_calc)(struct xrt_device *xdev, int view, float u, float v, struct xrt_uv_triplet *result); 28 28 29 29 static int 30 - index_for(int row, int col, int stride, int offset) 30 + index_for(int row, int col, uint32_t stride, uint32_t offset) 31 31 { 32 32 return row * stride + col + offset; 33 33 } 34 34 35 - void 36 - run_func(struct xrt_device *xdev, func_calc calc, int view_count, struct xrt_hmd_parts *target, size_t num) 35 + static void 36 + run_func(struct xrt_device *xdev, func_calc calc, int view_count, struct xrt_hmd_parts *target, uint32_t num) 37 37 { 38 38 assert(calc != NULL); 39 39 assert(view_count == 2); 40 40 assert(view_count <= 2); 41 41 42 - size_t vertex_offsets[2] = {0}; 43 - size_t index_offsets[2] = {0}; 42 + uint32_t vertex_offsets[2] = {0}; 43 + uint32_t index_offsets[2] = {0}; 44 44 45 - int cells_cols = num; 46 - int cells_rows = num; 47 - int vert_cols = cells_cols + 1; 48 - int vert_rows = cells_rows + 1; 45 + uint32_t cells_cols = num; 46 + uint32_t cells_rows = num; 47 + uint32_t vert_cols = cells_cols + 1; 48 + uint32_t vert_rows = cells_rows + 1; 49 49 50 - size_t vertex_count_per_view = vert_rows * vert_cols; 51 - size_t vertex_count = vertex_count_per_view * view_count; 50 + uint32_t vertex_count_per_view = vert_rows * vert_cols; 51 + uint32_t vertex_count = vertex_count_per_view * view_count; 52 52 53 - size_t uv_channels_count = 3; 54 - size_t stride_in_floats = 2 + uv_channels_count * 2; 55 - size_t float_count = vertex_count * stride_in_floats; 53 + uint32_t uv_channels_count = 3; 54 + uint32_t stride_in_floats = 2 + uv_channels_count * 2; 55 + uint32_t float_count = vertex_count * stride_in_floats; 56 56 57 57 float *verts = U_TYPED_ARRAY_CALLOC(float, float_count); 58 58 59 59 // Setup the vertices for all views. 60 - size_t i = 0; 60 + uint32_t i = 0; 61 61 for (int view = 0; view < view_count; view++) { 62 62 vertex_offsets[view] = i / stride_in_floats; 63 63 64 - for (int r = 0; r < vert_rows; r++) { 64 + for (uint32_t r = 0; r < vert_rows; r++) { 65 65 // This goes from 0 to 1.0 inclusive. 66 66 float v = (float)r / (float)cells_rows; 67 67 68 - for (int c = 0; c < vert_cols; c++) { 68 + for (uint32_t c = 0; c < vert_cols; c++) { 69 69 // This goes from 0 to 1.0 inclusive. 70 70 float u = (float)c / (float)cells_cols; 71 71 72 72 // Make the position in the range of [-1, 1] 73 - verts[i + 0] = u * 2.0 - 1.0; 74 - verts[i + 1] = v * 2.0 - 1.0; 73 + verts[i + 0] = u * 2.0f - 1.0f; 74 + verts[i + 1] = v * 2.0f - 1.0f; 75 75 76 76 if (!calc(xdev, view, u, v, (struct xrt_uv_triplet *)&verts[i + 2])) { 77 77 // bail on error, without updating ··· 84 84 } 85 85 } 86 86 87 - size_t index_count_per_view = cells_rows * (vert_cols * 2 + 2); 88 - size_t index_count_total = index_count_per_view * view_count; 87 + uint32_t index_count_per_view = cells_rows * (vert_cols * 2 + 2); 88 + uint32_t index_count_total = index_count_per_view * view_count; 89 89 int *indices = U_TYPED_ARRAY_CALLOC(int, index_count_total); 90 90 91 91 // Set up indices for all views. ··· 93 93 for (int view = 0; view < view_count; view++) { 94 94 index_offsets[view] = i; 95 95 96 - size_t off = vertex_offsets[view]; 96 + uint32_t off = vertex_offsets[view]; 97 97 98 - for (int r = 0; r < cells_rows; r++) { 98 + for (uint32_t r = 0; r < cells_rows; r++) { 99 99 // Top vertex row for this cell row, left most vertex. 100 100 indices[i++] = index_for(r, 0, vert_cols, off); 101 101 102 - for (int c = 0; c < vert_cols; c++) { 102 + for (uint32_t c = 0; c < vert_cols; c++) { 103 103 indices[i++] = index_for(r, c, vert_cols, off); 104 104 indices[i++] = index_for(r + 1, c, vert_cols, off); 105 105 } ··· 129 129 // Reading the whole struct like this gives the compiler more opportunity to optimize. 130 130 const struct u_vive_values val = *values; 131 131 132 - const float common_factor_value = 0.5 / (1.0 + val.grow_for_undistort); 132 + const float common_factor_value = 0.5f / (1.0f + val.grow_for_undistort); 133 133 const struct xrt_vec2 factor = { 134 134 common_factor_value, 135 135 common_factor_value * val.aspect_x_over_y, 136 136 }; 137 137 138 138 // Results r/g/b. 139 - struct xrt_vec2 tc[3]; 139 + struct xrt_vec2 tc[3] = {{0, 0}, {0, 0}, {0, 0}}; 140 140 141 141 // Dear compiler, please vectorize. 142 142 for (int i = 0; i < 3; i++) { 143 143 struct xrt_vec2 texCoord = { 144 - 2.0 * u - 1.0, 145 - 2.0 * v - 1.0, 144 + 2.f * u - 1.f, 145 + 2.f * v - 1.f, 146 146 }; 147 147 148 148 texCoord.y /= val.aspect_x_over_y; ··· 167 167 * 1.0 + r^2 * ((k1 + r^2 * k2) + r^2 * k3) 168 168 */ 169 169 170 - float top = 1.0; 171 - float bottom = 1.0 + r2 * (k1 + r2 * (k2 + r2 * k3)); 170 + float top = 1.f; 171 + float bottom = 1.f + r2 * (k1 + r2 * (k2 + r2 * k3)); 172 172 float d = (top / bottom) + k4; 173 173 174 - struct xrt_vec2 offset = {0.5, 0.5}; 174 + struct xrt_vec2 offset = {0.5f, 0.5f}; 175 175 176 176 tc[i].x = offset.x + (texCoord.x * d + val.center[i].x) * factor.x; 177 177 tc[i].y = offset.y + (texCoord.y * d + val.center[i].y) * factor.y; ··· 294 294 { 295 295 // I think that OpenCV and Monado have different definitions of v coordinates, but not sure. if not, 296 296 // unexplainable 297 - v = 1.0 - v; 297 + v = 1.0f - v; 298 298 299 299 float x_ray = u_ns_polyval2d(u, v, view ? values->x_coefficients_left : values->x_coefficients_right); 300 300 float y_ray = u_ns_polyval2d(u, v, view ? values->y_coefficients_left : values->y_coefficients_right); ··· 306 306 float up_ray_bound = tanf(fov.angle_up); 307 307 float down_ray_bound = tanf(fov.angle_down); 308 308 309 - float u_eye = math_map_ranges(x_ray, left_ray_bound, right_ray_bound, 0, 1); 309 + float u_eye = (float)math_map_ranges(x_ray, left_ray_bound, right_ray_bound, 0, 1); 310 310 311 - float v_eye = math_map_ranges(y_ray, down_ray_bound, up_ray_bound, 0, 1); 311 + float v_eye = (float)math_map_ranges(y_ray, down_ray_bound, up_ray_bound, 0, 1); 312 312 313 313 // boilerplate, put the UV coordinates in all the RGB slots 314 314 result->r.x = u_eye; ··· 333 333 bool 334 334 u_compute_distortion_ns_vipd(struct u_ns_vipd_values *values, int view, float u, float v, struct xrt_uv_triplet *result) 335 335 { 336 - int u_index_int = floorf(u * 64); 337 - int v_index_int = floorf(v * 64); 336 + int u_index_int = (int)floorf(u * 64); 337 + int v_index_int = (int)floorf(v * 64); 338 338 float u_index_frac = (u * 64) - u_index_int; 339 339 float v_index_frac = (v * 64) - v_index_int; 340 340 ··· 349 349 struct xrt_vec2 topright = values->grid_for_use.grid[view][v_index_int][u_index_int + 1]; 350 350 struct xrt_vec2 bottomleft = values->grid_for_use.grid[view][v_index_int + 1][u_index_int]; 351 351 struct xrt_vec2 bottomright = values->grid_for_use.grid[view][v_index_int + 1][u_index_int + 1]; 352 - struct xrt_vec2 leftcorrect = {math_map_ranges(v_index_frac, 0, 1, topleft.x, bottomleft.x), 353 - math_map_ranges(v_index_frac, 0, 1, topleft.y, bottomleft.y)}; 354 - struct xrt_vec2 rightcorrect = {math_map_ranges(v_index_frac, 0, 1, topright.x, bottomright.x), 355 - math_map_ranges(v_index_frac, 0, 1, topright.y, bottomright.y)}; 356 - y_ray = math_map_ranges(u_index_frac, 0, 1, leftcorrect.x, rightcorrect.x); 357 - x_ray = math_map_ranges(u_index_frac, 0, 1, leftcorrect.y, rightcorrect.y); 352 + struct xrt_vec2 leftcorrect = {(float)math_map_ranges(v_index_frac, 0, 1, topleft.x, bottomleft.x), 353 + (float)math_map_ranges(v_index_frac, 0, 1, topleft.y, bottomleft.y)}; 354 + struct xrt_vec2 rightcorrect = {(float)math_map_ranges(v_index_frac, 0, 1, topright.x, bottomright.x), 355 + (float)math_map_ranges(v_index_frac, 0, 1, topright.y, bottomright.y)}; 356 + y_ray = (float)math_map_ranges(u_index_frac, 0, 1, leftcorrect.x, rightcorrect.x); 357 + x_ray = (float)math_map_ranges(u_index_frac, 0, 1, leftcorrect.y, rightcorrect.y); 358 358 } else { 359 359 // probably this path if grid size is 65x65 like normal 360 360 x_ray = values->grid_for_use.grid[view][v_index_int][u_index_int].y; ··· 369 369 float down_ray_bound = tanf(fov.angle_down); 370 370 // printf("%f %f", fov.angle_down, fov.angle_up); 371 371 372 - float u_eye = math_map_ranges(x_ray, left_ray_bound, right_ray_bound, 0, 1); 372 + float u_eye = (float)math_map_ranges(x_ray, left_ray_bound, right_ray_bound, 0, 1); 373 373 374 - float v_eye = math_map_ranges(y_ray, down_ray_bound, up_ray_bound, 0, 1); 374 + float v_eye = (float)math_map_ranges(y_ray, down_ray_bound, up_ray_bound, 0, 1); 375 375 376 376 // boilerplate, put the UV coordinates in all the RGB slots 377 377 result->r.x = u_eye; ··· 462 462 463 463 struct xrt_hmd_parts *target = xdev->hmd; 464 464 465 - size_t num = debug_get_num_option_mesh_size(); 465 + uint32_t num = (uint32_t)debug_get_num_option_mesh_size(); 466 466 run_func(xdev, calc, 2, target, num); 467 467 }
-6
src/xrt/auxiliary/util/u_hand_tracking.h
··· 135 135 * @ingroup aux_util 136 136 */ 137 137 bool 138 - u_hand_joint_is_tip(enum xrt_hand_joint joint); 139 - 140 - /*! 141 - * @ingroup aux_util 142 - */ 143 - bool 144 138 u_hand_joint_is_thumb(enum xrt_hand_joint joint); 145 139 146 140 /*!
+3
src/xrt/auxiliary/util/u_time.cpp
··· 42 42 time_state_create() 43 43 { 44 44 time_state *state = new (std::nothrow) time_state; 45 + if (!state) { 46 + return state; 47 + } 45 48 state->offset = os_monotonic_get_ns(); 46 49 return state; 47 50 }
+2 -2
src/xrt/auxiliary/util/u_var.cpp
··· 55 55 public: 56 56 std::unordered_map<std::string, size_t> counters = {}; 57 57 std::unordered_map<ptrdiff_t, Obj> map = {}; 58 - bool on; 59 - bool tested; 58 + bool on = false; 59 + bool tested = false; 60 60 61 61 public: 62 62 int