Blender V4.3
overlay_next_engine.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2019 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
11#include "DRW_engine.hh"
12#include "DRW_render.hh"
13
15
16#include "ED_view3d.hh"
17
18#include "UI_interface.hh"
19
20#include "BKE_duplilist.hh"
21#include "BKE_object.hh"
22#include "BKE_paint.hh"
23
24#include "GPU_capabilities.hh"
25
26#include "DNA_space_types.h"
27
28#include "draw_manager.hh"
30
31#include "overlay_engine.h"
33
34using namespace blender::draw;
35
37
38/* -------------------------------------------------------------------- */
42static void OVERLAY_next_engine_init(void *vedata)
43{
44 OVERLAY_Data *ved = reinterpret_cast<OVERLAY_Data *>(vedata);
45
46 const DRWContextState *draw_ctx = DRW_context_state_get();
47 const RegionView3D *rv3d = draw_ctx->rv3d;
48 const View3D *v3d = draw_ctx->v3d;
49 const bool clipping_enabled = RV3D_CLIPPING_ENABLED(v3d, rv3d);
50
51 /* WORKAROUND: Restart the engine when clipping is being toggled. */
52 if (ved->instance != nullptr &&
53 reinterpret_cast<Instance *>(ved->instance)->clipping_enabled() != clipping_enabled)
54 {
55 delete reinterpret_cast<Instance *>(ved->instance);
56 ved->instance = nullptr;
57 }
58
59 if (ved->instance == nullptr) {
60 ved->instance = new Instance(select::SelectionType::DISABLED, clipping_enabled);
61 }
62
63 reinterpret_cast<Instance *>(ved->instance)->init();
64}
65
66static void OVERLAY_next_cache_init(void *vedata)
67{
68 reinterpret_cast<Instance *>(reinterpret_cast<OVERLAY_Data *>(vedata)->instance)->begin_sync();
69}
70
71static void OVERLAY_next_cache_populate(void *vedata, Object *object)
72{
73 ObjectRef ref;
74 ref.object = object;
77 ref.handle.raw = 0;
78
79 reinterpret_cast<Instance *>(reinterpret_cast<OVERLAY_Data *>(vedata)->instance)
81}
82
83static void OVERLAY_next_cache_finish(void *vedata)
84{
85 reinterpret_cast<Instance *>(reinterpret_cast<OVERLAY_Data *>(vedata)->instance)->end_sync();
86}
87
88static void OVERLAY_next_draw_scene(void *vedata)
89{
90 reinterpret_cast<Instance *>(reinterpret_cast<OVERLAY_Data *>(vedata)->instance)
91 ->draw(*DRW_manager_get());
92}
93
94static void OVERLAY_next_instance_free(void *instance_)
95{
96 Instance *instance = (Instance *)instance_;
97 if (instance != nullptr) {
98 delete instance;
99 }
100}
101
104/* -------------------------------------------------------------------- */
109
111 /*next*/ nullptr,
112 /*prev*/ nullptr,
113 /*idname*/ N_("Overlay"),
114 /*vedata_size*/ &overlay_data_size,
115 /*engine_init*/ &OVERLAY_next_engine_init,
116 /*engine_free*/ nullptr,
117 /*instance_free*/ &OVERLAY_next_instance_free,
118 /*cache_init*/ &OVERLAY_next_cache_init,
119 /*cache_populate*/ &OVERLAY_next_cache_populate,
120 /*cache_finish*/ &OVERLAY_next_cache_finish,
121 /*draw_scene*/ &OVERLAY_next_draw_scene,
122 /*view_update*/ nullptr,
123 /*id_update*/ nullptr,
124 /*render_to_image*/ nullptr,
125 /*store_metadata*/ nullptr,
126};
127
General operations, lookup, etc. for blender objects.
#define RV3D_CLIPPING_ENABLED(v3d, rv3d)
#define DRW_VIEWPORT_DATA_SIZE(ty)
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object instance
void init()
A running instance of the engine.
void object_sync(Object *ob)
blender::draw::Manager * DRW_manager_get()
Object * DRW_object_get_dupli_parent(const Object *)
const DRWContextState * DRW_context_state_get()
DupliObject * DRW_object_get_dupli(const Object *)
static void OVERLAY_next_engine_init(void *vedata)
static const DrawEngineDataSize overlay_data_size
blender::draw::overlay::Instance Instance
static void OVERLAY_next_cache_init(void *vedata)
static void OVERLAY_next_cache_finish(void *vedata)
static void OVERLAY_next_instance_free(void *instance_)
DrawEngineType draw_engine_overlay_next_type
static void OVERLAY_next_draw_scene(void *vedata)
static void OVERLAY_next_cache_populate(void *vedata, Object *object)
RegionView3D * rv3d
DupliObject * dupli_object
#define N_(msgid)