Merge branch 'blender-v3.4-release'
This commit is contained in:
commit
f4e1f62c62
Notes:
blender-bot
2023-02-14 04:24:05 +01:00
Referenced by issue #102745, Sculpt Mode: Inconsistent cavity auto-masking results
|
@ -478,6 +478,7 @@ static PyObject *osl_update_node_func(PyObject * /*self*/, PyObject *args)
|
|||
|
||||
/* Read metadata. */
|
||||
bool is_bool_param = false;
|
||||
bool hide_value = !param->validdefault;
|
||||
ustring param_label = param->name;
|
||||
|
||||
for (const OSL::OSLQuery::Parameter &metadata : param->metadata) {
|
||||
|
@ -487,6 +488,9 @@ static PyObject *osl_update_node_func(PyObject * /*self*/, PyObject *args)
|
|||
if (metadata.sdefault[0] == "boolean" || metadata.sdefault[0] == "checkBox") {
|
||||
is_bool_param = true;
|
||||
}
|
||||
else if (metadata.sdefault[0] == "null") {
|
||||
hide_value = true;
|
||||
}
|
||||
}
|
||||
else if (metadata.name == "label") {
|
||||
/* Socket label. */
|
||||
|
@ -596,6 +600,9 @@ static PyObject *osl_update_node_func(PyObject * /*self*/, PyObject *args)
|
|||
if (b_sock.name() != param_label) {
|
||||
b_sock.name(param_label.string());
|
||||
}
|
||||
if (b_sock.hide_value() != hide_value) {
|
||||
b_sock.hide_value(hide_value);
|
||||
}
|
||||
used_sockets.insert(b_sock.ptr.data);
|
||||
found_existing = true;
|
||||
}
|
||||
|
@ -635,6 +642,8 @@ static PyObject *osl_update_node_func(PyObject * /*self*/, PyObject *args)
|
|||
set_boolean(b_sock.ptr, "default_value", default_boolean);
|
||||
}
|
||||
|
||||
b_sock.hide_value(hide_value);
|
||||
|
||||
used_sockets.insert(b_sock.ptr.data);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,7 +66,9 @@ struct SocketType {
|
|||
LINK_NORMAL = (1 << 8),
|
||||
LINK_POSITION = (1 << 9),
|
||||
LINK_TANGENT = (1 << 10),
|
||||
DEFAULT_LINK_MASK = (1 << 4) | (1 << 5) | (1 << 6) | (1 << 7) | (1 << 8) | (1 << 9) | (1 << 10)
|
||||
LINK_OSL_INITIALIZER = (1 << 11),
|
||||
DEFAULT_LINK_MASK = (1 << 4) | (1 << 5) | (1 << 6) | (1 << 7) | (1 << 8) | (1 << 9) |
|
||||
(1 << 10) | (1 << 11)
|
||||
};
|
||||
|
||||
ustring name;
|
||||
|
|
|
@ -552,6 +552,7 @@ OSLNode *OSLShaderManager::osl_node(ShaderGraph *graph,
|
|||
|
||||
SocketType::Type socket_type;
|
||||
|
||||
/* Read type and default value. */
|
||||
if (param->isclosure) {
|
||||
socket_type = SocketType::CLOSURE;
|
||||
}
|
||||
|
@ -606,7 +607,21 @@ OSLNode *OSLShaderManager::osl_node(ShaderGraph *graph,
|
|||
node->add_output(param->name, socket_type);
|
||||
}
|
||||
else {
|
||||
node->add_input(param->name, socket_type);
|
||||
/* Detect if we should leave parameter initialization to OSL, either though
|
||||
* not constant default or widget metadata. */
|
||||
int socket_flags = 0;
|
||||
if (!param->validdefault) {
|
||||
socket_flags |= SocketType::LINK_OSL_INITIALIZER;
|
||||
}
|
||||
for (const OSL::OSLQuery::Parameter &metadata : param->metadata) {
|
||||
if (metadata.type == TypeDesc::STRING) {
|
||||
if (metadata.name == "widget" && metadata.sdefault[0] == "null") {
|
||||
socket_flags |= SocketType::LINK_OSL_INITIALIZER;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
node->add_input(param->name, socket_type, socket_flags);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -731,8 +746,12 @@ void OSLCompiler::add(ShaderNode *node, const char *name, bool isfilepath)
|
|||
foreach (ShaderInput *input, node->inputs) {
|
||||
if (!input->link) {
|
||||
/* checks to untangle graphs */
|
||||
if (node_skip_input(node, input))
|
||||
if (node_skip_input(node, input)) {
|
||||
continue;
|
||||
}
|
||||
if (input->flags() & SocketType::LINK_OSL_INITIALIZER) {
|
||||
continue;
|
||||
}
|
||||
|
||||
string param_name = compatible_name(node, input);
|
||||
const SocketType &socket = input->socket_type;
|
||||
|
|
|
@ -7257,12 +7257,12 @@ char *OSLNode::input_default_value()
|
|||
return (char *)this + align_up(sizeof(OSLNode), 16) + inputs_size;
|
||||
}
|
||||
|
||||
void OSLNode::add_input(ustring name, SocketType::Type socket_type)
|
||||
void OSLNode::add_input(ustring name, SocketType::Type socket_type, const int flags)
|
||||
{
|
||||
char *memory = input_default_value();
|
||||
size_t offset = memory - (char *)this;
|
||||
const_cast<NodeType *>(type)->register_input(
|
||||
name, name, socket_type, offset, memory, NULL, NULL, SocketType::LINKABLE);
|
||||
name, name, socket_type, offset, memory, NULL, NULL, flags | SocketType::LINKABLE);
|
||||
}
|
||||
|
||||
void OSLNode::add_output(ustring name, SocketType::Type socket_type)
|
||||
|
|
|
@ -1525,7 +1525,7 @@ class OSLNode final : public ShaderNode {
|
|||
ShaderNode *clone(ShaderGraph *graph) const;
|
||||
|
||||
char *input_default_value();
|
||||
void add_input(ustring name, SocketType::Type type);
|
||||
void add_input(ustring name, SocketType::Type type, const int flags = 0);
|
||||
void add_output(ustring name, SocketType::Type type);
|
||||
|
||||
SHADER_NODE_NO_CLONE_CLASS(OSLNode)
|
||||
|
|
Loading…
Reference in New Issue