24template<
typename T,
typename U>
72 switch (socket_type) {
74 return std::is_same_v<T, int>;
76 return std::is_same_v<T, float>;
78 return std::is_same_v<T, bool>;
80 return std::is_same_v<T, float3>;
82 return std::is_same_v<T, ColorGeometry4f>;
84 return std::is_same_v<T, math::Quaternion>;
86 return std::is_same_v<T, float4x4>;
88 return std::is_same_v<T, std::string>;
90 return std::is_same_v<T, int>;
107 if constexpr (std::is_same_v<T, fn::GField>) {
132 else if constexpr (std::is_same_v<T, GVolumeGrid>) {
136 return std::move(value_.
get<GVolumeGrid>());
142 return GVolumeGrid(*grid_type);
150 else if constexpr (is_VolumeGrid_v<T>) {
157 if (kind_ == Kind::Single) {
158 return std::move(value_.
get<T>());
160 if (kind_ == Kind::Field) {
162 std::destroy_at(&ret_value);
176 return copied_variant.
extract<T>();
179template<
typename T>
void SocketValueVariant::store_impl(T value)
181 if constexpr (std::is_same_v<T, fn::GField>) {
182 const std::optional<eNodeSocketDatatype> new_socket_type =
185 socket_type_ = *new_socket_type;
191 this->store_impl<fn::GField>(std::move(value));
194 else if constexpr (std::is_same_v<T, GVolumeGrid>) {
200 socket_type_ = *new_socket_type;
202 value_.
emplace<GVolumeGrid>(std::move(value));
204 else if constexpr (is_VolumeGrid_v<T>) {
206 this->store_impl<GVolumeGrid>(std::move(value));
212 socket_type_ = *new_socket_type;
213 kind_ = Kind::Single;
214 value_.
emplace<T>(std::move(value));
220 kind_ = Kind::Single;
221 socket_type_ = socket_type;
222 switch (socket_type) {
224 value_.
emplace<
float>(*
static_cast<const float *
>(value));
228 value_.
emplace<
int>(*
static_cast<const int *
>(value));
236 value_.
emplace<
bool>(*
static_cast<const bool *
>(value));
252 value_.
emplace<std::string>(*
static_cast<const std::string *
>(value));
276 return kind_ == Kind::Grid;
313 const void *data = value_.
get();
325 kind_ = Kind::Single;
326 socket_type_ = socket_type;
327 switch (socket_type) {
343 return value_.
allocate<std::string>();
357 if (value_variant.kind_ == SocketValueVariant::Kind::Single) {
359 const CPPType &cpp_type = *value.type();
361 std::stringstream ss;
362 cpp_type.
print(value.get(), ss);
367 stream <<
"SocketValueVariant";
373 if (kind_ == Kind::None) {
376 return socket_type_ == socket_type;
379#define INSTANTIATE(TYPE) \
380 template TYPE SocketValueVariant::extract(); \
381 template TYPE SocketValueVariant::get() const; \
382 template void SocketValueVariant::store_impl(TYPE);
385# define INSTANTIATE_SINGLE_AND_FIELD_AND_GRID(TYPE) \
387 INSTANTIATE(fn::Field<TYPE>) \
388 INSTANTIATE(VolumeGrid<TYPE>)
390# define INSTANTIATE_SINGLE_AND_FIELD_AND_GRID(TYPE) \
392 INSTANTIATE(fn::Field<TYPE>)
CustomData interface, see also DNA_customdata_types.h.
#define BLI_assert_unreachable()
std::decay_t< T > & emplace(Args &&...args)
bool is_printable() const
const void * default_value() const
void print(const void *value, std::stringstream &ss) const
const CPPType * type() const
bool is_context_dependent_field() const
bool valid_for_socket(eNodeSocketDatatype socket_type) const
bool is_volume_grid() const
void store_single(eNodeSocketDatatype socket_type, const void *value)
GPointer get_single_ptr() const
void * allocate_single(eNodeSocketDatatype socket_type)
bool depends_on_input() const
const FieldNode & node() const
std::optional< eNodeSocketDatatype > geo_nodes_base_cpp_type_to_socket_type(const CPPType &type)
std::optional< VolumeGridType > socket_type_to_grid_type(eNodeSocketDatatype type)
static constexpr bool is_single_or_field_or_grid_v
std::optional< eNodeSocketDatatype > grid_type_to_socket_type(VolumeGridType type)
static std::optional< eNodeSocketDatatype > static_type_to_socket_type()
const CPPType * socket_type_to_geo_nodes_base_cpp_type(eNodeSocketDatatype type)
static bool static_type_is_base_socket_type(const eNodeSocketDatatype socket_type)
std::ostream & operator<<(std::ostream &stream, const GeometrySet &geometry_set)
GField make_constant_field(const CPPType &type, const void *value)
void evaluate_constant_field(const GField &field, void *r_value)
static constexpr bool is_field_v
constexpr bool is_same_any_v
MatBase< float, 4, 4 > float4x4
#define INSTANTIATE_SINGLE_AND_FIELD_AND_GRID(TYPE)
#define INSTANTIATE(TYPE)