Merge branch 'blender-v4.0-release'

This commit is contained in:
Julian Eisel
2023-09-27 15:48:37 +02:00
23 changed files with 106 additions and 21 deletions

View File

@@ -307,7 +307,7 @@ class NewGeometryNodeGroupTool(Operator):
def execute(self, context):
group = geometry_node_group_empty_tool_new(context)
context.space_data.node_tree = group
context.space_data.geometry_nodes_tool_tree = group
return {'FINISHED'}

View File

@@ -162,7 +162,7 @@ class NODE_HT_header(Header):
else:
row.template_ID(snode, "node_tree", new="node.new_geometry_nodes_modifier")
else:
layout.template_ID(snode, "node_tree", new="node.new_geometry_node_group_tool")
layout.template_ID(snode, "geometry_nodes_tool_tree", new="node.new_geometry_node_group_tool")
if snode.node_tree:
layout.popover(panel="NODE_PT_geometry_node_tool_object_types", text="Types")
layout.popover(panel="NODE_PT_geometry_node_tool_mode", text="Modes")

View File

@@ -7,6 +7,10 @@ if(WITH_BLENDER)
add_definitions(-DWITH_INPUT_NDOF)
endif()
if(WITH_EXPERIMENTAL_FEATURES)
add_definitions(-DWITH_GREASE_PENCIL_V3)
endif()
add_subdirectory(animation)
add_subdirectory(armature)
add_subdirectory(asset)

View File

@@ -54,6 +54,9 @@ if(WITH_PYTHON)
add_definitions(-DWITH_PYTHON)
endif()
if(WITH_EXPERIMENTAL_FEATURES)
add_definitions(-DWITH_GREASE_PENCIL_V3)
endif()
blender_add_lib(bf_editor_animation "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")

View File

