diff options
author | Monique <mdewanchand@atmind.nl> | 2022-09-13 20:08:34 +0300 |
---|---|---|
committer | Monique <mdewanchand@atmind.nl> | 2022-09-13 20:08:34 +0300 |
commit | e449a9bb5e11c07b315f9eb2dcb7de0237f37c02 (patch) | |
tree | 6a7eeddd3738701a1a8a0b78135965f02d30ccbc /source/blender/blenkernel/BKE_cryptomatte.hh | |
parent | 22d1673b927e041838cd49e3d13615365bbdafdd (diff) | |
parent | 08a8de739d8c7fa60f257ed171d292879edae013 (diff) |
Merge branch 'master' into temp-T73411-add-scene-parameterstemp-T73411-add-scene-parameters
Diffstat (limited to 'source/blender/blenkernel/BKE_cryptomatte.hh')
-rw-r--r-- | source/blender/blenkernel/BKE_cryptomatte.hh | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/source/blender/blenkernel/BKE_cryptomatte.hh b/source/blender/blenkernel/BKE_cryptomatte.hh index cd3f8dc9f58..dd08f7b5c4f 100644 --- a/source/blender/blenkernel/BKE_cryptomatte.hh +++ b/source/blender/blenkernel/BKE_cryptomatte.hh @@ -12,6 +12,7 @@ #include "BKE_cryptomatte.h" +#include "BLI_hash_mm3.h" #include "BLI_map.hh" #include "BLI_string_ref.hh" @@ -54,10 +55,14 @@ struct CryptomatteHash { uint32_t hash; CryptomatteHash(uint32_t hash); - CryptomatteHash(const char *name, int name_len); - static CryptomatteHash from_hex_encoded(blender::StringRef hex_encoded); + CryptomatteHash(const char *name, int name_len) + { + hash = BLI_hash_mm3((const unsigned char *)name, name_len, 0); + } + static CryptomatteHash from_hex_encoded(blender::StringRef hex_encoded); std::string hex_encoded() const; + /** * Convert a cryptomatte hash to a float. * @@ -70,7 +75,20 @@ struct CryptomatteHash { * * Note that this conversion assumes to be running on a L-endian system. */ - float float_encoded() const; + float float_encoded() const + { + uint32_t mantissa = hash & ((1 << 23) - 1); + uint32_t exponent = (hash >> 23) & ((1 << 8) - 1); + exponent = MAX2(exponent, (uint32_t)1); + exponent = MIN2(exponent, (uint32_t)254); + exponent = exponent << 23; + uint32_t sign = (hash >> 31); + sign = sign << 31; + uint32_t float_bits = sign | exponent | mantissa; + float f; + memcpy(&f, &float_bits, sizeof(uint32_t)); + return f; + } }; struct CryptomatteLayer { @@ -107,6 +125,8 @@ struct CryptomatteStampDataCallbackData { const blender::Vector<std::string> &BKE_cryptomatte_layer_names_get( const CryptomatteSession &session); +CryptomatteLayer *BKE_cryptomatte_layer_get(CryptomatteSession &session, + const StringRef layer_name); struct CryptomatteSessionDeleter { void operator()(CryptomatteSession *session) |