|
Blender V4.5
|
#include <BKE_node_socket_value.hh>
Public Member Functions | |
| SocketValueVariant ()=default | |
| template<typename T> | |
| SocketValueVariant (T &&value) | |
| bool | valid_for_socket (eNodeSocketDatatype socket_type) const |
| template<typename T> | |
| T | extract () |
| template<typename T> | |
| T | get () const |
| template<typename T> | |
| void | set (T &&value) |
| bool | is_context_dependent_field () const |
| bool | is_volume_grid () const |
| bool | is_single () const |
| GPointer | get_single_ptr () const |
| GMutablePointer | get_single_ptr () |
| const void * | get_single_ptr_raw () const |
| void | store_single (eNodeSocketDatatype socket_type, const void *value) |
| void * | allocate_single (eNodeSocketDatatype socket_type) |
Friends | |
| std::ostream & | operator<< (std::ostream &stream, const SocketValueVariant &value_variant) |
SocketValueVariant is used by geometry nodes in the lazy-function evaluator to pass data between nodes. Specifically, it is the container type for the following socket types: bool, float, integer, vector, rotation, color and string.
The data passed through e.g. an integer socket can be a single value, a field or a grid (and in the lists and images). Each of those is stored differently, but this container can store them all.
A key requirement for this container is that it is type-erased, i.e. not all code that uses it has to include all the headers required to process the other storage types. This is achieved by using the Any type and by providing templated accessors that are implemented outside of a header.
Definition at line 32 of file BKE_node_socket_value.hh.
Create an empty variant. This is not valid for any socket type yet.
|
inlineexplicit |
Create a variant based on the given value. This works for primitive types, #GField and #Field<T>.
Definition at line 177 of file BKE_node_socket_value.hh.
| void * blender::bke::SocketValueVariant::allocate_single | ( | eNodeSocketDatatype | socket_type | ) |
Replaces the stored value with a new uninitialized single value for the given socket type. The caller is responsible to construct the value in the returned memory before it is used.
Definition at line 347 of file node_socket_value.cc.
| T blender::bke::SocketValueVariant::extract | ( | ) |
Get the stored value as a specific type. For convenience this allows accessing the stored type as a different type. For example, a stored single int can also be accessed as GField or Field<int> (but not float or Field<float>).
This method may leave the variant empty, in a moved from state or unchanged. Therefore, this should only be called once.
Definition at line 116 of file node_socket_value.cc.
| T blender::bke::SocketValueVariant::get | ( | ) | const |
Same as extract, but always leaves the variant unchanged. So this method can be called multiple times.
Definition at line 182 of file node_socket_value.cc.
Definition at line 341 of file node_socket_value.cc.
Convert the stored value into a single value. For simple value access, this is not necessary, because get` does the conversion implicitly. However, it is necessary if one wants to use get_single_ptr. Context-dependent fields or grids will just result in a fallback value.
The caller has to make sure that the stored value is a single value, field or grid. */ void convert_to_single();
/** Get a pointer to the embedded single value. The caller has to make sure that there actually is a single value stored, e.g. by calling #convert_to_single.
Definition at line 332 of file node_socket_value.cc.
|
inline |
Similar to get_single_ptr, but returns an untyped pointer. This can only be used if the caller knows for sure which type is contained. In that case, it can be a bit faster though, because the corresponding CPPType does not have to be looked up based on the socket type.
Definition at line 187 of file BKE_node_socket_value.hh.
| bool blender::bke::SocketValueVariant::is_context_dependent_field | ( | ) | const |
If true, the stored value cannot be converted to a single value without loss of information.
Definition at line 281 of file node_socket_value.cc.
| bool blender::bke::SocketValueVariant::is_single | ( | ) | const |
The stored value is a single value.
Definition at line 298 of file node_socket_value.cc.
| bool blender::bke::SocketValueVariant::is_volume_grid | ( | ) | const |
The stored value is a volume grid.
Definition at line 293 of file node_socket_value.cc.
|
inline |
Replaces the stored value with a new value of potentially a different type.
Definition at line 182 of file BKE_node_socket_value.hh.
| void blender::bke::SocketValueVariant::store_single | ( | eNodeSocketDatatype | socket_type, |
| const void * | value ) |
Replace the stored value with the given single value.
Definition at line 229 of file node_socket_value.cc.
| bool blender::bke::SocketValueVariant::valid_for_socket | ( | eNodeSocketDatatype | socket_type | ) | const |
Definition at line 399 of file node_socket_value.cc.
|
friend |
Definition at line 381 of file node_socket_value.cc.