support for string parameters in OSL nodes
for now subtype is not defined, but once we start parsing the metadata we can set texture inputs as FILEPATH also, it takes relative strings and convert to absolute for all strings (which is arguably a good solution, but should work for now)
This commit is contained in:
@@ -217,6 +217,7 @@ static PyObject *osl_update_node_func(PyObject *self, PyObject *args)
|
||||
float default_float4[4] = {0.0f, 0.0f, 0.0f, 1.0f};
|
||||
float default_float = 0.0f;
|
||||
int default_int = 0;
|
||||
std::string default_string = "";
|
||||
|
||||
if(param->isclosure) {
|
||||
socket_type = BL::NodeSocket::type_SHADER;
|
||||
@@ -252,6 +253,11 @@ static PyObject *osl_update_node_func(PyObject *self, PyObject *args)
|
||||
if(param->validdefault)
|
||||
default_float = param->fdefault[0];
|
||||
}
|
||||
else if(param->type.basetype == TypeDesc::STRING) {
|
||||
socket_type = BL::NodeSocket::type_STRING;
|
||||
if(param->validdefault)
|
||||
default_string = param->sdefault[0];
|
||||
}
|
||||
}
|
||||
else
|
||||
continue;
|
||||
@@ -286,6 +292,10 @@ static PyObject *osl_update_node_func(PyObject *self, PyObject *args)
|
||||
BL::NodeSocketVectorNone b_vector_sock(b_sock.ptr);
|
||||
b_vector_sock.default_value(default_float4);
|
||||
}
|
||||
else if(socket_type == BL::NodeSocket::type_STRING) {
|
||||
BL::NodeSocketStringNone b_string_sock(b_sock.ptr);
|
||||
b_string_sock.default_value(default_string);
|
||||
}
|
||||
}
|
||||
|
||||
used_sockets.insert(b_sock.ptr.data);
|
||||
|
||||
Reference in New Issue
Block a user