Overlay-Next: Add NURBS edit handles
Draws NURBS edit handles in Overlay-Next. Rel #102179 Pull Request: https://projects.blender.org/blender/blender/pulls/128093
This commit is contained in:
committed by
Clément Foucault
parent
d401b36509
commit
71098ce904
@@ -34,6 +34,11 @@ class Curves {
|
||||
PassSimple::Sub *edit_legacy_curve_points_ = nullptr;
|
||||
PassSimple::Sub *edit_legacy_curve_handles_ = nullptr;
|
||||
|
||||
PassSimple edit_legacy_surface_handles_ps = {"Surface Edit"};
|
||||
PassSimple::Sub *edit_legacy_surface_handles_ = nullptr;
|
||||
/* Handles that are below the geometry and are rendered with lower alpha. */
|
||||
PassSimple::Sub *edit_legacy_surface_xray_handles_ = nullptr;
|
||||
|
||||
/* TODO(fclem): This is quite wasteful and expensive, prefer in shader Z modification like the
|
||||
* retopology offset. */
|
||||
View view_edit_cage = {"view_edit_cage"};
|
||||
@@ -126,6 +131,7 @@ class Curves {
|
||||
sub.bind_ubo("globalsBlock", &res.globals_buf);
|
||||
sub.push_constant("showCurveHandles", state.overlay.handle_display != CURVE_HANDLE_NONE);
|
||||
sub.push_constant("curveHandleDisplay", int(state.overlay.handle_display));
|
||||
sub.push_constant("alpha", 1.0f);
|
||||
edit_legacy_curve_handles_ = ⊂
|
||||
}
|
||||
/* Points need to be rendered after handles. */
|
||||
@@ -139,6 +145,30 @@ class Curves {
|
||||
edit_legacy_curve_points_ = ⊂
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
auto &pass = edit_legacy_surface_handles_ps;
|
||||
pass.init();
|
||||
|
||||
auto create_sub = [&](const char *name, DRWState drw_state, float alpha) {
|
||||
auto &sub = pass.sub(name);
|
||||
sub.state_set(drw_state, state.clipping_plane_count);
|
||||
sub.shader_set(res.shaders.legacy_curve_edit_handles.get());
|
||||
sub.bind_ubo("globalsBlock", &res.globals_buf);
|
||||
sub.push_constant("showCurveHandles", state.overlay.handle_display != CURVE_HANDLE_NONE);
|
||||
sub.push_constant("curveHandleDisplay", int(state.overlay.handle_display));
|
||||
sub.push_constant("alpha", alpha);
|
||||
return ⊂
|
||||
};
|
||||
|
||||
const DRWState state_xray = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_GREATER |
|
||||
DRW_STATE_BLEND_ALPHA;
|
||||
edit_legacy_surface_xray_handles_ = create_sub("SurfaceXrayHandles", state_xray, 0.2f);
|
||||
|
||||
const DRWState state_front = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH |
|
||||
DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_BLEND_ALPHA;
|
||||
edit_legacy_surface_handles_ = create_sub("SurfaceHandles", state_front, 1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
void edit_object_sync(Manager &manager, const ObjectRef &ob_ref, Resources & /*res*/)
|
||||
@@ -177,7 +207,7 @@ class Curves {
|
||||
Object *ob = ob_ref.object;
|
||||
::Curve &curve = *static_cast<::Curve *>(ob->data);
|
||||
|
||||
{
|
||||
if (ob->type == OB_CURVES_LEGACY) {
|
||||
gpu::Batch *geom = DRW_cache_curve_edge_wire_get(ob);
|
||||
edit_legacy_curve_wires_->draw(geom, res_handle);
|
||||
}
|
||||
@@ -187,7 +217,13 @@ class Curves {
|
||||
}
|
||||
{
|
||||
gpu::Batch *geom = DRW_cache_curve_edge_overlay_get(ob);
|
||||
edit_legacy_curve_handles_->draw_expand(geom, GPU_PRIM_TRIS, 8, 1, res_handle);
|
||||
if (ob->type == OB_CURVES_LEGACY) {
|
||||
edit_legacy_curve_handles_->draw_expand(geom, GPU_PRIM_TRIS, 8, 1, res_handle);
|
||||
}
|
||||
else {
|
||||
edit_legacy_surface_xray_handles_->draw_expand(geom, GPU_PRIM_TRIS, 8, 1, res_handle);
|
||||
edit_legacy_surface_handles_->draw_expand(geom, GPU_PRIM_TRIS, 8, 1, res_handle);
|
||||
}
|
||||
}
|
||||
{
|
||||
gpu::Batch *geom = DRW_cache_curve_vert_overlay_get(ob);
|
||||
@@ -195,6 +231,18 @@ class Curves {
|
||||
}
|
||||
}
|
||||
|
||||
void draw(Framebuffer &framebuffer, Manager &manager, View &view)
|
||||
{
|
||||
if (!enabled_) {
|
||||
return;
|
||||
}
|
||||
|
||||
view_edit_cage.sync(view.viewmat(), winmat_polygon_offset(view.winmat(), view_dist, 0.5f));
|
||||
|
||||
GPU_framebuffer_bind(framebuffer);
|
||||
manager.submit(edit_legacy_surface_handles_ps, view);
|
||||
}
|
||||
|
||||
void draw_color_only(Framebuffer &framebuffer, Manager &manager, View &view)
|
||||
{
|
||||
if (!enabled_) {
|
||||
|
||||
@@ -216,14 +216,13 @@ void Instance::object_sync(ObjectRef &ob_ref, Manager &manager)
|
||||
case OB_ARMATURE:
|
||||
layer.armatures.edit_object_sync(ob_ref, resources, shapes, state);
|
||||
break;
|
||||
case OB_SURF:
|
||||
case OB_CURVES_LEGACY:
|
||||
layer.curves.edit_object_sync_legacy(manager, ob_ref, resources);
|
||||
break;
|
||||
case OB_CURVES:
|
||||
layer.curves.edit_object_sync(manager, ob_ref, resources);
|
||||
break;
|
||||
case OB_SURF:
|
||||
break;
|
||||
case OB_LATTICE:
|
||||
layer.lattices.edit_object_sync(manager, ob_ref, resources);
|
||||
break;
|
||||
@@ -481,6 +480,7 @@ void Instance::draw(Manager &manager)
|
||||
layer.grease_pencil.draw(framebuffer, manager, view);
|
||||
layer.meshes.draw(framebuffer, manager, view);
|
||||
layer.mesh_uvs.draw(framebuffer, manager, view);
|
||||
layer.curves.draw(framebuffer, manager, view);
|
||||
};
|
||||
|
||||
auto draw_layer_color_only = [&](OverlayLayer &layer, Framebuffer &framebuffer) {
|
||||
|
||||
@@ -553,6 +553,7 @@ GPU_SHADER_CREATE_INFO(overlay_edit_curve_handle_next)
|
||||
.vertex_out(overlay_edit_smooth_color_iface)
|
||||
.push_constant(Type::BOOL, "showCurveHandles")
|
||||
.push_constant(Type::INT, "curveHandleDisplay")
|
||||
.push_constant(Type::FLOAT, "alpha")
|
||||
.fragment_out(0, Type::VEC4, "fragColor")
|
||||
.vertex_source("overlay_edit_curve_handle_next_vert.glsl")
|
||||
.fragment_source("overlay_varying_color.glsl")
|
||||
|
||||
@@ -79,6 +79,7 @@ void output_vertex_pair(const uint line_id,
|
||||
{
|
||||
GeomOut geom_out;
|
||||
geom_out.color = color;
|
||||
geom_out.color.a *= alpha;
|
||||
geom_out.offset = offset;
|
||||
|
||||
geom_out.gpu_position = geom_in[0].gpu_position;
|
||||
|
||||
Reference in New Issue
Block a user