diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-01-24 22:19:48 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-01-29 19:07:08 +0300 |
commit | 1eeb846e781dac3f55d6c108d0fc4c3cfe88f4cc (patch) | |
tree | c80b01eb79df21ad995cb22831ac6012dc0fd1c1 /intern/cycles/graph | |
parent | fb941679bb6e537a8fb1e1de69b5a446490e761b (diff) |
Fix Cycles viewport render not updating when tweaking displacement shader.
This was disabled to avoid updating the geometry every time when the
material includes displacement, because there was no way to distinguish
between surface shader and displacement updates.
As a solution, we now compute an MD5 hash of the nodes linked to the
displacement socket, and only update the mesh if that changes.
Differential Revision: https://developer.blender.org/D3018
Diffstat (limited to 'intern/cycles/graph')
-rw-r--r-- | intern/cycles/graph/node.cpp | 20 | ||||
-rw-r--r-- | intern/cycles/graph/node.h | 4 |
2 files changed, 24 insertions, 0 deletions
diff --git a/intern/cycles/graph/node.cpp b/intern/cycles/graph/node.cpp index 10d91a1e4ef..c71221746ad 100644 --- a/intern/cycles/graph/node.cpp +++ b/intern/cycles/graph/node.cpp @@ -18,6 +18,7 @@ #include "graph/node_type.h" #include "util/util_foreach.h" +#include "util/util_md5.h" #include "util/util_param.h" #include "util/util_transform.h" @@ -403,5 +404,24 @@ bool Node::equals(const Node& other) const return true; } +/* Hash */ + +void Node::hash(MD5Hash& md5) +{ + md5.append(type->name.string()); + + foreach(const SocketType& socket, type->inputs) { + md5.append(socket.name.string()); + + if(socket.is_array()) { + const array<bool>* a = (const array<bool>*)(((char*)this) + socket.struct_offset); + md5.append((uint8_t*)a->data(), socket.size() * a->size()); + } + else { + md5.append(((uint8_t*)this) + socket.struct_offset, socket.size()); + } + } +} + CCL_NAMESPACE_END diff --git a/intern/cycles/graph/node.h b/intern/cycles/graph/node.h index 53425f5faf1..d198c38be32 100644 --- a/intern/cycles/graph/node.h +++ b/intern/cycles/graph/node.h @@ -24,6 +24,7 @@ CCL_NAMESPACE_BEGIN +class MD5Hash; struct Node; struct NodeType; struct Transform; @@ -88,6 +89,9 @@ struct Node /* equals */ bool equals(const Node& other) const; + /* compute hash of node and its socket values */ + void hash(MD5Hash& md5); + ustring name; const NodeType *type; }; |