paint: path layer fixes
This commit is contained in:
@@ -57,8 +57,8 @@ static node_shader_context_t *make_pathsphere_shader(char *name) {
|
||||
node_shader_add_function(kong, str_envmap_sample);
|
||||
node_shader_add_function(kong, str_env_brdf_approx);
|
||||
|
||||
node_shader_write_frag(kong, "var basecol: float3 = float3(0.1, 0.1, 0.1);");
|
||||
node_shader_write_frag(kong, "var roughness: float = 0.3;");
|
||||
node_shader_write_frag(kong, "var basecol: float3 = float3(0.4, 0.0, 0.0);");
|
||||
node_shader_write_frag(kong, "var roughness: float = 0.5;");
|
||||
node_shader_write_frag(kong, "var metallic: float = 0.0;");
|
||||
|
||||
// Indirect lighting
|
||||
|
||||
@@ -86,13 +86,13 @@ static void path_set_camera(f32_array_t *points_camera, i32 num_camera, i32 ci)
|
||||
}
|
||||
}
|
||||
|
||||
static void path_paint(f32 px, f32 py, f32 *prev_px, f32 *prev_py) {
|
||||
static void path_paint(f32 px, f32 py, f32 *prev_px, f32 *prev_py, bool sphere_mode) {
|
||||
g_context->decal_x = px;
|
||||
g_context->decal_y = py;
|
||||
g_context->paint_vec.x = px;
|
||||
g_context->paint_vec.y = py;
|
||||
g_context->last_paint_vec_x = *prev_px;
|
||||
g_context->last_paint_vec_y = *prev_py;
|
||||
g_context->last_paint_vec_x = sphere_mode ? px : *prev_px;
|
||||
g_context->last_paint_vec_y = sphere_mode ? py : *prev_py;
|
||||
g_context->pdirty = 1;
|
||||
render_path_paint_commands_paint(false);
|
||||
*prev_px = px;
|
||||
@@ -112,7 +112,7 @@ static void path_paint_curved(f32_array_t *points, f32_array_t *points_world, f3
|
||||
prev_py = pt0y;
|
||||
g_context->prev_paint_vec_x = pt0x;
|
||||
g_context->prev_paint_vec_y = pt0y;
|
||||
path_paint(pt0x, pt0y, &prev_px, &prev_py);
|
||||
path_paint(pt0x, pt0y, &prev_px, &prev_py, sphere_mode);
|
||||
|
||||
// Paint curve - anchor[p], control[j-1], anchor[j]
|
||||
for (i32 j = 2; j < num_world; j += 2) {
|
||||
@@ -180,7 +180,7 @@ static void path_paint_curved(f32_array_t *points, f32_array_t *points_world, f3
|
||||
}
|
||||
f32 bx = ax1, by = ay1;
|
||||
project_to_screen((vec4_t){bwx, bwy, bwz, 1.0f}, &bx, &by);
|
||||
path_paint(bx, by, &prev_px, &prev_py);
|
||||
path_paint(bx, by, &prev_px, &prev_py, sphere_mode);
|
||||
prev_bwx = bwx;
|
||||
prev_bwy = bwy;
|
||||
prev_bwz = bwz;
|
||||
@@ -202,7 +202,7 @@ static void path_paint_curved(f32_array_t *points, f32_array_t *points_world, f3
|
||||
}
|
||||
f32 bx = ax1, by = ay1;
|
||||
project_to_screen((vec4_t){bwx, bwy, bwz, 1.0f}, &bx, &by);
|
||||
path_paint(bx, by, &prev_px, &prev_py);
|
||||
path_paint(bx, by, &prev_px, &prev_py, sphere_mode);
|
||||
prev_bwx = bwx;
|
||||
prev_bwy = bwy;
|
||||
prev_bwz = bwz;
|
||||
@@ -254,7 +254,7 @@ static void path_paint_straight(f32_array_t *points, f32_array_t *points_world,
|
||||
f32 iwz = pwz + t * (cwz - pwz);
|
||||
f32 ix = 0.0f, iy = 0.0f;
|
||||
if (project_to_screen((vec4_t){iwx, iwy, iwz, 1.0f}, &ix, &iy)) {
|
||||
path_paint(ix, iy, &prev_px, &prev_py);
|
||||
path_paint(ix, iy, &prev_px, &prev_py, sphere_mode);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -265,7 +265,7 @@ static void path_paint_straight(f32_array_t *points, f32_array_t *points_world,
|
||||
f32 pwz = points_world->buffer[parent * 3 + 2];
|
||||
project_to_screen((vec4_t){pwx, pwy, pwz, 1.0f}, &prev_px, &prev_py);
|
||||
}
|
||||
path_paint(cur_px, cur_py, &prev_px, &prev_py);
|
||||
path_paint(cur_px, cur_py, &prev_px, &prev_py, sphere_mode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -477,7 +477,7 @@ void util_layer_check_path_grab() {
|
||||
}
|
||||
|
||||
slot_layer_t *l = g_context->layer;
|
||||
if (!slot_layer_is_path(l)) {
|
||||
if (!slot_layer_is_path(l) || !slot_layer_is_visible(l)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -520,7 +520,7 @@ void util_layer_update_path() {
|
||||
}
|
||||
|
||||
slot_layer_t *l = g_context->layer;
|
||||
bool is_path = slot_layer_is_path(l);
|
||||
bool is_path = slot_layer_is_path(l) && slot_layer_is_visible(l);
|
||||
|
||||
// Clear spheres when switching away from path layer
|
||||
if (path_layer_current != l || !is_path) {
|
||||
|
||||
@@ -360,12 +360,44 @@ void util_render_make_brush_preview() {
|
||||
0.7 + 0.05,
|
||||
},
|
||||
10);
|
||||
|
||||
bool sphere_mode = g_context->brush_lazy_radius > 0 && g_context->brush_lazy_step > 0;
|
||||
f32 dot_spacing = 0.0;
|
||||
if (sphere_mode) {
|
||||
f32 _posx = g_context->posx_picked;
|
||||
f32 _posy = g_context->posy_picked;
|
||||
f32 _posz = g_context->posz_picked;
|
||||
g_context->posx_picked = planeo->base->transform->loc.x;
|
||||
g_context->posy_picked = planeo->base->transform->loc.y;
|
||||
g_context->posz_picked = planeo->base->transform->loc.z;
|
||||
dot_spacing = g_context->brush_lazy_radius * g_context->brush_lazy_step * util_layer_brush_screen_radius() * 3.0;
|
||||
g_context->posx_picked = _posx;
|
||||
g_context->posy_picked = _posy;
|
||||
g_context->posz_picked = _posz;
|
||||
}
|
||||
|
||||
f32 aspect = sys_w() / (f32)sys_h();
|
||||
for (i32 i = 1; i < points_x->length; ++i) {
|
||||
g_context->last_paint_vec_x = points_x->buffer[i - 1];
|
||||
g_context->last_paint_vec_y = points_y->buffer[i - 1];
|
||||
g_context->paint_vec.x = points_x->buffer[i];
|
||||
g_context->paint_vec.y = points_y->buffer[i];
|
||||
render_path_paint_commands_paint(false);
|
||||
f32 x0 = points_x->buffer[i - 1];
|
||||
f32 y0 = points_y->buffer[i - 1];
|
||||
f32 x1 = points_x->buffer[i];
|
||||
f32 y1 = points_y->buffer[i];
|
||||
i32 n = 1;
|
||||
if (dot_spacing > 0.0) {
|
||||
f32 len = vec4_dist((vec4_t){x0 * aspect, y0, 0.0, 1.0}, (vec4_t){x1 * aspect, y1, 0.0, 1.0});
|
||||
n = ceilf(len / dot_spacing);
|
||||
n = n < 1 ? 1 : n > 16 ? 16 : n;
|
||||
}
|
||||
for (i32 s = 1; s <= n; ++s) {
|
||||
f32 t = s / (f32)n;
|
||||
f32 px = x0 + (x1 - x0) * t;
|
||||
f32 py = y0 + (y1 - y0) * t;
|
||||
g_context->last_paint_vec_x = sphere_mode ? px : x0;
|
||||
g_context->last_paint_vec_y = sphere_mode ? py : y0;
|
||||
g_context->paint_vec.x = px;
|
||||
g_context->paint_vec.y = py;
|
||||
render_path_paint_commands_paint(false);
|
||||
}
|
||||
}
|
||||
|
||||
g_context->brush_radius = _brush_radius;
|
||||
|
||||
Reference in New Issue
Block a user