29template<
typename T,
typename U>
104 switch (socket_type) {
106 return std::is_same_v<T, int>;
108 return std::is_same_v<T, float>;
110 return std::is_same_v<T, bool>;
112 return std::is_same_v<T, float3>;
114 return std::is_same_v<T, ColorGeometry4f>;
116 return std::is_same_v<T, math::Quaternion>;
118 return std::is_same_v<T, float4x4>;
120 return std::is_same_v<T, std::string>;
122 return std::is_same_v<T, nodes::MenuValue>;
124 return std::is_same_v<T, nodes::BundlePtr>;
126 return std::is_same_v<T, nodes::ClosurePtr>;
128 return std::is_same_v<T, Object *>;
130 return std::is_same_v<T, Collection *>;
132 return std::is_same_v<T, Tex *>;
134 return std::is_same_v<T, Image *>;
136 return std::is_same_v<T, Material *>;
138 return std::is_same_v<T, bke::GeometrySet>;
149 if constexpr (std::is_same_v<T, fn::GField>) {
174 else if constexpr (std::is_same_v<T, nodes::ListPtr>) {
175 if (kind_ != Kind::List) {
181 else if constexpr (std::is_same_v<T, GVolumeGrid>) {
185 return std::move(value_.get<GVolumeGrid>());
192 return GVolumeGrid(*grid_type);
207 if (kind_ == Kind::Single) {
208 return std::move(value_.get<
T>());
210 if (kind_ == Kind::Field) {
212 std::destroy_at(&ret_value);
216 if (kind_ == Kind::List) {
232template<
typename T>
void SocketValueVariant::store_impl(
T value)
234 if constexpr (std::is_same_v<T, fn::GField>) {
235 const std::optional<eNodeSocketDatatype> new_socket_type =
238 socket_type_ = *new_socket_type;
244 this->store_impl<fn::GField>(std::move(value));
246 else if constexpr (std::is_same_v<T, nodes::ListPtr>) {
248 const std::optional<eNodeSocketDatatype> new_socket_type =
251 socket_type_ = *new_socket_type;
255 else if constexpr (std::is_same_v<T, GVolumeGrid>) {
261 socket_type_ = *new_socket_type;
263 value_.emplace<GVolumeGrid>(std::move(value));
267 this->store_impl<GVolumeGrid>(std::move(value));
273 socket_type_ = *new_socket_type;
274 kind_ = Kind::Single;
275 value_.emplace<
T>(std::move(value));
281 kind_ = Kind::Single;
282 socket_type_ = socket_type;
283 switch (socket_type) {
285 value_.emplace<
float>(*
static_cast<const float *
>(value));
289 value_.emplace<
int>(*
static_cast<const int *
>(value));
293 value_.emplace<
float3>(*
static_cast<const float3 *
>(value));
297 value_.emplace<
bool>(*
static_cast<const bool *
>(value));
317 value_.emplace<std::string>(*
static_cast<const std::string *
>(value));
329 value_.emplace<
Object *>(*
static_cast<Object *
const *
>(value));
337 value_.emplace<
Tex *>(*
static_cast<Tex *
const *
>(value));
341 value_.emplace<
Image *>(*
static_cast<Image *
const *
>(value));
373 return kind_ == Kind::Grid;
378 return kind_ == Kind::Single;
383 return kind_ == Kind::List;
421 const void *
data = value_.get();
433 kind_ = Kind::Single;
434 socket_type_ = socket_type;
435 switch (socket_type) {
437 return value_.allocate<
float>();
439 return value_.allocate<
int>();
441 return value_.allocate<
float3>();
443 return value_.allocate<
bool>();
451 return value_.allocate<std::string>();
459 return value_.allocate<
Object *>();
463 return value_.allocate<
Tex *>();
465 return value_.allocate<
Image *>();
467 return value_.allocate<
Material *>();
479 if (value_variant.kind_ == SocketValueVariant::Kind::Single) {
483 std::stringstream ss;
489 stream <<
"SocketValueVariant";
495 if (kind_ == Kind::None) {
498 return socket_type_ == socket_type;
501#define INSTANTIATE(TYPE) \
502 template TYPE SocketValueVariant::extract(); \
503 template TYPE SocketValueVariant::get() const; \
504 template void SocketValueVariant::store_impl(TYPE);
507# define INSTANTIATE_SINGLE_AND_FIELD_AND_GRID(TYPE) \
509 INSTANTIATE(fn::Field<TYPE>) \
510 INSTANTIATE(VolumeGrid<TYPE>)
512# define INSTANTIATE_SINGLE_AND_FIELD_AND_GRID(TYPE) \
514 INSTANTIATE(fn::Field<TYPE>)
#define BLI_assert_unreachable()
BMesh const char void * data
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< List > ListPtr
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)