Blender V4.3
overlay_next_instance.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#pragma once
10
12
19#include "overlay_next_curve.hh"
21#include "overlay_next_empty.hh"
23#include "overlay_next_fade.hh"
24#include "overlay_next_fluid.hh"
27#include "overlay_next_grid.hh"
29#include "overlay_next_light.hh"
31#include "overlay_next_mesh.hh"
37#include "overlay_next_paint.hh"
45
46namespace blender::draw::overlay {
47
52class Instance {
53 const SelectionType selection_type_;
54 const bool clipping_enabled_;
55
56 public:
57 /* WORKAROUND: Legacy. Move to grid pass. */
58 GPUUniformBuf *grid_ubo = nullptr;
59
61
63 Resources resources = {selection_type_,
64 overlay::ShaderModule::module_get(selection_type_, clipping_enabled_)};
66
72
103
105
108
109 Instance(const SelectionType selection_type, const bool clipping_enabled)
110 : selection_type_(selection_type), clipping_enabled_(clipping_enabled){};
111
116
117 void init();
118 void begin_sync();
119 void object_sync(ObjectRef &ob_ref, Manager &manager);
120 void end_sync();
121 void draw(Manager &manager);
122
123 bool clipping_enabled() const
124 {
125 return clipping_enabled_;
126 }
127
128 private:
129 bool object_is_selected(const ObjectRef &ob_ref);
130 bool object_is_edit_mode(const Object *object);
131 bool object_is_paint_mode(const Object *object);
132 bool object_is_particle_edit_mode(const ObjectRef &ob_ref);
133 /* Checks for both curve sculpt and regular sculpt mode. */
134 bool object_is_sculpt_mode(const ObjectRef &ob_ref);
135 /* Checks only for sculpt mode. */
136 bool object_is_sculpt_mode(const Object *object);
137 /* Any mode that requires to view the object without distraction. */
138 bool object_is_edit_paint_mode(const ObjectRef &ob_ref,
139 bool in_edit_mode,
140 bool in_paint_mode,
141 bool in_sculpt_mode);
142 bool object_is_in_front(const Object *object, const State &state);
143 bool object_needs_prepass(const ObjectRef &ob_ref, bool in_paint_mode);
144
145 /* Returns true if the object is rendered transparent by the render engine.
146 * Overlays should not rely on the correct depth being available (and do a depth pre-pass). */
147 bool object_is_rendered_transparent(const Object *object, const State &state);
148};
149
150} // namespace blender::draw::overlay
#define DRW_UBO_FREE_SAFE(ubo)
void object_sync(ObjectRef &ob_ref, Manager &manager)
Instance(const SelectionType selection_type, const bool clipping_enabled)
static ShaderModule & module_get(SelectionType selection_type, bool clipping_enabled)