Cleanup: Removed unused variables in bNodePanel

The flag in bNodePanel is anticipated to store settings such as whether
a panel is open or closed by default. It's not currently used, so for
now the flag is removed.

The next_panel_identifier in bNodeTree is also not needed any more. It
was used to set a unique identifier for each panel, which isn't needed.

Added comments to remaining fields in bNodePanel.

Pull Request: https://projects.blender.org/blender/blender/pulls/109028
This commit is contained in:
Lukas Tönne 2023-06-16 10:12:21 +02:00
parent 9535248911
commit e32f85c03e
4 changed files with 8 additions and 13 deletions

View File

@ -576,17 +576,15 @@ int ntreeGetPanelIndex(const bNodeTree *ntree, const bNodePanel *panel);
/**
* Add a new panel to the node tree.
* \param name: Name of the new panel.
* \param flag: Flags of the new panel.
*/
bNodePanel *ntreeAddPanel(bNodeTree *ntree, const char *name, int flag);
bNodePanel *ntreeAddPanel(bNodeTree *ntree, const char *name);
/**
* Insert a new panel in the node tree.
* \param name: Name of the new panel.
* \param flag: Flags of the new panel.
* \param index: Index at which to insert the panel.
*/
bNodePanel *ntreeInsertPanel(bNodeTree *ntree, const char *name, int flag, int index);
bNodePanel *ntreeInsertPanel(bNodeTree *ntree, const char *name, int index);
/** Remove a panel from the node tree. */
void ntreeRemovePanel(bNodeTree *ntree, bNodePanel *panel);

View File

@ -3854,7 +3854,7 @@ int ntreeGetPanelIndex(const bNodeTree *ntree, const bNodePanel *panel)
return ntree->panels().first_index_try(const_cast<bNodePanel *>(panel));
}
bNodePanel *ntreeAddPanel(bNodeTree *ntree, const char *name, int flag)
bNodePanel *ntreeAddPanel(bNodeTree *ntree, const char *name)
{
bNodePanel **old_panels_array = ntree->panels_array;
const Span<const bNodePanel *> old_panels = ntree->panels();
@ -3867,7 +3867,7 @@ bNodePanel *ntreeAddPanel(bNodeTree *ntree, const char *name, int flag)
new_panels.data());
bNodePanel *new_panel = MEM_cnew<bNodePanel>(__func__);
*new_panel = {BLI_strdup(name), flag, ntree->next_panel_identifier++};
*new_panel = {BLI_strdup(name)};
new_panels[new_panels.size() - 1] = new_panel;
MEM_SAFE_FREE(old_panels_array);
@ -3877,7 +3877,7 @@ bNodePanel *ntreeAddPanel(bNodeTree *ntree, const char *name, int flag)
return new_panel;
}
bNodePanel *ntreeInsertPanel(bNodeTree *ntree, const char *name, int flag, int index)
bNodePanel *ntreeInsertPanel(bNodeTree *ntree, const char *name, int index)
{
if (!blender::IndexRange(ntree->panels().size() + 1).contains(index)) {
return nullptr;
@ -3899,7 +3899,7 @@ bNodePanel *ntreeInsertPanel(bNodeTree *ntree, const char *name, int flag, int i
new_panels.drop_front(index + 1).data());
bNodePanel *new_panel = MEM_cnew<bNodePanel>(__func__);
*new_panel = {BLI_strdup(name), flag, ntree->next_panel_identifier++};
*new_panel = {BLI_strdup(name)};
new_panels[index] = new_panel;
MEM_SAFE_FREE(old_panels_array);

View File

@ -536,9 +536,8 @@ typedef struct bNodeLink {
/** Panel in node tree for grouping sockets. */
typedef struct bNodePanel {
/* UI name of the panel (not unique) */
char *name;
int flag;
int _pad;
} bNodePanel;
/* the basis for a Node tree, all links and nodes reside internal here */
@ -608,8 +607,6 @@ typedef struct bNodeTree {
struct bNodePanel **panels_array;
int panels_num;
int active_panel;
int next_panel_identifier;
char _pad2[4];
bNodeTreeRuntimeHandle *runtime;

View File

@ -3320,7 +3320,7 @@ static bNodePanel *rna_NodeTree_panels_new(bNodeTree *ntree,
ReportList *reports,
const char *name)
{
bNodePanel *panel = ntreeAddPanel(ntree, name, 0);
bNodePanel *panel = ntreeAddPanel(ntree, name);
if (panel == nullptr) {
BKE_report(reports, RPT_ERROR, "Unable to create panel");