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