Blender
V5.0
source
blender
draw
engines
overlay
overlay_mode_transfer.hh
Go to the documentation of this file.
1
/* SPDX-FileCopyrightText: 2024 Blender Authors
2
*
3
* SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9
#pragma once
10
11
#include "
BLI_map.hh
"
12
13
#include "
BKE_paint.hh
"
14
15
#include "
draw_cache.hh
"
16
#include "
draw_sculpt.hh
"
17
18
#include "
overlay_base.hh
"
19
20
namespace
blender::draw::overlay
{
21
26
class
ModeTransfer
:
Overlay
{
27
private
:
28
PassSimple
ps_ = {
"ModeTransfer"
};
29
30
Map<std::string, float, 1>
object_factors_;
31
32
float4
flash_color_;
33
34
public
:
35
void
begin_sync
(
Resources
&res,
const
State
&
state
)
final
;
36
37
void
object_sync
(
Manager
&manager,
38
const
ObjectRef
&ob_ref,
39
Resources
&
/*res*/
,
40
const
State
&
state
)
final
41
{
42
if
(!
enabled_
) {
43
return
;
44
}
45
46
const
std::optional<float> alpha_opt = object_factors_.lookup_try_as(ob_ref.object->id.name);
47
if
(!alpha_opt) {
48
return
;
49
}
50
51
const
bool
renderable =
DRW_object_is_renderable
(ob_ref.object);
52
const
bool
draw_surface = (ob_ref.object->dt >=
OB_WIRE
) &&
53
(renderable || (ob_ref.object->dt ==
OB_WIRE
));
54
if
(!draw_surface) {
55
return
;
56
}
57
58
constexpr
float
flash_alpha = 0.25f;
59
const
float
alpha = *alpha_opt * flash_alpha;
60
61
ps_.push_constant(
"ucolor"
,
float4
(flash_color_.xyz() * alpha, alpha));
62
63
const
bool
use_sculpt_pbvh =
BKE_sculptsession_use_pbvh_draw
(ob_ref.object,
state
.rv3d) &&
64
!
state
.is_image_render;
65
if
(use_sculpt_pbvh) {
66
ResourceHandleRange
handle = manager.unique_handle_for_sculpt(ob_ref);
67
68
for
(
SculptBatch
&
batch
:
sculpt_batches_get
(ob_ref.object,
SCULPT_BATCH_DEFAULT
)) {
69
ps_.draw(
batch
.batch, handle);
70
}
71
}
72
else
{
73
gpu::Batch *geom =
DRW_cache_object_surface_get
((
Object
*)ob_ref.object);
74
if
(geom) {
75
ps_.draw(geom, manager.unique_handle(ob_ref));
76
}
77
}
78
}
79
80
void
draw
(
Framebuffer
&framebuffer,
Manager
&manager,
View
&
view
)
final
81
{
82
if
(!
enabled_
) {
83
return
;
84
}
85
86
GPU_framebuffer_bind
(framebuffer);
87
manager.submit(ps_,
view
);
88
89
/* Request redraws until the object fades out (enabled_ will be reset to false). */
90
DRW_viewport_request_redraw
();
91
}
92
};
93
94
}
// namespace blender::draw::overlay
BKE_paint.hh
BKE_sculptsession_use_pbvh_draw
bool BKE_sculptsession_use_pbvh_draw(const Object *ob, const RegionView3D *rv3d)
Definition
paint.cc:3068
BLI_map.hh
OB_WIRE
@ OB_WIRE
Definition
DNA_object_enums.h:34
view
static AppView * view
Definition
FRS_freestyle.cpp:59
GPU_framebuffer_bind
void GPU_framebuffer_bind(blender::gpu::FrameBuffer *fb)
Definition
gpu_framebuffer.cc:239
blender::Map
Definition
BLI_map.hh:129
blender::draw::Framebuffer
Definition
DRW_gpu_wrapper.hh:1202
blender::draw::Manager
Definition
draw_manager.hh:45
blender::draw::ObjectRef
Definition
draw_handle.hh:207
blender::draw::ResourceHandleRange
Definition
draw_handle.hh:152
blender::draw::View
Definition
draw_view.hh:37
blender::draw::overlay::ModeTransfer
Definition
overlay_mode_transfer.hh:26
blender::draw::overlay::ModeTransfer::object_sync
void object_sync(Manager &manager, const ObjectRef &ob_ref, Resources &, const State &state) final
Definition
overlay_mode_transfer.hh:37
blender::draw::overlay::ModeTransfer::begin_sync
void begin_sync(Resources &res, const State &state) final
Definition
overlay_mode_transfer.cc:13
blender::draw::overlay::ModeTransfer::draw
void draw(Framebuffer &framebuffer, Manager &manager, View &view) final
Definition
overlay_mode_transfer.hh:80
draw_cache.hh
DRW_object_is_renderable
bool DRW_object_is_renderable(const Object *ob)
Definition
draw_context.cc:286
DRW_viewport_request_redraw
void DRW_viewport_request_redraw()
Definition
draw_context.cc:534
draw_sculpt.hh
batch
struct @021025263243242147216143265077100330027142264337::@225245033123204053237120173316075113304004012000 batch
state
static ulong state[N]
Definition
mathutils_noise.cc:56
blender::draw::overlay
Definition
overlay_antialiasing.hh:49
blender::draw::PassSimple
detail::Pass< command::DrawCommandBuf > PassSimple
Definition
draw_manager.hh:41
blender::draw::sculpt_batches_get
Vector< SculptBatch > sculpt_batches_get(const Object *ob, SculptBatchFeature features)
Definition
draw_sculpt.cc:156
blender::draw::DRW_cache_object_surface_get
gpu::Batch * DRW_cache_object_surface_get(Object *ob)
Definition
draw_cache.cc:138
blender::draw::SCULPT_BATCH_DEFAULT
@ SCULPT_BATCH_DEFAULT
Definition
draw_sculpt.hh:32
blender::float4
VecBase< float, 4 > float4
Definition
BLI_math_vector_types.hh:620
overlay_base.hh
Object
Definition
DNA_object_types.h:191
blender::draw::SculptBatch
Definition
draw_sculpt.hh:24
blender::draw::overlay::Overlay
Definition
overlay_base.hh:22
blender::draw::overlay::Overlay::enabled_
bool enabled_
Definition
overlay_base.hh:29
blender::draw::overlay::Resources
Definition
overlay_private.hh:588
blender::draw::overlay::State
Definition
overlay_private.hh:125
Generated on
for Blender by
doxygen
1.16.1