Blender  V2.93
procedural.cpp
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 #include "procedural.h"
18 
19 #include "render/scene.h"
20 #include "render/stats.h"
21 
22 #include "util/util_foreach.h"
23 #include "util/util_progress.h"
24 
26 
28 {
29  NodeType *type = NodeType::add("procedural_base", NULL);
30  return type;
31 }
32 
34 {
35 }
36 
38 {
39 }
40 
42 {
43  need_update_ = true;
44 }
45 
47 {
48 }
49 
51 {
52  if (!need_update()) {
53  return;
54  }
55 
56  progress.set_status("Updating Procedurals");
57 
58  scoped_callback_timer timer([scene](double time) {
59  if (scene->update_stats) {
60  scene->update_stats->procedurals.times.add_entry({"update", time});
61  }
62  });
63 
64  foreach (Procedural *procedural, scene->procedurals) {
65  if (progress.get_cancel()) {
66  return;
67  }
68 
69  procedural->generate(scene, progress);
70  }
71 
72  if (progress.get_cancel()) {
73  return;
74  }
75 
76  need_update_ = false;
77 }
78 
80 {
81  need_update_ = true;
82 }
83 
85 {
86  return need_update_;
87 }
88 
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
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
NODE_ABSTRACT_DECLARE Procedural(const NodeType *type)
Definition: procedural.cpp:33
void set_status(const string &status_, const string &substatus_="")
double time
Scene scene
#define CCL_NAMESPACE_END
CCL_NAMESPACE_BEGIN NODE_ABSTRACT_DEFINE(Procedural)
Definition: procedural.cpp:27
static NodeType * add(const char *name, CreateFunc create, Type type=NONE, const NodeType *base=NULL)
Definition: node.h:98
vector< Procedural * > procedurals
Definition: scene.h:240
SceneUpdateStats * update_stats
Definition: scene.h:270