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
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2018-02-18 05:20:39 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2018-02-23 20:57:58 +0300
commita963c7d48dade70474ec3b40bea5e99ebdbbc5d4 (patch)
tree7df66a8c09dec4f9bd1f9eb1f9d390339213c21d /intern/cycles/render/attribute.cpp
parent4448ed6c5e6d321c9f0822ca2d969f7e7041fe27 (diff)
Code refactor: improve attribute handling for optional volume attributes.
A volume shader should be able to request attributes, and still be rendered as homogeneous if no volume attributes are available for the object.
Diffstat (limited to 'intern/cycles/render/attribute.cpp')
-rw-r--r--intern/cycles/render/attribute.cpp32
1 files changed, 27 insertions, 5 deletions
diff --git a/intern/cycles/render/attribute.cpp b/intern/cycles/render/attribute.cpp
index f959b1fef8b..6816f8ca3f3 100644
--- a/intern/cycles/render/attribute.cpp
+++ b/intern/cycles/render/attribute.cpp
@@ -298,9 +298,13 @@ const char *Attribute::standard_name(AttributeStandard std)
AttributeStandard Attribute::name_standard(const char *name)
{
- for(int std = ATTR_STD_NONE; std < ATTR_STD_NUM; std++)
- if(strcmp(name, Attribute::standard_name((AttributeStandard)std)) == 0)
- return (AttributeStandard)std;
+ if(name) {
+ for(int std = ATTR_STD_NONE; std < ATTR_STD_NUM; std++) {
+ if(strcmp(name, Attribute::standard_name((AttributeStandard)std)) == 0) {
+ return (AttributeStandard)std;
+ }
+ }
+ }
return ATTR_STD_NONE;
}
@@ -615,9 +619,11 @@ bool AttributeRequestSet::modified(const AttributeRequestSet& other)
void AttributeRequestSet::add(ustring name)
{
- foreach(AttributeRequest& req, requests)
- if(req.name == name)
+ foreach(AttributeRequest& req, requests) {
+ if(req.name == name) {
return;
+ }
+ }
requests.push_back(AttributeRequest(name));
}
@@ -641,6 +647,22 @@ void AttributeRequestSet::add(AttributeRequestSet& reqs)
}
}
+void AttributeRequestSet::add_standard(ustring name)
+{
+ if(!name) {
+ return;
+ }
+
+ AttributeStandard std = Attribute::name_standard(name.c_str());
+
+ if(std) {
+ add(std);
+ }
+ else {
+ add(name);
+ }
+}
+
bool AttributeRequestSet::find(ustring name)
{
foreach(AttributeRequest& req, requests)