diff options
author | Campbell Barton <campbell@blender.org> | 2022-09-26 03:56:05 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-09-26 04:33:22 +0300 |
commit | 3961d3493be9c666850e71abe6102f72d3db9332 (patch) | |
tree | 83b903f8040f6384cbd4f702546db52a02bcd3dc /source/blender/windowmanager | |
parent | 3a7dc572dc9bbad35bdff3a3aeca8eab0ccb3fb7 (diff) |
Cleanup: use 'u' prefixed integer types for brevity in C code
This also simplifies using function style casts when moving to C++.
Diffstat (limited to 'source/blender/windowmanager')
4 files changed, 32 insertions, 33 deletions
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index b7a3538aeb2..85e1227ab73 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -1628,7 +1628,7 @@ wmTimer *WM_event_add_timer(wmWindowManager *wm, wmWindow *win, int event_type, wmTimer *WM_event_add_timer_notifier(wmWindowManager *wm, wmWindow *win, - unsigned int type, + uint type, double timestep) { wmTimer *wt = MEM_callocN(sizeof(wmTimer), "window timer"); diff --git a/source/blender/windowmanager/xr/intern/wm_xr_action.c b/source/blender/windowmanager/xr/intern/wm_xr_action.c index a83415c98af..68f6bfc1aff 100644 --- a/source/blender/windowmanager/xr/intern/wm_xr_action.c +++ b/source/blender/windowmanager/xr/intern/wm_xr_action.c @@ -72,8 +72,8 @@ static wmXrAction *action_create(const char *action_name, strcpy(action->name, action_name); action->type = type; - const unsigned int count = (unsigned int)BLI_listbase_count(user_paths); - unsigned int subaction_idx = 0; + const uint count = (uint)BLI_listbase_count(user_paths); + uint subaction_idx = 0; action->count_subaction_paths = count; action->subaction_paths = MEM_mallocN(sizeof(*action->subaction_paths) * count, @@ -142,7 +142,7 @@ static void action_destroy(void *val) char **subaction_paths = action->subaction_paths; if (subaction_paths) { - for (unsigned int i = 0; i < action->count_subaction_paths; ++i) { + for (uint i = 0; i < action->count_subaction_paths; ++i) { MEM_SAFE_FREE(subaction_paths[i]); } MEM_freeN(subaction_paths); @@ -241,8 +241,8 @@ bool WM_xr_action_create(wmXrData *xr, action_flag, haptic_flag); - const unsigned int count = (unsigned int)BLI_listbase_count(user_paths); - unsigned int subaction_idx = 0; + const uint count = (uint)BLI_listbase_count(user_paths); + uint subaction_idx = 0; char **subaction_paths = MEM_calloc_arrayN( count, sizeof(*subaction_paths), "XrAction_SubactionPathPointers"); @@ -336,8 +336,8 @@ bool WM_xr_action_binding_create(wmXrData *xr, const eXrAxisFlag *axis_flags, const struct wmXrPose *poses) { - const unsigned int count = (unsigned int)BLI_listbase_count(user_paths); - BLI_assert(count == (unsigned int)BLI_listbase_count(component_paths)); + const uint count = (uint)BLI_listbase_count(user_paths); + BLI_assert(count == (uint)BLI_listbase_count(component_paths)); GHOST_XrActionBindingInfo *binding_infos = MEM_calloc_arrayN( count, sizeof(*binding_infos), "XrActionBinding_Infos"); @@ -345,7 +345,7 @@ bool WM_xr_action_binding_create(wmXrData *xr, char **subaction_paths = MEM_calloc_arrayN( count, sizeof(*subaction_paths), "XrActionBinding_SubactionPathPointers"); - for (unsigned int i = 0; i < count; ++i) { + for (uint i = 0; i < count; ++i) { GHOST_XrActionBindingInfo *binding_info = &binding_infos[i]; const XrUserPath *user_path = BLI_findlink(user_paths, i); const XrComponentPath *component_path = BLI_findlink(component_paths, i); @@ -448,12 +448,12 @@ bool WM_xr_controller_pose_actions_set(wmXrData *xr, } /* Ensure consistent subaction paths. */ - const unsigned int count = grip_action->count_subaction_paths; + const uint count = grip_action->count_subaction_paths; if (count != aim_action->count_subaction_paths) { return false; } - for (unsigned int i = 0; i < count; ++i) { + for (uint i = 0; i < count; ++i) { if (!STREQ(grip_action->subaction_paths[i], aim_action->subaction_paths[i])) { return false; } @@ -483,7 +483,7 @@ bool WM_xr_action_state_get(const wmXrData *xr, r_state->type = (int)action->type; /* Find the action state corresponding to the subaction path. */ - for (unsigned int i = 0; i < action->count_subaction_paths; ++i) { + for (uint i = 0; i < action->count_subaction_paths; ++i) { if (STREQ(subaction_path, action->subaction_paths[i])) { switch (action->type) { case XR_BOOLEAN_INPUT: diff --git a/source/blender/windowmanager/xr/intern/wm_xr_draw.c b/source/blender/windowmanager/xr/intern/wm_xr_draw.c index 3b1acee2b99..6e32c5a0aae 100644 --- a/source/blender/windowmanager/xr/intern/wm_xr_draw.c +++ b/source/blender/windowmanager/xr/intern/wm_xr_draw.c @@ -213,9 +213,9 @@ static GPUBatch *wm_xr_controller_model_batch_create(GHOST_XrContextHandle xr_co GPUIndexBuf *ibo = NULL; if (model_data.count_indices > 0 && ((model_data.count_indices % 3) == 0)) { GPUIndexBufBuilder ibo_builder; - const unsigned int prim_len = model_data.count_indices / 3; + const uint prim_len = model_data.count_indices / 3; GPU_indexbuf_init(&ibo_builder, GPU_PRIM_TRIS, prim_len, model_data.count_vertices); - for (unsigned int i = 0; i < prim_len; ++i) { + for (uint i = 0; i < prim_len; ++i) { const uint32_t *idx = &model_data.indices[i * 3]; GPU_indexbuf_add_tri_verts(&ibo_builder, idx[0], idx[1], idx[2]); } @@ -261,8 +261,7 @@ static void wm_xr_controller_model_draw(const XrSessionSettings *settings, GPU_matrix_push(); GPU_matrix_mul(controller->grip_mat); - for (unsigned int component_idx = 0; component_idx < model_data.count_components; - ++component_idx) { + for (uint component_idx = 0; component_idx < model_data.count_components; ++component_idx) { const GHOST_XrControllerModelComponent *component = &model_data.components[component_idx]; GPU_matrix_push(); GPU_matrix_mul(component->transform); diff --git a/source/blender/windowmanager/xr/intern/wm_xr_session.c b/source/blender/windowmanager/xr/intern/wm_xr_session.c index a4d2a65830f..abc41833de6 100644 --- a/source/blender/windowmanager/xr/intern/wm_xr_session.c +++ b/source/blender/windowmanager/xr/intern/wm_xr_session.c @@ -432,7 +432,7 @@ bool WM_xr_session_state_viewer_pose_matrix_info_get(const wmXrData *xr, } bool WM_xr_session_state_controller_grip_location_get(const wmXrData *xr, - unsigned int subaction_idx, + uint subaction_idx, float r_location[3]) { if (!WM_xr_session_is_ready(xr) || !xr->runtime->session_state.is_view_data_set || @@ -449,7 +449,7 @@ bool WM_xr_session_state_controller_grip_location_get(const wmXrData *xr, } bool WM_xr_session_state_controller_grip_rotation_get(const wmXrData *xr, - unsigned int subaction_idx, + uint subaction_idx, float r_rotation[4]) { if (!WM_xr_session_is_ready(xr) || !xr->runtime->session_state.is_view_data_set || @@ -466,7 +466,7 @@ bool WM_xr_session_state_controller_grip_rotation_get(const wmXrData *xr, } bool WM_xr_session_state_controller_aim_location_get(const wmXrData *xr, - unsigned int subaction_idx, + uint subaction_idx, float r_location[3]) { if (!WM_xr_session_is_ready(xr) || !xr->runtime->session_state.is_view_data_set || @@ -483,7 +483,7 @@ bool WM_xr_session_state_controller_aim_location_get(const wmXrData *xr, } bool WM_xr_session_state_controller_aim_rotation_get(const wmXrData *xr, - unsigned int subaction_idx, + uint subaction_idx, float r_rotation[4]) { if (!WM_xr_session_is_ready(xr) || !xr->runtime->session_state.is_view_data_set || @@ -615,7 +615,7 @@ static void wm_xr_session_controller_data_update(const XrSessionSettings *settin BLI_assert(grip_action->count_subaction_paths == aim_action->count_subaction_paths); BLI_assert(grip_action->count_subaction_paths == BLI_listbase_count(&state->controllers)); - unsigned int subaction_idx = 0; + uint subaction_idx = 0; float view_ofs[3], base_mat[4][4], nav_mat[4][4]; if ((settings->flag & XR_SESSION_USE_POSITION_TRACKING) == 0) { @@ -816,7 +816,7 @@ static void wm_xr_session_haptic_timers_check(ListBase *active_haptic_actions, i static void wm_xr_session_action_states_interpret(wmXrData *xr, const char *action_set_name, wmXrAction *action, - unsigned int subaction_idx, + uint subaction_idx, ListBase *active_modal_actions, ListBase *active_haptic_actions, int64_t time_now, @@ -960,8 +960,8 @@ static void wm_xr_session_action_states_interpret(wmXrData *xr, static bool wm_xr_session_action_test_bimanual(const wmXrSessionState *session_state, wmXrAction *action, - unsigned int subaction_idx, - unsigned int *r_subaction_idx_other, + uint subaction_idx, + uint *r_subaction_idx_other, const GHOST_XrPose **r_aim_pose_other) { if ((action->action_flag & XR_ACTION_BIMANUAL) == 0) { @@ -971,7 +971,7 @@ static bool wm_xr_session_action_test_bimanual(const wmXrSessionState *session_s bool bimanual = false; *r_subaction_idx_other = (subaction_idx == 0) ? - (unsigned int)min_ii(1, action->count_subaction_paths - 1) : + (uint)min_ii(1, action->count_subaction_paths - 1) : 0; switch (action->type) { @@ -1018,8 +1018,8 @@ static wmXrActionData *wm_xr_session_event_create(const char *action_set_name, const wmXrAction *action, const GHOST_XrPose *controller_aim_pose, const GHOST_XrPose *controller_aim_pose_other, - unsigned int subaction_idx, - unsigned int subaction_idx_other, + uint subaction_idx, + uint subaction_idx_other, bool bimanual) { wmXrActionData *data = MEM_callocN(sizeof(wmXrActionData), __func__); @@ -1092,7 +1092,7 @@ static void wm_xr_session_events_dispatch(wmXrData *xr, { const char *action_set_name = action_set->name; - const unsigned int count = GHOST_XrGetActionCount(xr_context, action_set_name); + const uint count = GHOST_XrGetActionCount(xr_context, action_set_name); if (count < 1) { return; } @@ -1109,14 +1109,14 @@ static void wm_xr_session_events_dispatch(wmXrData *xr, /* Check haptic action timers. */ wm_xr_session_haptic_timers_check(active_haptic_actions, time_now); - for (unsigned int action_idx = 0; action_idx < count; ++action_idx) { + for (uint action_idx = 0; action_idx < count; ++action_idx) { wmXrAction *action = actions[action_idx]; if (action && action->ot) { const bool modal = action->ot->modal; const bool haptic = (GHOST_XrGetActionCustomdata( xr_context, action_set_name, action->haptic_name) != NULL); - for (unsigned int subaction_idx = 0; subaction_idx < action->count_subaction_paths; + for (uint subaction_idx = 0; subaction_idx < action->count_subaction_paths; ++subaction_idx) { short val = KM_NOTHING; @@ -1143,7 +1143,7 @@ static void wm_xr_session_events_dispatch(wmXrData *xr, const GHOST_XrPose *aim_pose = wm_xr_session_controller_aim_pose_find( session_state, action->subaction_paths[subaction_idx]); const GHOST_XrPose *aim_pose_other = NULL; - unsigned int subaction_idx_other = 0; + uint subaction_idx_other = 0; /* Test for bimanual interaction. */ const bool bimanual = wm_xr_session_action_test_bimanual( @@ -1242,11 +1242,11 @@ void wm_xr_session_controller_data_populate(const wmXrAction *grip_action, ListBase *controllers = &state->controllers; BLI_assert(grip_action->count_subaction_paths == aim_action->count_subaction_paths); - const unsigned int count = grip_action->count_subaction_paths; + const uint count = grip_action->count_subaction_paths; wm_xr_session_controller_data_free(state); - for (unsigned int i = 0; i < count; ++i) { + for (uint i = 0; i < count; ++i) { wmXrController *controller = MEM_callocN(sizeof(*controller), __func__); BLI_assert(STREQ(grip_action->subaction_paths[i], aim_action->subaction_paths[i])); |