WIP: Onion Skinning Prototype #107641

Closed
Christoph Lendenfeld wants to merge 22 commits from ChrisLend/blender:onion_skin_test into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
6 changed files with 85 additions and 19 deletions
Showing only changes of commit 18d660da73 - Show all commits

View File

@ -715,6 +715,29 @@ class RENDER_PT_gpencil(RenderButtonsPanel, Panel):
col.prop(props, "antialias_threshold")
class RENDER_PT_onion_skins(RenderButtonsPanel, Panel):
bl_label = "Onion Skins"
bl_options = {'DEFAULT_CLOSED'}
bl_order = 10
COMPAT_ENGINES = {
'BLENDER_RENDER',
'BLENDER_EEVEE',
'BLENDER_EEVEE_NEXT',
'BLENDER_WORKBENCH',
'BLENDER_WORKBENCH_NEXT'}
def draw(self, context):
layout = self.layout
# layout.use_property_split = True
# layout.use_property_decorate = False # No animation.
scene = context.scene
col = layout.column()
col.prop(scene, "onion_skin_color")
col.prop(scene, "onion_skin_alpha")
class RENDER_PT_opengl_sampling(RenderButtonsPanel, Panel):
bl_label = "Sampling"
COMPAT_ENGINES = {'BLENDER_WORKBENCH', 'BLENDER_WORKBENCH_NEXT'}
@ -921,6 +944,8 @@ classes = (
RENDER_PT_simplify_viewport,
RENDER_PT_simplify_render,
RENDER_PT_simplify_greasepencil,
RENDER_PT_onion_skins,
)
if __name__ == "__main__": # only for live edit.

View File

@ -1,4 +1,5 @@
#include "DRW_render.h"
#include "draw_cache_impl.h"
#include "overlay_private.hh"
void OVERLAY_onion_skin_init(OVERLAY_Data *vedata)
@ -23,10 +24,15 @@ void OVERLAY_onion_skin_populate(OVERLAY_Data *vedata, Object *ob)
const DRWContextState *draw_ctx = DRW_context_state_get();
float color[3] = {1, 1, 0};
DRW_shgroup_uniform_vec3_copy(grp, "color", color);
DRW_shgroup_uniform_float_copy(grp, "alpha", 0.2f);
DRW_shgroup_uniform_vec3_copy(grp, "color", draw_ctx->scene->onion_skin_cache.color);
DRW_shgroup_uniform_float_copy(grp, "alpha", draw_ctx->scene->onion_skin_cache.alpha);
/* LISTBASE_FOREACH (OnionSkinMeshLink *, mesh_link, &draw_ctx->scene->onion_skin_cache.meshes) {
struct GPUBatch *geom = DRW_mesh_batch_cache_get_surface((Mesh *)mesh_link->mesh);
if (geom) {
DRW_shgroup_call(pd->onion_skin_grp, geom, ob);
}
} */
struct GPUBatch *geom = DRW_cache_object_surface_get(ob);
if (geom) {
DRW_shgroup_call(pd->onion_skin_grp, geom, ob);

View File

@ -1,26 +1,44 @@
#include "BKE_context.h"
#include "BKE_lib_id.h"
#include "BKE_mesh.h"
#include "DNA_scene_types.h"
#include "DNA_windowmanager_types.h"
#include "ED_onion_skin.h"
#include "MEM_guardedalloc.h"
#include "WM_api.h"
#include "WM_types.h"
static int onion_skin_add_exec(bContext *C, wmOperator *op)
static void graveyard()
{
ListBase selected = {NULL, NULL};
CTX_data_selected_objects(C, &selected);
LISTBASE_FOREACH (CollectionPointerLink *, object_ptr_link, &selected) {
/* Mesh *mesh = BKE_mesh_from_object(ob);
if (!mesh) {
continue;
} */
/* Mesh *copy = BKE_mesh_copy_for_eval(mesh); */
/* Mesh *mesh_result = (Mesh *)BKE_id_copy_ex(
NULL, &mesh->id, NULL, LIB_ID_CREATE_NO_MAIN | LIB_ID_CREATE_NO_USER_REFCOUNT); */
/*
OnionSkinMeshLink *link = MEM_callocN(sizeof(OnionSkinMeshLink), "onion skin mesh link");
link->mesh = copy;
BLI_addtail(&scene->onion_skin_cache.meshes, link); */
}
BLI_freelistN(&selected);
}
static int onion_skin_add_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
LISTBASE_FOREACH (Object *, ob, &selected) {
/* Mesh *mesh; */
OnionSkinMesh *link = MEM_callocN(sizeof(OnionSkinMesh), "onion skin mesh link");
/* link->mesh = mesh; */
BLI_addtail(&scene->onion_skin_cache.meshes, link);
}
Object *ob = CTX_data_active_object(C);
Mesh *mesh = BKE_mesh_from_object(ob);
Mesh *copy = BKE_mesh_copy_for_eval(mesh);
OnionSkinMeshLink *link = MEM_callocN(sizeof(OnionSkinMeshLink), "onion skin mesh link");
link->mesh = copy;
BLI_addtail(&scene->onion_skin_cache.meshes, link);
BLI_freelistN(&selected);
return OPERATOR_FINISHED;
}

