Nodes: Panel declarations for grouping sockets #108649
|
@ -115,7 +115,6 @@ set(SRC_DNA_DEFAULTS_INC
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_meta_defaults.h
|
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_meta_defaults.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_modifier_defaults.h
|
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_modifier_defaults.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_movieclip_defaults.h
|
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_movieclip_defaults.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_node_defaults.h
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_object_defaults.h
|
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_object_defaults.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_particle_defaults.h
|
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_particle_defaults.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_pointcloud_defaults.h
|
${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_pointcloud_defaults.h
|
||||||
|
|
|
@ -677,6 +677,7 @@ static void direct_link_node_socket(BlendDataReader *reader, bNodeSocket *sock)
|
||||||
BLO_read_data_address(reader, &sock->storage);
|
BLO_read_data_address(reader, &sock->storage);
|
||||||
BLO_read_data_address(reader, &sock->default_value);
|
BLO_read_data_address(reader, &sock->default_value);
|
||||||
BLO_read_data_address(reader, &sock->default_attribute_name);
|
BLO_read_data_address(reader, &sock->default_attribute_name);
|
||||||
|
BLO_read_data_address(reader, &sock->panel);
|
||||||
sock->runtime = MEM_new<bNodeSocketRuntime>(__func__);
|
sock->runtime = MEM_new<bNodeSocketRuntime>(__func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3651,16 +3652,21 @@ static bNodeSocket *make_socket_interface(bNodeTree *ntree,
|
||||||
STRNCPY(sock->name, name);
|
STRNCPY(sock->name, name);
|
||||||
sock->storage = nullptr;
|
sock->storage = nullptr;
|
||||||
sock->flag |= SOCK_COLLAPSED;
|
sock->flag |= SOCK_COLLAPSED;
|
||||||
sock->panel_id = -1;
|
|
||||||
|
|
||||||
return sock;
|
return sock;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int node_socket_panel_cmp(const void *a, const void *b)
|
using PanelIndexMap = blender::Map<const bNodeSocketPanel *, int>;
|
||||||
|
|
||||||
|
static int node_socket_panel_cmp(void *panel_index_map_v, const void *a, const void *b)
|
||||||
{
|
{
|
||||||
|
const PanelIndexMap &panel_index_map = *static_cast<const PanelIndexMap *>(panel_index_map_v);
|
||||||
const bNodeSocket *sock_a = static_cast<const bNodeSocket *>(a);
|
const bNodeSocket *sock_a = static_cast<const bNodeSocket *>(a);
|
||||||
const bNodeSocket *sock_b = static_cast<const bNodeSocket *>(b);
|
const bNodeSocket *sock_b = static_cast<const bNodeSocket *>(b);
|
||||||
return (sock_a->panel_id > sock_b->panel_id) ? 1 : 0;
|
return panel_index_map.lookup_default(sock_a->panel, -1) >
|
||||||
|
panel_index_map.lookup_default(sock_b->panel, -1) ?
|
||||||
|
1 :
|
||||||
|
0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bNodeSocket *ntreeFindSocketInterface(bNodeTree *ntree,
|
bNodeSocket *ntreeFindSocketInterface(bNodeTree *ntree,
|
||||||
|
@ -3680,30 +3686,14 @@ bNodeSocket *ntreeFindSocketInterface(bNodeTree *ntree,
|
||||||
|
|
||||||
void ntreeEnsureSocketInterfacePanelOrder(bNodeTree *ntree)
|
void ntreeEnsureSocketInterfacePanelOrder(bNodeTree *ntree)
|
||||||
{
|
{
|
||||||
/* XXX Hack: store panel index in panel_id temporarily for sorting. */
|
/* Store panel index for sorting. */
|
||||||
LISTBASE_FOREACH (bNodeSocket *, iosock, &ntree->inputs) {
|
blender::Map<const bNodeSocketPanel *, int> panel_index_map;
|
||||||
const bNodeSocketPanel *panel = ntreeFindSocketPanelByID(ntree, iosock->panel_id);
|
int index = 0;
|
||||||
iosock->panel_id = ntreeGetSocketPanelIndex(ntree, panel);
|
for (const bNodeSocketPanel *panel : ntree->socket_panels()) {
|
||||||
}
|
panel_index_map.add_new(panel, index++);
|
||||||
LISTBASE_FOREACH (bNodeSocket *, iosock, &ntree->outputs) {
|
|
||||||
const bNodeSocketPanel *panel = ntreeFindSocketPanelByID(ntree, iosock->panel_id);
|
|
||||||
iosock->panel_id = ntreeGetSocketPanelIndex(ntree, panel);
|
|
||||||
}
|
|
||||||
BLI_listbase_sort(&ntree->inputs, blender::bke::node_socket_panel_cmp);
|
|
||||||
BLI_listbase_sort(&ntree->outputs, blender::bke::node_socket_panel_cmp);
|
|
||||||
/* Restore panel_id. */
|
|
||||||
LISTBASE_FOREACH (bNodeSocket *, iosock, &ntree->inputs) {
|
|
||||||
if (iosock->panel_id >= 0) {
|
|
||||||
const bNodeSocketPanel *panel = ntree->socket_panels()[iosock->panel_id];
|
|
||||||
iosock->panel_id = panel->identifier;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
LISTBASE_FOREACH (bNodeSocket *, iosock, &ntree->outputs) {
|
|
||||||
if (iosock->panel_id >= 0) {
|
|
||||||
const bNodeSocketPanel *panel = ntree->socket_panels()[iosock->panel_id];
|
|
||||||
iosock->panel_id = panel->identifier;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
BLI_listbase_sort_r(&ntree->inputs, blender::bke::node_socket_panel_cmp, &panel_index_map);
|
||||||
|
BLI_listbase_sort_r(&ntree->outputs, blender::bke::node_socket_panel_cmp, &panel_index_map);
|
||||||
}
|
}
|
||||||
|
|
||||||
bNodeSocket *ntreeAddSocketInterface(bNodeTree *ntree,
|
bNodeSocket *ntreeAddSocketInterface(bNodeTree *ntree,
|
||||||
|
@ -3727,15 +3717,11 @@ bNodeSocket *ntreeAddSocketInterface(bNodeTree *ntree,
|
||||||
|
|
||||||
void ntreeSetSocketInterfacePanel(bNodeTree *ntree, bNodeSocket *socket, bNodeSocketPanel *panel)
|
void ntreeSetSocketInterfacePanel(bNodeTree *ntree, bNodeSocket *socket, bNodeSocketPanel *panel)
|
||||||
{
|
{
|
||||||
if (panel == NULL) {
|
BLI_assert(panel == nullptr || ntreeContainsSocketPanel(ntree, panel));
|
||||||
socket->panel_id = -1;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
socket->panel_id = panel->identifier;
|
socket->panel = panel;
|
||||||
|
|
||||||
ntreeEnsureSocketInterfacePanelOrder(ntree);
|
ntreeEnsureSocketInterfacePanelOrder(ntree);
|
||||||
|
|
||||||
BKE_ntree_update_tag_interface(ntree);
|
BKE_ntree_update_tag_interface(ntree);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3896,6 +3882,18 @@ void ntreeRemoveSocketPanel(bNodeTree *ntree, bNodeSocketPanel *panel)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Remove references */
|
||||||
|
LISTBASE_FOREACH (bNodeSocket *, iosock, &ntree->inputs) {
|
||||||
|
if (iosock->panel == panel) {
|
||||||
|
iosock->panel = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LISTBASE_FOREACH (bNodeSocket *, iosock, &ntree->outputs) {
|
||||||
|
if (iosock->panel == panel) {
|
||||||
|
iosock->panel = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bNodeSocketPanel **old_panels_array = ntree->socket_panels_array;
|
bNodeSocketPanel **old_panels_array = ntree->socket_panels_array;
|
||||||
const Span<bNodeSocketPanel *> old_panels = ntree->socket_panels();
|
const Span<bNodeSocketPanel *> old_panels = ntree->socket_panels();
|
||||||
ntree->socket_panels_array = MEM_cnew_array<bNodeSocketPanel *>(ntree->socket_panels_num - 1,
|
ntree->socket_panels_array = MEM_cnew_array<bNodeSocketPanel *>(ntree->socket_panels_num - 1,
|
||||||
|
@ -3917,6 +3915,14 @@ void ntreeRemoveSocketPanel(bNodeTree *ntree, bNodeSocketPanel *panel)
|
||||||
|
|
||||||
void ntreeClearSocketPanels(bNodeTree *ntree)
|
void ntreeClearSocketPanels(bNodeTree *ntree)
|
||||||
{
|
{
|
||||||
|
/* Remove references */
|
||||||
|
LISTBASE_FOREACH (bNodeSocket *, iosock, &ntree->inputs) {
|
||||||
|
iosock->panel = nullptr;
|
||||||
|
}
|
||||||
|
LISTBASE_FOREACH (bNodeSocket *, iosock, &ntree->outputs) {
|
||||||
|
iosock->panel = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
for (bNodeSocketPanel *panel : ntree->socket_panels_for_write()) {
|
for (bNodeSocketPanel *panel : ntree->socket_panels_for_write()) {
|
||||||
MEM_SAFE_FREE(panel->name);
|
MEM_SAFE_FREE(panel->name);
|
||||||
MEM_SAFE_FREE(panel);
|
MEM_SAFE_FREE(panel);
|
||||||
|
|
|
@ -212,18 +212,6 @@ void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain)
|
||||||
}
|
}
|
||||||
FOREACH_NODETREE_END;
|
FOREACH_NODETREE_END;
|
||||||
|
|
||||||
if (!DNA_struct_elem_find(fd->filesdna, "bNodeSocket", "int", "panel_id")) {
|
|
||||||
FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
|
|
||||||
LISTBASE_FOREACH (bNodeSocket *, socket, &ntree->inputs) {
|
|
||||||
socket->panel_id = -1;
|
|
||||||
}
|
|
||||||
LISTBASE_FOREACH (bNodeSocket *, socket, &ntree->outputs) {
|
|
||||||
socket->panel_id = -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
FOREACH_NODETREE_END;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Keep this block, even when empty. */
|
/* Keep this block, even when empty. */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2199,7 +2199,7 @@ static int ntree_socket_add_exec(bContext *C, wmOperator *op)
|
||||||
/* XXX this only works for actual sockets, not interface templates! */
|
/* XXX this only works for actual sockets, not interface templates! */
|
||||||
// nodeSocketCopyValue(sock, &ntree_ptr, active_sock, &ntree_ptr);
|
// nodeSocketCopyValue(sock, &ntree_ptr, active_sock, &ntree_ptr);
|
||||||
/* Inherit socket panel from the active socket interface. */
|
/* Inherit socket panel from the active socket interface. */
|
||||||
sock->panel_id = active_sock->panel_id;
|
sock->panel = active_sock->panel;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* XXX TODO: define default socket type for a tree! */
|
/* XXX TODO: define default socket type for a tree! */
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
||||||
|
|
||||||
/** \file
|
|
||||||
* \ingroup DNA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
/* Struct members on own line. */
|
|
||||||
/* clang-format off */
|
|
||||||
|
|
||||||
/* -------------------------------------------------------------------- */
|
|
||||||
/** \name bArmature Struct
|
|
||||||
* \{ */
|
|
||||||
|
|
||||||
#define _DNA_DEFAULT_bNodeSocket \
|
|
||||||
{ \
|
|
||||||
.panel_id = -1, \
|
|
||||||
}
|
|
||||||
|
|
||||||
/** \} */
|
|
||||||
|
|
||||||
/* clang-format on */
|
|
|
@ -168,9 +168,8 @@ typedef struct bNodeSocket {
|
||||||
/** Custom data for inputs, only UI writes in this. */
|
/** Custom data for inputs, only UI writes in this. */
|
||||||
bNodeStack ns DNA_DEPRECATED;
|
bNodeStack ns DNA_DEPRECATED;
|
||||||
|
|
||||||
/* ID of the UI panel of the socket. */
|
/* UI panel of the socket. */
|
||||||
int panel_id;
|
struct bNodeSocketPanel *panel;
|
||||||
int _pad2;
|
|
||||||
|
|
||||||
bNodeSocketRuntimeHandle *runtime;
|
bNodeSocketRuntimeHandle *runtime;
|
||||||
|
|
||||||
|
|
|
@ -126,7 +126,6 @@
|
||||||
#include "DNA_meta_defaults.h"
|
#include "DNA_meta_defaults.h"
|
||||||
#include "DNA_modifier_defaults.h"
|
#include "DNA_modifier_defaults.h"
|
||||||
#include "DNA_movieclip_defaults.h"
|
#include "DNA_movieclip_defaults.h"
|
||||||
#include "DNA_node_defaults.h"
|
|
||||||
#include "DNA_object_defaults.h"
|
#include "DNA_object_defaults.h"
|
||||||
#include "DNA_particle_defaults.h"
|
#include "DNA_particle_defaults.h"
|
||||||
#include "DNA_pointcloud_defaults.h"
|
#include "DNA_pointcloud_defaults.h"
|
||||||
|
|
|
@ -3169,17 +3169,6 @@ static IDProperty **rna_NodeSocketInterface_idprops(PointerRNA *ptr)
|
||||||
return &sock->prop;
|
return &sock->prop;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PointerRNA rna_NodeSocketInterface_panel_get(PointerRNA *ptr)
|
|
||||||
{
|
|
||||||
bNodeSocket *socket = (bNodeSocket *)ptr->data;
|
|
||||||
bNodeTree *ntree = (bNodeTree *)ptr->owner_id;
|
|
||||||
bNodeSocketPanel *panel = ntreeFindSocketPanelByID(ntree, socket->panel_id);
|
|
||||||
|
|
||||||
PointerRNA r_ptr;
|
|
||||||
RNA_pointer_create(&ntree->id, &RNA_NodeSocketPanel, panel, &r_ptr);
|
|
||||||
return r_ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void rna_NodeSocketInterface_panel_set(PointerRNA *ptr,
|
static void rna_NodeSocketInterface_panel_set(PointerRNA *ptr,
|
||||||
PointerRNA value,
|
PointerRNA value,
|
||||||
struct ReportList *reports)
|
struct ReportList *reports)
|
||||||
|
@ -11742,7 +11731,7 @@ static void rna_def_node_socket_interface(BlenderRNA *brna)
|
||||||
|
|
||||||
prop = RNA_def_property(srna, "panel", PROP_POINTER, PROP_NONE);
|
prop = RNA_def_property(srna, "panel", PROP_POINTER, PROP_NONE);
|
||||||
RNA_def_property_pointer_funcs(prop,
|
RNA_def_property_pointer_funcs(prop,
|
||||||
"rna_NodeSocketInterface_panel_get",
|
NULL,
|
||||||
"rna_NodeSocketInterface_panel_set",
|
"rna_NodeSocketInterface_panel_set",
|
||||||
NULL,
|
NULL,
|
||||||
"rna_NodeSocketInterface_panel_poll");
|
"rna_NodeSocketInterface_panel_poll");
|
||||||
|
|
Loading…
Reference in New Issue