Blender  V3.3
depsgraph_registry.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2019 Blender Foundation. All rights reserved. */
3 
9 
10 #include "BLI_utildefines.h"
11 
12 #include "intern/depsgraph.h"
13 
14 namespace blender::deg {
15 
18 {
19  static GraphRegistry graph_registry;
20  return graph_registry;
21 }
22 
24 {
25  Main *bmain = depsgraph->bmain;
27 }
28 
30 {
31  Main *bmain = depsgraph->bmain;
32  GraphRegistry &graph_registry = get_graph_registry();
33  VectorSet<Depsgraph *> &graphs = graph_registry.lookup(bmain);
34  graphs.remove(depsgraph);
35 
36  /* If this was the last depsgraph associated with the main, remove the main entry as well. */
37  if (graphs.is_empty()) {
38  graph_registry.remove(bmain);
39  }
40 }
41 
43 {
45  if (graphs != nullptr) {
46  return *graphs;
47  }
48  return {};
49 }
50 
51 } // namespace blender::deg
const Value & lookup(const Key &key) const
Definition: BLI_map.hh:485
Value & lookup_or_add_default(const Key &key)
Definition: BLI_map.hh:580
bool remove(const Key &key)
Definition: BLI_map.hh:323
const Value * lookup_ptr(const Key &key) const
Definition: BLI_map.hh:463
bool is_empty() const
bool remove(const Key &key)
const Depsgraph * depsgraph
Span< Depsgraph * > get_all_registered_graphs(Main *bmain)
static GraphRegistry & get_graph_registry()
void unregister_graph(Depsgraph *depsgraph)
void register_graph(Depsgraph *depsgraph)
Definition: BKE_main.h:121