Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/intern
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2016-05-07 21:30:16 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2016-05-22 18:29:25 +0300
commite7d13b8a1da046d7bb78a3c0e21bbb575ed6074e (patch)
tree5af00d1e1e72fb15212decc2448152696ea519b7 /intern
parent0062d9f58c74e6dd021a3517e0dcba41c414ac97 (diff)
Code refactor: nodify Cycles background and film.
Differential Revision: https://developer.blender.org/D2016
Diffstat (limited to 'intern')
-rw-r--r--intern/cycles/app/cycles_xml.cpp23
-rw-r--r--intern/cycles/blender/blender_session.cpp2
-rw-r--r--intern/cycles/render/background.cpp33
-rw-r--r--intern/cycles/render/background.h7
-rw-r--r--intern/cycles/render/buffers.cpp14
-rw-r--r--intern/cycles/render/buffers.h2
-rw-r--r--intern/cycles/render/film.cpp70
-rw-r--r--intern/cycles/render/film.h16
8 files changed, 83 insertions, 84 deletions
diff --git a/intern/cycles/app/cycles_xml.cpp b/intern/cycles/app/cycles_xml.cpp
index c2636a0e8c5..7f262c709e0 100644
--- a/intern/cycles/app/cycles_xml.cpp
+++ b/intern/cycles/app/cycles_xml.cpp
@@ -279,18 +279,6 @@ static ShaderSocketType xml_read_socket_type(pugi::xml_node node, const char *na
return SHADER_SOCKET_UNDEFINED;
}
-/* Film */
-
-static void xml_read_film(const XMLReadState& state, pugi::xml_node node)
-{
- Film *film = state.scene->film;
-
- xml_read_float(&film->exposure, node, "exposure");
-
- /* ToDo: Filter Type */
- xml_read_float(&film->filter_width, node, "filter_width");
-}
-
/* Camera */
static void xml_read_camera(const XMLReadState& state, pugi::xml_node node)
@@ -839,15 +827,10 @@ static void xml_read_shader(const XMLReadState& state, pugi::xml_node node)
/* Background */
-static void xml_read_background(const XMLReadState& state, pugi::xml_node node)
+static void xml_read_background(XMLReadState& state, pugi::xml_node node)
{
/* Background Settings */
- Background *bg = state.scene->background;
-
- xml_read_float(&bg->ao_distance, node, "ao_distance");
- xml_read_float(&bg->ao_factor, node, "ao_factor");
-
- xml_read_bool(&bg->transparent, node, "transparent");
+ xml_read_node(state, state.scene->background, node);
/* Background Shader */
Shader *shader = state.scene->default_background;
@@ -1185,7 +1168,7 @@ static void xml_read_scene(XMLReadState& state, pugi::xml_node scene_node)
{
for(pugi::xml_node node = scene_node.first_child(); node; node = node.next_sibling()) {
if(string_iequals(node.name(), "film")) {
- xml_read_film(state, node);
+ xml_read_node(state, state.scene->film, node);
}
else if(string_iequals(node.name(), "integrator")) {
xml_read_node(state, state.scene->integrator, node);
diff --git a/intern/cycles/blender/blender_session.cpp b/intern/cycles/blender/blender_session.cpp
index 7a5243d3234..80a16e0ef27 100644
--- a/intern/cycles/blender/blender_session.cpp
+++ b/intern/cycles/blender/blender_session.cpp
@@ -473,7 +473,7 @@ void BlenderSession::render()
BL::RenderLayer b_rlay = *b_single_rlay;
/* add passes */
- vector<Pass> passes;
+ array<Pass> passes;
Pass::add(PASS_COMBINED, passes);
if(session_params.device.advanced_shading) {
diff --git a/intern/cycles/render/background.cpp b/intern/cycles/render/background.cpp
index 89f90bc8dad..28ca04fe615 100644
--- a/intern/cycles/render/background.cpp
+++ b/intern/cycles/render/background.cpp
@@ -28,18 +28,25 @@
CCL_NAMESPACE_BEGIN
-Background::Background()
+NODE_DEFINE(Background)
{
- ao_factor = 0.0f;
- ao_distance = FLT_MAX;
+ NodeType* type = NodeType::add("background", create);
- use_shader = true;
- use_ao = false;
+ SOCKET_INT(ao_factor, "AO Factor", 0.0f);
+ SOCKET_FLOAT(ao_distance, "AO Distance", FLT_MAX);
- visibility = PATH_RAY_ALL_VISIBILITY;
- shader = NULL;
+ SOCKET_BOOLEAN(use_shader, "Use Shader", true);
+ SOCKET_BOOLEAN(use_ao, "Use AO", false);
+ SOCKET_INT(visibility, "Visibility", PATH_RAY_ALL_VISIBILITY);
+ SOCKET_BOOLEAN(transparent, "Transparent", false);
- transparent = false;
+ return type;
+}
+
+Background::Background()
+: Node(node_type)
+{
+ shader = NULL;
need_update = true;
}
@@ -108,16 +115,6 @@ void Background::device_free(Device * /*device*/, DeviceScene * /*dscene*/)
{
}
-bool Background::modified(const Background& background)
-{
- return !(transparent == background.transparent &&
- use_shader == background.use_shader &&
- use_ao == background.use_ao &&
- ao_factor == background.ao_factor &&
- ao_distance == background.ao_distance &&
- visibility == background.visibility);
-}
-
void Background::tag_update(Scene *scene)
{
scene->integrator->tag_update(scene);
diff --git a/intern/cycles/render/background.h b/intern/cycles/render/background.h
index 645d002424e..ae2ffe2b078 100644
--- a/intern/cycles/render/background.h
+++ b/intern/cycles/render/background.h
@@ -17,6 +17,8 @@
#ifndef __BACKGROUND_H__
#define __BACKGROUND_H__
+#include "node.h"
+
#include "util_types.h"
CCL_NAMESPACE_BEGIN
@@ -26,8 +28,10 @@ class DeviceScene;
class Shader;
class Scene;
-class Background {
+class Background : public Node {
public:
+ NODE_DECLARE;
+
float ao_factor;
float ao_distance;
@@ -46,7 +50,6 @@ public:
void device_update(Device *device, DeviceScene *dscene, Scene *scene);
void device_free(Device *device, DeviceScene *dscene);
- bool modified(const Background& background);
void tag_update(Scene *scene);
};
diff --git a/intern/cycles/render/buffers.cpp b/intern/cycles/render/buffers.cpp
index 558f5e59342..1e170d3a96e 100644
--- a/intern/cycles/render/buffers.cpp
+++ b/intern/cycles/render/buffers.cpp
@@ -66,8 +66,8 @@ int BufferParams::get_passes_size()
{
int size = 0;
- foreach(Pass& pass, passes)
- size += pass.components;
+ for(size_t i = 0; i < passes.size(); i++)
+ size += passes[i].components;
return align_up(size, 4);
}
@@ -160,7 +160,9 @@ bool RenderBuffers::get_pass_rect(PassType type, float exposure, int sample, int
{
int pass_offset = 0;
- foreach(Pass& pass, params.passes) {
+ for(size_t j = 0; j < params.passes.size(); j++) {
+ Pass& pass = params.passes[j];
+
if(pass.type != type) {
pass_offset += pass.components;
continue;
@@ -228,7 +230,8 @@ bool RenderBuffers::get_pass_rect(PassType type, float exposure, int sample, int
else if(pass.divide_type != PASS_NONE) {
/* RGB lighting passes that need to divide out color */
pass_offset = 0;
- foreach(Pass& color_pass, params.passes) {
+ for(size_t k = 0; k < params.passes.size(); k++) {
+ Pass& color_pass = params.passes[k];
if(color_pass.type == pass.divide_type)
break;
pass_offset += color_pass.components;
@@ -276,7 +279,8 @@ bool RenderBuffers::get_pass_rect(PassType type, float exposure, int sample, int
else if(type == PASS_MOTION) {
/* need to normalize by number of samples accumulated for motion */
pass_offset = 0;
- foreach(Pass& color_pass, params.passes) {
+ for(size_t k = 0; k < params.passes.size(); k++) {
+ Pass& color_pass = params.passes[k];
if(color_pass.type == PASS_MOTION_WEIGHT)
break;
pass_offset += color_pass.components;
diff --git a/intern/cycles/render/buffers.h b/intern/cycles/render/buffers.h
index 57ffd9630f5..c9c2a21079a 100644
--- a/intern/cycles/render/buffers.h
+++ b/intern/cycles/render/buffers.h
@@ -50,7 +50,7 @@ public:
int full_height;
/* passes */
- vector<Pass> passes;
+ array<Pass> passes;
/* functions */
BufferParams();
diff --git a/intern/cycles/render/film.cpp b/intern/cycles/render/film.cpp
index 95cb10ab13b..12dce6ad999 100644
--- a/intern/cycles/render/film.cpp
+++ b/intern/cycles/render/film.cpp
@@ -39,10 +39,10 @@ static bool compare_pass_order(const Pass& a, const Pass& b)
return (a.components > b.components);
}
-void Pass::add(PassType type, vector<Pass>& passes)
+void Pass::add(PassType type, array<Pass>& passes)
{
- foreach(Pass& existing_pass, passes)
- if(existing_pass.type == type)
+ for(size_t i = 0; i < passes.size(); i++)
+ if(passes[i].type == type)
return;
Pass pass;
@@ -169,17 +169,17 @@ void Pass::add(PassType type, vector<Pass>& passes)
#endif
}
- passes.push_back(pass);
+ passes.push_back_slow(pass);
/* order from by components, to ensure alignment so passes with size 4
* come first and then passes with size 1 */
- sort(passes.begin(), passes.end(), compare_pass_order);
+ sort(&passes[0], &passes[0] + passes.size(), compare_pass_order);
if(pass.divide_type != PASS_NONE)
Pass::add(pass.divide_type, passes);
}
-bool Pass::equals(const vector<Pass>& A, const vector<Pass>& B)
+bool Pass::equals(const array<Pass>& A, const array<Pass>& B)
{
if(A.size() != B.size())
return false;
@@ -191,10 +191,10 @@ bool Pass::equals(const vector<Pass>& A, const vector<Pass>& B)
return true;
}
-bool Pass::contains(const vector<Pass>& passes, PassType type)
+bool Pass::contains(const array<Pass>& passes, PassType type)
{
- foreach(const Pass& pass, passes)
- if(pass.type == type)
+ for(size_t i = 0; i < passes.size(); i++)
+ if(passes[i].type == type)
return true;
return false;
@@ -263,22 +263,37 @@ static vector<float> filter_table(FilterType type, float width)
/* Film */
-Film::Film()
+NODE_DEFINE(Film)
{
- exposure = 0.8f;
- Pass::add(PASS_COMBINED, passes);
- pass_alpha_threshold = 0.5f;
+ NodeType* type = NodeType::add("film", create);
- filter_type = FILTER_BOX;
- filter_width = 1.0f;
- filter_table_offset = TABLE_OFFSET_INVALID;
+ SOCKET_FLOAT(exposure, "Exposure", 0.8f);
+ SOCKET_FLOAT(pass_alpha_threshold, "Pass Alpha Threshold", 0.5f);
+
+ static NodeEnum filter_enum;
+ filter_enum.insert("box", FILTER_BOX);
+ filter_enum.insert("gaussian", FILTER_GAUSSIAN);
+ filter_enum.insert("blackman_harris", FILTER_BLACKMAN_HARRIS);
- mist_start = 0.0f;
- mist_depth = 100.0f;
- mist_falloff = 1.0f;
+ SOCKET_ENUM(filter_type, "Filter Type", filter_enum, FILTER_BOX);
+ SOCKET_FLOAT(filter_width, "Filter Width", 1.0f);
+
+ SOCKET_FLOAT(mist_start, "Mist Start", 0.0f);
+ SOCKET_FLOAT(mist_depth, "Mist Depth", 100.0f);
+ SOCKET_FLOAT(mist_falloff, "Mist Falloff", 1.0f);
+
+ SOCKET_BOOLEAN(use_sample_clamp, "Use Sample Clamp", false);
+
+ return type;
+}
+
+Film::Film()
+: Node(node_type)
+{
+ Pass::add(PASS_COMBINED, passes);
use_light_visibility = false;
- use_sample_clamp = false;
+ filter_table_offset = TABLE_OFFSET_INVALID;
need_update = true;
}
@@ -302,7 +317,8 @@ void Film::device_update(Device *device, DeviceScene *dscene, Scene *scene)
kfilm->pass_stride = 0;
kfilm->use_light_pass = use_light_visibility || use_sample_clamp;
- foreach(Pass& pass, passes) {
+ for(size_t i = 0; i < passes.size(); i++) {
+ Pass& pass = passes[i];
kfilm->pass_flag |= pass.type;
switch(pass.type) {
@@ -449,18 +465,10 @@ void Film::device_free(Device * /*device*/,
bool Film::modified(const Film& film)
{
- return !(exposure == film.exposure
- && Pass::equals(passes, film.passes)
- && pass_alpha_threshold == film.pass_alpha_threshold
- && use_sample_clamp == film.use_sample_clamp
- && filter_type == film.filter_type
- && filter_width == film.filter_width
- && mist_start == film.mist_start
- && mist_depth == film.mist_depth
- && mist_falloff == film.mist_falloff);
+ return Node::modified(film) || !Pass::equals(passes, film.passes);
}
-void Film::tag_passes_update(Scene *scene, const vector<Pass>& passes_)
+void Film::tag_passes_update(Scene *scene, const array<Pass>& passes_)
{
if(Pass::contains(passes, PASS_UV) != Pass::contains(passes_, PASS_UV)) {
scene->mesh_manager->tag_update(scene);
diff --git a/intern/cycles/render/film.h b/intern/cycles/render/film.h
index 966e00a8d1f..9fa51c51f52 100644
--- a/intern/cycles/render/film.h
+++ b/intern/cycles/render/film.h
@@ -22,6 +22,8 @@
#include "kernel_types.h"
+#include "node.h"
+
CCL_NAMESPACE_BEGIN
class Device;
@@ -44,15 +46,17 @@ public:
bool exposure;
PassType divide_type;
- static void add(PassType type, vector<Pass>& passes);
- static bool equals(const vector<Pass>& A, const vector<Pass>& B);
- static bool contains(const vector<Pass>& passes, PassType);
+ static void add(PassType type, array<Pass>& passes);
+ static bool equals(const array<Pass>& A, const array<Pass>& B);
+ static bool contains(const array<Pass>& passes, PassType);
};
-class Film {
+class Film : public Node {
public:
+ NODE_DECLARE;
+
float exposure;
- vector<Pass> passes;
+ array<Pass> passes;
float pass_alpha_threshold;
FilterType filter_type;
@@ -75,7 +79,7 @@ public:
void device_free(Device *device, DeviceScene *dscene, Scene *scene);
bool modified(const Film& film);
- void tag_passes_update(Scene *scene, const vector<Pass>& passes_);
+ void tag_passes_update(Scene *scene, const array<Pass>& passes_);
void tag_update(Scene *scene);
};