Blender  V2.93
procedural.h
Go to the documentation of this file.
1 /*
2  * Copyright 2011-2018 Blender Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include "graph/node.h"
20 
22 
23 class Progress;
24 class Scene;
25 
26 /* A Procedural is a Node which can create other Nodes before rendering starts.
27  *
28  * The Procedural is supposed to be the owner of any nodes that it creates. It can also create
29  * Nodes directly in the Scene (through Scene.create_node), it should still be set as the owner of
30  * those Nodes.
31  */
32 class Procedural : public Node, public NodeOwner {
33  public:
35 
36  explicit Procedural(const NodeType *type);
37  virtual ~Procedural();
38 
39  /* Called each time the ProceduralManager is tagged for an update, this function is the entry
40  * point for the data generated by this Procedural. */
41  virtual void generate(Scene *scene, Progress &progress) = 0;
42 
43  /* Create a node and set this Procedural as the owner. */
44  template<typename T> T *create_node()
45  {
46  T *node = new T();
47  node->set_owner(this);
48  return node;
49  }
50 
51  /* Delete a Node created and owned by this Procedural. */
52  template<typename T> void delete_node(T *node)
53  {
54  assert(node->get_owner() == this);
55  delete node;
56  }
57 };
58 
60  bool need_update_;
61 
62  public:
65 
66  void update(Scene *scene, Progress &progress);
67 
68  void tag_update();
69 
70  bool need_update() const;
71 };
72 
bool need_update() const
Definition: procedural.cpp:84
void update(Scene *scene, Progress &progress)
Definition: procedural.cpp:50
virtual ~Procedural()
Definition: procedural.cpp:37
virtual void generate(Scene *scene, Progress &progress)=0
T * create_node()
Definition: procedural.h:44
void delete_node(T *node)
Definition: procedural.h:52
NODE_ABSTRACT_DECLARE Procedural(const NodeType *type)
Definition: procedural.cpp:33
OperationNode * node
Scene scene
#define CCL_NAMESPACE_END
#define T
#define NODE_ABSTRACT_DECLARE
Definition: node_type.h:166
Definition: node.h:94
Definition: node.h:98
const NodeType * type
Definition: node.h:175