GPv3: Onion Skinning #119792

Merged
Falk David merged 20 commits from filedescriptor/blender:gpv3-old-onion-skinning into main 2024-04-03 15:34:51 +02:00
5 changed files with 53 additions and 9 deletions
Showing only changes of commit 55c2f1d214 - Show all commits

View File

@ -105,6 +105,7 @@ set(SRC_DNA_DEFAULTS_INC
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_defaults.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_fluid_defaults.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_gpencil_modifier_defaults.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_grease_pencil_defaults.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_image_defaults.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_lattice_defaults.h
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_light_defaults.h

View File

@ -42,6 +42,7 @@
#include "BLI_string.h"
#include "BLI_string_ref.hh"
#include "BLI_string_utils.hh"
#include "BLI_utildefines.h"
#include "BLI_vector_set.hh"
#include "BLI_virtual_array.hh"
@ -52,6 +53,7 @@
#include "DNA_ID.h"
#include "DNA_ID_enums.h"
#include "DNA_brush_types.h"
#include "DNA_defaults.h"
#include "DNA_gpencil_modifier_types.h"
#include "DNA_grease_pencil_types.h"
#include "DNA_material_types.h"
@ -80,10 +82,12 @@ static void grease_pencil_init_data(ID *id)
using namespace blender::bke;
GreasePencil *grease_pencil = reinterpret_cast<GreasePencil *>(id);
BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(grease_pencil, id));
MEMCPY_STRUCT_AFTER(grease_pencil, DNA_struct_default_get(GreasePencil), id);
grease_pencil->root_group_ptr = MEM_new<greasepencil::LayerGroup>(__func__);
grease_pencil->active_layer = nullptr;
grease_pencil->flag |= GREASE_PENCIL_ANIM_CHANNEL_EXPANDED;
CustomData_reset(&grease_pencil->layers_data);

View File

@ -0,0 +1,38 @@
/* SPDX-FileCopyrightText: 2024 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup DNA
*/
#pragma once
/* clang-format off */
/* -------------------------------------------------------------------- */
/** \name Grease Pencil Struct
* \{ */
#define _DNA_DEFAULT_GreasePencilOnionSkinningSettings \
{ \
.opacity = 0.5f, \
.mode = GP_ONION_SKINNING_MODE_RELATIVE, \
.flag = (GP_ONION_SKINNING_USE_FADE | GP_ONION_SKINNING_USE_CUSTOM_COLORS), \
.filter = GREASE_PENCIL_ONION_SKINNING_FILTER_ALL, \
.num_frames_before = 1, \
.num_frames_after = 1, \
.color_before = {0.145098f, 0.419608f, 0.137255f}, \
.color_after = {0.125490f, 0.082353f, 0.529412f},\
}
#define _DNA_DEFAULT_GreasePencil \
{ \
.flag = GREASE_PENCIL_ANIM_CHANNEL_EXPANDED, \
.onion_skinning_settings = _DNA_DEFAULT_GreasePencilOnionSkinningSettings, \
}
/** \} */
/* clang-format on */

View File

