WIP: Subtype for input function nodes #107010
|
@ -1325,6 +1325,7 @@ typedef struct NodeInputInt {
|
|||
|
||||
typedef struct NodeInputVector {
|
||||
float vector[3];
|
||||
int subtype;
|
||||
} NodeInputVector;
|
||||
|
||||
typedef struct NodeInputColor {
|
||||
|
|
|
@ -592,6 +592,8 @@ void RNA_collection_clear(PointerRNA *ptr, const char *name);
|
|||
} \
|
||||
((void)0)
|
||||
|
||||
void RNA_property_subtype_set(PointerRNA *ptr, const char *propname, PropertySubType value);
|
||||
|
||||
/**
|
||||
* Check if the #IDproperty exists, for operators.
|
||||
*
|
||||
|
|
|
@ -5380,6 +5380,12 @@ bool RNA_collection_is_empty(PointerRNA *ptr, const char *name)
|
|||
return false;
|
||||
}
|
||||
|
||||
void RNA_property_subtype_set(PointerRNA *ptr, const char *propname, PropertySubType value)
|
||||
{
|
||||
PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
|
||||
prop->subtype = value;
|
||||
}
|
||||
|
||||
bool RNA_property_is_set_ex(PointerRNA *ptr, PropertyRNA *prop, bool use_ghost)
|
||||
{
|
||||
prop = rna_ensure_property(prop);
|
||||
|
|
|
@ -2448,6 +2448,13 @@ static void rna_Node_update_relations(Main *bmain, Scene *scene, PointerRNA *ptr
|
|||
DEG_relations_tag_update(bmain);
|
||||
}
|
||||
|
||||
static void rna_Node_update_individual(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
|
||||
{
|
||||
bNodeTree *ntree = (bNodeTree *)ptr->owner_id;
|
||||
bNode *node = (bNode *)ptr->data;
|
||||
node->typeinfo->updatefunc(ntree, node);
|
||||
}
|
||||
|
||||
static void rna_Node_socket_value_update(ID *id, bNode *UNUSED(node), bContext *C)
|
||||
{
|
||||
BKE_ntree_update_tag_all((bNodeTree *)id);
|
||||
|
@ -5172,6 +5179,13 @@ static void def_fn_input_vector(StructRNA *srna)
|
|||
RNA_def_property_float_sdna(prop, NULL, "vector");
|
||||
RNA_def_property_ui_text(prop, "Vector", "");
|
||||
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
|
||||
|
||||
const EnumPropertyItem *rna_input_vector_subtype = rna_enum_property_subtype_number_array_items;
|
||||
prop = RNA_def_property(srna, "subtype", PROP_ENUM, PROP_XYZ);
|
||||
RNA_def_property_enum_sdna(prop, NULL, "subtype");
|
||||
RNA_def_property_enum_items(prop, rna_input_vector_subtype);
|
||||
RNA_def_property_ui_text(prop, "Subtype", "");
|
||||
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update_individual");
|
||||
}
|
||||
|
||||
static void def_fn_input_string(StructRNA *srna)
|
||||
|
|
|
@ -14,6 +14,7 @@ set(INC
|
|||
../../makesrna
|
||||
../../windowmanager
|
||||
../../../../intern/guardedalloc
|
||||
${CMAKE_BINARY_DIR}/source/blender/makesrna
|
||||
)
|
||||
|
||||
set(INC_SYS
|
||||
|
|
|
@ -4,22 +4,46 @@
|
|||
|
||||
#include "BLI_hash.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
#include "RNA_prototypes.h"
|
||||
|
||||
#include "UI_interface.h"
|
||||
#include "UI_resources.h"
|
||||
|
||||
namespace blender::nodes::node_fn_input_vector_cc {
|
||||
|
||||
NODE_STORAGE_FUNCS(NodeInputVector)
|
||||
|
||||
static void node_declare(NodeDeclarationBuilder &b)
|
||||
{
|
||||
b.add_output<decl::Vector>(N_("Vector"));
|
||||
}
|
||||
|
||||
static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
|
||||
static void node_layout_share(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
|
||||
{
|
||||
uiLayout *col = uiLayoutColumn(layout, true);
|
||||
uiItemR(col, ptr, "vector", UI_ITEM_R_EXPAND, "", ICON_NONE);
|
||||
}
|
||||
|
||||
static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
|
||||
{
|
||||
node_layout_share(layout, nullptr, ptr);
|
||||
}
|
||||
|
||||
static void node_layout_ex(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
|
||||
{
|
||||
uiItemR(layout, ptr, "subtype", UI_ITEM_R_SPLIT_EMPTY_NAME, IFACE_("Subtype"), ICON_NONE);
|
||||
node_layout_share(layout, nullptr, ptr);
|
||||
}
|
||||
|
||||
static void node_update(bNodeTree *ntree, bNode *node) {
|
||||
NodeInputVector *data = static_cast<NodeInputVector *>(node->storage);
|
||||
|
||||
PointerRNA ptr;
|
||||
RNA_pointer_create(&ntree->id, &RNA_Node, node, &ptr);
|
||||
RNA_property_subtype_set(&ptr, "vector", static_cast<PropertySubType>(data->subtype));
|
||||
}
|
||||
|
||||
static void node_build_multi_function(NodeMultiFunctionBuilder &builder)
|
||||
{
|
||||
const bNode &bnode = builder.node();
|
||||
|
@ -31,6 +55,7 @@ static void node_build_multi_function(NodeMultiFunctionBuilder &builder)
|
|||
static void node_init(bNodeTree * /*tree*/, bNode *node)
|
||||
{
|
||||
NodeInputVector *data = MEM_cnew<NodeInputVector>(__func__);
|
||||
data->subtype = PROP_XYZ;
|
||||
node->storage = data;
|
||||
}
|
||||
|
||||
|
@ -49,5 +74,7 @@ void register_node_type_fn_input_vector()
|
|||
&ntype, "NodeInputVector", node_free_standard_storage, node_copy_standard_storage);
|
||||
ntype.build_multi_function = file_ns::node_build_multi_function;
|
||||
ntype.draw_buttons = file_ns::node_layout;
|
||||
ntype.draw_buttons_ex = file_ns::node_layout_ex;
|
||||
ntype.updatefunc = file_ns::node_update;
|
||||
nodeRegisterType(&ntype);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue