Files
test/source/blender/blenkernel/BKE_anonymous_attribute_make.hh
Jacques Lucke b279a6d703 Refactor: Geometry Nodes: remove AnonymousAttributeID in favor of just strings
This removes `AnonymousAttributeID` which was "attached" to every anonymous
attribute before. It adds more complexity than is justified for its
functionality.

It was originally introduced to keep the reference count of the anonymous
attribute so that it can be deleted automatically when the attribute is not
referenced anymore. For quite some time we have had deterministic attribute
life-times though which don't rely on the reference count anymore.

Anonymous attributes are sometimes shown in the UI as "friendly looking" string
like `"UV Map" from Cube`. Some information necessary for this was also stored
in `AnonymousAttributeID`. However, this can also be solved differently.
Specifically, this functionality has now been added directly to
`AttributeFieldInput`.

This refactor also allows removing `AttributeIDRef` which was mainly introduced
because we had to keep the `AnonymousAttributeID` attached with the attribute
name. Just using simple string types to identify attributes can reduce the
mental overhead quite significantly. This will be done as a separate refactor
though.

Pull Request: https://projects.blender.org/blender/blender/pulls/127081
2024-09-03 15:38:51 +02:00

21 lines
550 B
C++

/* SPDX-FileCopyrightText: 2024 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include <fmt/format.h>
#include <sstream>
#include <xxhash.h>
namespace blender::bke {
template<typename... Args> inline std::string hash_to_anonymous_attribute_name(Args &&...args)
{
std::stringstream ss;
((ss << args), ...);
const std::string long_name = ss.str();
const XXH128_hash_t hash = XXH3_128bits(long_name.c_str(), long_name.size());
return fmt::format(".a_{:x}{:x}", hash.low64, hash.high64);
}
} // namespace blender::bke