UI: Asset Shelf (Experimental Feature) #104831

Closed
Julian Eisel wants to merge 399 commits from asset-shelf into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
5 changed files with 71 additions and 58 deletions
Showing only changes of commit 19881697a1 - Show all commits

View File

@ -185,7 +185,7 @@ set(SRC
engines/workbench/workbench_transparent.c
engines/workbench/workbench_volume.c
engines/workbench/workbench_volume_next.cc
engines/external/external_engine.c
engines/external/external_engine.cc
engines/gpencil/gpencil_antialiasing.c
engines/gpencil/gpencil_cache_utils.c
engines/gpencil/gpencil_draw_data.c

View File

@ -84,7 +84,7 @@ typedef struct EXTERNAL_Data {
static struct {
/* Depth Pre Pass */
GPUShader *depth_sh;
} e_data = {NULL}; /* Engine data */
} e_data = {nullptr}; /* Engine data */
typedef struct EXTERNAL_PrivateData {
DRWShadingGroup *depth_shgrp;
@ -110,7 +110,7 @@ static void external_engine_init(void *vedata)
if (!stl->g_data) {
/* Alloc transient pointers */
stl->g_data = MEM_mallocN(sizeof(*stl->g_data), __func__);
stl->g_data = MEM_cnew<EXTERNAL_PrivateData>(__func__);
stl->g_data->need_depth = true;
}
@ -149,7 +149,8 @@ static void external_cache_init(void *vedata)
const View3D *v3d = draw_ctx->v3d;
{
DRW_texture_ensure_fullscreen_2d(&txl->depth_buffer_tx, GPU_DEPTH24_STENCIL8, 0);
DRW_texture_ensure_fullscreen_2d(
&txl->depth_buffer_tx, GPU_DEPTH24_STENCIL8, DRWTextureFlag(0));
GPU_framebuffer_ensure_config(&fbl->depth_buffer_fb,
{
@ -164,12 +165,12 @@ static void external_cache_init(void *vedata)
stl->g_data->depth_shgrp = DRW_shgroup_create(e_data.depth_sh, psl->depth_pass);
}
if (v3d != NULL) {
if (v3d != nullptr) {
/* Do not draw depth pass when overlays are turned off. */
stl->g_data->need_depth = (v3d->flag2 & V3D_HIDE_OVERLAYS) == 0;
}
else if (draw_ctx->space_data != NULL) {
const eSpace_Type space_type = draw_ctx->space_data->spacetype;
else if (draw_ctx->space_data != nullptr) {
const eSpace_Type space_type = eSpace_Type(draw_ctx->space_data->spacetype);
if (space_type == SPACE_IMAGE) {
external_cache_image_add(stl->g_data->depth_shgrp);
@ -184,8 +185,8 @@ static void external_cache_populate(void *vedata, Object *ob)
const DRWContextState *draw_ctx = DRW_context_state_get();
EXTERNAL_StorageList *stl = ((EXTERNAL_Data *)vedata)->stl;
if (draw_ctx->space_data != NULL) {
const eSpace_Type space_type = draw_ctx->space_data->spacetype;
if (draw_ctx->space_data != nullptr) {
const eSpace_Type space_type = eSpace_Type(draw_ctx->space_data->spacetype);
if (space_type == SPACE_IMAGE) {
return;
}
@ -203,7 +204,7 @@ static void external_cache_populate(void *vedata, Object *ob)
return;
}
if (ob->type == OB_MESH && ob->modifiers.first != NULL) {
if (ob->type == OB_MESH && ob->modifiers.first != nullptr) {
LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
if (md->type != eModifierType_ParticleSystem) {
continue;
@ -216,8 +217,8 @@ static void external_cache_populate(void *vedata, Object *ob)
const int draw_as = (part->draw_as == PART_DRAW_REND) ? part->ren_as : part->draw_as;
if (draw_as == PART_DRAW_PATH) {
GPUBatch *hairs = DRW_cache_particles_get_hair(ob, psys, NULL);
DRW_shgroup_call(stl->g_data->depth_shgrp, hairs, NULL);
GPUBatch *hairs = DRW_cache_particles_get_hair(ob, psys, nullptr);
DRW_shgroup_call(stl->g_data->depth_shgrp, hairs, nullptr);
}
}
}
@ -228,7 +229,7 @@ static void external_cache_populate(void *vedata, Object *ob)
}
}
static void external_cache_finish(void *UNUSED(vedata)) {}
static void external_cache_finish(void * /*vedata*/) {}
static void external_draw_scene_do_v3d(void *vedata)
{
@ -270,7 +271,7 @@ static void external_draw_scene_do_v3d(void *vedata)
GPU_matrix_pop_projection();
/* Set render info. */
EXTERNAL_Data *data = vedata;
EXTERNAL_Data *data = static_cast<EXTERNAL_Data *>(vedata);
if (rv3d->render_engine->text[0] != '\0') {
STRNCPY(data->info, rv3d->render_engine->text);
}
@ -286,7 +287,7 @@ static void external_draw_scene_do_v3d(void *vedata)
* need to switch from normalized space to pixel space, and "un-apply" offset. */
static void external_image_space_matrix_set(const RenderEngine *engine)
{
BLI_assert(engine != NULL);
BLI_assert(engine != nullptr);
const DRWContextState *draw_ctx = DRW_context_state_get();
const DRWView *view = DRW_view_get_active();
@ -325,7 +326,7 @@ static void external_image_space_matrix_set(const RenderEngine *engine)
}
}
static void external_draw_scene_do_image(void *UNUSED(vedata))
static void external_draw_scene_do_image(void * /*vedata*/)
{
const DRWContextState *draw_ctx = DRW_context_state_get();
Scene *scene = draw_ctx->scene;
@ -333,8 +334,8 @@ static void external_draw_scene_do_image(void *UNUSED(vedata))
RenderEngine *engine = RE_engine_get(re);
/* Is tested before enabling the drawing engine. */
BLI_assert(re != NULL);
BLI_assert(engine != NULL);
BLI_assert(re != nullptr);
BLI_assert(engine != nullptr);
DRW_state_reset_ex(DRW_STATE_WRITE_COLOR);
@ -359,8 +360,8 @@ static void external_draw_scene_do_image(void *UNUSED(vedata))
GPU_debug_group_begin("External Engine");
const RenderEngineType *engine_type = engine->type;
BLI_assert(engine_type != NULL);
BLI_assert(engine_type->draw != NULL);
BLI_assert(engine_type != nullptr);
BLI_assert(engine_type->draw != nullptr);
engine_type->draw(engine, draw_ctx->evil_C, draw_ctx->depsgraph);
@ -379,16 +380,16 @@ static void external_draw_scene_do(void *vedata)
{
const DRWContextState *draw_ctx = DRW_context_state_get();
if (draw_ctx->v3d != NULL) {
if (draw_ctx->v3d != nullptr) {
external_draw_scene_do_v3d(vedata);
return;
}
if (draw_ctx->space_data == NULL) {
if (draw_ctx->space_data == nullptr) {
return;
}
const eSpace_Type space_type = draw_ctx->space_data->spacetype;
const eSpace_Type space_type = eSpace_Type(draw_ctx->space_data->spacetype);
if (space_type == SPACE_IMAGE) {
external_draw_scene_do_image(vedata);
return;
@ -403,7 +404,7 @@ static void external_draw_scene(void *vedata)
EXTERNAL_FramebufferList *fbl = ((EXTERNAL_Data *)vedata)->fbl;
const DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
/* Will be NULL during OpenGL render.
/* Will be nullptr during OpenGL render.
* OpenGL render is used for quick preview (thumbnails or sequencer preview)
* where using the rendering engine to preview doesn't make so much sense. */
if (draw_ctx->evil_C) {
@ -426,7 +427,7 @@ static void external_draw_scene(void *vedata)
GPU_framebuffer_blit(fbl->depth_buffer_fb, 0, dfbl->depth_only_fb, 0, GPU_DEPTH_BIT);
}
static void external_engine_free(void)
static void external_engine_free()
{
DRW_SHADER_FREE_SAFE(e_data.depth_sh);
}
@ -434,63 +435,63 @@ static void external_engine_free(void)
static const DrawEngineDataSize external_data_size = DRW_VIEWPORT_DATA_SIZE(EXTERNAL_Data);
DrawEngineType draw_engine_external_type = {
NULL,
NULL,
nullptr,
nullptr,
N_("External"),
&external_data_size,
&external_engine_init,
&external_engine_free,
/*instance_free*/ NULL,
/*instance_free*/ nullptr,
&external_cache_init,
&external_cache_populate,
&external_cache_finish,
&external_draw_scene,
NULL,
NULL,
NULL,
NULL,
nullptr,
nullptr,
nullptr,
nullptr,
};
/* NOTE: currently unused,
* we should not register unless we want to see this when debugging the view. */
RenderEngineType DRW_engine_viewport_external_type = {
NULL,
NULL,
nullptr,
nullptr,
EXTERNAL_ENGINE,
N_("External"),
RE_INTERNAL | RE_USE_STEREO_VIEWPORT,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
&draw_engine_external_type,
{NULL, NULL, NULL},
{nullptr, nullptr, nullptr},
};
bool DRW_engine_external_acquire_for_image_editor(void)
bool DRW_engine_external_acquire_for_image_editor()
{
const DRWContextState *draw_ctx = DRW_context_state_get();
const SpaceLink *space_data = draw_ctx->space_data;
Scene *scene = draw_ctx->scene;
if (space_data == NULL) {
if (space_data == nullptr) {
return false;
}
const eSpace_Type space_type = draw_ctx->space_data->spacetype;
const eSpace_Type space_type = eSpace_Type(draw_ctx->space_data->spacetype);
if (space_type != SPACE_IMAGE) {
return false;
}
SpaceImage *space_image = (SpaceImage *)space_data;
const Image *image = ED_space_image(space_image);
if (image == NULL || image->type != IMA_TYPE_R_RESULT) {
if (image == nullptr || image->type != IMA_TYPE_R_RESULT) {
return false;
}
@ -501,7 +502,7 @@ bool DRW_engine_external_acquire_for_image_editor(void)
/* Render is allocated on main thread, so it is safe to access it from here. */
Render *re = RE_GetSceneRender(scene);
if (re == NULL) {
if (re == nullptr) {
return false;
}

View File

@ -8,6 +8,10 @@
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
extern DrawEngineType draw_engine_external_type;
extern RenderEngineType DRW_engine_viewport_external_type;
@ -17,3 +21,7 @@ extern RenderEngineType DRW_engine_viewport_external_type;
*
* NOTE: Released by the draw engine when it is done drawing. */
bool DRW_engine_external_acquire_for_image_editor(void);
#ifdef __cplusplus
}
#endif

View File

@ -41,6 +41,7 @@
#include "BKE_global.h"
#include "BKE_idtype.h"
#include "BKE_key.h"
#include "BKE_lib_id.h"
#include "BKE_main.h"
#include "BKE_material.h"
#include "BKE_nla.h"
@ -1496,6 +1497,11 @@ int insert_keyframe(Main *bmain,
return 0;
}
if (!BKE_id_is_editable(bmain, id)) {
BKE_reportf(reports, RPT_ERROR, "'%s' on %s is not editable", rna_path, id->name + 2);
return 0;
}
RNA_id_pointer_create(id, &id_ptr);
if (RNA_path_resolve_property(&id_ptr, rna_path, &ptr, &prop) == false) {
BKE_reportf(

View File

@ -289,7 +289,6 @@ BuildOnlyVisibleButtonsHelper::BuildOnlyVisibleButtonsHelper(const View2D &v2d,
IndexRange BuildOnlyVisibleButtonsHelper::get_visible_range() const
{
int first_idx_in_view = 0;
int max_items_in_view = 0;
const float scroll_ofs_y = abs(v2d_.cur.ymax - v2d_.tot.ymax);
if (!IS_EQF(scroll_ofs_y, 0)) {
@ -298,9 +297,9 @@ IndexRange BuildOnlyVisibleButtonsHelper::get_visible_range() const
first_idx_in_view = scrolled_away_rows * cols_per_row_;
}
const float view_height = BLI_rctf_size_y(&v2d_.cur);
const int count_rows_in_view = std::max(round_fl_to_int(view_height / style_.tile_height), 1);
max_items_in_view = (count_rows_in_view + 1) * cols_per_row_;
const int view_height = BLI_rcti_size_y(&v2d_.mask);
const int count_rows_in_view = std::max(view_height / style_.tile_height, 1);
const int max_items_in_view = (count_rows_in_view + 1) * cols_per_row_;
BLI_assert(max_items_in_view > 0);
return IndexRange(first_idx_in_view, max_items_in_view);
@ -313,13 +312,12 @@ bool BuildOnlyVisibleButtonsHelper::is_item_visible(const int item_idx) const
void BuildOnlyVisibleButtonsHelper::fill_layout_before_visible(uiBlock &block) const
{
const float scroll_ofs_y = abs(v2d_.cur.ymax - v2d_.tot.ymax);
if (IS_EQF(scroll_ofs_y, 0)) {
const int first_idx_in_view = visible_items_range_.first();
if (first_idx_in_view < 1) {
return;
}
const int scrolled_away_rows = int(scroll_ofs_y) / style_.tile_height;
const int tot_tiles_before_visible = first_idx_in_view;
const int scrolled_away_rows = tot_tiles_before_visible / cols_per_row_;
add_spacer_button(block, scrolled_away_rows);
}