@ -87,6 +87,7 @@
#include "DNA_curves_types.h"
#include "DNA_fluid_types.h"
#include "DNA_gpencil_modifier_types.h"
#include "DNA_grease_pencil_types.h"
#include "DNA_image_types.h"
#include "DNA_key_types.h"
#include "DNA_lattice_types.h"
@ -120,6 +121,7 @@
#include "DNA_curves_defaults.h"
#include "DNA_fluid_defaults.h"
#include "DNA_gpencil_modifier_defaults.h"
#include "DNA_grease_pencil_defaults.h"
#include "DNA_image_defaults.h"
#include "DNA_lattice_defaults.h"
#include "DNA_light_defaults.h"
@ -181,6 +183,9 @@ SDNA_DEFAULT_DECL_STRUCT(Image);
/* DNA_curves_defaults.h */
SDNA_DEFAULT_DECL_STRUCT(Curves);
/* DNA_grease_pencil_defaults.h */
SDNA_DEFAULT_DECL_STRUCT(GreasePencil);
/* DNA_lattice_defaults.h */
SDNA_DEFAULT_DECL_STRUCT(Lattice);
@ -427,6 +432,9 @@ const void *DNA_default_table[SDNA_TYPE_MAX] = {
/* DNA_curves_defaults.h */
SDNA_DEFAULT_DECL(Curves),
/* DNA_grease_pencil_defaults.h */
SDNA_DEFAULT_DECL(GreasePencil),
/* DNA_lattice_defaults.h */
SDNA_DEFAULT_DECL(Lattice),

View File

@ -573,6 +573,7 @@ static void rna_def_grease_pencil_onion_skinning(StructRNA *srna)
};
static EnumPropertyItem prop_enum_onion_keyframe_type_items[] = {
{GREASE_PENCIL_ONION_SKINNING_FILTER_ALL, "ALL", 0, "All", "Include all Keyframe types"},
{GP_ONION_SKINNING_FILTER_KEYTYPE_KEYFRAME,
"KEYFRAME",
ICON_KEYTYPE_KEYFRAME_VEC,
@ -601,13 +602,9 @@ static void rna_def_grease_pencil_onion_skinning(StructRNA *srna)
{0, nullptr, 0, nullptr, nullptr},
};
static float onion_default_before[3] = {0.145098f, 0.419608f, 0.137255f}; /* green */
static float onion_default_after[3] = {0.125490f, 0.082353f, 0.529412f}; /* blue */
prop = RNA_def_property(srna, "ghost_before_range", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, nullptr, "onion_skinning_settings.num_frames_before");
RNA_def_property_range(prop, 0, 120);
RNA_def_property_int_default(prop, 1);
RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, ParameterFlag(0));
RNA_def_property_ui_text(prop,
"Frames Before",
@ -618,7 +615,6 @@ static void rna_def_grease_pencil_onion_skinning(StructRNA *srna)
prop = RNA_def_property(srna, "ghost_after_range", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, nullptr, "onion_skinning_settings.num_frames_after");
RNA_def_property_range(prop, 0, 120);
RNA_def_property_int_default(prop, 1);
RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, ParameterFlag(0));
RNA_def_property_ui_text(prop,
"Frames After",
@ -637,7 +633,6 @@ static void rna_def_grease_pencil_onion_skinning(StructRNA *srna)
RNA_def_property_float_sdna(prop, nullptr, "onion_skinning_settings.color_before");
RNA_def_property_array(prop, 3);
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_float_array_default(prop, onion_default_before);
RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, ParameterFlag(0));
RNA_def_property_ui_text(prop, "Before Color", "Base color for ghosts before the active frame");
RNA_def_property_update(prop,
@ -648,7 +643,6 @@ static void rna_def_grease_pencil_onion_skinning(StructRNA *srna)
RNA_def_property_float_sdna(prop, nullptr, "onion_skinning_settings.color_after");
RNA_def_property_array(prop, 3);
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_float_array_default(prop, onion_default_after);
RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, ParameterFlag(0));
RNA_def_property_ui_text(prop, "After Color", "Base color for ghosts after the active frame");
RNA_def_property_update(prop,
@ -687,7 +681,6 @@ static void rna_def_grease_pencil_onion_skinning(StructRNA *srna)
prop = RNA_def_property(srna, "onion_factor", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, nullptr, "onion_skinning_settings.opacity");
RNA_def_property_float_default(prop, 0.5f);
RNA_def_property_range(prop, 0.0, 1.0f);
RNA_def_parameter_clear_flags(prop, PROP_ANIMATABLE, ParameterFlag(0));
RNA_def_property_ui_text(prop, "Onion Opacity", "Change fade opacity of displayed onion frames");