Files
test2/source/blender/draw/engines/overlay/overlay_next_pointcloud.hh
Dalai Felinto f5d929dbb1 Point Cloud: Draw selection overlay
This uses a fixed point size for selection, so that point selection is always visible
regardless of radius size.

The radius size is used to offset the selection point, so it is always visible, even when the radius is too large.

Co-authored by Hans Goudey.

---

Pull Request: https://projects.blender.org/blender/blender/pulls/134908
2025-02-25 15:20:52 +01:00

76 lines
1.7 KiB
C++

/* SPDX-FileCopyrightText: 2025 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup overlay
*/
#pragma once
#include "draw_cache.hh"
#include "draw_cache_impl.hh"
#include "draw_common_c.hh"
#include "overlay_next_base.hh"
namespace blender::draw::overlay {
/**
* Draw Point Cloud objects in edit mode.
*/
class PointClouds : Overlay {
private:
PassMain ps_ = {"PointCloud"};
public:
void begin_sync(Resources &res, const State &state) final
{
enabled_ = state.is_space_v3d();
if (!enabled_) {
return;
}
ps_.init();
ps_.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL,
state.clipping_plane_count);
ps_.shader_set(res.shaders.pointcloud_points.get());
ps_.bind_ubo(OVERLAY_GLOBALS_SLOT, &res.globals_buf);
}
void edit_object_sync(Manager &manager,
const ObjectRef &ob_ref,
Resources &res,
const State & /*state*/) final
{
if (!enabled_) {
return;
}
ResourceHandle res_handle = manager.unique_handle(ob_ref);
{
gpu::Batch *geom = DRW_cache_pointcloud_vert_overlay_get(ob_ref.object);
ps_.draw(geom, res_handle, res.select_id(ob_ref).get());
}
}
void pre_draw(Manager &manager, View &view) final
{
if (!enabled_) {
return;
}
manager.generate_commands(ps_, view);
}
void draw_line(Framebuffer &framebuffer, Manager &manager, View &view) final
{
if (!enabled_) {
return;
}
GPU_framebuffer_bind(framebuffer);
manager.submit_only(ps_, view);
}
};
} // namespace blender::draw::overlay