Blender V5.0
main_invariants.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2024 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
7
8#include "DEG_depsgraph.hh"
9
10#include "DNA_node_types.h"
11
12#include "WM_api.hh"
13#include "WM_types.hh"
14#include <optional>
15
17{
19
20 if (ntree->type == NTREE_SHADER && id != nullptr) {
21 if (GS(id->name) == ID_MA) {
23 }
24 else if (GS(id->name) == ID_LA) {
26 }
27 else if (GS(id->name) == ID_WO) {
29 }
30 }
31 else if (ntree->type == NTREE_COMPOSIT) {
33 }
34 else if (ntree->type == NTREE_TEXTURE) {
36 }
37 else if (ntree->type == NTREE_GEOMETRY) {
39 }
40}
41
43 const std::optional<blender::Span<ID *>> modified_ids)
44{
46 params.tree_changed_fn = [](bNodeTree &ntree, ID &owner_id) {
49 };
50 params.tree_output_changed_fn = [](bNodeTree &ntree, ID & /*owner_id*/) {
52 };
53
54 std::optional<blender::Vector<bNodeTree *>> modified_trees;
55 if (modified_ids.has_value()) {
56 modified_trees.emplace();
57 for (ID *id : *modified_ids) {
58 if (GS(id->name) == ID_NT) {
59 modified_trees->append(reinterpret_cast<bNodeTree *>(id));
60 }
61 }
62 }
63
64 BKE_ntree_update(bmain, modified_trees, params);
65}
66
67void BKE_main_ensure_invariants(Main &bmain, const std::optional<blender::Span<ID *>> modified_ids)
68{
69 propagate_node_tree_changes(bmain, modified_ids);
70}
71
72void BKE_main_ensure_invariants(Main &bmain, ID &modified_id)
73{
74 BKE_main_ensure_invariants(bmain, {{&modified_id}});
75}
void BKE_ntree_update(Main &bmain, std::optional< blender::Span< bNodeTree * > > modified_trees=std::nullopt, const NodeTreeUpdateExtraParams &params={})
void DEG_id_tag_update(ID *id, unsigned int flags)
@ ID_RECALC_SYNC_TO_EVAL
Definition DNA_ID.h:1118
@ ID_RECALC_NTREE_OUTPUT
Definition DNA_ID.h:1155
@ ID_NT
@ ID_LA
@ ID_WO
@ ID_MA
@ NTREE_TEXTURE
@ NTREE_SHADER
@ NTREE_GEOMETRY
@ NTREE_COMPOSIT
#define NC_WORLD
Definition WM_types.hh:387
#define ND_SHADING
Definition WM_types.hh:477
#define ND_WORLD
Definition WM_types.hh:452
#define NC_NODE
Definition WM_types.hh:394
#define NC_SCENE
Definition WM_types.hh:378
#define ND_NODES
Definition WM_types.hh:436
#define ND_MODIFIER
Definition WM_types.hh:462
#define NA_EDITED
Definition WM_types.hh:584
#define NC_MATERIAL
Definition WM_types.hh:380
#define NC_LAMP
Definition WM_types.hh:382
#define NC_TEXTURE
Definition WM_types.hh:381
#define ND_LIGHTING
Definition WM_types.hh:483
#define NC_OBJECT
Definition WM_types.hh:379
#define GS(x)
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
void BKE_main_ensure_invariants(Main &bmain, const std::optional< blender::Span< ID * > > modified_ids)
static void send_notifiers_after_node_tree_change(ID *id, bNodeTree *ntree)
static void propagate_node_tree_changes(Main &bmain, const std::optional< blender::Span< ID * > > modified_ids)
Definition DNA_ID.h:414
char name[258]
Definition DNA_ID.h:432
void WM_main_add_notifier(uint type, void *reference)