diff --git a/paint/sources/uniforms.c b/paint/sources/uniforms.c index 83b63c38..7d4e7fb7 100644 --- a/paint/sources/uniforms.c +++ b/paint/sources/uniforms.c @@ -14,7 +14,8 @@ f32 uniforms_ext_f32_link(object_t *object, material_data_t *mat, char *link) { bool decal_mask = decal && operator_shortcut(string("%s+%s", any_map_get(config_keymap, "decal_mask"), any_map_get(config_keymap, "action_paint")), SHORTCUT_TYPE_DOWN); f32 brush_decal_mask_radius = g_context->brush_decal_mask_radius; - brush_decal_mask_radius *= g_context->paint2d ? 0.35 * ui_view2d_pan_scale : 2.0; + bool paint2d = g_context->paint2d || g_context->paint2d_view; + brush_decal_mask_radius *= paint2d ? 0.35 * ui_view2d_pan_scale : 2.0; f32 radius = decal_mask ? brush_decal_mask_radius : g_context->brush_radius; f32 val = (radius * g_context->brush_nodes_radius) / 15.0; if (g_config->pressure_radius && pen_down("tip")) { @@ -22,7 +23,7 @@ f32 uniforms_ext_f32_link(object_t *object, material_data_t *mat, char *link) { } f32 scale2d = (900 / (float)base_h()) * g_config->window_scale; if (!decal) { - val *= g_context->paint2d ? 0.5 * 0.5 * scale2d * ui_view2d_pan_scale : 2; + val *= paint2d ? 0.5 * 0.5 * scale2d * ui_view2d_pan_scale : 2; } else { val *= scale2d; // Projection ratio @@ -64,7 +65,7 @@ f32 uniforms_ext_f32_link(object_t *object, material_data_t *mat, char *link) { if (g_config->pressure_hardness && pen_down("tip")) { val *= pen_pressure * g_config->pressure_sensitivity; } - if (g_context->paint2d) { + if (g_context->paint2d || g_context->paint2d_view) { val *= 1.0 / (float)ui_view2d_pan_scale; } else { diff --git a/paint/sources/util_layer.c b/paint/sources/util_layer.c index 29c6c0e2..2801db0b 100644 --- a/paint/sources/util_layer.c +++ b/paint/sources/util_layer.c @@ -315,6 +315,19 @@ void util_layer_add_path_point(slot_layer_t *l, f32 screen_x, f32 screen_y) { return; } + bool _paint2d = g_context->paint2d; + if (_paint2d) { + // Convert 2D view x-coordinate [1, 1+ww/base_w] to 3D range [0, 1] + screen_x = (screen_x * base_w() - base_w()) / (float)ui_view2d_ww; + render_path_paint_set_plane_mesh(); + g_context->paint2d = false; + } + + f32_array_t *points = l->path_points; + f32_array_t *points_world = l->path_points_world; + f32_array_t *points_camera = l->path_points_camera; + i32_array_t *points_parent = l->path_points_parent; + for (i32 j = 0; j < path_point_sphere_count; j++) { path_point_spheres[j]->visible = false; } @@ -322,11 +335,6 @@ void util_layer_add_path_point(slot_layer_t *l, f32 screen_x, f32 screen_y) { // Re-render gbuffer without spheres so gbufferD is clean render_path_base_draw_gbuffer(); - f32_array_t *points = l->path_points; - f32_array_t *points_world = l->path_points_world; - f32_array_t *points_camera = l->path_points_camera; - i32_array_t *points_parent = l->path_points_parent; - f32_array_push(points, screen_x); f32_array_push(points, screen_y); f32 saved_pvx = g_context->paint_vec.x; @@ -362,6 +370,11 @@ void util_layer_add_path_point(slot_layer_t *l, f32 screen_x, f32 screen_y) { for (i32 j = 0; j < path_point_sphere_count; j++) { path_point_spheres[j]->visible = true; } + + if (_paint2d) { + g_context->paint2d = true; + render_path_paint_restore_plane_mesh(); + } } void util_layer_repaint_path(slot_layer_t *l) {