25template<
typename T,
typename U>
79 switch (socket_type) {
81 return std::is_same_v<T, int>;
83 return std::is_same_v<T, float>;
85 return std::is_same_v<T, bool>;
87 return std::is_same_v<T, float3>;
89 return std::is_same_v<T, ColorGeometry4f>;
91 return std::is_same_v<T, math::Quaternion>;
93 return std::is_same_v<T, float4x4>;
95 return std::is_same_v<T, std::string>;
97 return std::is_same_v<T, int>;
99 return std::is_same_v<T, nodes::BundlePtr>;
101 return std::is_same_v<T, nodes::ClosurePtr>;
118 if constexpr (std::is_same_v<T, fn::GField>) {
143 else if constexpr (std::is_same_v<T, GVolumeGrid>) {
147 return std::move(value_.get<GVolumeGrid>());
153 return GVolumeGrid(*grid_type);
168 if (kind_ == Kind::Single) {
169 return std::move(value_.get<
T>());
171 if (kind_ == Kind::Field) {
173 std::destroy_at(&ret_value);
190template<
typename T>
void SocketValueVariant::store_impl(
T value)
192 if constexpr (std::is_same_v<T, fn::GField>) {
193 const std::optional<eNodeSocketDatatype> new_socket_type =
196 socket_type_ = *new_socket_type;
202 this->store_impl<fn::GField>(std::move(value));
205 else if constexpr (std::is_same_v<T, GVolumeGrid>) {
211 socket_type_ = *new_socket_type;
213 value_.
emplace<GVolumeGrid>(std::move(value));
217 this->store_impl<GVolumeGrid>(std::move(value));
223 socket_type_ = *new_socket_type;
224 kind_ = Kind::Single;
225 value_.emplace<
T>(std::move(value));
231 kind_ = Kind::Single;
232 socket_type_ = socket_type;
233 switch (socket_type) {
235 value_.emplace<
float>(*
static_cast<const float *
>(value));
239 value_.emplace<
int>(*
static_cast<const int *
>(value));
243 value_.emplace<
float3>(*
static_cast<const float3 *
>(value));
247 value_.emplace<
bool>(*
static_cast<const bool *
>(value));
263 value_.emplace<std::string>(*
static_cast<const std::string *
>(value));
295 return kind_ == Kind::Grid;
300 return kind_ == Kind::Single;
303void SocketValueVariant::convert_to_single()
337 const void *
data = value_.get();
349 kind_ = Kind::Single;
350 socket_type_ = socket_type;
351 switch (socket_type) {
353 return value_.allocate<
float>();
355 return value_.allocate<
int>();
357 return value_.allocate<
float3>();
359 return value_.allocate<
bool>();
367 return value_.allocate<std::string>();
369 return value_.allocate<
int>();
384 variant_copy.convert_to_single();
385 if (value_variant.kind_ == SocketValueVariant::Kind::Single) {
389 std::stringstream ss;
395 stream <<
"SocketValueVariant";
401 if (kind_ == Kind::None) {
404 return socket_type_ == socket_type;
407#define INSTANTIATE(TYPE) \
408 template TYPE SocketValueVariant::extract(); \
409 template TYPE SocketValueVariant::get() const; \
410 template void SocketValueVariant::store_impl(TYPE);
413# define INSTANTIATE_SINGLE_AND_FIELD_AND_GRID(TYPE) \
415 INSTANTIATE(fn::Field<TYPE>) \
416 INSTANTIATE(VolumeGrid<TYPE>)
418# define INSTANTIATE_SINGLE_AND_FIELD_AND_GRID(TYPE) \
420 INSTANTIATE(fn::Field<TYPE>)
#define BLI_assert_unreachable()
BMesh const char void * data
const void * default_value() const
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
SocketValueVariant()=default
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)
static constexpr bool is_VolumeGrid_v
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
QuaternionBase< float > Quaternion
ImplicitSharingPtr< Bundle > BundlePtr
ImplicitSharingPtr< Closure > ClosurePtr
constexpr bool is_same_any_v
MatBase< float, 4, 4 > float4x4
ColorSceneLinear4f< eAlpha::Premultiplied > ColorGeometry4f
VecBase< float, 3 > float3
#define INSTANTIATE_SINGLE_AND_FIELD_AND_GRID(TYPE)
#define INSTANTIATE(TYPE)