@@ -3507,6 +3507,7 @@ static bAnimChannelType ACF_GPL_LEGACY = {
/* Grease Pencil Animation functions ------------------------------------------- */
#ifdef WITH_GREASE_PENCIL_V3
namespace blender::ed::animation::greasepencil {
/* Get pointer to the setting */
@@ -3740,6 +3741,7 @@ static bAnimChannelType ACF_GPLGROUP = {
/*setting_flag*/ greasepencil::layer_setting_flag,
/*setting_ptr*/ greasepencil::layer_group_setting_ptr,
};
#endif
/* Mask Datablock ------------------------------------------- */
@@ -4306,9 +4308,15 @@ static void ANIM_init_channel_typeinfo_data()
animchannelTypeInfo[type++] = &ACF_GPD_LEGACY; /* Grease Pencil Datablock (Legacy) */
animchannelTypeInfo[type++] = &ACF_GPL_LEGACY; /* Grease Pencil Layer (Legacy) */
#ifdef WITH_GREASE_PENCIL_V3
animchannelTypeInfo[type++] = &ACF_GPD; /* Grease Pencil Datablock. */
animchannelTypeInfo[type++] = &ACF_GPLGROUP; /* Grease Pencil Layer Group. */
animchannelTypeInfo[type++] = &ACF_GPL; /* Grease Pencil Layer. */
#else
animchannelTypeInfo[type++] = nullptr;
animchannelTypeInfo[type++] = nullptr;
animchannelTypeInfo[type++] = nullptr;
#endif
animchannelTypeInfo[type++] = &ACF_MASKDATA; /* Mask Datablock */
animchannelTypeInfo[type++] = &ACF_MASKLAYER; /* Mask Layer */
@@ -5422,6 +5430,7 @@ static void draw_setting_widget(bAnimContext *ac,
}
}
#ifdef WITH_GREASE_PENCIL_V3
static void draw_grease_pencil_layer_widgets(bAnimListElem *ale,
uiBlock *block,
const rctf *rect,
@@ -5484,6 +5493,7 @@ static void draw_grease_pencil_layer_widgets(bAnimListElem *ale,
}
MEM_freeN(opacity_rna_path);
}
#endif
void ANIM_channel_draw_widgets(const bContext *C,
bAnimContext *ac,
@@ -5905,9 +5915,11 @@ void ANIM_channel_draw_widgets(const bContext *C,
MEM_freeN(gp_rna_path);
}
}
#ifdef WITH_GREASE_PENCIL_V3
else if (ale->type == ANIMTYPE_GREASE_PENCIL_LAYER) {
draw_grease_pencil_layer_widgets(ale, block, rect, offset, channel_height, array_index);
}
#endif
/* Only if RNA-Path found. */
if (rna_path) {

View File

@@ -2662,7 +2662,9 @@ void uiTemplateLightLinkingCollection(uiLayout *layout,
PointerRNA *ptr,
const char *propname);
#ifdef WITH_GREASE_PENCIL_V3
void uiTemplateGreasePencilLayerTree(uiLayout *layout, bContext *C);
#endif
void uiTemplateNodeTreeInterface(struct uiLayout *layout, struct PointerRNA *ptr);

View File

@@ -69,7 +69,6 @@ set(SRC
interface_style.cc
interface_template_asset_view.cc
interface_template_attribute_search.cc
interface_template_grease_pencil_layer_tree.cc
interface_template_light_linking.cc
interface_template_list.cc
interface_template_node_tree_interface.cc
@@ -123,6 +122,13 @@ if(WIN32 OR APPLE)
endif()
endif()
if(WITH_EXPERIMENTAL_FEATURES)
add_definitions(-DWITH_GREASE_PENCIL_V3)
list(APPEND SRC
interface_template_grease_pencil_layer_tree.cc
)
endif()
blender_add_lib(bf_editor_interface "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")

View File

@@ -61,6 +61,10 @@ static Vector<rcti> button_section_bounds_calc(const ARegion *region, const bool
BLI_rcti_init_minmax(&cur_section_bounds);
LISTBASE_FOREACH (uiBlock *, block, &region->uiblocks) {
if (!block->active) {
continue;
}
LISTBASE_FOREACH (uiBut *, but, &block->buttons) {
if (but->type == UI_BTYPE_SEPR_SPACER) {
/* Start a new section. */

View File

@@ -42,6 +42,7 @@ endif()
if(WITH_EXPERIMENTAL_FEATURES)
add_definitions(-DWITH_SIMULATION_DATABLOCK)
add_definitions(-DWITH_POINT_CLOUD)
add_definitions(-DWITH_GREASE_PENCIL_V3)
endif()
blender_add_lib(bf_editor_space_buttons "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")

View File

@@ -262,9 +262,11 @@ static bool buttons_context_path_data(ButsContextPath *path, int type)
if (RNA_struct_is_a(ptr->type, &RNA_GreasePencil) && ELEM(type, -1, OB_GPENCIL_LEGACY)) {
return true;
}
#ifdef WITH_GREASE_PENCIL_V3
if (RNA_struct_is_a(ptr->type, &RNA_GreasePencilv3) && ELEM(type, -1, OB_GREASE_PENCIL)) {
return true;
}
#endif
if (RNA_struct_is_a(ptr->type, &RNA_Curves) && ELEM(type, -1, OB_CURVES)) {
return true;
}
@@ -1172,10 +1174,12 @@ int /*eContextResult*/ buttons_context(const bContext *C,
set_pointer_type(path, result, &RNA_GreasePencil);
return CTX_RESULT_OK;
}
#ifdef WITH_GREASE_PENCIL_V3
if (CTX_data_equals(member, "grease_pencil")) {
set_pointer_type(path, result, &RNA_GreasePencilv3);
return CTX_RESULT_OK;
}
#endif
return CTX_RESULT_MEMBER_NOT_FOUND;
}

View File

@@ -941,6 +941,18 @@ static void image_tools_region_listener(const wmRegionListenerParams *params)
}
}
/************************* Tool header region **************************/
static void image_tools_header_region_draw(const bContext *C, ARegion *region)
{
ScrArea *area = CTX_wm_area(C);
SpaceImage *sima = static_cast<SpaceImage *>(area->spacedata.first);
image_user_refresh_scene(C, sima);
ED_region_header_with_button_sections(C, region, uiButtonSectionsAlign::Top);
}
/************************* header region **************************/
/* add handlers, stuff you only do once or on area/region changes */
@@ -1153,7 +1165,7 @@ void ED_spacetype_image()
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER;
art->listener = image_header_region_listener;
art->init = image_header_region_init;
art->draw = image_header_region_draw;
art->draw = image_tools_header_region_draw;
art->message_subscribe = ED_area_do_mgs_subscribe_for_tool_header;
BLI_addhead(&st->regiontypes, art);

View File

@@ -1253,6 +1253,8 @@ static void node_foreach_id(SpaceLink *space_link, LibraryForeachIDData *data)
}
}
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, snode->geometry_nodes_tool_tree, IDWALK_CB_USER_ONE);
/* Both `snode->id` and `snode->nodetree` have been remapped now, so their data can be
* accessed. */
BLI_assert(snode->id == nullptr || snode->nodetree == nullptr ||

View File

@@ -1501,6 +1501,7 @@ static void outliner_draw_restrictbuts(uiBlock *block,
UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK);
}
}
#ifdef WITH_GREASE_PENCIL_V3
else if (tselem->type == TSE_GREASE_PENCIL_NODE) {
bke::greasepencil::TreeNode &node =
tree_element_cast<TreeElementGreasePencilNode>(te)->node();
@@ -1538,6 +1539,7 @@ static void outliner_draw_restrictbuts(uiBlock *block,
}
}
}
#endif
else if (outliner_is_collection_tree_element(te)) {
PointerRNA collection_ptr;
PointerRNA layer_collection_ptr;

View File

@@ -1626,6 +1626,13 @@ typedef struct SpaceNode {
*/
char geometry_nodes_type;
/**
* Used as the editor's top-level node group for #SNODE_GEOMETRY_TOOL. This is stored in the
* node editor because it isn't part of the context otherwise, and it isn't meant to be set
* separately from the editor's regular node group.
*/
struct bNodeTree *geometry_nodes_tool_tree;
/** Grease-pencil data. */
struct bGPdata *gpd;

View File

@@ -4732,7 +4732,9 @@ static RNAProcessItem PROCESS_ITEMS[] = {
{"rna_dynamicpaint.cc", nullptr, RNA_def_dynamic_paint},
{"rna_fcurve.cc", "rna_fcurve_api.cc", RNA_def_fcurve},
{"rna_gpencil_legacy.cc", nullptr, RNA_def_gpencil},
#ifdef WITH_GREASE_PENCIL_V3
{"rna_grease_pencil.cc", nullptr, RNA_def_grease_pencil},
#endif
{"rna_curves.cc", nullptr, RNA_def_curves},
{"rna_image.cc", "rna_image_api.cc", RNA_def_image},
{"rna_key.cc", nullptr, RNA_def_key},

View File

@@ -484,7 +484,9 @@ StructRNA *ID_code_to_RNA_type(short idcode)
case ID_GD_LEGACY:
return &RNA_GreasePencil;
case ID_GP:
# ifdef WITH_GREASE_PENCIL_V3
return &RNA_GreasePencilv3;
# endif
break;
case ID_GR:
return &RNA_Collection;

View File

@@ -158,7 +158,9 @@ void RNA_def_depsgraph(struct BlenderRNA *brna);
void RNA_def_dynamic_paint(struct BlenderRNA *brna);
void RNA_def_fcurve(struct BlenderRNA *brna);
void RNA_def_gpencil(struct BlenderRNA *brna);
#ifdef WITH_GREASE_PENCIL_V3
void RNA_def_grease_pencil(struct BlenderRNA *brna);
#endif
void RNA_def_greasepencil_modifier(struct BlenderRNA *brna);
void RNA_def_shader_fx(struct BlenderRNA *brna);
void RNA_def_curves(struct BlenderRNA *brna);
@@ -500,7 +502,9 @@ void RNA_def_main_actions(BlenderRNA *brna, PropertyRNA *cprop);
void RNA_def_main_particles(BlenderRNA *brna, PropertyRNA *cprop);
void RNA_def_main_palettes(BlenderRNA *brna, PropertyRNA *cprop);
void RNA_def_main_gpencil_legacy(BlenderRNA *brna, PropertyRNA *cprop);
#ifdef WITH_GREASE_PENCIL_V3
void RNA_def_main_grease_pencil(BlenderRNA *brna, PropertyRNA *cprop);
#endif
void RNA_def_main_movieclips(BlenderRNA *brna, PropertyRNA *cprop);
void RNA_def_main_masks(BlenderRNA *brna, PropertyRNA *cprop);
void RNA_def_main_linestyles(BlenderRNA *brna, PropertyRNA *cprop);

View File

@@ -98,7 +98,9 @@ RNA_MAIN_LISTBASE_FUNCS_DEF(collections)
RNA_MAIN_LISTBASE_FUNCS_DEF(curves)
RNA_MAIN_LISTBASE_FUNCS_DEF(fonts)
RNA_MAIN_LISTBASE_FUNCS_DEF(gpencils)
# ifdef WITH_GREASE_PENCIL_V3
RNA_MAIN_LISTBASE_FUNCS_DEF(grease_pencils)
# endif
RNA_MAIN_LISTBASE_FUNCS_DEF(hair_curves)
RNA_MAIN_LISTBASE_FUNCS_DEF(images)
RNA_MAIN_LISTBASE_FUNCS_DEF(lattices)
@@ -340,12 +342,14 @@ void RNA_def_main(BlenderRNA *brna)
"Grease Pencil data-blocks",
# endif
RNA_def_main_gpencil_legacy},
# ifdef WITH_GREASE_PENCIL_V3
{"grease_pencils_v3",
"GreasePencilv3",
"rna_Main_grease_pencils_begin",
"Grease Pencil",
"Grease Pencil data-blocks",
RNA_def_main_grease_pencil},
# endif
{"movieclips",
"MovieClip",
"rna_Main_movieclips_begin",

View File

@@ -2041,6 +2041,7 @@ void RNA_def_main_gpencil_legacy(BlenderRNA *brna, PropertyRNA *cprop)
func, "do_ui_user", true, "", "Make sure interface does not reference this grease pencil");
}
#ifdef WITH_GREASE_PENCIL_V3
void RNA_def_main_grease_pencil(BlenderRNA *brna, PropertyRNA *cprop)
{
StructRNA *srna;
@@ -2050,6 +2051,7 @@ void RNA_def_main_grease_pencil(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_struct_sdna(srna, "Main");
RNA_def_struct_ui_text(srna, "Main Grease Pencils", "Collection of grease pencils");
}
#endif
void RNA_def_main_movieclips(BlenderRNA *brna, PropertyRNA *cprop)
{

View File

@@ -607,8 +607,10 @@ static StructRNA *rna_Object_data_typef(PointerRNA *ptr)
return &RNA_LightProbe;
case OB_GPENCIL_LEGACY:
return &RNA_GreasePencil;
# ifdef WITH_GREASE_PENCIL_V3
case OB_GREASE_PENCIL:
return &RNA_GreasePencilv3;
# endif
case OB_CURVES:
return &RNA_Curves;
case OB_POINTCLOUD:

View File

@@ -2507,6 +2507,22 @@ static void rna_SpaceNodeEditor_node_tree_set(PointerRNA *ptr,
ED_node_tree_start(snode, (bNodeTree *)value.data, nullptr, nullptr);
}
static bool rna_SpaceNodeEditor_geometry_nodes_tool_tree_poll(PointerRNA * /*ptr*/,
const PointerRNA value)
{
const bNodeTree &ntree = *static_cast<const bNodeTree *>(value.data);
if (ntree.type != NTREE_GEOMETRY) {
return false;
}
if (!ntree.geometry_node_asset_traits) {
return false;
}
if ((ntree.geometry_node_asset_traits->flag & GEO_NODE_ASSET_TOOL) == 0) {
return false;
}
return true;
}
static bool space_node_node_geometry_nodes_poll(const SpaceNode &snode, const bNodeTree &ntree)
{
switch (SpaceNodeGeometryNodesType(snode.geometry_nodes_type)) {
@@ -2547,20 +2563,6 @@ static bool rna_SpaceNodeEditor_node_tree_poll(PointerRNA *ptr, const PointerRNA
return true;
}
static void rna_SpaceNodeEditor_geometry_nodes_type_update(Main * /*bmain*/,
Scene * /*scene*/,
PointerRNA *ptr)
{
SpaceNode &snode = *static_cast<SpaceNode *>(ptr->data);
if (snode.nodetree) {
if (snode.nodetree->type == NTREE_GEOMETRY) {
if (!space_node_node_geometry_nodes_poll(snode, *snode.nodetree)) {
snode.nodetree = nullptr;
}
}
}
}
static void rna_SpaceNodeEditor_node_tree_update(const bContext *C, PointerRNA * /*ptr*/)
{
ED_node_tree_update(C);
@@ -7512,8 +7514,7 @@ static void rna_def_space_node(BlenderRNA *brna)
RNA_def_property_enum_items(prop, geometry_nodes_type_items);
RNA_def_property_ui_text(prop, "Geometry Nodes Type", "");
RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_ID);
RNA_def_property_update(
prop, NC_SPACE | ND_SPACE_NODE, "rna_SpaceNodeEditor_geometry_nodes_type_update");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_NODE, nullptr);
prop = RNA_def_property(srna, "id", PROP_POINTER, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
@@ -7561,6 +7562,13 @@ static void rna_def_space_node(BlenderRNA *brna)
RNA_def_property_update(
prop, NC_SPACE | ND_SPACE_NODE_VIEW, "rna_SpaceNodeEditor_show_backdrop_update");
prop = RNA_def_property(srna, "geometry_nodes_tool_tree", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_funcs(
prop, nullptr, nullptr, nullptr, "rna_SpaceNodeEditor_geometry_nodes_tool_tree_poll");
RNA_def_property_flag(prop, PROP_EDITABLE | PROP_CONTEXT_UPDATE);
RNA_def_property_ui_text(prop, "Node Tool Tree", "Node group to edit as node tool");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_NODE, "rna_SpaceNodeEditor_node_tree_update");
prop = RNA_def_property(srna, "show_annotation", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, nullptr, "flag", SNODE_SHOW_GPENCIL);
RNA_def_property_ui_text(prop, "Show Annotation", "Show annotations for this view");

View File

@@ -2114,10 +2114,12 @@ void RNA_api_ui_layout(StructRNA *srna)
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
api_ui_item_rna_common(func);
# ifdef WITH_GREASE_PENCIL_V3
func = RNA_def_function(
srna, "template_grease_pencil_layer_tree", "uiTemplateGreasePencilLayerTree");
RNA_def_function_ui_description(func, "View of the active grease pencil layer tree");
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
# endif
func = RNA_def_function(srna, "template_node_tree_interface", "uiTemplateNodeTreeInterface");
RNA_def_function_ui_description(func, "Show a node tree interface");

View File

@@ -35,7 +35,7 @@ static void geometry_node_tree_get_from_context(
{
const SpaceNode *snode = CTX_wm_space_node(C);
if (snode->geometry_nodes_type == SNODE_GEOMETRY_TOOL) {
*r_ntree = snode->nodetree;
*r_ntree = snode->geometry_nodes_tool_tree;
return;
}