Fix: Overlay-Next: Origins are not selectable

The implementation was missing.
This commit is contained in:
Clément Foucault
2024-11-19 17:51:29 +01:00
parent 8762087114
commit 6aedb317b0
5 changed files with 16 additions and 2 deletions

View File

@@ -68,7 +68,7 @@ class Instance {
/** Overlay types. */
Background background;
Origins origins;
Origins origins = {selection_type_};
Outline outline;
MotionPath motion_paths;

View File

@@ -14,12 +14,15 @@ namespace blender::draw::overlay {
class Origins {
private:
StorageVectorBuffer<VertexData> point_buf_;
select::SelectBuf select_buf_;
PassSimple ps_ = {"Origins"};
bool enabled_ = false;
public:
Origins(SelectionType selection_type) : select_buf_(selection_type) {}
void begin_sync(const State &state)
{
const bool is_paint_mode = (state.object_mode &
@@ -47,14 +50,17 @@ class Origins {
const float4 location = float4(ob->object_to_world().location());
if (ob == BKE_view_layer_active_object_get(state.view_layer)) {
select_buf_.select_append(res.select_id(ob_ref));
point_buf_.append(VertexData{location, res.theme_settings.color_active});
}
else if (ob->base_flag & BASE_SELECTED) {
select_buf_.select_append(res.select_id(ob_ref));
point_buf_.append(VertexData{location,
is_library ? res.theme_settings.color_library_select :
res.theme_settings.color_select});
}
else if (state.v3d_flag & V3D_DRAW_CENTERS) {
select_buf_.select_append(res.select_id(ob_ref));
point_buf_.append(VertexData{location,
is_library ? res.theme_settings.color_library :
res.theme_settings.color_deselect});
@@ -70,6 +76,7 @@ class Origins {
ps_.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_ALPHA, state.clipping_plane_count);
ps_.shader_set(res.shaders.extra_point.get());
ps_.bind_ubo("globalsBlock", &res.globals_buf);
select_buf_.select_bind(ps_);
point_buf_.push_update();
ps_.bind_ssbo("data_buf", &point_buf_);
ps_.draw_procedural(GPU_PRIM_POINTS, 1, point_buf_.size());

View File

@@ -166,7 +166,7 @@ ShaderModule::ShaderModule(const SelectionType selection_type, const bool clippi
curve_edit_line = shader("overlay_edit_particle_strand",
[](gpu::shader::ShaderCreateInfo &info) { shader_patch_common(info); });
extra_point = shader("overlay_extra_point", [](gpu::shader::ShaderCreateInfo &info) {
extra_point = selectable_shader("overlay_extra_point", [](gpu::shader::ShaderCreateInfo &info) {
info.additional_infos_.clear();
info.vertex_inputs_.pop_last();
info.push_constants_.pop_last();

View File

@@ -4,9 +4,12 @@
#include "common_view_clipping_lib.glsl"
#include "common_view_lib.glsl"
#include "select_lib.glsl"
void main()
{
select_id_set(in_select_buf[gl_VertexID]);
vec3 world_pos = point_object_to_world(pos);
gl_Position = point_world_to_ndc(world_pos);

View File

@@ -2,6 +2,8 @@
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "select_lib.glsl"
void main()
{
float dist = length(gl_PointCoord - vec2(0.5));
@@ -27,4 +29,6 @@ void main()
else {
fragColor = mix(fillColor, outlineColor, smoothstep(radii[3], radii[2], dist));
}
select_id_output(select_id);
}