diff options
author | Jacques Lucke <jacques@blender.org> | 2021-03-29 11:54:04 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-03-29 11:54:04 +0300 |
commit | 8034b276ba6c5369a356a1b8f5e858305f8b47b9 (patch) | |
tree | 61284da05350ea529f3100078fe9ac52b6acdb5e /source/blender/modifiers | |
parent | fa1569a072ad78c8a9c037a46a6581692729d6cc (diff) |
Fix T86876: cannot modify float properties of geometry nodes modifier from Python
Previously, the code expected the id property to have the `IDP_FLOAT` type.
However, when assigning a Python float (which is a double internally)
to an id property, it would change the type to `IDP_DOUBLE`.
The fix is to allow both types in the geometry nodes modifier.
Diffstat (limited to 'source/blender/modifiers')
-rw-r--r-- | source/blender/modifiers/intern/MOD_nodes.cc | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/source/blender/modifiers/intern/MOD_nodes.cc b/source/blender/modifiers/intern/MOD_nodes.cc index d2fb2e0260c..d6f7b4c8561 100644 --- a/source/blender/modifiers/intern/MOD_nodes.cc +++ b/source/blender/modifiers/intern/MOD_nodes.cc @@ -722,10 +722,17 @@ static const SocketPropertyType *get_socket_property_type(const bNodeSocket &bso [](const bNodeSocket &socket) { return (PropertyType)((bNodeSocketValueFloat *)socket.default_value)->subtype; }, - [](const IDProperty &property) { return property.type == IDP_FLOAT; }, + [](const IDProperty &property) { return ELEM(property.type, IDP_FLOAT, IDP_DOUBLE); }, [](const IDProperty &property, const PersistentDataHandleMap &UNUSED(handles), - void *r_value) { *(float *)r_value = IDP_Float(&property); }, + void *r_value) { + if (property.type == IDP_FLOAT) { + *(float *)r_value = IDP_Float(&property); + } + else if (property.type == IDP_DOUBLE) { + *(float *)r_value = (float)IDP_Double(&property); + } + }, }; return &float_type; } |