Blender  V3.3
depsgraph_relation.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2020 Blender Foundation. All rights reserved. */
3 
8 #include "intern/depsgraph_relation.h" /* own include */
9 
10 #include "BLI_utildefines.h"
11 
12 #include "intern/depsgraph_type.h"
13 #include "intern/node/deg_node.h"
14 
15 namespace blender::deg {
16 
17 Relation::Relation(Node *from, Node *to, const char *description)
18  : from(from), to(to), name(description), flag(0)
19 {
20  /* Hook it up to the nodes which use it.
21  *
22  * NOTE: We register relation in the nodes which this link connects to here
23  * in constructor but we don't un-register it in the destructor.
24  *
25  * Reasoning:
26  *
27  * - Destructor is currently used on global graph destruction, so there's no
28  * real need in avoiding dangling pointers, all the memory is to be freed
29  * anyway.
30  *
31  * - Un-registering relation is not a cheap operation, so better to have it
32  * as an explicit call if we need this. */
33  from->outlinks.append(this);
34  to->inlinks.append(this);
35 }
36 
38 {
39  /* Sanity check. */
40  BLI_assert(from != nullptr && to != nullptr);
41 }
42 
44 {
45  /* Sanity check. */
46  BLI_assert(from != nullptr && to != nullptr);
49 }
50 
51 } // namespace blender::deg
#define BLI_assert(a)
Definition: BLI_assert.h:46
void append(const T &value)
Definition: BLI_vector.hh:433
void remove_first_occurrence_and_reorder(const T &value)
Definition: BLI_vector.hh:761
StackEntry * from
Relations inlinks
Definition: deg_node.h:173
Relations outlinks
Definition: deg_node.h:174
Relation(Node *from, Node *to, const char *description)