2023-08-16 00:20:26 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2023-05-23 15:00:38 +02:00
|
|
|
|
|
|
|
|
/** \file
|
|
|
|
|
* \ingroup select
|
|
|
|
|
*/
|
|
|
|
|
|
2024-01-05 11:16:57 -05:00
|
|
|
#include "DRW_render.hh"
|
2023-05-23 15:00:38 +02:00
|
|
|
|
2024-03-23 01:24:18 +01:00
|
|
|
#include "GPU_capabilities.hh"
|
2023-05-23 15:00:38 +02:00
|
|
|
|
2023-10-04 14:32:18 -03:00
|
|
|
#include "select_engine.hh"
|
2023-05-23 15:00:38 +02:00
|
|
|
|
|
|
|
|
#include "../overlay/overlay_next_instance.hh"
|
|
|
|
|
#include "select_instance.hh"
|
|
|
|
|
|
|
|
|
|
using namespace blender::draw;
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Select-Next Engine
|
|
|
|
|
* \{ */
|
|
|
|
|
|
|
|
|
|
using Instance = overlay::Instance;
|
|
|
|
|
|
2023-07-02 19:37:19 +10:00
|
|
|
struct SELECT_NextData {
|
2023-05-23 15:00:38 +02:00
|
|
|
void *engine_type;
|
|
|
|
|
DRWViewportEmptyList *fbl;
|
|
|
|
|
DRWViewportEmptyList *txl;
|
|
|
|
|
DRWViewportEmptyList *psl;
|
|
|
|
|
DRWViewportEmptyList *stl;
|
|
|
|
|
|
|
|
|
|
Instance *instance;
|
2023-07-02 19:37:19 +10:00
|
|
|
};
|
2023-05-23 15:00:38 +02:00
|
|
|
|
|
|
|
|
static void SELECT_next_engine_init(void *vedata)
|
|
|
|
|
{
|
|
|
|
|
OVERLAY_Data *ved = reinterpret_cast<OVERLAY_Data *>(vedata);
|
|
|
|
|
|
|
|
|
|
if (ved->instance == nullptr) {
|
|
|
|
|
ved->instance = new Instance(select::SelectionType::ENABLED);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
reinterpret_cast<Instance *>(ved->instance)->init();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void SELECT_next_cache_init(void *vedata)
|
|
|
|
|
{
|
|
|
|
|
reinterpret_cast<Instance *>(reinterpret_cast<OVERLAY_Data *>(vedata)->instance)->begin_sync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void SELECT_next_cache_populate(void *vedata, Object *object)
|
|
|
|
|
{
|
|
|
|
|
ObjectRef ref;
|
|
|
|
|
ref.object = object;
|
|
|
|
|
ref.dupli_object = DRW_object_get_dupli(object);
|
|
|
|
|
ref.dupli_parent = DRW_object_get_dupli_parent(object);
|
|
|
|
|
|
|
|
|
|
reinterpret_cast<Instance *>(reinterpret_cast<OVERLAY_Data *>(vedata)->instance)
|
|
|
|
|
->object_sync(ref, *DRW_manager_get());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void SELECT_next_cache_finish(void *vedata)
|
|
|
|
|
{
|
|
|
|
|
reinterpret_cast<Instance *>(reinterpret_cast<OVERLAY_Data *>(vedata)->instance)->end_sync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void SELECT_next_draw_scene(void *vedata)
|
|
|
|
|
{
|
|
|
|
|
reinterpret_cast<Instance *>(reinterpret_cast<OVERLAY_Data *>(vedata)->instance)
|
|
|
|
|
->draw(*DRW_manager_get());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void SELECT_next_instance_free(void *instance_)
|
|
|
|
|
{
|
2023-09-08 16:53:27 +10:00
|
|
|
Instance *instance = (Instance *)instance_;
|
2023-05-23 15:00:38 +02:00
|
|
|
if (instance != nullptr) {
|
|
|
|
|
delete instance;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const DrawEngineDataSize SELECT_next_data_size = DRW_VIEWPORT_DATA_SIZE(SELECT_NextData);
|
|
|
|
|
|
|
|
|
|
DrawEngineType draw_engine_select_next_type = {
|
2023-07-18 14:18:10 +10:00
|
|
|
/*next*/ nullptr,
|
|
|
|
|
/*prev*/ nullptr,
|
|
|
|
|
/*idname*/ N_("Select-Next"),
|
|
|
|
|
/*vedata_size*/ &SELECT_next_data_size,
|
|
|
|
|
/*engine_init*/ &SELECT_next_engine_init,
|
|
|
|
|
/*engine_free*/ nullptr,
|
|
|
|
|
/*instance_free*/ &SELECT_next_instance_free,
|
|
|
|
|
/*cache_init*/ &SELECT_next_cache_init,
|
|
|
|
|
/*cache_populate*/ &SELECT_next_cache_populate,
|
|
|
|
|
/*cache_finish*/ &SELECT_next_cache_finish,
|
|
|
|
|
/*draw_scene*/ &SELECT_next_draw_scene,
|
|
|
|
|
/*view_update*/ nullptr,
|
|
|
|
|
/*id_update*/ nullptr,
|
|
|
|
|
/*render_to_image*/ nullptr,
|
|
|
|
|
/*store_metadata*/ nullptr,
|
2023-05-23 15:00:38 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/** \} */
|