Overlay-Next: Origin #127578
@ -309,6 +309,7 @@ set(SRC
|
||||
engines/overlay/overlay_next_mesh.hh
|
||||
engines/overlay/overlay_next_metaball.hh
|
||||
engines/overlay/overlay_next_mode_transfer.hh
|
||||
engines/overlay/overlay_next_origin.hh
|
||||
engines/overlay/overlay_next_outline.hh
|
||||
engines/overlay/overlay_next_paint.hh
|
||||
engines/overlay/overlay_next_particle.hh
|
||||
|
@ -115,6 +115,7 @@ void Instance::begin_sync()
|
||||
resources.begin_sync();
|
||||
|
||||
background.begin_sync(resources, state);
|
||||
origins.begin_sync(state);
|
||||
outline.begin_sync(resources, state);
|
||||
|
||||
auto begin_sync_layer = [&](OverlayLayer &layer) {
|
||||
@ -284,6 +285,8 @@ void Instance::object_sync(ObjectRef &ob_ref, Manager &manager)
|
||||
layer.particles.object_sync(manager, ob_ref, resources, state);
|
||||
layer.relations.object_sync(ob_ref, resources, state);
|
||||
|
||||
origins.object_sync(ob_ref, resources, state);
|
||||
|
||||
if (object_is_selected(ob_ref) && !in_edit_paint_mode) {
|
||||
outline.object_sync(manager, ob_ref, state);
|
||||
}
|
||||
@ -292,6 +295,7 @@ void Instance::object_sync(ObjectRef &ob_ref, Manager &manager)
|
||||
|
||||
void Instance::end_sync()
|
||||
{
|
||||
origins.end_sync(resources, state);
|
||||
resources.end_sync();
|
||||
|
||||
auto end_sync_layer = [&](OverlayLayer &layer) {
|
||||
@ -497,6 +501,8 @@ void Instance::draw(Manager &manager)
|
||||
regular.cameras.draw_in_front(resources.overlay_color_only_fb, manager, view);
|
||||
infront.cameras.draw_in_front(resources.overlay_color_only_fb, manager, view);
|
||||
|
||||
origins.draw(resources.overlay_color_only_fb, manager, view);
|
||||
|
||||
background.draw(resources.overlay_output_fb, manager, view);
|
||||
anti_aliasing.draw(resources.overlay_output_fb, manager, view);
|
||||
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "overlay_next_mesh.hh"
|
||||
#include "overlay_next_metaball.hh"
|
||||
#include "overlay_next_mode_transfer.hh"
|
||||
#include "overlay_next_origin.hh"
|
||||
#include "overlay_next_outline.hh"
|
||||
#include "overlay_next_paint.hh"
|
||||
#include "overlay_next_particle.hh"
|
||||
@ -63,6 +64,7 @@ class Instance {
|
||||
|
||||
/** Overlay types. */
|
||||
Background background;
|
||||
Origins origins;
|
||||
Outline outline;
|
||||
|
||||
struct OverlayLayer {
|
||||
|
83
source/blender/draw/engines/overlay/overlay_next_origin.hh
Normal file
83
source/blender/draw/engines/overlay/overlay_next_origin.hh
Normal file
@ -0,0 +1,83 @@
|
||||
|
||||
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
/** \file
|
||||
* \ingroup overlay
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "overlay_next_private.hh"
|
||||
|
||||
namespace blender::draw::overlay {
|
||||
class Origins {
|
||||
private:
|
||||
StorageVectorBuffer<VertexData> point_buf_;
|
||||
|
||||
PassSimple ps_ = {"Origins"};
|
||||
|
||||
bool enabled_ = false;
|
||||
|
||||
public:
|
||||
void begin_sync(const State &state)
|
||||
{
|
||||
const bool is_paint_mode = (state.object_mode &
|
||||
(OB_MODE_ALL_PAINT | OB_MODE_ALL_PAINT_GPENCIL |
|
||||
OB_MODE_SCULPT_CURVES)) != 0;
|
||||
enabled_ = state.v3d && !is_paint_mode &&
|
||||
laurynas marked this conversation as resolved
Outdated
|
||||
(state.overlay.flag & V3D_OVERLAY_HIDE_OBJECT_ORIGINS) == 0;
|
||||
point_buf_.clear();
|
||||
}
|
||||
|
||||
void object_sync(const ObjectRef &ob_ref, Resources &res, State &state)
|
||||
{
|
||||
if (!enabled_) {
|
||||
return;
|
||||
}
|
||||
const Object *ob = ob_ref.object;
|
||||
const bool is_library = ID_REAL_USERS(&ob->id) > 1 || ID_IS_LINKED(ob);
|
||||
Laurynas Duburas
commented
`ViewLayer` is modified inside `BKE_view_layer_synced_ensure`.
|
||||
BKE_view_layer_synced_ensure(state.scene, (ViewLayer *)state.view_layer);
|
||||
const float4 location = float4(ob->object_to_world().location());
|
||||
laurynas marked this conversation as resolved
Clément Foucault
commented
unused unused `color`
|
||||
|
||||
if (ob == BKE_view_layer_active_object_get(state.view_layer)) {
|
||||
point_buf_.append(VertexData{location, res.theme_settings.color_active});
|
||||
}
|
||||
else if (ob->base_flag & BASE_SELECTED) {
|
||||
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) {
|
||||
point_buf_.append(VertexData{location,
|
||||
is_library ? res.theme_settings.color_library :
|
||||
res.theme_settings.color_deselect});
|
||||
}
|
||||
}
|
||||
|
||||
void end_sync(Resources &res, const State &state)
|
||||
{
|
||||
if (!enabled_) {
|
||||
return;
|
||||
}
|
||||
ps_.init();
|
||||
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);
|
||||
point_buf_.push_update();
|
||||
ps_.bind_ssbo("data_buf", &point_buf_);
|
||||
ps_.draw_procedural(GPU_PRIM_POINTS, 1, point_buf_.size());
|
||||
}
|
||||
|
||||
void draw(Framebuffer &framebuffer, Manager &manager, View &view)
|
||||
{
|
||||
if (!enabled_) {
|
||||
return;
|
||||
}
|
||||
|
||||
GPU_framebuffer_bind(framebuffer);
|
||||
manager.submit(ps_, view);
|
||||
}
|
||||
};
|
||||
} // namespace blender::draw::overlay
|
@ -206,6 +206,7 @@ class ShaderModule {
|
||||
ShaderPtr curve_edit_points;
|
||||
ShaderPtr curve_edit_line;
|
||||
ShaderPtr curve_edit_handles;
|
||||
ShaderPtr extra_point;
|
||||
ShaderPtr facing;
|
||||
ShaderPtr grid = shader("overlay_grid");
|
||||
ShaderPtr grid_background;
|
||||
|
@ -142,6 +142,17 @@ ShaderModule::ShaderModule(const SelectionType selection_type, const bool clippi
|
||||
"overlay_edit_curves_handle",
|
||||
[](gpu::shader::ShaderCreateInfo &info) { shader_patch_common(info); });
|
||||
|
||||
extra_point = shader("overlay_extra_point", [](gpu::shader::ShaderCreateInfo &info) {
|
||||
info.additional_infos_.clear();
|
||||
info.vertex_inputs_.pop_last();
|
||||
info.push_constants_.pop_last();
|
||||
info.additional_info("draw_view", "draw_modelmat_new", "draw_globals")
|
||||
.typedef_source("overlay_shader_shared.h")
|
||||
.storage_buf(0, Qualifier::READ, "VertexData", "data_buf[]")
|
||||
.define("pos", "data_buf[gl_VertexID].pos_.xyz")
|
||||
.define("ucolor", "data_buf[gl_VertexID].color_");
|
||||
});
|
||||
|
||||
grid_background = shader("overlay_grid_background", [](gpu::shader::ShaderCreateInfo &info) {
|
||||
shader_patch_common(info);
|
||||
info.define("tile_pos", "vec3(0.0)");
|
||||
|
Loading…
Reference in New Issue
Block a user
Check if it is space view 3D.