Extract canvas projection helpers and thin preview and node loading

This commit is contained in:
2026-06-16 18:16:04 +02:00
parent 1442c13dd7
commit 8906756d12
11 changed files with 565 additions and 341 deletions

View File

@@ -584,84 +584,26 @@ void NodeStrokePreview::draw_stroke_immediate()
const auto& b = m_brush;
Stroke m_stroke;
Stroke m_dual_stroke;
m_stroke.m_filter_points = false;
m_stroke.m_max_size = stroke_setup.stroke_max_size;
m_stroke.m_camera.fov = Canvas::I->m_cam_fov;
m_stroke.m_camera.rot = Canvas::I->m_cam_rot;
m_stroke.reset(true);
m_stroke.start(b);
auto dual_brush = std::make_shared<Brush>();
dual_brush->m_tip_scale = b->m_dual_scale;
dual_brush->m_tip_angle = b->m_dual_angle;
dual_brush->m_tip_flow = b->m_dual_flow;
dual_brush->m_tip_opacity = b->m_dual_opacity;
dual_brush->m_tip_flipx = b->m_dual_flipx;
dual_brush->m_tip_flipy = b->m_dual_flipy;
dual_brush->m_tip_invert = b->m_dual_invert;
dual_brush->m_blend_mode = b->m_dual_blend_mode;
dual_brush->m_tip_randflipx = b->m_dual_randflip;
dual_brush->m_tip_randflipy = b->m_dual_randflip;
dual_brush->m_tip_size = b->m_dual_size * b->m_tip_size;
dual_brush->m_tip_spacing = b->m_dual_spacing;
dual_brush->m_jitter_scatter = b->m_dual_scatter;
dual_brush->m_jitter_scatter_bothaxis = b->m_dual_scatter_bothaxis;
dual_brush->m_jitter_angle = b->m_dual_rotate;
dual_brush->m_tip_texture = b->m_dual_texture;
dual_brush->m_tip_aspect = b->m_dual_aspect;
if (stroke_setup.dual_enabled)
{
m_dual_stroke.m_filter_points = false;
m_dual_stroke.m_max_size = stroke_setup.dual_stroke_max_size;
m_dual_stroke.m_camera.fov = Canvas::I->m_cam_fov;
m_dual_stroke.m_camera.rot = Canvas::I->m_cam_rot;
m_dual_stroke.reset(true);
m_dual_stroke.start(dual_brush);
}
for (const auto& point : stroke_setup.points)
{
m_stroke.add_point(point.position, point.pressure);
if (stroke_setup.dual_enabled)
m_dual_stroke.add_point(point.position, point.pressure);
}
auto prepared_strokes = pp::panopainter::prepare_legacy_node_stroke_preview_strokes(
b,
stroke_setup,
Canvas::I->m_cam_fov,
Canvas::I->m_cam_rot);
apply_stroke_preview_capability(pp::renderer::gl::blend_state(), false);
const auto pass_orchestration = pp::panopainter::plan_legacy_node_stroke_preview_pass_orchestration(
pp::panopainter::LegacyNodeStrokePreviewPassOrchestrationRequest {
.features = stroke_preview_render_device_features(),
.preview_size = size,
.pattern_scale = b->m_pattern_scale,
.pattern_flipx = b->m_pattern_flipx,
.pattern_flipy = b->m_pattern_flipy,
.pattern_invert = b->m_pattern_invert,
.pattern_brightness = b->m_pattern_brightness,
.pattern_contrast = b->m_pattern_contrast,
.pattern_depth = b->m_pattern_depth,
.pattern_rand_offset = b->m_pattern_rand_offset,
.pattern_enabled = b->m_pattern_enabled,
.pattern_eachsample = b->m_pattern_eachsample,
.tip_mix = b->m_tip_mix,
.tip_wet = b->m_tip_wet,
.tip_noise = b->m_tip_noise,
.dual_enabled = b->m_dual_enabled,
.dual_blend_mode = b->m_dual_blend_mode,
.dual_opacity = b->m_dual_opacity,
.pattern_blend_mode = b->m_pattern_blend_mode,
.blend_mode = b->m_blend_mode,
.mvp = ortho_proj,
});
pp::panopainter::make_legacy_node_stroke_preview_pass_orchestration_request(
stroke_preview_render_device_features(),
size,
*b,
ortho_proj));
const bool copy_stroke_destination = pass_orchestration.copy_stroke_destination;
pp::panopainter::setup_legacy_stroke_shader(pass_orchestration.stroke_shader);
execute_stroke_draw_immediate_pass_sequence(
m_stroke,
m_dual_stroke,
prepared_strokes.stroke,
prepared_strokes.dual_stroke,
*b,
std::move(dual_brush),
std::move(prepared_strokes.dual_brush),
pass_orchestration,
copy_stroke_destination,
zoom,