Functions: add float2 cpp type

This also adds a hash function for `float2`, because `CPPType`
expects that currently.
This commit is contained in:
Jacques Lucke 2020-11-18 12:00:45 +01:00
parent 8268b9827a
commit d65628466a
2 changed files with 8 additions and 0 deletions

View File

@ -80,6 +80,13 @@ struct float2 {
return *this;
}
uint64_t hash() const
{
uint64_t x1 = *reinterpret_cast<const uint32_t *>(&x);
uint64_t x2 = *reinterpret_cast<const uint32_t *>(&y);
return (x1 * 812519) ^ (x2 * 707951);
}
friend float2 operator+(const float2 &a, const float2 &b)
{
return {a.x + b.x, a.y + b.y};

View File

@ -26,6 +26,7 @@ namespace blender::fn {
MAKE_CPP_TYPE(bool, bool)
MAKE_CPP_TYPE(float, float)
MAKE_CPP_TYPE(float2, blender::float2)
MAKE_CPP_TYPE(float3, blender::float3)
MAKE_CPP_TYPE(float4x4, blender::float4x4)