Blender  V3.3
procedural.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: Apache-2.0
2  * Copyright 2011-2022 Blender Foundation */
3 
4 #pragma once
5 
6 #include "graph/node.h"
7 
9 
10 class Progress;
11 class Scene;
12 
13 /* A Procedural is a Node which can create other Nodes before rendering starts.
14  *
15  * The Procedural is supposed to be the owner of any nodes that it creates. It can also create
16  * Nodes directly in the Scene (through Scene.create_node), it should still be set as the owner of
17  * those Nodes.
18  */
19 class Procedural : public Node, public NodeOwner {
20  public:
22 
23  explicit Procedural(const NodeType *type);
24  virtual ~Procedural();
25 
26  /* Called each time the ProceduralManager is tagged for an update, this function is the entry
27  * point for the data generated by this Procedural. */
28  virtual void generate(Scene *scene, Progress &progress) = 0;
29 
30  /* Create a node and set this Procedural as the owner. */
31  template<typename T> T *create_node()
32  {
33  T *node = new T();
34  node->set_owner(this);
35  return node;
36  }
37 
38  /* Delete a Node created and owned by this Procedural. */
39  template<typename T> void delete_node(T *node)
40  {
41  assert(node->get_owner() == this);
42  delete node;
43  }
44 };
45 
47  bool need_update_;
48 
49  public:
52 
53  void update(Scene *scene, Progress &progress);
54 
55  void tag_update();
56 
57  bool need_update() const;
58 };
59 
bool need_update() const
Definition: procedural.cpp:70
void update(Scene *scene, Progress &progress)
Definition: procedural.cpp:36
virtual ~Procedural()
Definition: procedural.cpp:23
virtual void generate(Scene *scene, Progress &progress)=0
T * create_node()
Definition: procedural.h:31
void delete_node(T *node)
Definition: procedural.h:39
NODE_ABSTRACT_DECLARE Procedural(const NodeType *type)
Definition: procedural.cpp:19
#define CCL_NAMESPACE_END
Definition: cuda/compat.h:9
OperationNode * node
Scene scene
#define T
#define NODE_ABSTRACT_DECLARE
Definition: node_type.h:153
const NodeType * type
Definition: graph/node.h:175