View File

@ -1848,16 +1848,16 @@ typedef struct SceneGpencil {
char _pad[4];
} SceneGpencil;
typedef struct OnionSkinMesh {
struct OnionSkinMesh *prev, *next;
typedef struct OnionSkinMeshLink {
struct OnionSkinMeshLink *prev, *next;
/* Having a Mesh pointer here breaks compilation. Complains about "extern C" issues. */
void *mesh;
} OnionSkinMesh;
} OnionSkinMeshLink;
typedef struct SceneOnionSkin {
float color[3];
float alpha;
ListBase meshes /* OnionSkinMesh */;
ListBase meshes /* OnionSkinMeshLink */;
} SceneOnionSkin;
/** \} */

View File

@ -8358,6 +8358,21 @@ void RNA_def_scene(BlenderRNA *brna)
RNA_def_property_struct_type(prop, "SceneGpencil");
RNA_def_property_ui_text(prop, "Grease Pencil", "Grease Pencil settings for the scene");
prop = RNA_def_property(srna, "onion_skin_color", PROP_FLOAT, PROP_COLOR);
RNA_def_property_float_sdna(prop, NULL, "onion_skin_cache.color");
RNA_def_property_array(prop, 3);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_text(prop, "Onion Skin Color", "Define the color of onion skins");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D | NS_VIEW3D_SHADING, NULL);
prop = RNA_def_property(srna, "onion_skin_alpha", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "onion_skin_cache.alpha");
RNA_def_property_ui_text(prop, "Onion Skin Alpha", "Alpha of drawn onion skins");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_range(prop, 0.0f, 1.0f, 1, 2);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D | NS_VIEW3D_SHADING, NULL);
/* Nestled Data. */
/* *** Non-Animated *** */
RNA_define_animate_sdna(false);

View File

@ -1541,7 +1541,8 @@ static void rna_3DViewShading_render_pass_set(PointerRNA *ptr, int value)
BLI_strncpy(shading->aov_name, aov->name, sizeof(aov->name));
}
else if (value == EEVEE_RENDER_PASS_BLOOM &&
((scene->eevee.flag & SCE_EEVEE_BLOOM_ENABLED) == 0)) {
((scene->eevee.flag & SCE_EEVEE_BLOOM_ENABLED) == 0))
{
shading->render_pass = EEVEE_RENDER_PASS_COMBINED;
}
else {
@ -3298,7 +3299,8 @@ const EnumPropertyItem *rna_SpaceSpreadsheet_attribute_domain_itemf(bContext *UN
ATTR_DOMAIN_CORNER,
ATTR_DOMAIN_EDGE,
ATTR_DOMAIN_POINT,
ATTR_DOMAIN_FACE)) {
ATTR_DOMAIN_FACE))
{
continue;
}
}