Geometry Nodes: Operators: Support more object types and modes #109526
|
@ -258,15 +258,15 @@ class NewGeometryNodeTreeAssign(Operator):
|
|||
return {'FINISHED'}
|
||||
|
||||
|
||||
class NewGeometryNodeGroupOperator(Operator):
|
||||
"""Create a new geometry node group for an operator"""
|
||||
bl_idname = "node.new_geometry_node_group_operator"
|
||||
bl_label = "New Geometry Node Operator Group"
|
||||
class NewGeometryNodeGroupTool(Operator):
|
||||
"""Create a new geometry node group for an tool"""
|
||||
bl_idname = "node.new_geometry_node_group_tool"
|
||||
bl_label = "New Geometry Node Tool Group"
|
||||
bl_options = {'REGISTER', 'UNDO'}
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return context.space_data.type == 'NODE_EDITOR' and context.space_data.geometry_nodes_type == 'OPERATOR'
|
||||
return context.space_data.type == 'NODE_EDITOR' and context.space_data.geometry_nodes_type == 'TOOL'
|
||||
|
||||
def execute(self, context):
|
||||
group = geometry_node_group_empty_new()
|
||||
|
@ -476,7 +476,7 @@ class RepeatZoneItemMoveOperator(RepeatZoneOperator, Operator):
|
|||
classes = (
|
||||
NewGeometryNodesModifier,
|
||||
NewGeometryNodeTreeAssign,
|
||||
NewGeometryNodeGroupOperator,
|
||||
NewGeometryNodeGroupTool,
|
||||
MoveModifierToNodes,
|
||||
SimulationZoneItemAddOperator,
|
||||
SimulationZoneItemRemoveOperator,
|
||||
|
|
|
@ -163,7 +163,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_operator")
|
||||
layout.template_ID(snode, "node_tree", new="node.new_geometry_node_group_tool")
|
||||
else:
|
||||
# Custom node tree is edited as independent ID block
|
||||
NODE_MT_editor_menus.draw_collapsible(context, layout)
|
||||
|
@ -446,13 +446,13 @@ class NODE_PT_geometry_node_asset_traits(Panel):
|
|||
group = snode.node_tree
|
||||
|
||||
col = layout.column(heading="Type")
|
||||
col.prop(group, "is_operator")
|
||||
col.prop(group, "is_tool")
|
||||
col = layout.column(heading="Mode")
|
||||
col.active = group.is_operator
|
||||
col.active = group.is_tool
|
||||
col.prop(group, "is_mode_edit")
|
||||
col.prop(group, "is_mode_sculpt")
|
||||
col = layout.column(heading="Geometry")
|
||||
col.active = group.is_operator
|
||||
col.active = group.is_tool
|
||||
col.prop(group, "is_type_mesh")
|
||||
col.prop(group, "is_type_curve")
|
||||
if context.preferences.experimental.use_new_point_cloud_type:
|
||||
|
|
|
@ -423,15 +423,15 @@ static GeometryNodeAssetTraitFlag asset_flag_for_context(const eContextObjectMod
|
|||
{
|
||||
switch (ctx_mode) {
|
||||
case CTX_MODE_EDIT_MESH:
|
||||
return (GEO_NODE_ASSET_OPERATOR | GEO_NODE_ASSET_EDIT | GEO_NODE_ASSET_MESH);
|
||||
return (GEO_NODE_ASSET_TOOL | GEO_NODE_ASSET_EDIT | GEO_NODE_ASSET_MESH);
|
||||
case CTX_MODE_EDIT_CURVES:
|
||||
return (GEO_NODE_ASSET_OPERATOR | GEO_NODE_ASSET_EDIT | GEO_NODE_ASSET_CURVE);
|
||||
return (GEO_NODE_ASSET_TOOL | GEO_NODE_ASSET_EDIT | GEO_NODE_ASSET_CURVE);
|
||||
case CTX_MODE_EDIT_POINT_CLOUD:
|
||||
return (GEO_NODE_ASSET_OPERATOR | GEO_NODE_ASSET_EDIT | GEO_NODE_ASSET_POINT_CLOUD);
|
||||
return (GEO_NODE_ASSET_TOOL | GEO_NODE_ASSET_EDIT | GEO_NODE_ASSET_POINT_CLOUD);
|
||||
case CTX_MODE_SCULPT:
|
||||
return (GEO_NODE_ASSET_OPERATOR | GEO_NODE_ASSET_SCULPT | GEO_NODE_ASSET_MESH);
|
||||
return (GEO_NODE_ASSET_TOOL | GEO_NODE_ASSET_SCULPT | GEO_NODE_ASSET_MESH);
|
||||
case CTX_MODE_SCULPT_CURVES:
|
||||
return (GEO_NODE_ASSET_OPERATOR | GEO_NODE_ASSET_SCULPT | GEO_NODE_ASSET_CURVE);
|
||||
return (GEO_NODE_ASSET_TOOL | GEO_NODE_ASSET_SCULPT | GEO_NODE_ASSET_CURVE);
|
||||
default:
|
||||
BLI_assert_unreachable();
|
||||
return GeometryNodeAssetTraitFlag(0);
|
||||
|
|
|
@ -874,7 +874,7 @@ typedef struct GeometryNodeAssetTraits {
|
|||
} GeometryNodeAssetTraits;
|
||||
|
||||
typedef enum GeometryNodeAssetTraitFlag {
|
||||
GEO_NODE_ASSET_OPERATOR = (1 << 0),
|
||||
GEO_NODE_ASSET_TOOL = (1 << 0),
|
||||
GEO_NODE_ASSET_EDIT = (1 << 1),
|
||||
GEO_NODE_ASSET_SCULPT = (1 << 2),
|
||||
GEO_NODE_ASSET_MESH = (1 << 3),
|
||||
|
|
|
@ -2141,13 +2141,13 @@ static void geometry_node_asset_trait_flag_set(PointerRNA *ptr,
|
|||
SET_FLAG_FROM_TEST(ntree->geometry_node_asset_traits->flag, value, flag);
|
||||
}
|
||||
|
||||
static bool rna_GeometryNodeTree_is_operator_get(PointerRNA *ptr)
|
||||
static bool rna_GeometryNodeTree_is_tool_get(PointerRNA *ptr)
|
||||
{
|
||||
return geometry_node_asset_trait_flag_get(ptr, GEO_NODE_ASSET_OPERATOR);
|
||||
return geometry_node_asset_trait_flag_get(ptr, GEO_NODE_ASSET_TOOL);
|
||||
}
|
||||
static void rna_GeometryNodeTree_is_operator_set(PointerRNA *ptr, bool value)
|
||||
static void rna_GeometryNodeTree_is_tool_set(PointerRNA *ptr, bool value)
|
||||
{
|
||||
geometry_node_asset_trait_flag_set(ptr, GEO_NODE_ASSET_OPERATOR, value);
|
||||
geometry_node_asset_trait_flag_set(ptr, GEO_NODE_ASSET_TOOL, value);
|
||||
}
|
||||
|
||||
static bool rna_GeometryNodeTree_is_mode_edit_get(PointerRNA *ptr)
|
||||
|
@ -12399,12 +12399,12 @@ static void rna_def_geometry_nodetree(BlenderRNA *brna)
|
|||
RNA_def_struct_sdna(srna, "bNodeTree");
|
||||
RNA_def_struct_ui_icon(srna, ICON_NODETREE);
|
||||
|
||||
prop = RNA_def_property(srna, "is_operator", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, nullptr, "flag", GEO_NODE_ASSET_OPERATOR);
|
||||
prop = RNA_def_property(srna, "is_tool", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, nullptr, "flag", GEO_NODE_ASSET_TOOL);
|
||||
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
RNA_def_property_ui_text(prop, "Operator", "The node group is used as an operator");
|
||||
RNA_def_property_ui_text(prop, "Tool", "The node group is used as a tool");
|
||||
RNA_def_property_boolean_funcs(
|
||||
prop, "rna_GeometryNodeTree_is_operator_get", "rna_GeometryNodeTree_is_operator_set");
|
||||
prop, "rna_GeometryNodeTree_is_tool_get", "rna_GeometryNodeTree_is_tool_set");
|
||||
|
||||
prop = RNA_def_property(srna, "is_mode_edit", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, nullptr, "flag", GEO_NODE_ASSET_EDIT);
|
||||
|
|
Loading…
Reference in New Issue