diff options
author | Brecht Van Lommel <brecht@blender.org> | 2021-11-05 22:05:08 +0300 |
---|---|---|
committer | Brecht Van Lommel <brecht@blender.org> | 2021-11-05 22:07:03 +0300 |
commit | f24ad274cb3002f380aa206c07ca564711bba089 (patch) | |
tree | 5a109d4b35eba3ed74ac1311ce7c2b2fdb72fa8b /intern | |
parent | ae899e4bb8b916c555a6fa490f201d5fa51f578f (diff) |
Fix T92503: Cycles OSL crash with object attributes
Can't cast to float4 because it might not have correct alignment.
Diffstat (limited to 'intern')
-rw-r--r-- | intern/cycles/kernel/osl/services.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/intern/cycles/kernel/osl/services.cpp b/intern/cycles/kernel/osl/services.cpp index ca0a5a068b3..389c1e2b746 100644 --- a/intern/cycles/kernel/osl/services.cpp +++ b/intern/cycles/kernel/osl/services.cpp @@ -832,16 +832,21 @@ static bool get_object_attribute(const OSLGlobals::Attribute &attr, { if (attr.type == TypeDesc::TypePoint || attr.type == TypeDesc::TypeVector || attr.type == TypeDesc::TypeNormal || attr.type == TypeDesc::TypeColor) { - return set_attribute_float3(*(float3 *)attr.value.data(), type, derivatives, val); + const float *data = (const float *)attr.value.data(); + return set_attribute_float3(make_float3(data[0], data[1], data[2]), type, derivatives, val); } else if (attr.type == TypeFloat2) { - return set_attribute_float2(*(float2 *)attr.value.data(), type, derivatives, val); + const float *data = (const float *)attr.value.data(); + return set_attribute_float2(make_float2(data[0], data[1]), type, derivatives, val); } else if (attr.type == TypeDesc::TypeFloat) { - return set_attribute_float(*(float *)attr.value.data(), type, derivatives, val); + const float *data = (const float *)attr.value.data(); + return set_attribute_float(data[0], type, derivatives, val); } else if (attr.type == TypeRGBA || attr.type == TypeDesc::TypeFloat4) { - return set_attribute_float4(*(float4 *)attr.value.data(), type, derivatives, val); + const float *data = (const float *)attr.value.data(); + return set_attribute_float4( + make_float4(data[0], data[1], data[2], data[3]), type, derivatives, val); } else if (attr.type == type) { size_t datasize = attr.value.datasize(); |