diff --git a/paint/sources/base.c b/paint/sources/base.c index 798cd304..d15c600c 100644 --- a/paint/sources/base.c +++ b/paint/sources/base.c @@ -99,7 +99,7 @@ void base_init() { if (config_raw->layout->buffer[LAYOUT_SIZE_HEADER] == 1) { base_appy = ui_header_h * 2; } - scene_camera->data->fov = math_floor(scene_camera->data->fov * 100) / (float)100; + scene_camera->data->fov = math_floor(scene_camera->data->fov * 100) / 100.0; camera_object_build_proj(scene_camera, -1.0); args_run(); @@ -167,7 +167,7 @@ i32 base_view3d_w() { res = iron_window_width(); } if (context_raw->view_index > -1) { - res = math_ceil(res / (float)2); + res = math_ceil(res / 2.0); } if (context_raw->paint2d_view) { res = ui_view2d_ww; @@ -1005,13 +1005,13 @@ void ui_base_update(void *_) { operator_shortcut(string("%s+%s", any_map_get(config_keymap, "decal_mask"), any_map_get(config_keymap, "brush_radius")), SHORTCUT_TYPE_DOWN))) { if (context_raw->brush_locked) { if (operator_shortcut(any_map_get(config_keymap, "brush_opacity"), SHORTCUT_TYPE_DOWN)) { - context_raw->brush_opacity += mouse_movement_x / (float)500; + context_raw->brush_opacity += mouse_movement_x / 500.0; context_raw->brush_opacity = math_max(0.0, math_min(1.0, context_raw->brush_opacity)); - context_raw->brush_opacity = math_round(context_raw->brush_opacity * 100) / (float)100; + context_raw->brush_opacity = math_round(context_raw->brush_opacity * 100) / 100.0; context_raw->brush_opacity_handle->f = context_raw->brush_opacity; } else if (operator_shortcut(any_map_get(config_keymap, "brush_angle"), SHORTCUT_TYPE_DOWN)) { - context_raw->brush_angle += mouse_movement_x / (float)5; + context_raw->brush_angle += mouse_movement_x / 5.0; i32 i = math_floor(context_raw->brush_angle); context_raw->brush_angle = i % 360; if (context_raw->brush_angle < 0) @@ -1021,15 +1021,15 @@ void ui_base_update(void *_) { } else if (decal_mask && operator_shortcut(string("%s+%s", any_map_get(config_keymap, "decal_mask"), any_map_get(config_keymap, "brush_radius")), SHORTCUT_TYPE_DOWN)) { - context_raw->brush_decal_mask_radius += mouse_movement_x / (float)150; + context_raw->brush_decal_mask_radius += mouse_movement_x / 150.0; context_raw->brush_decal_mask_radius = math_max(0.01, math_min(4.0, context_raw->brush_decal_mask_radius)); - context_raw->brush_decal_mask_radius = math_round(context_raw->brush_decal_mask_radius * 100) / (float)100; + context_raw->brush_decal_mask_radius = math_round(context_raw->brush_decal_mask_radius * 100) / 100.0; context_raw->brush_decal_mask_radius_handle->f = context_raw->brush_decal_mask_radius; } else { - context_raw->brush_radius += mouse_movement_x / (float)150; + context_raw->brush_radius += mouse_movement_x / 150.0; context_raw->brush_radius = math_max(0.01, math_min(4.0, context_raw->brush_radius)); - context_raw->brush_radius = math_round(context_raw->brush_radius * 100) / (float)100; + context_raw->brush_radius = math_round(context_raw->brush_radius * 100) / 100.0; context_raw->brush_radius_handle->f = context_raw->brush_radius; } ui_header_handle->redraws = 2; @@ -1124,13 +1124,13 @@ void ui_base_update(void *_) { } else if (operator_shortcut(any_map_get(config_keymap, "brush_radius_decrease"), SHORTCUT_TYPE_REPEAT)) { context_raw->brush_radius -= ui_base_get_radius_increment(); - context_raw->brush_radius = math_max(math_round(context_raw->brush_radius * 100) / (float)100, 0.01); + context_raw->brush_radius = math_max(math_round(context_raw->brush_radius * 100) / 100.0, 0.01); context_raw->brush_radius_handle->f = context_raw->brush_radius; ui_header_handle->redraws = 2; } else if (operator_shortcut(any_map_get(config_keymap, "brush_radius_increase"), SHORTCUT_TYPE_REPEAT)) { context_raw->brush_radius += ui_base_get_radius_increment(); - context_raw->brush_radius = math_round(context_raw->brush_radius * 100) / (float)100; + context_raw->brush_radius = math_round(context_raw->brush_radius * 100) / 100.0; context_raw->brush_radius_handle->f = context_raw->brush_radius; ui_header_handle->redraws = 2; } @@ -1138,14 +1138,14 @@ void ui_base_update(void *_) { if (operator_shortcut(string("%s+%s", any_map_get(config_keymap, "decal_mask"), any_map_get(config_keymap, "brush_radius_decrease")), SHORTCUT_TYPE_REPEAT)) { context_raw->brush_decal_mask_radius -= ui_base_get_radius_increment(); - context_raw->brush_decal_mask_radius = math_max(math_round(context_raw->brush_decal_mask_radius * 100) / (float)100, 0.01); + context_raw->brush_decal_mask_radius = math_max(math_round(context_raw->brush_decal_mask_radius * 100) / 100.0, 0.01); context_raw->brush_decal_mask_radius_handle->f = context_raw->brush_decal_mask_radius; ui_header_handle->redraws = 2; } else if (operator_shortcut(string("%s+%s", any_map_get(config_keymap, "decal_mask"), any_map_get(config_keymap, "brush_radius_increase")), SHORTCUT_TYPE_REPEAT)) { context_raw->brush_decal_mask_radius += ui_base_get_radius_increment(); - context_raw->brush_decal_mask_radius = math_round(context_raw->brush_decal_mask_radius * 100) / (float)100; + context_raw->brush_decal_mask_radius = math_round(context_raw->brush_decal_mask_radius * 100) / 100.0; context_raw->brush_decal_mask_radius_handle->f = context_raw->brush_decal_mask_radius; ui_header_handle->redraws = 2; } @@ -1163,16 +1163,16 @@ void ui_base_update(void *_) { viewport_scale_to_bounds(2.0); } else if (operator_shortcut(any_map_get(config_keymap, "view_back"), SHORTCUT_TYPE_STARTED)) { - viewport_set_view(0, 1, 0, math_pi() / (float)2, 0, math_pi()); + viewport_set_view(0, 1, 0, math_pi() / 2.0, 0, math_pi()); } else if (operator_shortcut(any_map_get(config_keymap, "view_front"), SHORTCUT_TYPE_STARTED)) { - viewport_set_view(0, -1, 0, math_pi() / (float)2, 0, 0); + viewport_set_view(0, -1, 0, math_pi() / 2.0, 0, 0); } else if (operator_shortcut(any_map_get(config_keymap, "view_left"), SHORTCUT_TYPE_STARTED)) { - viewport_set_view(-1, 0, 0, math_pi() / (float)2, 0, -math_pi() / (float)2); + viewport_set_view(-1, 0, 0, math_pi() / 2.0, 0, -math_pi() / 2.0); } else if (operator_shortcut(any_map_get(config_keymap, "view_right"), SHORTCUT_TYPE_STARTED)) { - viewport_set_view(1, 0, 0, math_pi() / (float)2, 0, math_pi() / (float)2); + viewport_set_view(1, 0, 0, math_pi() / 2.0, 0, math_pi() / 2.0); } else if (operator_shortcut(any_map_get(config_keymap, "view_bottom"), SHORTCUT_TYPE_STARTED)) { viewport_set_view(0, 0, -1, math_pi(), 0, math_pi()); @@ -1183,16 +1183,16 @@ void ui_base_update(void *_) { viewport_update_camera_type(context_raw->camera_type); } else if (operator_shortcut(any_map_get(config_keymap, "view_orbit_left"), SHORTCUT_TYPE_REPEAT)) { - viewport_orbit(-math_pi() / (float)12, 0); + viewport_orbit(-math_pi() / 12.0, 0); } else if (operator_shortcut(any_map_get(config_keymap, "view_orbit_right"), SHORTCUT_TYPE_REPEAT)) { - viewport_orbit(math_pi() / (float)12, 0); + viewport_orbit(math_pi() / 12.0, 0); } else if (operator_shortcut(any_map_get(config_keymap, "view_orbit_up"), SHORTCUT_TYPE_REPEAT)) { - viewport_orbit(0, -math_pi() / (float)12); + viewport_orbit(0, -math_pi() / 12.0); } else if (operator_shortcut(any_map_get(config_keymap, "view_orbit_down"), SHORTCUT_TYPE_REPEAT)) { - viewport_orbit(0, math_pi() / (float)12); + viewport_orbit(0, math_pi() / 12.0); } else if (operator_shortcut(any_map_get(config_keymap, "view_orbit_opposite"), SHORTCUT_TYPE_STARTED)) { viewport_orbit_opposite(); @@ -1509,23 +1509,23 @@ void ui_base_update_ui() { f32 cosa = math_cos(-context_raw->brush_stencil_angle); f32 sina = math_sin(-context_raw->brush_stencil_angle); f32 ox = 0; - f32 oy = -r->h / (float)2; + f32 oy = -r->h / 2.0; f32 x = ox * cosa - oy * sina; f32 y = ox * sina + oy * cosa; - x += r->x + r->w / (float)2; - y += r->y + r->h / (float)2; + x += r->x + r->w / 2.0; + y += r->y + r->h / 2.0; context_raw->brush_stencil_rotating = ui_base_hit_rect(mouse_x, mouse_y, math_floor(x - 16), math_floor(y - 16), 32, 32); } f32 _scale = context_raw->brush_stencil_scale; if (mouse_down("left")) { if (context_raw->brush_stencil_scaling) { - i32 mult = mouse_x > r->x + r->w / (float)2 ? 1 : -1; - context_raw->brush_stencil_scale += mouse_movement_x / (float)400 * mult; + i32 mult = mouse_x > r->x + r->w / 2 ? 1 : -1; + context_raw->brush_stencil_scale += mouse_movement_x / 400.0 * mult; } else if (context_raw->brush_stencil_rotating) { - f32 gizmo_x = r->x + r->w / (float)2; - f32 gizmo_y = r->y + r->h / (float)2; - context_raw->brush_stencil_angle = -math_atan2(mouse_y - gizmo_y, mouse_x - gizmo_x) - math_pi() / (float)2; + f32 gizmo_x = r->x + r->w / 2.0; + f32 gizmo_y = r->y + r->h / 2.0; + context_raw->brush_stencil_angle = -math_atan2(mouse_y - gizmo_y, mouse_x - gizmo_x) - math_pi() / 2.0; } else { context_raw->brush_stencil_x += mouse_movement_x / (float)base_w(); @@ -1536,7 +1536,7 @@ void ui_base_update_ui() { context_raw->brush_stencil_scaling = false; } if (mouse_wheel_delta != 0) { - context_raw->brush_stencil_scale -= mouse_wheel_delta / (float)10; + context_raw->brush_stencil_scale -= mouse_wheel_delta / 10.0; } // Center after scale f32 ratio = base_h() / (float)context_raw->brush_stencil_image->height; @@ -1544,8 +1544,8 @@ void ui_base_update_ui() { f32 new_w = context_raw->brush_stencil_scale * context_raw->brush_stencil_image->width * ratio; f32 old_h = _scale * base_h(); f32 new_h = context_raw->brush_stencil_scale * base_h(); - context_raw->brush_stencil_x += (old_w - new_w) / (float)base_w() / (float)2; - context_raw->brush_stencil_y += (old_h - new_h) / (float)base_h() / (float)2; + context_raw->brush_stencil_x += (old_w - new_w) / (float)base_w() / 2.0; + context_raw->brush_stencil_y += (old_h - new_h) / (float)base_h() / 2.0; } bool set_clone_source = context_raw->tool == TOOL_TYPE_CLONE && @@ -1744,7 +1744,7 @@ void ui_base_render(void *_) { draw_begin(NULL, true, base_theme->SEPARATOR_COL); gpu_texture_t *img = data_get_image("badge_bw.k"); draw_set_color(0x22ffffff); - draw_image(img, base_view3d_w() / (float)2 - img->width / (float)2, base_h() / (float)2 - img->height / (float)2); + draw_image(img, base_view3d_w() / 2.0 - img->width / 2.0, base_h() / 2.0 - img->height / 2.0); draw_end(); } ui_begin(ui); @@ -1797,11 +1797,11 @@ void ui_base_render_cursor(void *_) { f32 cosa = math_cos(-context_raw->brush_stencil_angle); f32 sina = math_sin(-context_raw->brush_stencil_angle); f32 ox = 0; - f32 oy = -r->h / (float)2; + f32 oy = -r->h / 2.0; f32 x = ox * cosa - oy * sina; f32 y = ox * sina + oy * cosa; - x += r->x + r->w / (float)2; - y += r->y + r->h / (float)2; + x += r->x + r->w / 2.0; + y += r->y + r->h / 2.0; draw_filled_circle(x, y, 8, 0); } } @@ -1823,8 +1823,8 @@ void ui_base_render_cursor(void *_) { // Clone source cursor if (context_raw->tool == TOOL_TYPE_CLONE && !keyboard_down("alt") && (mouse_down("left") || pen_down("tip"))) { draw_set_color(0x66ffffff); - draw_scaled_image(cursor_img, mx + context_raw->clone_delta_x * sys_w() - psize / (float)2, - my + context_raw->clone_delta_y * sys_h() - psize / (float)2, psize, psize); + draw_scaled_image(cursor_img, mx + context_raw->clone_delta_x * sys_w() - psize / 2.0, + my + context_raw->clone_delta_y * sys_h() - psize / 2.0, psize, psize); draw_set_color(0xffffffff); } @@ -1845,12 +1845,12 @@ void ui_base_render_cursor(void *_) { i32 psizey = math_floor(256 * UI_SCALE() * (context_raw->brush_radius * context_raw->brush_nodes_radius)); context_raw->view_index = context_raw->view_index_last; - f32 decalx = base_x() + context_raw->decal_x * base_w() - psizex / (float)2; - f32 decaly = base_y() + context_raw->decal_y * base_h() - psizey / (float)2; + f32 decalx = base_x() + context_raw->decal_x * base_w() - psizex / 2.0; + f32 decaly = base_y() + context_raw->decal_y * base_h() - psizey / 2.0; context_raw->view_index = -1; draw_set_color(color_from_floats(1, 1, 1, decal_alpha)); - f32 angle = (context_raw->brush_angle + context_raw->brush_nodes_angle) * (math_pi() / (float)180); + f32 angle = (context_raw->brush_angle + context_raw->brush_nodes_angle) * (math_pi() / 180.0); draw_set_transform(mat3_multmat(mat3_multmat(mat3_translation(0.5, 0.5), mat3_rotation(angle)), mat3_translation(-0.5, -0.5))); draw_scaled_image(context_raw->decal_image, decalx, decaly, psizex, psizey); draw_set_transform(mat3_nan()); @@ -1866,7 +1866,7 @@ void ui_base_render_cursor(void *_) { if (context_in_2d_view(VIEW_2D_TYPE_LAYER)) { psize = math_floor(psize * ui_view2d_pan_scale); } - draw_scaled_image(cursor_img, mx - psize / (float)2, my - psize / (float)2, psize, psize); + draw_scaled_image(cursor_img, mx - psize / 2.0, my - psize / 2.0, psize, psize); } } @@ -1879,7 +1879,7 @@ void ui_base_render_cursor(void *_) { my = context_raw->brush_lazy_y * base_h() + base_y(); f32 radius = context_raw->brush_lazy_radius * 180; draw_set_color(0xff666666); - draw_scaled_image(cursor_img, mx - radius / (float)2, my - radius / (float)2, radius, radius); + draw_scaled_image(cursor_img, mx - radius / 2.0, my - radius / 2.0, radius, radius); draw_set_color(0xffffffff); } draw_end(); diff --git a/paint/sources/box_export.c b/paint/sources/box_export.c index d0cf3df8..99b2663f 100644 --- a/paint/sources/box_export.c +++ b/paint/sources/box_export.c @@ -264,9 +264,9 @@ void box_export_tab_presets() { f32_array_t *row = f32_array_create_from_raw( (f32[]){ - 3 / (float)5, - 1 / (float)5, - 1 / (float)5, + 3 / 5.0, + 1 / 5.0, + 1 / 5.0, }, 3); ui_row(row); @@ -354,7 +354,7 @@ void box_export_tab_presets() { row = f32_array_create_from_raw( (f32[]){ - 1 / (float)6, + 1 / 6.0, }, 1); ui_row(row); @@ -493,7 +493,7 @@ void box_export_tab_export_mesh(ui_handle_t *htab) { } for (i32 i = 0; i < paint_objects->length; ++i) { mesh_object_t *po = paint_objects->buffer[i]; - tris += math_floor(po->data->index_array->length / (float)3); + tris += math_floor(po->data->index_array->length / 3.0); } ui_text(string("%s %s", i32_to_string(tris), tr("triangles")), UI_ALIGN_LEFT, 0x00000000); diff --git a/paint/sources/box_preferences.c b/paint/sources/box_preferences.c index 989f3a21..3169a2bb 100644 --- a/paint/sources/box_preferences.c +++ b/paint/sources/box_preferences.c @@ -247,8 +247,8 @@ void box_preferences_theme_tab() { if (is_hex) { f32_array_t *row = f32_array_create_from_raw( (f32[]){ - 1 / (float)8, - 7 / (float)8, + 1 / 8.0, + 7 / 8.0, }, 2); ui_row(row); @@ -498,7 +498,7 @@ void box_preferences_pen_tab() { ui_end_element(); f32_array_t *row = f32_array_create_from_raw( (f32[]){ - 1 / (float)4, + 1 / 4.0, }, 1); ui_row(row); @@ -604,8 +604,8 @@ void box_preferences_viewport_tab() { camera_data_t *cam_raw = cam->data; ui_handle_t *h_near = ui_handle(__ID__); ui_handle_t *h_far = ui_handle(__ID__); - h_near->f = math_floor(cam_raw->near_plane * 1000) / (float)1000; - h_far->f = math_floor(cam_raw->far_plane * 100) / (float)100; + h_near->f = math_floor(cam_raw->near_plane * 1000) / 1000.0; + h_far->f = math_floor(cam_raw->far_plane * 100) / 100.0; cam_raw->near_plane = ui_slider(h_near, tr("Clip Start"), 0.001, 1.0, true, 100.0, true, UI_ALIGN_RIGHT, true); cam_raw->far_plane = ui_slider(h_far, tr("Clip End"), 50.0, 100.0, true, 100.0, true, UI_ALIGN_RIGHT, true); if (h_near->changed || h_far->changed) { @@ -747,7 +747,7 @@ void box_preferences_neural_tab() { f32_array_t *row = f32_array_create_from_raw( (f32[]){ - 1 / (float)4, + 1 / 4.0, }, 1); ui_row(row); @@ -796,8 +796,8 @@ void box_preferences_model_panel(neural_node_model_t *m) { ui->enabled = false; u64 u = iron_net_bytes_downloaded; - i32 i = (u / (float)1000000000) * 100; - f32 f = i / (float)100; + i32 i = (u / 1000000000.0) * 100; + f32 f = i / 100.0; char *downloaded = string("%sGB", f32_to_string(f)); ui_box_hwnd->redraws = 2; box_preferences_htab->redraws = 2; @@ -901,8 +901,8 @@ void box_preferences_plugins_tab() { ui_begin_sticky(); f32_array_t *row = f32_array_create_from_raw( (f32[]){ - 1 / (float)4, - 1 / (float)4, + 1 / 4.0, + 1 / 4.0, }, 2); ui_row(row); diff --git a/paint/sources/box_projects.c b/paint/sources/box_projects.c index d6e6b1f9..8f86a09d 100644 --- a/paint/sources/box_projects.c +++ b/paint/sources/box_projects.c @@ -169,7 +169,7 @@ void box_projects_tab() { } if (show_asset_names) { - ui->_x = uix - (150 - 128) / (float)2; + ui->_x = uix - (150 - 128) / 2.0; ui->_y += slotw * 0.9; ui_text(name, UI_ALIGN_CENTER, 0x00000000); if (ui->is_hovered) { @@ -279,6 +279,6 @@ void box_projects_align_to_fullscreen() { i32 apph = iron_window_height(); i32 mw = appw; i32 mh = apph; - ui_box_hwnd->drag_x = math_floor(-appw / (float)2 + mw / (float)2); - ui_box_hwnd->drag_y = math_floor(-apph / (float)2 + mh / (float)2); + ui_box_hwnd->drag_x = math_floor(-appw / 2.0 + mw / 2.0); + ui_box_hwnd->drag_y = math_floor(-apph / 2.0 + mh / 2.0); } diff --git a/paint/sources/brush_nodes/input_node.c b/paint/sources/brush_nodes/input_node.c index 57a7d776..049be62a 100644 --- a/paint/sources/brush_nodes/input_node.c +++ b/paint/sources/brush_nodes/input_node.c @@ -16,7 +16,7 @@ input_node_t *input_node_create(ui_node_t *raw, f32_array_t *args) { void input_node_update(float_node_t *self) { if (context_raw->split_view) { - context_raw->view_index = mouse_view_x() > base_w() / (float)2 ? 1 : 0; + context_raw->view_index = mouse_view_x() > base_w() / 2.0 ? 1 : 0; } bool decal_mask = context_is_decal_mask_paint(); diff --git a/paint/sources/brush_nodes/math_node.c b/paint/sources/brush_nodes/math_node.c index a19def5a..3e344887 100644 --- a/paint/sources/brush_nodes/math_node.c +++ b/paint/sources/brush_nodes/math_node.c @@ -104,16 +104,16 @@ logic_node_value_t *math_node_get(math_node_t *self, i32 from) { f = (v2 != 0.0) ? v2 - math_abs(math_fmod(math_abs(v1), (2 * v2)) - v2) : 0.0; } else if (string_equals(op, "Hyperbolic Sine")) { - f = (math_exp(v1) - math_exp(-v1)) / (float)2.0; + f = (math_exp(v1) - math_exp(-v1)) / 2.0; } else if (string_equals(op, "Hyperbolic Cosine")) { - f = (math_exp(v1) + math_exp(-v1)) / (float)2.0; + f = (math_exp(v1) + math_exp(-v1)) / 2.0; } else if (string_equals(op, "Hyperbolic Tangent")) { f = 1.0 - (2.0 / (float)(math_exp(2 * v1) + 1)); } else if (string_equals(op, "To Radians")) { - f = v1 / (float)180.0 * math_pi(); + f = v1 / 180.0 * math_pi(); } else if (string_equals(op, "To Degrees")) { f = v1 / (float)math_pi() * 180.0; diff --git a/paint/sources/camera.c b/paint/sources/camera.c index 6e9dec0b..67e8d80d 100644 --- a/paint/sources/camera.c +++ b/paint/sources/camera.c @@ -62,11 +62,11 @@ void camera_update(void * _) { camera_redraws = 2; f32 dist = camera_distance(); transform_move(camera->base->transform, camera_object_look_world(camera), dist); - transform_rotate(camera->base->transform, vec4_z_axis(), -mouse_movement_x / (float)100 * config_raw->camera_rotation_speed); - transform_rotate(camera->base->transform, camera_object_right_world(camera), -mouse_movement_y / (float)100 * config_raw->camera_rotation_speed); + transform_rotate(camera->base->transform, vec4_z_axis(), -mouse_movement_x / 100.0 * config_raw->camera_rotation_speed); + transform_rotate(camera->base->transform, camera_object_right_world(camera), -mouse_movement_y / 100.0 * config_raw->camera_rotation_speed); vec4_t up_world = camera_object_up_world(camera); if (up_world.z < 0 && !config_raw->camera_upside_down) { - transform_rotate(camera->base->transform, camera_object_right_world(camera), mouse_movement_y / (float)100 * config_raw->camera_rotation_speed); + transform_rotate(camera->base->transform, camera_object_right_world(camera), mouse_movement_y / 100.0 * config_raw->camera_rotation_speed); } transform_move(camera->base->transform, camera_object_look_world(camera), -dist); } @@ -75,13 +75,13 @@ void camera_update(void * _) { camera_redraws = 2; transform_t *t = context_main_object()->base->transform; vec4_t up = transform_up(t); - transform_rotate(t, up, (mouse_movement_x / (float)120) * config_raw->camera_rotation_speed); + transform_rotate(t, up, (mouse_movement_x / 120.0) * config_raw->camera_rotation_speed); vec4_t right = camera_object_right_world(camera); - transform_rotate(t, right, (mouse_movement_y / (float)120) * config_raw->camera_rotation_speed); + transform_rotate(t, right, (mouse_movement_y / 120.0) * config_raw->camera_rotation_speed); transform_build_matrix(t); vec4_t tup = transform_up(t); if (tup.z < 0 && !config_raw->camera_upside_down) { - transform_rotate(t, right, -(mouse_movement_y / (float)120) * config_raw->camera_rotation_speed); + transform_rotate(t, right, -(mouse_movement_y / 120.0) * config_raw->camera_rotation_speed); } } @@ -90,14 +90,14 @@ void camera_update(void * _) { if (operator_shortcut(any_map_get(config_keymap, "action_zoom"), SHORTCUT_TYPE_DOWN)) { camera_redraws = 2; - f32 f = camera_get_zoom_delta() / (float)(150 * (1.0 / (float)(camera_distance() / (float)2.0))); + f32 f = camera_get_zoom_delta() / (float)(150.0 * (1.0 / (camera_distance() / 2.0))); f *= camera_get_zoom_speed(); transform_move(camera->base->transform, camera_object_look(camera), f); } if (mouse_wheel_delta != 0 && !modif_key) { camera_redraws = 2; - f32 f = mouse_wheel_delta * (-0.2) * ((camera_distance() / (float)4.0)); + f32 f = mouse_wheel_delta * (-0.2) * ((camera_distance() / 4.0)); f *= camera_get_zoom_speed(); transform_move(camera->base->transform, camera_object_look(camera), f); } @@ -157,8 +157,8 @@ void camera_update(void * _) { } camera_redraws = 2; - transform_rotate(camera->base->transform, vec4_z_axis(), -mouse_movement_x / (float)200 * config_raw->camera_rotation_speed); - transform_rotate(camera->base->transform, camera_object_right(camera), -mouse_movement_y / (float)200 * config_raw->camera_rotation_speed); + transform_rotate(camera->base->transform, vec4_z_axis(), -mouse_movement_x / 200.0 * config_raw->camera_rotation_speed); + transform_rotate(camera->base->transform, camera_object_right(camera), -mouse_movement_y / 200.0 * config_raw->camera_rotation_speed); } if (operator_shortcut(any_map_get(config_keymap, "view_pivot_center"), SHORTCUT_TYPE_STARTED)) { @@ -167,7 +167,7 @@ void camera_update(void * _) { if (operator_shortcut(any_map_get(config_keymap, "rotate_envmap"), SHORTCUT_TYPE_DOWN)) { camera_redraws = 2; - context_raw->envmap_angle -= mouse_movement_x / (float)100; + context_raw->envmap_angle -= mouse_movement_x / 100.0; } if (camera_redraws > 0) { @@ -243,7 +243,7 @@ void camera_pan_action(bool modif, bool default_keymap) { camera_object_t *camera = scene_camera; if (operator_shortcut(any_map_get(config_keymap, "action_pan"), SHORTCUT_TYPE_DOWN) || (mouse_down("middle") && !modif && default_keymap)) { camera_redraws = 2; - f32 f = 150 * (1.0 / (float)(camera_distance() / (float)4.0)); + f32 f = 150 * (1.0 / (float)(camera_distance() / 4.0)); vec4_t look = vec4_mult(transform_look(camera->base->transform), mouse_movement_y / (float)f * config_raw->camera_pan_speed); vec4_t right = vec4_mult(transform_right(camera->base->transform), -mouse_movement_x / (float)f * config_raw->camera_pan_speed); camera->base->transform->loc = vec4_add(camera->base->transform->loc, look); diff --git a/paint/sources/compass.c b/paint/sources/compass.c index e1c8bf1c..f27163c3 100644 --- a/paint/sources/compass.c +++ b/paint/sources/compass.c @@ -128,9 +128,9 @@ void compass_update() { if (t == _compass_hitbox_x->transform) { if (mouse_started("left")) { // Flip between left / right - _compass_compare_quat(quat_from_euler(math_pi() / (float)2, 0, math_pi() / (float)2), cq) - ? viewport_set_view(-1, 0, 0, math_pi() / (float)2, 0, -math_pi() / (float)2) // Left - : viewport_set_view(1, 0, 0, math_pi() / (float)2, 0, math_pi() / (float)2); // Right + _compass_compare_quat(quat_from_euler(math_pi() / 2.0, 0, math_pi() / 2.0), cq) + ? viewport_set_view(-1, 0, 0, math_pi() / 2.0, 0, -math_pi() / 2.0) // Left + : viewport_set_view(1, 0, 0, math_pi() / 2.0, 0, math_pi() / 2.0); // Right } gc_unroot(_compass_hovered); _compass_hovered = _compass_hitbox_x; @@ -139,9 +139,9 @@ void compass_update() { else if (t == _compass_hitbox_y->transform) { if (mouse_started("left")) { - _compass_compare_quat(quat_from_euler(math_pi() / (float)2, 0, math_pi()), cq) - ? viewport_set_view(0, -1, 0, math_pi() / (float)2, 0, 0) // Front - : viewport_set_view(0, 1, 0, math_pi() / (float)2, 0, math_pi()); // Back + _compass_compare_quat(quat_from_euler(math_pi() / 2.0, 0, math_pi()), cq) + ? viewport_set_view(0, -1, 0, math_pi() / 2.0, 0, 0) // Front + : viewport_set_view(0, 1, 0, math_pi() / 2.0, 0, math_pi()); // Back } gc_unroot(_compass_hovered); _compass_hovered = _compass_hitbox_y; diff --git a/paint/sources/config.c b/paint/sources/config.c index 259cb5bd..dcc863fd 100644 --- a/paint/sources/config.c +++ b/paint/sources/config.c @@ -271,8 +271,8 @@ void config_init_layout() { i32_array_t *new_layout = i32_array_create_from_raw((i32[]){}, 0); i32_array_push(new_layout, math_floor(ui_sidebar_default_w * raw->window_scale)); // LayoutSidebarW - i32_array_push(new_layout, math_floor(iron_window_height() / (float)2)); // LayoutSidebarH0 - i32_array_push(new_layout, math_floor(iron_window_height() / (float)2)); // LayoutSidebarH1 + i32_array_push(new_layout, math_floor(iron_window_height() / 2.0)); // LayoutSidebarH0 + i32_array_push(new_layout, math_floor(iron_window_height() / 2.0)); // LayoutSidebarH1 #ifdef IRON_IOS i32_array_push(new_layout, show2d ? math_floor((sys_w() + raw->layout->buffer[LAYOUT_SIZE_NODES_W]) * 0.473) : math_floor(sys_w() * 0.473)); // LayoutNodesW @@ -284,7 +284,7 @@ void config_init_layout() { : math_floor(sys_w() * 0.515)); // Align with ui header controls #endif - i32_array_push(new_layout, math_floor(sys_h() / (float)2)); // LayoutNodesH + i32_array_push(new_layout, math_floor(sys_h() / 2.0)); // LayoutNodesH i32_array_push(new_layout, math_floor(ui_statusbar_default_h * raw->window_scale)); // LayoutStatusH #if defined(IRON_ANDROID) || defined(IRON_IOS) @@ -427,11 +427,11 @@ i32 config_get_scene_atlas_res() { } i32 config_get_texture_res_x() { - return context_raw->project_aspect_ratio == 2 ? math_floor(config_get_texture_res() / (float)2) : config_get_texture_res(); + return context_raw->project_aspect_ratio == 2 ? math_floor(config_get_texture_res() / 2.0) : config_get_texture_res(); } i32 config_get_texture_res_y() { - return context_raw->project_aspect_ratio == 1 ? math_floor(config_get_texture_res() / (float)2) : config_get_texture_res(); + return context_raw->project_aspect_ratio == 1 ? math_floor(config_get_texture_res() / 2.0) : config_get_texture_res(); } i32 config_get_texture_res_pos(i32 i) { diff --git a/paint/sources/console.c b/paint/sources/console.c index 2966cd5b..8d99c383 100644 --- a/paint/sources/console.c +++ b/paint/sources/console.c @@ -6,12 +6,12 @@ void console_draw_toast(char *s) { draw_set_color(0x55000000); draw_filled_rect(0, 0, iron_window_width(), iron_window_height()); f32 scale = UI_SCALE(); - f32 x = iron_window_width() / (float)2; + f32 x = iron_window_width() / 2.0; f32 y = iron_window_height() - 200 * scale; draw_filled_rect(x - 200 * scale, y, 400 * scale, 80 * scale); draw_set_font(base_font, math_floor(22 * scale)); draw_set_color(0xffffffff); - draw_string(s, x - draw_string_width(draw_font, draw_font_size, s) / (float)2, y + 40 * scale - draw_font_height(draw_font, draw_font_size) / (float)2); + draw_string(s, x - draw_string_width(draw_font, draw_font_size, s) / 2.0, y + 40 * scale - draw_font_height(draw_font, draw_font_size) / 2.0); draw_end(); } diff --git a/paint/sources/export_arm.c b/paint/sources/export_arm.c index 5ac06b1f..1ba309ae 100644 --- a/paint/sources/export_arm.c +++ b/paint/sources/export_arm.c @@ -153,13 +153,13 @@ void export_arm_run_project() { gpu_texture_t *mesh_icon = gpu_create_render_target(256, 256, GPU_TEXTURE_FORMAT_RGBA32); f32 r = sys_w() / (float)sys_h(); draw_begin(mesh_icon, false, 0); - draw_scaled_image(tex, -(256 * r - 256) / (float)2, 0, 256 * r, 256); + draw_scaled_image(tex, -(256 * r - 256) / 2.0, 0, 256 * r, 256); draw_end(); buffer_t *mesh_icon_pixels = gpu_get_texture_pixels(mesh_icon); u8_array_t *u8a = mesh_icon_pixels; for (i32 i = 0; i < 256 * 256 * 4; ++i) { - u8a->buffer[i] = math_floor(math_pow(u8a->buffer[i] / (float)255, 1.0 / (float)2.2) * 255); + u8a->buffer[i] = math_floor(math_pow(u8a->buffer[i] / 255.0, 1.0 / 2.2) * 255); } iron_write_png(string("%s_icon.png", substring(project_filepath, 0, string_length(project_filepath) - 4)), mesh_icon_pixels, 256, 256, 0); gpu_delete_texture(mesh_icon); @@ -284,7 +284,7 @@ void export_arm_run_material(char *path) { } buffer_t *export_arm_bgra_swap(buffer_t *buffer) { - for (i32 i = 0; i < math_floor((buffer->length) / (float)4); ++i) { + for (i32 i = 0; i < math_floor((buffer->length) / 4.0); ++i) { i32 r = buffer->buffer[i * 4]; buffer->buffer[i * 4] = buffer->buffer[i * 4 + 2]; buffer->buffer[i * 4 + 2] = r; @@ -293,7 +293,7 @@ buffer_t *export_arm_bgra_swap(buffer_t *buffer) { } buffer_t *export_arm_bgra64_swap(buffer_t *buffer) { - for (i32 i = 0; i < math_floor((buffer->length) / (float)8); ++i) { + for (i32 i = 0; i < math_floor((buffer->length) / 8.0); ++i) { i32 r_low = buffer->buffer[i * 8 + 4]; i32 r_high = buffer->buffer[i * 8 + 5]; buffer->buffer[i * 8 + 4] = buffer->buffer[i * 8 + 0]; @@ -494,7 +494,7 @@ f32_array_t *export_arm_vec3f32(vec4_t v) { } buffer_t *export_arm_rgba64_to_rgba32(buffer_t *buffer) { - for (i32 i = 0; i < buffer->length / (float)2; ++i) { + for (i32 i = 0; i < buffer->length / 2.0; ++i) { buffer->buffer[i] = half_to_u8_fast(buffer_get_u16(buffer, i * 2)); } return buffer; diff --git a/paint/sources/export_obj.c b/paint/sources/export_obj.c index fc15654e..c4f1934d 100644 --- a/paint/sources/export_obj.c +++ b/paint/sources/export_obj.c @@ -17,12 +17,12 @@ void export_obj_run(char *path, mesh_object_t_array_t *paint_objects, bool apply for (i32 i = 0; i < paint_objects->length; ++i) { mesh_object_t *p = paint_objects->buffer[i]; mesh_data_t *mesh = p->data; - f32 inv = 1 / (float)32767; + f32 inv = 1 / 32767.0; f32 sc = p->data->scale_pos * inv; i16_array_t *posa = mesh->vertex_arrays->buffer[0]->values; i16_array_t *nora = mesh->vertex_arrays->buffer[1]->values; i16_array_t *texa = mesh->vertex_arrays->buffer[2]->values; - i32 len = math_floor(posa->length / (float)4); + i32 len = math_floor(posa->length / 4.0); // Merge shared vertices and remap indices i16_array_t *posa2 = i16_array_create(len * 3); @@ -135,7 +135,7 @@ void export_obj_run(char *path, mesh_object_t_array_t *paint_objects, bool apply } u32_array_t *inda = mesh->index_array; - for (i32 i = 0; i < math_floor(inda->length / (float)3); ++i) { + for (i32 i = 0; i < math_floor(inda->length / 3.0); ++i) { i32 pi1 = posmap->buffer[inda->buffer[i * 3]] + 1 + poff; i32 pi2 = posmap->buffer[inda->buffer[i * 3 + 1]] + 1 + poff; i32 pi3 = posmap->buffer[inda->buffer[i * 3 + 2]] + 1 + poff; @@ -188,13 +188,13 @@ void export_obj_run_fast(char *path, mesh_object_t_array_t *paint_objects) { for (i32 i = 0; i < paint_objects->length; ++i) { mesh_object_t *p = paint_objects->buffer[i]; mesh_data_t *mesh = p->data; - f32 inv = 1 / (float)32767; + f32 inv = 1 / 32767.0; f32 sc = p->data->scale_pos * inv; i16_array_t *posa = mesh->vertex_arrays->buffer[0]->values; i16_array_t *nora = mesh->vertex_arrays->buffer[1]->values; i16_array_t *texa = mesh->vertex_arrays->buffer[2]->values; - i32 pi = posa->length / (float)4; + i32 pi = posa->length / 4.0; i32 ni = pi; i32 ti = pi; @@ -234,7 +234,7 @@ void export_obj_run_fast(char *path, mesh_object_t_array_t *paint_objects) { } u32_array_t *inda = mesh->index_array; - for (i32 i = 0; i < math_floor(inda->length / (float)3); ++i) { + for (i32 i = 0; i < math_floor(inda->length / 3.0); ++i) { i32 pi1 = inda->buffer[i * 3] + 1 + poff; i32 pi2 = inda->buffer[i * 3 + 1] + 1 + poff; i32 pi3 = inda->buffer[i * 3 + 2] + 1 + poff; diff --git a/paint/sources/export_texture.c b/paint/sources/export_texture.c index 62b93897..d6a34ffa 100644 --- a/paint/sources/export_texture.c +++ b/paint/sources/export_texture.c @@ -375,7 +375,7 @@ void export_texture_run_layers(char *path, slot_layer_t_array_t *layers, char *o } else { if (pix == NULL) { - pix = buffer_create(texture_size_x * texture_size_y * 4 * math_floor(bits / (float)8)); + pix = buffer_create(texture_size_x * texture_size_y * 4 * math_floor(bits / 8.0)); } for (i32 i = 0; i < 4; ++i) { char *c = t->channels->buffer[i]; @@ -512,7 +512,7 @@ void export_texture_copy_channel(buffer_t *from, i32 from_channel, buffer_t *to, #ifdef IRON_BGRA from_channel = _export_texture_channel_bgra_swap(from_channel); #endif - for (i32 i = 0; i < math_floor((to->length) / (float)4); ++i) { + for (i32 i = 0; i < math_floor((to->length) / 4.0); ++i) { buffer_set_u8(to, i * 4 + to_channel, buffer_get_u8(from, i * 4 + from_channel)); } if (!linear) { @@ -524,7 +524,7 @@ void export_texture_copy_channel_inv(buffer_t *from, i32 from_channel, buffer_t #ifdef IRON_BGRA from_channel = _export_texture_channel_bgra_swap(from_channel); #endif - for (i32 i = 0; i < math_floor((to->length) / (float)4); ++i) { + for (i32 i = 0; i < math_floor((to->length) / 4.0); ++i) { buffer_set_u8(to, i * 4 + to_channel, 255 - buffer_get_u8(from, i * 4 + from_channel)); } if (!linear) { @@ -536,7 +536,7 @@ void export_texture_extract_channel(buffer_t *from, i32 from_channel, buffer_t * #ifdef IRON_BGRA from_channel = _export_texture_channel_bgra_swap(from_channel); #endif - for (i32 i = 0; i < math_floor((to->length) / (float)4); ++i) { + for (i32 i = 0; i < math_floor((to->length) / 4.0); ++i) { buffer_set_u8(to, i * 4 + to_channel, buffer_get_u8(from, i * 4 + from_channel) % step == mask ? 255 : 0); } if (!linear) { @@ -545,7 +545,7 @@ void export_texture_extract_channel(buffer_t *from, i32 from_channel, buffer_t * } void export_texture_set_channel(i32 value, buffer_t *to, i32 to_channel, bool linear) { - for (i32 i = 0; i < math_floor((to->length) / (float)4); ++i) { + for (i32 i = 0; i < math_floor((to->length) / 4.0); ++i) { buffer_set_u8(to, i * 4 + to_channel, value); } if (!linear) { @@ -554,7 +554,7 @@ void export_texture_set_channel(i32 value, buffer_t *to, i32 to_channel, bool li } void export_texture_to_srgb(buffer_t *to, i32 to_channel) { - for (i32 i = 0; i < math_floor((to->length) / (float)4); ++i) { - buffer_set_u8(to, i * 4 + to_channel, math_floor(math_pow(buffer_get_u8(to, i * 4 + to_channel) / (float)255, export_texture_gamma) * 255)); + for (i32 i = 0; i < math_floor((to->length) / 4.0); ++i) { + buffer_set_u8(to, i * 4 + to_channel, math_floor(math_pow(buffer_get_u8(to, i * 4 + to_channel) / 255.0, export_texture_gamma) * 255)); } } diff --git a/paint/sources/geom.c b/paint/sources/geom.c index e93756b4..1f052498 100644 --- a/paint/sources/geom.c +++ b/paint/sources/geom.c @@ -10,8 +10,8 @@ raw_mesh_t *geom_make_plane(f32 size_x, f32 size_y, i32 verts_x, i32 verts_y, f3 mesh->has_next = false; // Pack positions to (-1, 1) range - f32 half_x = size_x / (float)2; - f32 half_y = size_y / (float)2; + f32 half_x = size_x / 2.0; + f32 half_y = size_y / 2.0; mesh->scale_pos = math_max(size_x, size_y); f32 inv = (1 / (float)mesh->scale_pos) * 32767; diff --git a/paint/sources/gizmo.c b/paint/sources/gizmo.c index a7f533d1..1e0b97ab 100644 --- a/paint/sources/gizmo.c +++ b/paint/sources/gizmo.c @@ -27,7 +27,7 @@ void gizmo_update() { camera_object_t *cam = scene_camera; f32 fov = cam->data->fov; - f32 dist = vec4_dist(cam->base->transform->loc, gizmo->transform->loc) / (float)8 * fov; + f32 dist = vec4_dist(cam->base->transform->loc, gizmo->transform->loc) / 8.0 * fov; gizmo->transform->scale = vec4_create(dist, dist, dist, 1.0); context_raw->gizmo_translate_x->transform->scale = vec4_create(dist, dist, dist, 1.0); context_raw->gizmo_translate_y->transform->scale = vec4_create(dist, dist, dist, 1.0); diff --git a/paint/sources/import_arm.c b/paint/sources/import_arm.c index cc987ab5..1f7fecbd 100644 --- a/paint/sources/import_arm.c +++ b/paint/sources/import_arm.c @@ -88,7 +88,7 @@ void import_arm_run_project(char *path) { base_res_handle->i = config_get_texture_res_pos(l0->res); texture_bits_t bits_pos = l0->bpp == 8 ? TEXTURE_BITS_BITS8 : l0->bpp == 16 ? TEXTURE_BITS_BITS16 : TEXTURE_BITS_BITS32; base_bits_handle->i = bits_pos; - i32 bytes_per_pixel = math_floor(l0->bpp / (float)8); + i32 bytes_per_pixel = math_floor(l0->bpp / 8.0); gpu_texture_format_t format = l0->bpp == 8 ? GPU_TEXTURE_FORMAT_RGBA32 : l0->bpp == 16 ? GPU_TEXTURE_FORMAT_RGBA64 : GPU_TEXTURE_FORMAT_RGBA128; char *base = path_base_dir(path); diff --git a/paint/sources/import_blend_mesh.c b/paint/sources/import_blend_mesh.c index 3c5472b6..d34bb1da 100644 --- a/paint/sources/import_blend_mesh.c +++ b/paint/sources/import_blend_mesh.c @@ -18,8 +18,8 @@ void import_blend_mesh_ui() { f32_array_t *ar = f32_array_create_from_raw( (f32[]){ - 7 / (float)8, - 1 / (float)8, + 7 / 8.0, + 1 / 8.0, }, 2); ui_row(ar); diff --git a/paint/sources/import_envmap.c b/paint/sources/import_envmap.c index 565a0a9c..00af9d72 100644 --- a/paint/sources/import_envmap.c +++ b/paint/sources/import_envmap.c @@ -31,8 +31,8 @@ void import_envmap_run(char *path, gpu_texture_t *image) { gc_root(import_envmap_mips); i32 w = 512; for (i32 i = 0; i < 5; ++i) { - any_array_push(import_envmap_mips, gpu_create_render_target(w, w > 1 ? math_floor(w / (float)2) : 1, GPU_TEXTURE_FORMAT_RGBA64)); - w = math_floor(w / (float)2); + any_array_push(import_envmap_mips, gpu_create_render_target(w, w > 1 ? math_floor(w / 2.0) : 1, GPU_TEXTURE_FORMAT_RGBA64)); + w = math_floor(w / 2.0); } } @@ -77,7 +77,7 @@ void import_envmap_get_radiance_mip(gpu_texture_t *mip, i32 level, gpu_texture_t import_envmap_params.y = 1024 * 16; #endif import_envmap_params.z = 1.0 / (float)pass_count; - import_envmap_params.x = (level + 1) / (float)10; + import_envmap_params.x = (level + 1) / 10.0; for (i32 i = 0; i < pass_count; ++i) { _gpu_begin(mip, NULL, NULL, i == 0 ? GPU_CLEAR_COLOR : GPU_CLEAR_NONE, 0x00000000, 0.0); @@ -108,11 +108,11 @@ f32_array_t *import_envmap_get_spherical_harmonics(buffer_t *source, i32 source_ f32_array_t *sh = f32_array_create(9 * 3 + 1); // Align to mult of 4 - 27->28 f32 accum = 0.0; f32 weight = 1.0; - f32 weight1 = weight * 4 / (float)17; - f32 weight2 = weight * 8 / (float)17; - f32 weight3 = weight * 15 / (float)17; - f32 weight4 = weight * 5 / (float)68; - f32 weight5 = weight * 15 / (float)68; + f32 weight1 = weight * 4 / 17.0; + f32 weight2 = weight * 8 / 17.0; + f32 weight3 = weight * 15 / 17.0; + f32 weight4 = weight * 5 / 68.0; + f32 weight5 = weight * 15 / 68.0; for (i32 x = 0; x < source_width; ++x) { for (i32 y = 0; y < source_height; ++y) { @@ -120,7 +120,7 @@ f32_array_t *import_envmap_get_spherical_harmonics(buffer_t *source, i32 source_ for (i32 i = 0; i < 3; ++i) { f32 value = buffer_get_f16(source, ((x + y * source_width) * 8 + i * 2)); - value = math_pow(value, 1.0 / (float)2.2); + value = math_pow(value, 1.0 / 2.2); sh->buffer[0 + i] += value * weight1; sh->buffer[3 + i] += value * weight2 * import_envmap_n.x; @@ -140,7 +140,7 @@ f32_array_t *import_envmap_get_spherical_harmonics(buffer_t *source, i32 source_ } for (i32 i = 0; i < sh->length; ++i) { - sh->buffer[i] /= accum / (float)16; + sh->buffer[i] /= accum / 16.0; } return sh; diff --git a/paint/sources/import_obj.c b/paint/sources/import_obj.c index 0ec9fb49..2905691a 100644 --- a/paint/sources/import_obj.c +++ b/paint/sources/import_obj.c @@ -70,18 +70,18 @@ void import_obj_run(char *path, bool replace_existing) { texa1 = parts->buffer[j]->texa != NULL ? parts->buffer[j]->texa : NULL; inda0 = parts->buffer[i]->inda; inda1 = parts->buffer[j]->inda; - i32 voff = math_floor(posa0->length / (float)4); + i32 voff = math_floor(posa0->length / 4.0); // Repack merged positions - f32_array_t *posa32 = f32_array_create(math_floor(posa0->length / (float)4) * 3 + math_floor(posa1->length / (float)4) * 3); - for (i32 k = 0; k < math_floor(posa0->length / (float)4); ++k) { - posa32->buffer[k * 3] = posa0->buffer[k * 4] / (float)32767 * parts->buffer[i]->scale_pos; - posa32->buffer[k * 3 + 1] = posa0->buffer[k * 4 + 1] / (float)32767 * parts->buffer[i]->scale_pos; - posa32->buffer[k * 3 + 2] = posa0->buffer[k * 4 + 2] / (float)32767 * parts->buffer[i]->scale_pos; + f32_array_t *posa32 = f32_array_create(math_floor(posa0->length / 4.0) * 3 + math_floor(posa1->length / 4.0) * 3); + for (i32 k = 0; k < math_floor(posa0->length / 4.0); ++k) { + posa32->buffer[k * 3] = posa0->buffer[k * 4] / 32767.0 * parts->buffer[i]->scale_pos; + posa32->buffer[k * 3 + 1] = posa0->buffer[k * 4 + 1] / 32767.0 * parts->buffer[i]->scale_pos; + posa32->buffer[k * 3 + 2] = posa0->buffer[k * 4 + 2] / 32767.0 * parts->buffer[i]->scale_pos; } - for (i32 k = 0; k < math_floor(posa1->length / (float)4); ++k) { - posa32->buffer[voff * 3 + k * 3] = posa1->buffer[k * 4] / (float)32767 * parts->buffer[j]->scale_pos; - posa32->buffer[voff * 3 + k * 3 + 1] = posa1->buffer[k * 4 + 1] / (float)32767 * parts->buffer[j]->scale_pos; - posa32->buffer[voff * 3 + k * 3 + 2] = posa1->buffer[k * 4 + 2] / (float)32767 * parts->buffer[j]->scale_pos; + for (i32 k = 0; k < math_floor(posa1->length / 4.0); ++k) { + posa32->buffer[voff * 3 + k * 3] = posa1->buffer[k * 4] / 32767.0 * parts->buffer[j]->scale_pos; + posa32->buffer[voff * 3 + k * 3 + 1] = posa1->buffer[k * 4 + 1] / 32767.0 * parts->buffer[j]->scale_pos; + posa32->buffer[voff * 3 + k * 3 + 2] = posa1->buffer[k * 4 + 2] / 32767.0 * parts->buffer[j]->scale_pos; } f32 scale_pos = 0.0; for (i32 k = 0; k < posa32->length; ++k) { @@ -92,15 +92,15 @@ void import_obj_run(char *path, bool replace_existing) { } f32 inv = 32767 * (1 / (float)scale_pos); i16_array_t *posa = i16_array_create(posa0->length + posa1->length); - for (i32 k = 0; k < math_floor(posa->length / (float)4); ++k) { + for (i32 k = 0; k < math_floor(posa->length / 4.0); ++k) { posa->buffer[k * 4] = math_floor(posa32->buffer[k * 3] * inv); posa->buffer[k * 4 + 1] = math_floor(posa32->buffer[k * 3 + 1] * inv); posa->buffer[k * 4 + 2] = math_floor(posa32->buffer[k * 3 + 2] * inv); } - for (i32 k = 0; k < math_floor(posa0->length / (float)4); ++k) { + for (i32 k = 0; k < math_floor(posa0->length / 4.0); ++k) { posa->buffer[k * 4 + 3] = posa0->buffer[k * 4 + 3]; } - for (i32 k = 0; k < math_floor(posa1->length / (float)4); ++k) { + for (i32 k = 0; k < math_floor(posa1->length / 4.0); ++k) { posa->buffer[posa0->length + k * 4 + 3] = posa1->buffer[k * 4 + 3]; } // Merge normals and uvs diff --git a/paint/sources/make_discard.c b/paint/sources/make_discard.c index 4b1d1357..39dfec39 100644 --- a/paint/sources/make_discard.c +++ b/paint/sources/make_discard.c @@ -41,7 +41,7 @@ void make_discard_material_id(node_shader_t *kong) { kong, "var picker_sample_tc: float2 = float2(input.wvpposition.x / input.wvpposition.w, input.wvpposition.y / input.wvpposition.w) * 0.5 + 0.5;"); node_shader_write_frag(kong, "picker_sample_tc.y = 1.0 - picker_sample_tc.y;"); node_shader_add_texture(kong, "texpaint_nor_undo", "_texpaint_nor_undo"); - i32 matid = context_raw->materialid_picked / (float)255; + i32 matid = context_raw->materialid_picked / 255.0; node_shader_write_frag(kong, string("if (%s != sample_lod(texpaint_nor_undo, sampler_linear, picker_sample_tc, 0.0).a) { discard; }", i32_to_string(matid))); } diff --git a/paint/sources/make_material.c b/paint/sources/make_material.c index 1189c447..1bcc29ec 100644 --- a/paint/sources/make_material.c +++ b/paint/sources/make_material.c @@ -231,8 +231,8 @@ void make_material_bake_node_preview(ui_node_t *node, ui_node_canvas_t *group, u char *id = parser_material_node_name(node, parents); gpu_texture_t *image = any_map_get(context_raw->node_previews, id); any_array_push(context_raw->node_previews_used, id); - i32 res_x = math_floor(config_get_texture_res_x() / (float)4); - i32 res_y = math_floor(config_get_texture_res_y() / (float)4); + i32 res_x = math_floor(config_get_texture_res_x() / 4.0); + i32 res_y = math_floor(config_get_texture_res_y() / 4.0); if (image == NULL || image->width != res_x || image->height != res_y) { if (image != NULL) { gpu_delete_texture(image); diff --git a/paint/sources/make_paint.c b/paint/sources/make_paint.c index f1e0e587..03f01807 100644 --- a/paint/sources/make_paint.c +++ b/paint/sources/make_paint.c @@ -461,9 +461,9 @@ node_shader_context_t *make_paint_run(material_t *data, material_context_t *matc node_shader_add_texture(kong, "texpaint_undo", "_texpaint_undo"); node_shader_write_frag(kong, "var sample_undo: float4 = sample_lod(texpaint_undo, sampler_linear, sample_tc, 0.0);"); - f32 matid = context_raw->material->id / (float)255; + f32 matid = context_raw->material->id / 255.0; if (context_raw->picker_mask_handle->i == PICKER_MASK_MATERIAL) { - matid = context_raw->materialid_picked / (float)255; // Keep existing material id in place when mask is set + matid = context_raw->materialid_picked / 255.0; // Keep existing material id in place when mask is set } char *matid_string = parser_material_vec1(matid * 3.0); node_shader_write_frag(kong, string("var matid: float = %s;", matid_string)); diff --git a/paint/sources/make_sculpt.c b/paint/sources/make_sculpt.c index 85251b47..969d2be8 100644 --- a/paint/sources/make_sculpt.c +++ b/paint/sources/make_sculpt.c @@ -5,9 +5,9 @@ void sculpt_import_mesh_pack_to_texture(mesh_data_t *mesh, slot_layer_t *l) { buffer_t *b = buffer_create(config_get_texture_res_x() * config_get_texture_res_y() * 4 * 4); for (i32 i = 0; i < math_floor(mesh->index_array->length); ++i) { i32 index = mesh->index_array->buffer[i]; - buffer_set_f32(b, 4 * i * 4, mesh->vertex_arrays->buffer[0]->values->buffer[index * 4] / (float)32767); - buffer_set_f32(b, 4 * i * 4 + 1 * 4, mesh->vertex_arrays->buffer[0]->values->buffer[index * 4 + 1] / (float)32767); - buffer_set_f32(b, 4 * i * 4 + 2 * 4, mesh->vertex_arrays->buffer[0]->values->buffer[index * 4 + 2] / (float)32767); + buffer_set_f32(b, 4 * i * 4, mesh->vertex_arrays->buffer[0]->values->buffer[index * 4] / 32767.0); + buffer_set_f32(b, 4 * i * 4 + 1 * 4, mesh->vertex_arrays->buffer[0]->values->buffer[index * 4 + 1] / 32767.0); + buffer_set_f32(b, 4 * i * 4 + 2 * 4, mesh->vertex_arrays->buffer[0]->values->buffer[index * 4 + 2] / 32767.0); buffer_set_f32(b, 4 * i * 4 + 3 * 4, 1.0); } diff --git a/paint/sources/material_nodes/color_ramp_node.c b/paint/sources/material_nodes/color_ramp_node.c index 89632de1..4e599ff6 100644 --- a/paint/sources/material_nodes/color_ramp_node.c +++ b/paint/sources/material_nodes/color_ramp_node.c @@ -12,7 +12,7 @@ char *color_ramp_node_vector(ui_node_t *node, ui_node_socket_t *socket) { i32 data0 = node->buttons->buffer[0]->data->buffer[0]; char *interp = data0 == 0 ? "LINEAR" : "CONSTANT"; f32_array_t *elems = node->buttons->buffer[0]->default_value; - i32 len = elems->length / (float)5; + i32 len = elems->length / 5.0; if (len == 1) { return parser_material_vec3(elems); } @@ -66,7 +66,7 @@ void nodes_material_color_ramp_button(i32 node_id) { f32_array_t *vals = but->default_value; // [r, g, b, a, pos, r, g, b, a, pos, ..] f32 sw = ui->_w / (float)UI_NODES_SCALE(); // Preview - for (i32 i = 0; i < vals->length / (float)5; ++i) { + for (i32 i = 0; i < vals->length / 5.0; ++i) { f32 pos = vals->buffer[i * 5 + 4]; i32 col = color_from_floats(vals->buffer[i * 5 + 0], vals->buffer[i * 5 + 1], vals->buffer[i * 5 + 2], 1.0); ui_fill(pos * sw, 0, (1.0 - pos) * sw, UI_LINE_H() - 2 * UI_NODES_SCALE(), col); @@ -76,9 +76,9 @@ void nodes_material_color_ramp_button(i32 node_id) { ui_handle_t *ihandle = ui_nest(ui_nest(nhandle, 0), 2); f32_array_t *row = f32_array_create_from_raw( (f32[]){ - 1 / (float)4, - 1 / (float)4, - 2 / (float)4, + 1 / 4.0, + 1 / 4.0, + 2 / 4.0, }, 3); ui_row(row); @@ -111,9 +111,9 @@ void nodes_material_color_ramp_button(i32 node_id) { 2); but->data->buffer[0] = ui_combo(h, interpolate_combo, tr("Interpolate"), false, UI_ALIGN_LEFT, true); ui_row2(); - i32 i = math_floor(ui_slider(ihandle, "Index", 0, (vals->length / (float)5) - 1, false, 1, true, UI_ALIGN_LEFT, true)); + i32 i = math_floor(ui_slider(ihandle, "Index", 0, (vals->length / 5.0) - 1, false, 1, true, UI_ALIGN_LEFT, true)); if (i >= (vals->length * 5) || i < 0) { - ihandle->f = i = (vals->length / (float)5) - 1; // Stay in bounds + ihandle->f = i = (vals->length / 5.0) - 1; // Stay in bounds } ui_nest(ui_nest(nhandle, 0), 3)->f = vals->buffer[i * 5 + 4]; vals->buffer[i * 5 + 4] = ui_slider(ui_nest(ui_nest(nhandle, 0), 3), "Pos", 0, 1, true, 100, true, UI_ALIGN_LEFT, true); @@ -131,7 +131,7 @@ void nodes_material_color_ramp_button(i32 node_id) { nodes->_input_started = ui->input_started = false; ui_nodes_rgba_popup(chandle, vals->buffer + i * 5, math_floor(rx), math_floor(ry + UI_ELEMENT_H())); } - vals->buffer[i * 5 + 0] = color_get_rb(chandle->color) / (float)255; - vals->buffer[i * 5 + 1] = color_get_gb(chandle->color) / (float)255; - vals->buffer[i * 5 + 2] = color_get_bb(chandle->color) / (float)255; + vals->buffer[i * 5 + 0] = color_get_rb(chandle->color) / 255.0; + vals->buffer[i * 5 + 1] = color_get_gb(chandle->color) / 255.0; + vals->buffer[i * 5 + 2] = color_get_bb(chandle->color) / 255.0; } diff --git a/paint/sources/material_nodes/vector_curves_node.c b/paint/sources/material_nodes/vector_curves_node.c index 0867189c..cc5c0ef7 100644 --- a/paint/sources/material_nodes/vector_curves_node.c +++ b/paint/sources/material_nodes/vector_curves_node.c @@ -80,9 +80,9 @@ void nodes_material_vector_curves_button(i32 node_id) { // Edit f32_array_t *row = f32_array_create_from_raw( (f32[]){ - 1 / (float)5, - 1 / (float)5, - 3 / (float)5, + 1 / 5.0, + 1 / 5.0, + 3 / 5.0, }, 3); ui_row(row); diff --git a/paint/sources/neural_nodes/image_to_3d_mesh_node.c b/paint/sources/neural_nodes/image_to_3d_mesh_node.c index 1d1ba566..f7e4d68b 100644 --- a/paint/sources/neural_nodes/image_to_3d_mesh_node.c +++ b/paint/sources/neural_nodes/image_to_3d_mesh_node.c @@ -8,7 +8,7 @@ void image_to_3d_mesh_node_init() { } buffer_t *image_to_3d_mesh_node_remove_background(buffer_t *buffer) { - for (i32 i = 0; i < math_floor((buffer->length) / (float)4); ++i) { + for (i32 i = 0; i < math_floor((buffer->length) / 4.0); ++i) { if (buffer->buffer[i * 4] <= 16 && buffer->buffer[i * 4 + 1] <= 16 && buffer->buffer[i * 4 + 2] <= 16) { buffer->buffer[i * 4 + 3] = 0; } diff --git a/paint/sources/neural_nodes/tile_image_node.c b/paint/sources/neural_nodes/tile_image_node.c index 21020a35..dbf01b71 100644 --- a/paint/sources/neural_nodes/tile_image_node.c +++ b/paint/sources/neural_nodes/tile_image_node.c @@ -32,7 +32,7 @@ void tile_image_node_button_on_next_frame(ui_node_t *node) { u8_array_t *u8a = u8_array_create(512 * 512); for (i32 i = 0; i < 512 * 512; ++i) { i32 x = i % 512; - i32 y = math_floor(i / (float)512); + i32 y = math_floor(i / 512.0); i32 l = y < 256 ? y : (511 - y); u8a->buffer[i] = (x > 256 - l && x < 256 + l) ? 255 : 0; // u8a[i] = (x > 256 - l && x < 256 + l) ? 128 : 0; diff --git a/paint/sources/render_path_base.c b/paint/sources/render_path_base.c index 9ac4004e..d1845cb5 100644 --- a/paint/sources/render_path_base.c +++ b/paint/sources/render_path_base.c @@ -38,7 +38,7 @@ void render_path_base_begin() { } else { // Set current viewport - context_raw->view_index = mouse_view_x() > base_w() / (float)2 ? 1 : 0; + context_raw->view_index = mouse_view_x() > base_w() / 2.0 ? 1 : 0; } camera_object_t *cam = scene_camera; diff --git a/paint/sources/render_path_paint.c b/paint/sources/render_path_paint.c index 8f0ae08b..5b1d2601 100644 --- a/paint/sources/render_path_paint.c +++ b/paint/sources/render_path_paint.c @@ -202,18 +202,18 @@ void render_path_paint_commands_paint(bool dilation) { context_raw->picked_color->normal = color_set_rb(context_raw->picked_color->normal, buffer_get_u8(b, i0)); context_raw->picked_color->normal = color_set_gb(context_raw->picked_color->normal, buffer_get_u8(b, i1)); context_raw->picked_color->normal = color_set_bb(context_raw->picked_color->normal, buffer_get_u8(b, i2)); - context_raw->picked_color->occlusion = buffer_get_u8(c, i0) / (float)255; - context_raw->picked_color->roughness = buffer_get_u8(c, i1) / (float)255; - context_raw->picked_color->metallic = buffer_get_u8(c, i2) / (float)255; - context_raw->picked_color->height = buffer_get_u8(c, i3) / (float)255; - context_raw->picked_color->opacity = buffer_get_u8(a, i3) / (float)255; - context_raw->uvx_picked = buffer_get_u8(d, i0) / (float)255; - context_raw->uvy_picked = buffer_get_u8(d, i1) / (float)255; + context_raw->picked_color->occlusion = buffer_get_u8(c, i0) / 255.0; + context_raw->picked_color->roughness = buffer_get_u8(c, i1) / 255.0; + context_raw->picked_color->metallic = buffer_get_u8(c, i2) / 255.0; + context_raw->picked_color->height = buffer_get_u8(c, i3) / 255.0; + context_raw->picked_color->opacity = buffer_get_u8(a, i3) / 255.0; + context_raw->uvx_picked = buffer_get_u8(d, i0) / 255.0; + context_raw->uvy_picked = buffer_get_u8(d, i1) / 255.0; // Pick material if (context_raw->picker_select_material && context_raw->color_picker_callback == NULL) { // matid % 3 == 0 - normal, 1 - emission, 2 - subsurface i32 id = buffer_get_u8(b, 3); - i32 matid = math_floor((id - (id % 3)) / (float)3); + i32 matid = math_floor((id - (id % 3)) / 3.0); for (i32 i = 0; i < project_materials->length; ++i) { slot_material_t *m = project_materials->buffer[i]; if (m->id == matid) { @@ -440,7 +440,7 @@ void render_path_paint_commands_cursor() { f32 my = 1.0 - context_raw->paint_vec.y; f32 radius = decal_mask ? context_raw->brush_decal_mask_radius : context_raw->brush_radius; - render_path_paint_draw_cursor(mx, my, context_raw->brush_nodes_radius * radius / (float)3.4, 1.0, 1.0, 1.0); + render_path_paint_draw_cursor(mx, my, context_raw->brush_nodes_radius * radius / 3.4, 1.0, 1.0, 1.0); } void render_path_paint_draw_cursor(f32 mx, f32 my, f32 radius, f32 tint_r, f32 tint_g, f32 tint_b) { @@ -830,7 +830,7 @@ void render_path_paint_set_plane_mesh() { vec4_t v = vec4_create(m.m00, m.m01, m.m02, 1.0); f32 sx = vec4_len(v); - render_path_paint_planeo->base->transform->rot = quat_from_euler(-math_pi() / (float)2, 0, 0); + render_path_paint_planeo->base->transform->rot = quat_from_euler(-math_pi() / 2.0, 0, 0); render_path_paint_planeo->base->transform->scale = vec4_create(sx, 1.0, sx, 1.0); render_path_paint_planeo->base->transform->scale.z *= config_get_texture_res_y() / (float)config_get_texture_res_x(); render_path_paint_planeo->base->transform->loc = vec4_create(m.m30, -m.m31, 0.0, 1.0); diff --git a/paint/sources/resource.c b/paint/sources/resource.c index 29e9608b..f23d1112 100644 --- a/paint/sources/resource.c +++ b/paint/sources/resource.c @@ -15,7 +15,7 @@ gpu_texture_t *resource_get(char *name) { rect_t *resource_tile50(gpu_texture_t *img, i32 i) { i32 x = i % 12; - i32 y = i / (float)12; + i32 y = i / 12.0; i32 size = config_raw->window_scale > 1 ? 100 : 50; rect_t *r = GC_ALLOC_INIT(rect_t, {.x = x * size, .y = y * size, .w = size, .h = size}); return r; diff --git a/paint/sources/tab_browser.c b/paint/sources/tab_browser.c index 189c9cc7..61d608bb 100644 --- a/paint/sources/tab_browser.c +++ b/paint/sources/tab_browser.c @@ -195,9 +195,9 @@ void tab_browser_draw(ui_handle_t *htab) { // Menu, Up, Refresh f32_array_t *row = f32_array_create_from_raw( (f32[]){ - 0.5 / (float)4, - 0.5 / (float)4, - 3 / (float)4, + 0.5 / 4.0, + 0.5 / 4.0, + 3.0 / 4.0, }, 3); ui_row(row); diff --git a/paint/sources/tab_layers.c b/paint/sources/tab_layers.c index 7d2a5d4d..c709014f 100644 --- a/paint/sources/tab_layers.c +++ b/paint/sources/tab_layers.c @@ -10,7 +10,7 @@ void tab_layers_draw_mini(ui_handle_t *htab) { ui_set_hovered_tab_name(tr("Layers")); i32 _ELEMENT_H = ui->ops->theme->ELEMENT_H; - ui->ops->theme->ELEMENT_H = math_floor(ui_sidebar_w_mini / (float)2 / (float)UI_SCALE()); + ui->ops->theme->ELEMENT_H = math_floor(ui_sidebar_w_mini / 2.0 / (float)UI_SCALE()); ui_begin_sticky(); ui_separator(5, true); @@ -287,7 +287,7 @@ void tab_layers_draw_layer_slot(slot_layer_t *l, i32 i, bool mini) { } i32 step = ui->ops->theme->ELEMENT_H; - f32 checkw = (ui->_window_w / (float)100 * 8) / (float)UI_SCALE(); + f32 checkw = (ui->_window_w / 100.0 * 8) / (float)UI_SCALE(); // Highlight drag destination f32 absy = ui->_window_y + ui->_y; @@ -351,7 +351,7 @@ void tab_layers_draw_layer_slot_full_delete_layer(void *_) { void tab_layers_draw_layer_slot_full(slot_layer_t *l, i32 i) { i32 step = ui->ops->theme->ELEMENT_H; - f32 center = (step / (float)2) * UI_SCALE(); + f32 center = (step / 2.0) * UI_SCALE(); f32 uiw = ui->_w; f32 uix = ui->_x; f32 uiy = ui->_y; @@ -625,10 +625,10 @@ ui_state_t tab_layers_draw_layer_icon(slot_layer_t *l, i32 i, f32 uix, f32 uiy, } if (l->parent != NULL) { - ui->_x += (icon_h - icon_h * 0.9) / (float)2; + ui->_x += (icon_h - icon_h * 0.9) / 2.0; icon_h *= 0.9; if (l->parent->parent != NULL) { - ui->_x += (icon_h - icon_h * 0.9) / (float)2; + ui->_x += (icon_h - icon_h * 0.9) / 2.0; icon_h *= 0.9; } } diff --git a/paint/sources/tab_materials.c b/paint/sources/tab_materials.c index 150cf3b7..19977746 100644 --- a/paint/sources/tab_materials.c +++ b/paint/sources/tab_materials.c @@ -356,8 +356,8 @@ void tab_materials_accept_swatch_drop(swatch_color_t *swatch) { for (i32 i = 0; i < context_raw->material->canvas->nodes->length; ++i) { ui_node_t *node = context_raw->material->canvas->nodes->buffer[i]; if (string_equals(node->type, "RGB")) { - node->outputs->buffer[0]->default_value = f32_array_create_xyzw(color_get_rb(swatch->base) / (float)255, color_get_gb(swatch->base) / (float)255, - color_get_bb(swatch->base) / (float)255, color_get_ab(swatch->base) / (float)255); + node->outputs->buffer[0]->default_value = f32_array_create_xyzw(color_get_rb(swatch->base) / 255.0, color_get_gb(swatch->base) / 255.0, + color_get_bb(swatch->base) / 255.0, color_get_ab(swatch->base) / 255.0); } else if (string_equals(node->type, "OUTPUT_MATERIAL_PBR")) { node->inputs->buffer[1]->default_value->buffer[0] = swatch->opacity; diff --git a/paint/sources/tab_meshes.c b/paint/sources/tab_meshes.c index 1d2a885a..d4ac0839 100644 --- a/paint/sources/tab_meshes.c +++ b/paint/sources/tab_meshes.c @@ -157,7 +157,7 @@ void tab_meshes_draw(ui_handle_t *htab) { gpu_texture_t *icons = resource_get("icons05x.k"); rect_t *rect = resource_tile50(icons, ICON_CUBE); i32 icon_h = 25 * UI_SCALE(); - ui_sub_image(icons, ui->ops->theme->LABEL_COL - 0x00333333, icon_h, rect->x / (float)2, rect->y / (float)2, rect->w / (float)2, rect->h / (float)2); + ui_sub_image(icons, ui->ops->theme->LABEL_COL - 0x00333333, icon_h, rect->x / 2.0, rect->y / 2.0, rect->w / 2.0, rect->h / 2.0); mesh_object_t *o = project_paint_objects->buffer[i]; ui_handle_t *h = ui_handle(__ID__); @@ -196,7 +196,7 @@ void tab_meshes_draw_properties(mesh_object_t *o) { transform_t *t = context_raw->selected_object->transform; vec4_t rot = quat_get_euler(t->rot); - rot = vec4_mult(rot, 180 / (float)3.141592); + rot = vec4_mult(rot, 180 / 3.141592); f32 f = 0.0; bool changed = false; @@ -309,7 +309,7 @@ void tab_meshes_draw_properties(mesh_object_t *o) { } if (changed) { - rot = vec4_mult(rot, 3.141592 / (float)180); + rot = vec4_mult(rot, 3.141592 / 180.0); context_raw->selected_object->transform->rot = quat_from_euler(rot.x, rot.y, rot.z); transform_build_matrix(context_raw->selected_object->transform); transform_compute_dim(context_raw->selected_object->transform); diff --git a/paint/sources/tab_scene.c b/paint/sources/tab_scene.c index 25daa681..b15df921 100644 --- a/paint/sources/tab_scene.c +++ b/paint/sources/tab_scene.c @@ -82,8 +82,8 @@ void tab_scene_draw_list(ui_handle_t *list_handle, object_t *current_object) { if (current_object->children->length > 0) { f32_array_t *row = f32_array_create_from_raw( (f32[]){ - 1 / (float)13, - 12 / (float)13, + 1 / 13.0, + 12 / 13.0, }, 2); ui_row(row); @@ -99,7 +99,7 @@ void tab_scene_draw_list(ui_handle_t *list_handle, object_t *current_object) { // Draw line that shows parent relations draw_set_color(ui->ops->theme->BUTTON_COL); - draw_line(ui->_x - 10, ui->_y + UI_ELEMENT_H() / (float)2, ui->_x, ui->_y + UI_ELEMENT_H() / (float)2, 1.0); + draw_line(ui->_x - 10, ui->_y + UI_ELEMENT_H() / 2.0, ui->_x, ui->_y + UI_ELEMENT_H() / 2.0, 1.0); draw_set_color(0xffffffff); ui_text(current_object->name, UI_ALIGN_LEFT, 0x00000000); @@ -131,7 +131,7 @@ void tab_scene_draw_list(ui_handle_t *list_handle, object_t *current_object) { // Draw line that shows parent relations draw_set_color(ui->ops->theme->BUTTON_COL); - draw_line(ui->_x + 14, current_y, ui->_x + 14, ui->_y - UI_ELEMENT_H() / (float)2, 1.0); + draw_line(ui->_x + 14, current_y, ui->_x + 14, ui->_y - UI_ELEMENT_H() / 2.0, 1.0); draw_set_color(0xffffffff); } } diff --git a/paint/sources/tab_swatches.c b/paint/sources/tab_swatches.c index 24387f9f..89aeeca5 100644 --- a/paint/sources/tab_swatches.c +++ b/paint/sources/tab_swatches.c @@ -218,7 +218,7 @@ void tab_swatches_draw(ui_handle_t *htab) { ui_header_handle->redraws = 2; } else if (state == UI_STATE_HOVERED) { - tab_swatches_drag_pos = (mouse_x > uix + ui->_window_x + slotw / (float)2) + tab_swatches_drag_pos = (mouse_x > uix + ui->_window_x + slotw / 2.0) ? i + 1 : i; // Switch to the next position if the mouse crosses the swatch rectangle center drag_pos_set = true; diff --git a/paint/sources/ui_box.c b/paint/sources/ui_box.c index 9cbdb866..cd7e7a7f 100644 --- a/paint/sources/ui_box.c +++ b/paint/sources/ui_box.c @@ -19,10 +19,10 @@ void ui_box_render() { i32 apph = iron_window_height(); i32 mw = math_floor(ui_box_modalw * UI_SCALE()); i32 mh = math_floor(ui_box_modalh * UI_SCALE()); - f32 left = (appw / (float)2 - mw / (float)2) + ui_box_hwnd->drag_x; - f32 right = (appw / (float)2 + mw / (float)2) + ui_box_hwnd->drag_x; - f32 top = (apph / (float)2 - mh / (float)2) + ui_box_hwnd->drag_y; - f32 bottom = (apph / (float)2 + mh / (float)2) + ui_box_hwnd->drag_y; + f32 left = (appw / 2.0 - mw / 2.0) + ui_box_hwnd->drag_x; + f32 right = (appw / 2.0 + mw / 2.0) + ui_box_hwnd->drag_x; + f32 top = (apph / 2.0 - mh / 2.0) + ui_box_hwnd->drag_y; + f32 bottom = (apph / 2.0 + mh / 2.0) + ui_box_hwnd->drag_y; i32 mx = mouse_x; i32 my = mouse_y; if ((ui_box_click_to_hide && (mx < left || mx > right || my < top || my > bottom)) || is_escape) { @@ -52,8 +52,8 @@ void ui_box_render() { if (mh > apph) { mh = apph; } - i32 left = math_floor(appw / (float)2 - mw / (float)2); - i32 top = math_floor(apph / (float)2 - mh / (float)2); + i32 left = math_floor(appw / 2.0 - mw / 2.0); + i32 top = math_floor(apph / 2.0 - mh / 2.0); ui_box_hwnd->text = string_copy(ui_box_title); if (ui_box_commands == NULL) { @@ -77,8 +77,8 @@ void ui_box_render() { else { f32_array_t *row = f32_array_create_from_raw( (f32[]){ - 2 / (float)3, - 1 / (float)3, + 2 / 3.0, + 1 / 3.0, }, 2); ui_row(row); @@ -86,8 +86,8 @@ void ui_box_render() { #else f32_array_t *row = f32_array_create_from_raw( (f32[]){ - 2 / (float)3, - 1 / (float)3, + 2 / 3.0, + 1 / 3.0, }, 2); ui_row(row); @@ -182,7 +182,7 @@ void ui_box_tween_in() { tween_anim_t *a = GC_ALLOC_INIT(tween_anim_t, {.target = &ui_box_tween_alpha, .to = 0.5, .duration = 0.2, .ease = EASE_EXPO_OUT}); tween_to(a); - ui_box_hwnd->drag_y = math_floor(iron_window_height() / (float)2); + ui_box_hwnd->drag_y = math_floor(iron_window_height() / 2.0); a = GC_ALLOC_INIT(tween_anim_t, {.target = &ui_box_hwnd->drag_y, .to = 0.0, .duration = 0.2, .ease = EASE_EXPO_OUT, .tick = ui_box_tween_tick}); tween_to(a); } diff --git a/paint/sources/ui_files.c b/paint/sources/ui_files.c index 8e6bed31..140544a5 100644 --- a/paint/sources/ui_files.c +++ b/paint/sources/ui_files.c @@ -217,7 +217,7 @@ char *ui_files_file_browser(ui_handle_t *handle, bool drag_files, char *search, if (ui_files_selected == i) col = ui->ops->theme->HIGHLIGHT_COL; - f32 off = ui->_w / (float)2 - 25 * UI_SCALE(); + f32 off = ui->_w / 2.0 - 25 * UI_SCALE(); ui->_x += off; f32 uix = ui->_x; diff --git a/paint/sources/ui_menu.c b/paint/sources/ui_menu.c index 5c4077e4..2de04713 100644 --- a/paint/sources/ui_menu.c +++ b/paint/sources/ui_menu.c @@ -130,7 +130,7 @@ bool ui_menu_button(char *text, char *label, icon_t icon) { ui->_x = _x_left - 2 * UI_SCALE(); ui->_y = _y_top + 2 * UI_SCALE(); } - ui_sub_image(icons, ui->ops->theme->LABEL_COL - 0x00222222, icon_h, rect->x / (float)2, rect->y / (float)2, rect->w / (float)2, rect->h / (float)2); + ui_sub_image(icons, ui->ops->theme->LABEL_COL - 0x00222222, icon_h, rect->x / 2.0, rect->y / 2.0, rect->w / 2.0, rect->h / 2.0); ui->_x = _x_left; ui->_y = _y_bottom; } @@ -171,7 +171,7 @@ bool ui_icon_button(char *text, icon_t icon, ui_align_t align) { gpu_texture_t *icons = resource_get("icons05x.k"); rect_t *rect = resource_tile50(icons, icon); i32 icon_h = 25 * UI_SCALE(); - ui->_x = align == UI_ALIGN_LEFT ? _x_left : _x_left + _w / (float)2 - textw / (float)2 - icon_h / (float)2; + ui->_x = align == UI_ALIGN_LEFT ? _x_left : _x_left + _w / 2.0 - textw / 2.0 - icon_h / 2.0; ui->_y = _y_top; if (config_raw->touch_ui) { @@ -186,8 +186,8 @@ bool ui_icon_button(char *text, icon_t icon, ui_align_t align) { } ui->image_scroll_align = false; - ui_sub_image(icons, ui->enabled ? ui_menu_color_sub(ui->ops->theme->LABEL_COL, 0x00333333) : 0xffffffff, icon_h, rect->x / (float)2, rect->y / (float)2, - rect->w / (float)2, rect->h / (float)2); + ui_sub_image(icons, ui->enabled ? ui_menu_color_sub(ui->ops->theme->LABEL_COL, 0x00333333) : 0xffffffff, icon_h, rect->x / 2.0, rect->y / 2.0, + rect->w / 2.0, rect->h / 2.0); ui->image_scroll_align = true; ui->_x = _x_right; @@ -227,8 +227,8 @@ void ui_menu_align() { if (!config_raw->touch_ui) { f32_array_t *row = f32_array_create_from_raw( (f32[]){ - 12 / (float)100, - 88 / (float)100, + 12 / 100.0, + 88 / 100.0, }, 2); ui_row(row); diff --git a/paint/sources/ui_menubar.c b/paint/sources/ui_menubar.c index 4460d734..10d075fb 100644 --- a/paint/sources/ui_menubar.c +++ b/paint/sources/ui_menubar.c @@ -480,14 +480,14 @@ void ui_menubar_draw_category_items() { ui_handle_t *enva_handle = ui_handle(__ID__); enva_handle->f = context_raw->envmap_angle / (float)math_pi() * 180.0; if (enva_handle->f < 0) { - enva_handle->f += (math_floor(-enva_handle->f / (float)360) + 1) * 360; + enva_handle->f += (math_floor(-enva_handle->f / 360.0) + 1) * 360; } else if (enva_handle->f > 360) { - enva_handle->f -= math_floor(enva_handle->f / (float)360) * 360; + enva_handle->f -= math_floor(enva_handle->f / 360.0) * 360; } ui_menu_align(); context_raw->envmap_angle = - ui_slider(enva_handle, tr("Environment Angle"), 0.0, 360.0, true, 1, true, UI_ALIGN_RIGHT, true) / (float)180.0 * math_pi(); + ui_slider(enva_handle, tr("Environment Angle"), 0.0, 360.0, true, 1, true, UI_ALIGN_RIGHT, true) / 180.0 * math_pi(); if (ui->is_hovered) { any_map_t *vars = any_map_create(); any_map_set(vars, "shortcut", any_map_get(config_keymap, "rotate_envmap")); @@ -671,16 +671,16 @@ void ui_menubar_draw_category_items() { if (ui_menu_sub_button(ui_handle(__ID__), tr("View"))) { ui_menu_sub_begin(6); if (ui_menu_button(tr("Front"), any_map_get(config_keymap, "view_front"), ICON_NONE)) { - viewport_set_view(0, -1, 0, math_pi() / (float)2, 0, 0); + viewport_set_view(0, -1, 0, math_pi() / 2.0, 0, 0); } if (ui_menu_button(tr("Back"), any_map_get(config_keymap, "view_back"), ICON_NONE)) { - viewport_set_view(0, 1, 0, math_pi() / (float)2, 0, math_pi()); + viewport_set_view(0, 1, 0, math_pi() / 2.0, 0, math_pi()); } if (ui_menu_button(tr("Right"), any_map_get(config_keymap, "view_right"), ICON_NONE)) { - viewport_set_view(1, 0, 0, math_pi() / (float)2, 0, math_pi() / (float)2); + viewport_set_view(1, 0, 0, math_pi() / 2.0, 0, math_pi() / 2.0); } if (ui_menu_button(tr("Left"), any_map_get(config_keymap, "view_left"), ICON_NONE)) { - viewport_set_view(-1, 0, 0, math_pi() / (float)2, 0, -math_pi() / (float)2); + viewport_set_view(-1, 0, 0, math_pi() / 2.0, 0, -math_pi() / 2.0); } if (ui_menu_button(tr("Top"), any_map_get(config_keymap, "view_top"), ICON_NONE)) { viewport_set_view(0, 0, 1, 0, 0, 0); @@ -696,16 +696,16 @@ void ui_menubar_draw_category_items() { if (ui_menu_sub_button(ui_handle(__ID__), tr("Orbit"))) { ui_menu_sub_begin(5); if (ui_menu_button(tr("Left"), any_map_get(config_keymap, "view_orbit_left"), ICON_ARROW_LEFT)) { - viewport_orbit(-math_pi() / (float)12, 0); + viewport_orbit(-math_pi() / 12.0, 0); } if (ui_menu_button(tr("Right"), any_map_get(config_keymap, "view_orbit_right"), ICON_ARROW_RIGHT)) { - viewport_orbit(math_pi() / (float)12, 0); + viewport_orbit(math_pi() / 12.0, 0); } if (ui_menu_button(tr("Up"), any_map_get(config_keymap, "view_orbit_up"), ICON_ARROW_UP)) { - viewport_orbit(0, -math_pi() / (float)12); + viewport_orbit(0, -math_pi() / 12.0); } if (ui_menu_button(tr("Down"), any_map_get(config_keymap, "view_orbit_down"), ICON_ARROW_DOWN)) { - viewport_orbit(0, math_pi() / (float)12); + viewport_orbit(0, math_pi() / 12.0); } if (ui_menu_button(tr("Opposite"), any_map_get(config_keymap, "view_orbit_opposite"), ICON_NONE)) { viewport_orbit_opposite(); @@ -722,7 +722,7 @@ void ui_menubar_draw_category_items() { } camera_object_t *cam = scene_camera; - context_raw->fov_handle->f = math_floor(cam->data->fov * 100) / (float)100; + context_raw->fov_handle->f = math_floor(cam->data->fov * 100) / 100.0; ui_menu_align(); cam->data->fov = ui_slider(context_raw->fov_handle, tr("FoV"), 0.3, 1.4, true, 100.0, true, UI_ALIGN_RIGHT, true); if (context_raw->fov_handle->changed) { @@ -915,7 +915,7 @@ void ui_menubar_show_menu(i32 category) { ui_menu_y = math_floor(ui_MENUBAR_H(ui)) + panel_y + 2; if (config_raw->touch_ui) { i32 menu_w = math_floor(base_default_element_w * UI_SCALE() * 2.0); - ui_menu_x -= math_floor((menu_w - ui->_w) / (float)2) + math_floor(ui_header_h / (float)2); + ui_menu_x -= math_floor((menu_w - ui->_w) / 2.0) + math_floor(ui_header_h / 2.0); ui_menu_x += math_floor(2 * UI_SCALE()); ui_menu_y -= math_floor(2 * UI_SCALE()); ui_menu_keep_open = true; diff --git a/paint/sources/ui_nodes.c b/paint/sources/ui_nodes.c index 72de2a95..4de9473c 100644 --- a/paint/sources/ui_nodes.c +++ b/paint/sources/ui_nodes.c @@ -417,7 +417,7 @@ ui_canvas_control_t *ui_nodes_get_canvas_control(bool controls_down) { } bool pan = ui->input_down_r || operator_shortcut(any_map_get(config_keymap, "action_pan"), SHORTCUT_TYPE_DOWN); - f32 zoom_delta = operator_shortcut(any_map_get(config_keymap, "action_zoom"), SHORTCUT_TYPE_DOWN) ? ui_nodes_get_zoom_delta() / (float)100.0 : 0.0; + f32 zoom_delta = operator_shortcut(any_map_get(config_keymap, "action_zoom"), SHORTCUT_TYPE_DOWN) ? ui_nodes_get_zoom_delta() / 100.0 : 0.0; ui_canvas_control_t *control = GC_ALLOC_INIT(ui_canvas_control_t, {.pan_x = pan ? ui->input_dx : 0.0, .pan_y = pan ? ui->input_dy : 0.0, .zoom = ui->input_wheel_delta != 0.0 ? -ui->input_wheel_delta / 10 : zoom_delta, @@ -442,11 +442,11 @@ f32 ui_nodes_get_zoom_delta() { bool ui_nodes_is_tab_selected() { return ui_nodes_htab->i > 0 && ui_nodes_htab->i % 2 == 1 && // [tab0, tab1, x, tab2, x, +] - ui_nodes_tabs->length >= ui_nodes_htab->i / (float)2; + ui_nodes_tabs->length >= ui_nodes_htab->i / 2.0; } i32 ui_nodes_tab_index() { - return (int)(ui_nodes_htab->i / (float)2); + return (int)(ui_nodes_htab->i / 2.0); } ui_node_canvas_t *ui_nodes_get_canvas(bool groups) { @@ -1083,7 +1083,7 @@ void ui_nodes_render(void *_) { nodes->nodes_drag = true; } // Next column - if (ui->_y - ui_nodes_wy + UI_ELEMENT_H() / (float)2 > ui_nodes_wh) { + if (ui->_y - ui_nodes_wy + UI_ELEMENT_H() / 2.0 > ui_nodes_wh) { ui->_x += menuw; ui->_y = py; } @@ -1094,8 +1094,8 @@ void ui_nodes_render(void *_) { ui->enabled = ui_nodes_can_place_group(g->canvas->name); f32_array_t *row = f32_array_create_from_raw( (f32[]){ - 5 / (float)6, - 1 / (float)6, + 5 / 6.0, + 1 / 6.0, }, 2); ui_row(row); @@ -1262,8 +1262,8 @@ void ui_nodes_draw_menubar() { if (config_raw->touch_ui) { ui_nodes_show_menu_first = true; i32 menuw = math_floor(ew * 2.3); - ui_nodes_popup_x -= menuw / (float)2; - ui_nodes_popup_x += ui->_w / (float)2; + ui_nodes_popup_x -= menuw / 2.0; + ui_nodes_popup_x += ui->_w / 2.0; } } ui->_x += ui->_w + 3; @@ -1394,8 +1394,8 @@ void ui_nodes_accept_swatch_drop(swatch_color_t *swatch) { ui_nodes_push_undo(NULL); node_group_t *g = ui_nodes_group_stack->length > 0 ? ui_nodes_group_stack->buffer[ui_nodes_group_stack->length - 1] : NULL; ui_node_t *n = nodes_material_create_node("RGB", g); - n->outputs->buffer[0]->default_value = f32_array_create_xyzw(color_get_rb(swatch->base) / (float)255, color_get_gb(swatch->base) / (float)255, - color_get_bb(swatch->base) / (float)255, color_get_ab(swatch->base) / (float)255); + n->outputs->buffer[0]->default_value = f32_array_create_xyzw(color_get_rb(swatch->base) / 255.0, color_get_gb(swatch->base) / 255.0, + color_get_bb(swatch->base) / 255.0, color_get_ab(swatch->base) / 255.0); ui_nodes_get_nodes()->nodes_selected_id = i32_array_create_from_raw( (i32[]){ n->id, diff --git a/paint/sources/ui_toolbar.c b/paint/sources/ui_toolbar.c index c2296bcc..02f927ac 100644 --- a/paint/sources/ui_toolbar.c +++ b/paint/sources/ui_toolbar.c @@ -12,7 +12,7 @@ void ui_toolbar_draw_tool(i32 tool, gpu_texture_t *img, i32 icon_accent) { if (context_raw->tool == tool) { ui_toolbar_draw_highlight(); } - i32 tile_y = math_floor(tool / (float)12); + i32 tile_y = math_floor(tool / 12.0); i32 tile_x = tile_y % 2 == 0 ? tool % 12 : (11 - (tool % 12)); i32 tile_i = tile_y * 12 + tile_x; rect_t *rect = resource_tile50(img, tile_i); @@ -98,7 +98,7 @@ void ui_toolbar_draw_show_3d_view() { ui->ops->theme->BUTTON_H = ui->ops->theme->ELEMENT_H; ui->ops->theme->BUTTON_COL = ui->ops->theme->WINDOW_BG_COL; i32 font_height = draw_font_height(ui->ops->font, ui->font_size); - ui->font_offset_y = (UI_ELEMENT_H() - font_height) / (float)2; + ui->font_offset_y = (UI_ELEMENT_H() - font_height) / 2.0; i32 _w = ui->_w; ui->_w = toolbar_w; if (ui_icon_button("", ICON_CUBE, UI_ALIGN_CENTER)) { @@ -174,7 +174,7 @@ void ui_toolbar_render_ui() { ui->ops->theme->BUTTON_H = ui->ops->theme->ELEMENT_H; ui->ops->theme->BUTTON_COL = ui->ops->theme->WINDOW_BG_COL; i32 font_height = draw_font_height(ui->ops->font, ui->font_size); - ui->font_offset_y = (UI_ELEMENT_H() - font_height) / (float)2; + ui->font_offset_y = (UI_ELEMENT_H() - font_height) / 2.0; i32 _w = ui->_w; ui->_w = ui_toolbar_w(false); diff --git a/paint/sources/ui_view2d.c b/paint/sources/ui_view2d.c index 66e345ab..4cf3ba9a 100644 --- a/paint/sources/ui_view2d.c +++ b/paint/sources/ui_view2d.c @@ -215,7 +215,7 @@ void ui_view2d_render(void *_) { i32 th = tw; if (tex != NULL) { th = tw * (tex->height / (float)tex->width); - ty = apph / (float)2 - th / (float)2 + ui_view2d_pan_y; + ty = apph / 2.0 - th / 2.0 + ui_view2d_pan_y; if (ui_view2d_type == VIEW_2D_TYPE_LAYER) { draw_set_pipeline(ui_view2d_pipe); } @@ -453,8 +453,8 @@ void ui_view2d_update(void *_) { if (ui_touch_control) { // Zoom to finger location - ui_view2d_pan_x -= (ui->input_x - ui->_window_x - ui->_window_w / (float)2) * control->zoom; - ui_view2d_pan_y -= (ui->input_y - ui->_window_y - ui->_window_h / (float)2) * control->zoom; + ui_view2d_pan_x -= (ui->input_x - ui->_window_x - ui->_window_w / 2.0) * control->zoom; + ui_view2d_pan_y -= (ui->input_y - ui->_window_y - ui->_window_h / 2.0) * control->zoom; } ui_view2d_grid_redraw = true; } @@ -482,10 +482,10 @@ void ui_view2d_update(void *_) { f32 wm = fmin(ui_view2d_ww, ui_view2d_wh); f32 tw = wm * 0.9 * ui_view2d_pan_scale; f32 th = tw * ratio; - f32 tx = ui_view2d_ww / (float)2 - tw / (float)2 + ui_view2d_pan_x; + f32 tx = ui_view2d_ww / 2.0 - tw / 2.0 + ui_view2d_pan_x; i32 headerh = config_raw->layout->buffer[LAYOUT_SIZE_HEADER] == 1 ? ui_header_h * 2 : ui_header_h; i32 apph = iron_window_height() - config_raw->layout->buffer[LAYOUT_SIZE_STATUS_H] + headerh; - f32 ty = apph / (float)2 - th / (float)2 + ui_view2d_pan_y; + f32 ty = apph / 2.0 - th / 2.0 + ui_view2d_pan_y; f32 mx = mouse_x - ui_view2d_wx; f32 my = mouse_y - ui_view2d_wy; if (mx > tx && mx < tx + tw && my > ty && my < ty + th) { @@ -526,21 +526,21 @@ void ui_view2d_update(void *_) { i32 border = 32; f32 wm = fmin(ui_view2d_ww, ui_view2d_wh); f32 tw = ui_view2d_ww * 0.9 * ui_view2d_pan_scale; - f32 tx = ui_view2d_ww / (float)2 - tw / (float)2 + ui_view2d_pan_x; + f32 tx = ui_view2d_ww / 2.0 - tw / 2.0 + ui_view2d_pan_x; f32 hh = sys_h(); - f32 ty = hh / (float)2 - tw / (float)2 + ui_view2d_pan_y; + f32 ty = hh / 2.0 - tw / 2.0 + ui_view2d_pan_y; if (tx + border > ui_view2d_ww) { - ui_view2d_pan_x = ui_view2d_ww / (float)2 + tw / (float)2 - border; + ui_view2d_pan_x = ui_view2d_ww / 2.0 + tw / 2.0 - border; } else if (tx - border < -tw) { - ui_view2d_pan_x = -tw / (float)2 - ui_view2d_ww / (float)2 + border; + ui_view2d_pan_x = -tw / 2.0 - ui_view2d_ww / 2.0 + border; } if (ty + border > hh) { - ui_view2d_pan_y = hh / (float)2 + tw / (float)2 - border; + ui_view2d_pan_y = hh / 2.0 + tw / 2.0 - border; } else if (ty - border < -tw) { - ui_view2d_pan_y = -tw / (float)2 - hh / (float)2 + border; + ui_view2d_pan_y = -tw / 2.0 - hh / 2.0 + border; } if (operator_shortcut(any_map_get(config_keymap, "view_reset"), SHORTCUT_TYPE_STARTED)) { diff --git a/paint/sources/uniforms_ext.c b/paint/sources/uniforms_ext.c index b5178ebf..b34aedb4 100644 --- a/paint/sources/uniforms_ext.c +++ b/paint/sources/uniforms_ext.c @@ -40,7 +40,7 @@ f32 uniforms_ext_f32_link(object_t *object, material_data_t *mat, char *link) { f32 brush_decal_mask_radius = context_raw->brush_decal_mask_radius; brush_decal_mask_radius *= context_raw->paint2d ? 0.55 * ui_view2d_pan_scale : 2.0; f32 radius = decal_mask ? brush_decal_mask_radius : context_raw->brush_radius; - f32 val = (radius * context_raw->brush_nodes_radius) / (float)15.0; + f32 val = (radius * context_raw->brush_nodes_radius) / 15.0; if (config_raw->pressure_radius && pen_down("tip")) { val *= pen_pressure * config_raw->pressure_sensitivity; } @@ -172,7 +172,7 @@ vec2_t uniforms_ext_vec2_link(object_t *object, material_data_t *mat, char *link else if (string_equals(link, "_brush_angle")) { f32 brush_angle = context_raw->brush_angle + context_raw->brush_nodes_angle; f32 angle = context_raw->layer->fill_layer != NULL ? context_raw->layer->angle : brush_angle; - angle *= (math_pi() / (float)180); + angle *= (math_pi() / 180.0); if (config_raw->pressure_angle && pen_down("tip")) { angle *= pen_pressure * config_raw->pressure_sensitivity; } @@ -196,7 +196,7 @@ vec4_t uniforms_ext_vec3_link(object_t *object, material_data_t *mat, char *link x = uniforms_ext_vec2d(x); lastx = uniforms_ext_vec2d(lastx); } - f32 angle = math_atan2(-y + lasty, x - lastx) - math_pi() / (float)2; + f32 angle = math_atan2(-y + lasty, x - lastx) - math_pi() / 2.0; v = vec4_create(math_cos(angle), math_sin(angle), allow_paint ? 1 : 0, 1.0); context_raw->prev_paint_vec_x = context_raw->last_paint_vec_x; context_raw->prev_paint_vec_y = context_raw->last_paint_vec_y; @@ -215,14 +215,14 @@ vec4_t uniforms_ext_vec3_link(object_t *object, material_data_t *mat, char *link } else if (string_equals(link, "_picker_base")) { v = _uniforms_vec; - v = vec4_create(color_get_rb(context_raw->picked_color->base) / (float)255, color_get_gb(context_raw->picked_color->base) / (float)255, - color_get_bb(context_raw->picked_color->base) / (float)255, 1.0); + v = vec4_create(color_get_rb(context_raw->picked_color->base) / 255.0, color_get_gb(context_raw->picked_color->base) / 255.0, + color_get_bb(context_raw->picked_color->base) / 255.0, 1.0); return v; } else if (string_equals(link, "_picker_normal")) { v = _uniforms_vec; - v = vec4_create(color_get_rb(context_raw->picked_color->normal) / (float)255, color_get_gb(context_raw->picked_color->normal) / (float)255, - color_get_bb(context_raw->picked_color->normal) / (float)255, 1.0); + v = vec4_create(color_get_rb(context_raw->picked_color->normal) / 255.0, color_get_gb(context_raw->picked_color->normal) / 255.0, + color_get_bb(context_raw->picked_color->normal) / 255.0, 1.0); return v; } else if (string_equals(link, "_particle_hit")) { @@ -282,7 +282,7 @@ vec4_t uniforms_ext_vec4_link(object_t *object, material_data_t *mat, char *link } else if (string_equals(link, "_decal_mask")) { bool decal_mask = context_is_decal_mask_paint(); - f32 val = (context_raw->brush_radius * context_raw->brush_nodes_radius) / (float)15.0; + f32 val = (context_raw->brush_radius * context_raw->brush_nodes_radius) / 15.0; f32 scale2d = (900 / (float)base_h()) * config_raw->window_scale; val *= scale2d; // Projection ratio vec4_t v = vec4_create(context_raw->decal_x, context_raw->decal_y, decal_mask ? 1 : 0, val); diff --git a/paint/sources/util_mesh.c b/paint/sources/util_mesh.c index e4ca36f4..ded42595 100644 --- a/paint/sources/util_mesh.c +++ b/paint/sources/util_mesh.c @@ -24,7 +24,7 @@ void util_mesh_merge(mesh_object_t_array_t *paint_objects) { max_scale = paint_objects->buffer[i]->data->scale_pos; } } - vlen = math_floor(vlen / (float)4); + vlen = math_floor(vlen / 4.0); i16_array_t *va0 = i16_array_create(vlen * 4); i16_array_t *va1 = i16_array_create(vlen * 2); i16_array_t *va2 = i16_array_create(vlen * 2); @@ -54,7 +54,7 @@ void util_mesh_merge(mesh_object_t_array_t *paint_objects) { // } // Re-scale - for (i32 j = voff; j < math_floor(va0->length / (float)4); ++j) { + for (i32 j = voff; j < math_floor(va0->length / 4.0); ++j) { va0->buffer[j * 4] = math_floor((va0->buffer[j * 4] * scale) / (float)max_scale); va0->buffer[j * 4 + 1] = math_floor((va0->buffer[j * 4 + 1] * scale) / (float)max_scale); va0->buffer[j * 4 + 2] = math_floor((va0->buffer[j * 4 + 2] * scale) / (float)max_scale); @@ -85,7 +85,7 @@ void util_mesh_merge(mesh_object_t_array_t *paint_objects) { ia->buffer[j + ioff] = ias->buffer[j] + voff; } - voff += math_floor(vas->buffer[0]->values->length / (float)4); + voff += math_floor(vas->buffer[0]->values->length / 4.0); ioff += math_floor(ias->length); } mesh_data_t *raw = GC_ALLOC_INIT(mesh_data_t, {.name = context_raw->paint_object->base->name, @@ -138,7 +138,7 @@ void util_mesh_swap_axis(i32 a, i32 b) { i32 d = b == 2 ? 3 : b; i32 e = a == 2 ? 4 : 2; i32 f = b == 2 ? 4 : 2; - for (i32 i = 0; i < math_floor(pa->length / (float)4); ++i) { + for (i32 i = 0; i < math_floor(pa->length / 4.0); ++i) { i32 t = pa->buffer[i * 4 + a]; pa->buffer[i * 4 + a] = pa->buffer[i * 4 + b]; pa->buffer[i * 4 + b] = -t; @@ -160,7 +160,7 @@ void util_mesh_flip_normals() { vertex_array_t_array_t *vas = o->data->vertex_arrays; i16_array_t *va0 = vas->buffer[0]->values; i16_array_t *va1 = vas->buffer[1]->values; - for (i32 i = 0; i < va0->length / (float)4; ++i) { + for (i32 i = 0; i < va0->length / 4.0; ++i) { va0->buffer[i * 4 + 3] = -va0->buffer[i * 4 + 3]; va1->buffer[i * 2] = -va1->buffer[i * 2]; va1->buffer[i * 2 + 1] = -va1->buffer[i * 2 + 1]; @@ -196,7 +196,7 @@ void util_mesh_calc_normals(bool smooth) { u32_array_t *inda = g->index_array; i16_array_t *va0 = o->data->vertex_arrays->buffer[0]->values; i16_array_t *va1 = o->data->vertex_arrays->buffer[1]->values; - i32 num_verts = math_floor(va0->length / (float)4); + i32 num_verts = math_floor(va0->length / 4.0); f32_array_t *smooth_vals = NULL; i32_array_t *vert_map = NULL; if (smooth) { @@ -228,7 +228,7 @@ void util_mesh_calc_normals(bool smooth) { } } - for (i32 i = 0; i < math_floor(inda->length / (float)3); ++i) { + for (i32 i = 0; i < math_floor(inda->length / 3.0); ++i) { i32 i1 = inda->buffer[i * 3]; i32 i2 = inda->buffer[i * 3 + 1]; i32 i3 = inda->buffer[i * 3 + 2]; @@ -305,7 +305,7 @@ void util_mesh_to_origin() { for (i32 i = 0; i < project_paint_objects->length; ++i) { mesh_object_t *o = project_paint_objects->buffer[i]; i32 l = 4; - f32 sc = o->data->scale_pos / (float)32767; + f32 sc = o->data->scale_pos / 32767.0; i16_array_t *va = o->data->vertex_arrays->buffer[0]->values; f32 minx = va->buffer[0]; f32 maxx = va->buffer[0]; @@ -333,9 +333,9 @@ void util_mesh_to_origin() { maxz = va->buffer[i * l + 2]; } } - dx += (minx + maxx) / (float)2 * sc; - dy += (miny + maxy) / (float)2 * sc; - dz += (minz + maxz) / (float)2 * sc; + dx += (minx + maxx) / 2.0 * sc; + dy += (miny + maxy) / 2.0 * sc; + dz += (minz + maxz) / 2.0 * sc; } dx /= project_paint_objects->length; dy /= project_paint_objects->length; @@ -344,10 +344,10 @@ void util_mesh_to_origin() { for (i32 i = 0; i < project_paint_objects->length; ++i) { mesh_object_t *o = project_paint_objects->buffer[i]; mesh_data_t *g = o->data; - f32 sc = o->data->scale_pos / (float)32767; + f32 sc = o->data->scale_pos / 32767.0; i16_array_t *va = o->data->vertex_arrays->buffer[0]->values; f32 max_scale = 0.0; - for (i32 i = 0; i < math_floor(va->length / (float)4); ++i) { + for (i32 i = 0; i < math_floor(va->length / 4.0); ++i) { if (math_abs(va->buffer[i * 4] * sc - dx) > max_scale) { max_scale = math_abs(va->buffer[i * 4] * sc - dx); } @@ -361,7 +361,7 @@ void util_mesh_to_origin() { o->base->transform->scale_world = o->data->scale_pos = o->data->scale_pos = max_scale; transform_build_matrix(o->base->transform); - for (i32 i = 0; i < math_floor(va->length / (float)4); ++i) { + for (i32 i = 0; i < math_floor(va->length / 4.0); ++i) { va->buffer[i * 4] = math_floor((va->buffer[i * 4] * sc - dx) / (float)max_scale * 32767); va->buffer[i * 4 + 1] = math_floor((va->buffer[i * 4 + 1] * sc - dy) / (float)max_scale * 32767); va->buffer[i * 4 + 2] = math_floor((va->buffer[i * 4 + 2] * sc - dz) / (float)max_scale * 32767); @@ -381,15 +381,15 @@ void util_mesh_apply_displacement(gpu_texture_t *texpaint_pack, f32 strength, f3 i16_array_t *va0 = g->vertex_arrays->buffer[0]->values; i16_array_t *va1 = g->vertex_arrays->buffer[1]->values; i16_array_t *va2 = g->vertex_arrays->buffer[2]->values; - i32 num_verts = math_floor(va0->length / (float)4); + i32 num_verts = math_floor(va0->length / 4.0); for (i32 i = 0; i < num_verts; ++i) { - i32 x = math_floor(va2->buffer[i * 2] / (float)32767 * res); - i32 y = math_floor(va2->buffer[i * 2 + 1] / (float)32767 * res); + i32 x = math_floor(va2->buffer[i * 2] / 32767.0 * res); + i32 y = math_floor(va2->buffer[i * 2 + 1] / 32767.0 * res); i32 ix = math_floor(x * uv_scale); i32 iy = math_floor(y * uv_scale); i32 xx = ix % res; i32 yy = iy % res; - f32 h = (1.0 - buffer_get_u8(height, (yy * res + xx) * 4 + 3) / (float)255) * strength; + f32 h = (1.0 - buffer_get_u8(height, (yy * res + xx) * 4 + 3) / 255.0) * strength; va0->buffer[i * 4] -= math_floor(va1->buffer[i * 2] * h); va0->buffer[i * 4 + 1] -= math_floor(va1->buffer[i * 2 + 1] * h); va0->buffer[i * 4 + 2] -= math_floor(va0->buffer[i * 4 + 3] * h); @@ -398,11 +398,11 @@ void util_mesh_apply_displacement(gpu_texture_t *texpaint_pack, f32 strength, f3 } void util_mesh_equirect_unwrap(raw_mesh_t *mesh) { - i32 verts = math_floor(mesh->posa->length / (float)4); + i32 verts = math_floor(mesh->posa->length / 4.0); mesh->texa = i16_array_create(verts * 2); vec4_t n = vec4_create(0.0, 0.0, 0.0, 1.0); for (i32 i = 0; i < verts; ++i) { - n = vec4_create(mesh->posa->buffer[i * 4] / (float)32767, mesh->posa->buffer[i * 4 + 1] / (float)32767, mesh->posa->buffer[i * 4 + 2] / (float)32767, + n = vec4_create(mesh->posa->buffer[i * 4] / 32767.0, mesh->posa->buffer[i * 4 + 1] / 32767.0, mesh->posa->buffer[i * 4 + 2] / 32767.0, 1.0); n = vec4_norm(n); // Sphere projection @@ -457,7 +457,7 @@ void util_mesh_decimate(f32 strength) { i16_array_t *va1 = g->vertex_arrays->buffer[1]->values; i16_array_t *va2 = g->vertex_arrays->buffer[2]->values; u32_array_t *inda = g->index_array; - i32 num_verts = math_floor(va0->length / (float)4); + i32 num_verts = math_floor(va0->length / 4.0); i32 min_x = 32767; i32 max_x = -32767; i32 min_y = 32767; @@ -551,7 +551,7 @@ void util_mesh_decimate(f32 strength) { } u32_array_t *new_inda = u32_array_create_from_raw((u32[]){}, 0); - for (i32 i = 0; i < math_floor(inda->length / (float)3); ++i) { + for (i32 i = 0; i < math_floor(inda->length / 3.0); ++i) { i32 i1 = remap->buffer[inda->buffer[i * 3]]; i32 i2 = remap->buffer[inda->buffer[i * 3 + 1]]; i32 i3 = remap->buffer[inda->buffer[i * 3 + 2]]; @@ -593,7 +593,7 @@ void util_mesh_pack_uvs(i16_array_t *texa) { i32 atlas_step = 32767 / (float)atlas_stride; i32 item_x = (item_i % atlas_stride) * atlas_step; i32 item_y = math_floor(item_i / (float)atlas_stride) * atlas_step; - for (i32 i = 0; i < texa->length / (float)2; ++i) { + for (i32 i = 0; i < texa->length / 2.0; ++i) { texa->buffer[i * 2] = texa->buffer[i * 2] / (float)atlas_stride + item_x; texa->buffer[i * 2 + 1] = texa->buffer[i * 2 + 1] / (float)atlas_stride + item_y; } diff --git a/paint/sources/util_render.c b/paint/sources/util_render.c index 662dc458..a5f0d2bf 100644 --- a/paint/sources/util_render.c +++ b/paint/sources/util_render.c @@ -92,7 +92,7 @@ void util_render_make_decal_preview() { mesh_object_t *plane = scene_get_child(".Plane")->ext; plane->base->transform->scale = vec4_create(1, 1, 1, 1.0); - plane->base->transform->rot = quat_from_euler(-math_pi() / (float)2, 0, 0); + plane->base->transform->rot = quat_from_euler(-math_pi() / 2.0, 0, 0); transform_build_matrix(plane->base->transform); plane->base->visible = true; mesh_object_t_array_t *meshes = scene_meshes; @@ -180,7 +180,7 @@ void util_render_make_text_preview() { draw_begin(context_raw->text_tool_image, true, 0xff000000); draw_set_font(font, font_size); draw_set_color(0xffffffff); - draw_string(text, tex_w / (float)2 - text_w / (float)2, tex_w / (float)2 - text_h / (float)2); + draw_string(text, tex_w / 2.0 - text_w / 2.0, tex_w / 2.0 - text_h / 2.0); draw_end(); if (in_use) @@ -205,7 +205,7 @@ void util_render_make_font_preview() { draw_begin(context_raw->font->image, true, 0x00000000); draw_set_font(font, font_size); draw_set_color(0xffffffff); - draw_string(text, tex_w / (float)2 - text_w / (float)2, tex_w / (float)2 - text_h / (float)2); + draw_string(text, tex_w / 2.0 - text_w / 2.0, tex_w / 2.0 - text_h / 2.0); draw_end(); context_raw->font->preview_ready = true; @@ -302,7 +302,7 @@ void util_render_make_brush_preview() { vec4_t v = vec4_create(0.0, 0.0, 0.0, 1.0); v = vec4_create(m.m00, m.m01, m.m02, 1.0); f32 sx = vec4_len(v); - planeo->base->transform->rot = quat_from_euler(-math_pi() / (float)2, 0, 0); + planeo->base->transform->rot = quat_from_euler(-math_pi() / 2.0, 0, 0); planeo->base->transform->scale = vec4_create(sx, 1.0, sx, 1.0); planeo->base->transform->loc = vec4_create(m.m30, -m.m31, 0.0, 1.0); transform_build_matrix(planeo->base->transform); @@ -538,10 +538,10 @@ void util_render_create_screen_aligned_full_data() { gpu_vertex_struct_add(structure, "col", GPU_VERTEX_DATA_I16_4X_NORM); gc_unroot(util_render_screen_aligned_full_vb); util_render_screen_aligned_full_vb = - gpu_create_vertex_buffer(math_floor(data->length / (float)math_floor(gpu_vertex_struct_size(structure) / (float)2)), structure); + gpu_create_vertex_buffer(math_floor(data->length / (float)math_floor(gpu_vertex_struct_size(structure) / 2.0)), structure); gc_root(util_render_screen_aligned_full_vb); buffer_t *vertices = gpu_lock_vertex_buffer(util_render_screen_aligned_full_vb); - for (i32 i = 0; i < math_floor((vertices->length) / (float)2); ++i) { + for (i32 i = 0; i < math_floor((vertices->length) / 2.0); ++i) { buffer_set_i16(vertices, i * 2, data->buffer[i]); } gpu_vertex_buffer_unlock(util_render_screen_aligned_full_vb); diff --git a/paint/sources/util_uv.c b/paint/sources/util_uv.c index 44ead8f3..a3759606 100644 --- a/paint/sources/util_uv.c +++ b/paint/sources/util_uv.c @@ -31,8 +31,8 @@ void util_uv_cache_uv_map() { draw_begin(util_uv_uvmap, true, 0x00000000); draw_set_color(0xffffffff); f32 strength = res_x > 2048 ? 2.0 : 1.0; - f32 f = (1 / (float)32767) * util_uv_uvmap->width; - for (i32 i = 0; i < math_floor(inda->length / (float)3); ++i) { + f32 f = (1 / 32767.0) * util_uv_uvmap->width; + for (i32 i = 0; i < math_floor(inda->length / 3.0); ++i) { f32 x1 = (texa->buffer[inda->buffer[i * 3] * 2]) * f; f32 x2 = (texa->buffer[inda->buffer[i * 3 + 1] * 2]) * f; f32 x3 = (texa->buffer[inda->buffer[i * 3 + 2] * 2]) * f; @@ -71,9 +71,9 @@ void util_uv_cache_triangle_map() { i16_array_t *texa = mesh->vertex_arrays->buffer[2]->values; u32_array_t *inda = mesh->index_array; draw_begin(util_uv_trianglemap, true, 0xff000000); - f32 f = (1 / (float)32767) * util_uv_trianglemap->width; + f32 f = (1 / 32767.0) * util_uv_trianglemap->width; i32 color = 0xff000001; - for (i32 i = 0; i < math_floor(inda->length / (float)3); ++i) { + for (i32 i = 0; i < math_floor(inda->length / 3.0); ++i) { if (color == 0xffffffff) color = 0xff000001; color++; diff --git a/paint/sources/viewport.c b/paint/sources/viewport.c index 22ba5139..31590575 100644 --- a/paint/sources/viewport.c +++ b/paint/sources/viewport.c @@ -82,7 +82,7 @@ void viewport_update_camera_type(i32 camera_type) { } else { f32_array_t *f32a = f32_array_create(4); - f32 f = cam->data->fov * vec4_len(mat4_get_loc(cam->base->transform->world)) / (float)2.5; + f32 f = cam->data->fov * vec4_len(mat4_get_loc(cam->base->transform->world)) / 2.5; f32a->buffer[0] = -2 * f; f32a->buffer[1] = 2 * f; f32a->buffer[2] = -2 * f * (sys_h() / (float)sys_w());