Blender V4.3
blender::bke::attribute_math Namespace Reference

Classes

class  BooleanPropagationMixer
 
class  ColorGeometry4bMixer
 
class  ColorGeometry4fMixer
 
struct  DefaultMixerStruct
 
struct  DefaultMixerStruct< bool >
 
struct  DefaultMixerStruct< ColorGeometry4b >
 
struct  DefaultMixerStruct< ColorGeometry4f >
 
struct  DefaultMixerStruct< float >
 
struct  DefaultMixerStruct< float2 >
 
struct  DefaultMixerStruct< float3 >
 
struct  DefaultMixerStruct< float4x4 >
 
struct  DefaultMixerStruct< int >
 
struct  DefaultMixerStruct< int2 >
 
struct  DefaultMixerStruct< int8_t >
 
struct  DefaultMixerStruct< math::Quaternion >
 
struct  DefaultPropagationMixerStruct
 
struct  DefaultPropagationMixerStruct< bool >
 
class  float4x4Mixer
 
class  SimpleMixer
 
class  SimpleMixerWithAccumulationType
 

Typedefs

Mix a dynamic amount of values with weights for many elements.

This section provides an abstraction for "mixers". The abstraction encapsulates details about how different types should be mixed. Usually DefaultMixer<T> should be used to get a mixer for a specific type.

template<typename T >
using DefaultPropagationMixer = typename DefaultPropagationMixerStruct<T>::type
 
template<typename T >
using DefaultMixer = typename DefaultMixerStruct<T>::type
 

Functions

template<typename Func >
void convert_to_static_type (const CPPType &cpp_type, const Func &func)
 
template<typename Func >
void convert_to_static_type (const eCustomDataType data_type, const Func &func)
 
template<>
math::Quaternion mix2 (const float factor, const math::Quaternion &a, const math::Quaternion &b)
 
template<>
math::Quaternion mix3 (const float3 &weights, const math::Quaternion &v0, const math::Quaternion &v1, const math::Quaternion &v2)
 
template<>
math::Quaternion mix4 (const float4 &weights, const math::Quaternion &v0, const math::Quaternion &v1, const math::Quaternion &v2, const math::Quaternion &v3)
 
template<>
float4x4 mix2 (const float factor, const float4x4 &a, const float4x4 &b)
 
template<>
float4x4 mix3 (const float3 &weights, const float4x4 &v0, const float4x4 &v1, const float4x4 &v2)
 
template<>
float4x4 mix4 (const float4 &weights, const float4x4 &v0, const float4x4 &v1, const float4x4 &v2, const float4x4 &v3)
 
Mix two values of the same type.

This is just basic linear interpolation.

template<typename T >
T mix2 (float factor, const T &a, const T &b)
 
template<>
bool mix2 (const float factor, const bool &a, const bool &b)
 
template<>
int8_t mix2 (const float factor, const int8_t &a, const int8_t &b)
 
template<>
int mix2 (const float factor, const int &a, const int &b)
 
template<>
int2 mix2 (const float factor, const int2 &a, const int2 &b)
 
template<>
float mix2 (const float factor, const float &a, const float &b)
 
template<>
float2 mix2 (const float factor, const float2 &a, const float2 &b)
 
template<>
float3 mix2 (const float factor, const float3 &a, const float3 &b)
 
template<>
ColorGeometry4f mix2 (const float factor, const ColorGeometry4f &a, const ColorGeometry4f &b)
 
template<>
ColorGeometry4b mix2 (const float factor, const ColorGeometry4b &a, const ColorGeometry4b &b)
 
Mix three values of the same type.

This is typically used to interpolate values within a triangle.

template<typename T >
T mix3 (const float3 &weights, const T &v0, const T &v1, const T &v2)
 
template<>
int8_t mix3 (const float3 &weights, const int8_t &v0, const int8_t &v1, const int8_t &v2)
 
template<>
bool mix3 (const float3 &weights, const bool &v0, const bool &v1, const bool &v2)
 
template<>
int mix3 (const float3 &weights, const int &v0, const int &v1, const int &v2)
 
template<>
int2 mix3 (const float3 &weights, const int2 &v0, const int2 &v1, const int2 &v2)
 
template<>
float mix3 (const float3 &weights, const float &v0, const float &v1, const float &v2)
 
template<>
float2 mix3 (const float3 &weights, const float2 &v0, const float2 &v1, const float2 &v2)
 
template<>
float3 mix3 (const float3 &weights, const float3 &v0, const float3 &v1, const float3 &v2)
 
template<>
ColorGeometry4f mix3 (const float3 &weights, const ColorGeometry4f &v0, const ColorGeometry4f &v1, const ColorGeometry4f &v2)
 
template<>
ColorGeometry4b mix3 (const float3 &weights, const ColorGeometry4b &v0, const ColorGeometry4b &v1, const ColorGeometry4b &v2)
 
Mix four values of the same type.
template<typename T >
T mix4 (const float4 &weights, const T &v0, const T &v1, const T &v2, const T &v3)
 
template<>
int8_t mix4 (const float4 &weights, const int8_t &v0, const int8_t &v1, const int8_t &v2, const int8_t &v3)
 
template<>
bool mix4 (const float4 &weights, const bool &v0, const bool &v1, const bool &v2, const bool &v3)
 
template<>
int mix4 (const float4 &weights, const int &v0, const int &v1, const int &v2, const int &v3)
 
template<>
int2 mix4 (const float4 &weights, const int2 &v0, const int2 &v1, const int2 &v2, const int2 &v3)
 
template<>
float mix4 (const float4 &weights, const float &v0, const float &v1, const float &v2, const float &v3)
 
template<>
float2 mix4 (const float4 &weights, const float2 &v0, const float2 &v1, const float2 &v2, const float2 &v3)
 
template<>
float3 mix4 (const float4 &weights, const float3 &v0, const float3 &v1, const float3 &v2, const float3 &v3)
 
template<>
ColorGeometry4f mix4 (const float4 &weights, const ColorGeometry4f &v0, const ColorGeometry4f &v1, const ColorGeometry4f &v2, const ColorGeometry4f &v3)
 
template<>
ColorGeometry4b mix4 (const float4 &weights, const ColorGeometry4b &v0, const ColorGeometry4b &v1, const ColorGeometry4b &v2, const ColorGeometry4b &v3)
 
Generic Array Utils Implementations

Extra implementations of functions from #BLI_array_utils.hh for all attribute types, used to avoid templating the same logic for each type in many places.

void gather (GSpan src, Span< int > map, GMutableSpan dst)
 
void gather (const GVArray &src, Span< int > map, GMutableSpan dst)
 
void gather_group_to_group (OffsetIndices< int > src_offsets, OffsetIndices< int > dst_offsets, const IndexMask &selection, GSpan src, GMutableSpan dst)
 
void gather_to_groups (OffsetIndices< int > dst_offsets, const IndexMask &src_selection, GSpan src, GMutableSpan dst)
 

Typedef Documentation

◆ DefaultMixer

template<typename T >
using blender::bke::attribute_math::DefaultMixer = typename DefaultMixerStruct<T>::type

Definition at line 649 of file BKE_attribute_math.hh.

◆ DefaultPropagationMixer

This mixer is meant for propagating attributes when creating new geometry. A key difference with the default mixer is that booleans are mixed with "or" instead of "at least half" (the default mixing for booleans).

Definition at line 645 of file BKE_attribute_math.hh.

Function Documentation

◆ convert_to_static_type() [1/2]

template<typename Func >
void blender::bke::attribute_math::convert_to_static_type ( const CPPType & cpp_type,
const Func & func )
inline

Utility function that simplifies calling a templated function based on a run-time data type.

Definition at line 27 of file BKE_attribute_math.hh.

References BLI_assert_unreachable, float, int, T, and blender::CPPType::to_static_type_tag().

Referenced by blender::draw::overlay::add_values_to_text_cache(), attr_create_generic(), attr_create_generic(), blender::geometry::bezier_generic_to_nurbs(), blender::bke::mesh_surface_sample::BaryWeightSampleFn::call(), blender::nodes::node_geo_curve_sample_cc::SampleCurveFunction::call(), blender::nodes::node_geo_sample_index_cc::SampleIndexFunction::call(), convert_to_static_type(), copy_attributes(), blender::bke::copy_with_checked_indices(), blender::nodes::node_geo_extrude_mesh_cc::copy_with_mixing(), blender::ed::sculpt_paint::greasepencil::create_blank_curve(), blender::draw::pbvh::fill_vbo_attribute_bmesh(), blender::draw::pbvh::fill_vbo_attribute_mesh(), blender::draw::pbvh::fill_vbos_grids(), gather(), gather(), gather_group_to_group(), gather_to_groups(), blender::nodes::node_geo_accumulate_field_cc::AccumulateFieldInput::get_varray_for_context(), blender::draw::init_format_for_attribute(), blender::bke::curves::catmull_rom::interpolate_to_evaluated(), blender::bke::curves::catmull_rom::interpolate_to_evaluated(), blender::geometry::merge_layers(), blender::bke::mesh_flip_faces(), blender::geometry::mix_arrays(), blender::nodes::mix_baked_data_item(), blender::geometry::nurbs_to_bezier_assign(), blender::draw::pbvh::pbvh_attr_supported(), blender::geometry::point_merge_by_distance(), blender::geometry::resample_to_uniform(), blender::bke::mesh_surface_sample::sample_corner_attribute(), blender::geometry::sample_curve_attribute(), blender::bke::mesh_surface_sample::sample_face_attribute(), blender::bke::mesh_surface_sample::sample_point_attribute(), blender::ed::curves::set_attribute_invoke(), blender::nodes::node_geo_dual_mesh_cc::transfer_attributes(), blender::geometry::trim_attribute_linear(), and blender::draw::vertbuf_data_extract_direct().

◆ convert_to_static_type() [2/2]

template<typename Func >
void blender::bke::attribute_math::convert_to_static_type ( const eCustomDataType data_type,
const Func & func )
inline

◆ gather() [1/2]

void blender::bke::attribute_math::gather ( const GVArray & src,
Span< int > map,
GMutableSpan dst )

Definition at line 262 of file attribute_math.cc.

References convert_to_static_type(), and blender::GVArrayCommon::type().

◆ gather() [2/2]

◆ gather_group_to_group()

void blender::bke::attribute_math::gather_group_to_group ( OffsetIndices< int > src_offsets,
OffsetIndices< int > dst_offsets,
const IndexMask & selection,
GSpan src,
GMutableSpan dst )

◆ gather_to_groups()

void blender::bke::attribute_math::gather_to_groups ( OffsetIndices< int > dst_offsets,
const IndexMask & src_selection,
GSpan src,
GMutableSpan dst )

◆ mix2() [1/12]

template<>
bool blender::bke::attribute_math::mix2 ( const float factor,
const bool & a,
const bool & b )
inline

Definition at line 66 of file BKE_attribute_math.hh.

References b.

◆ mix2() [2/12]

template<>
ColorGeometry4b blender::bke::attribute_math::mix2 ( const float factor,
const ColorGeometry4b & a,
const ColorGeometry4b & b )
inline

Definition at line 108 of file BKE_attribute_math.hh.

References b, and blender::math::interpolate().

◆ mix2() [3/12]

template<>
ColorGeometry4f blender::bke::attribute_math::mix2 ( const float factor,
const ColorGeometry4f & a,
const ColorGeometry4f & b )
inline

Definition at line 102 of file BKE_attribute_math.hh.

References b, and blender::math::interpolate().

◆ mix2() [4/12]

template<>
float blender::bke::attribute_math::mix2 ( const float factor,
const float & a,
const float & b )
inline

Definition at line 86 of file BKE_attribute_math.hh.

References b.

◆ mix2() [5/12]

template<>
float2 blender::bke::attribute_math::mix2 ( const float factor,
const float2 & a,
const float2 & b )
inline

Definition at line 91 of file BKE_attribute_math.hh.

References b, and blender::math::interpolate().

◆ mix2() [6/12]

template<>
float3 blender::bke::attribute_math::mix2 ( const float factor,
const float3 & a,
const float3 & b )
inline

Definition at line 96 of file BKE_attribute_math.hh.

References b, and blender::math::interpolate().

◆ mix2() [7/12]

template<>
float4x4 blender::bke::attribute_math::mix2 ( const float factor,
const float4x4 & a,
const float4x4 & b )

Definition at line 41 of file attribute_math.cc.

References b, and blender::math::interpolate().

◆ mix2() [8/12]

template<>
int blender::bke::attribute_math::mix2 ( const float factor,
const int & a,
const int & b )
inline

Definition at line 76 of file BKE_attribute_math.hh.

References b, and int.

◆ mix2() [9/12]

template<>
int2 blender::bke::attribute_math::mix2 ( const float factor,
const int2 & a,
const int2 & b )
inline

Definition at line 81 of file BKE_attribute_math.hh.

References b, and blender::math::interpolate().

◆ mix2() [10/12]

template<>
int8_t blender::bke::attribute_math::mix2 ( const float factor,
const int8_t & a,
const int8_t & b )
inline

Definition at line 71 of file BKE_attribute_math.hh.

References b.

◆ mix2() [11/12]

template<>
math::Quaternion blender::bke::attribute_math::mix2 ( const float factor,
const math::Quaternion & a,
const math::Quaternion & b )

Definition at line 15 of file attribute_math.cc.

References b, and blender::math::interpolate().

◆ mix2() [12/12]

◆ mix3() [1/12]

template<>
bool blender::bke::attribute_math::mix3 ( const float3 & weights,
const bool & v0,
const bool & v1,
const bool & v2 )
inline

Definition at line 129 of file BKE_attribute_math.hh.

References v2.

◆ mix3() [2/12]

template<>
ColorGeometry4b blender::bke::attribute_math::mix3 ( const float3 & weights,
const ColorGeometry4b & v0,
const ColorGeometry4b & v1,
const ColorGeometry4b & v2 )
inline

◆ mix3() [3/12]

template<>
ColorGeometry4f blender::bke::attribute_math::mix3 ( const float3 & weights,
const ColorGeometry4f & v0,
const ColorGeometry4f & v1,
const ColorGeometry4f & v2 )
inline

Definition at line 163 of file BKE_attribute_math.hh.

References interp_v4_v4v4v4(), result, and v2.

◆ mix3() [4/12]

template<>
float blender::bke::attribute_math::mix3 ( const float3 & weights,
const float & v0,
const float & v1,
const float & v2 )
inline

Definition at line 145 of file BKE_attribute_math.hh.

References v2.

◆ mix3() [5/12]

template<>
float2 blender::bke::attribute_math::mix3 ( const float3 & weights,
const float2 & v0,
const float2 & v1,
const float2 & v2 )
inline

Definition at line 151 of file BKE_attribute_math.hh.

References v2.

◆ mix3() [6/12]

template<>
float3 blender::bke::attribute_math::mix3 ( const float3 & weights,
const float3 & v0,
const float3 & v1,
const float3 & v2 )
inline

Definition at line 157 of file BKE_attribute_math.hh.

References v2.

◆ mix3() [7/12]

◆ mix3() [8/12]

template<>
int blender::bke::attribute_math::mix3 ( const float3 & weights,
const int & v0,
const int & v1,
const int & v2 )
inline

Definition at line 134 of file BKE_attribute_math.hh.

References int, and v2.

◆ mix3() [9/12]

template<>
int2 blender::bke::attribute_math::mix3 ( const float3 & weights,
const int2 & v0,
const int2 & v1,
const int2 & v2 )
inline

Definition at line 139 of file BKE_attribute_math.hh.

References v2.

◆ mix3() [10/12]

template<>
int8_t blender::bke::attribute_math::mix3 ( const float3 & weights,
const int8_t & v0,
const int8_t & v1,
const int8_t & v2 )
inline

Definition at line 124 of file BKE_attribute_math.hh.

References v2.

◆ mix3() [11/12]

template<>
math::Quaternion blender::bke::attribute_math::mix3 ( const float3 & weights,
const math::Quaternion & v0,
const math::Quaternion & v1,
const math::Quaternion & v2 )

◆ mix3() [12/12]

◆ mix4() [1/12]

template<>
bool blender::bke::attribute_math::mix4 ( const float4 & weights,
const bool & v0,
const bool & v1,
const bool & v2,
const bool & v3 )
inline

Definition at line 205 of file BKE_attribute_math.hh.

References v2.

◆ mix4() [2/12]

template<>
ColorGeometry4b blender::bke::attribute_math::mix4 ( const float4 & weights,
const ColorGeometry4b & v0,
const ColorGeometry4b & v1,
const ColorGeometry4b & v2,
const ColorGeometry4b & v3 )
inline

◆ mix4() [3/12]

template<>
ColorGeometry4f blender::bke::attribute_math::mix4 ( const float4 & weights,
const ColorGeometry4f & v0,
const ColorGeometry4f & v1,
const ColorGeometry4f & v2,
const ColorGeometry4f & v3 )
inline

Definition at line 247 of file BKE_attribute_math.hh.

References interp_v4_v4v4v4v4(), result, and v2.

◆ mix4() [4/12]

template<>
float blender::bke::attribute_math::mix4 ( const float4 & weights,
const float & v0,
const float & v1,
const float & v2,
const float & v3 )
inline

Definition at line 226 of file BKE_attribute_math.hh.

References v2.

◆ mix4() [5/12]

template<>
float2 blender::bke::attribute_math::mix4 ( const float4 & weights,
const float2 & v0,
const float2 & v1,
const float2 & v2,
const float2 & v3 )
inline

Definition at line 233 of file BKE_attribute_math.hh.

References v2.

◆ mix4() [6/12]

template<>
float3 blender::bke::attribute_math::mix4 ( const float4 & weights,
const float3 & v0,
const float3 & v1,
const float3 & v2,
const float3 & v3 )
inline

Definition at line 240 of file BKE_attribute_math.hh.

References v2.

◆ mix4() [7/12]

template<>
float4x4 blender::bke::attribute_math::mix4 ( const float4 & weights,
const float4x4 & v0,
const float4x4 & v1,
const float4x4 & v2,
const float4x4 & v3 )

◆ mix4() [8/12]

template<>
int blender::bke::attribute_math::mix4 ( const float4 & weights,
const int & v0,
const int & v1,
const int & v2,
const int & v3 )
inline

Definition at line 212 of file BKE_attribute_math.hh.

References int, and v2.

◆ mix4() [9/12]

template<>
int2 blender::bke::attribute_math::mix4 ( const float4 & weights,
const int2 & v0,
const int2 & v1,
const int2 & v2,
const int2 & v3 )
inline

Definition at line 218 of file BKE_attribute_math.hh.

References v2.

◆ mix4() [10/12]

template<>
int8_t blender::bke::attribute_math::mix4 ( const float4 & weights,
const int8_t & v0,
const int8_t & v1,
const int8_t & v2,
const int8_t & v3 )
inline

Definition at line 198 of file BKE_attribute_math.hh.

References v2.

◆ mix4() [11/12]

template<>
math::Quaternion blender::bke::attribute_math::mix4 ( const float4 & weights,
const math::Quaternion & v0,
const math::Quaternion & v1,
const math::Quaternion & v2,
const math::Quaternion & v3 )

◆ mix4() [12/12]

template<typename T >
T blender::bke::attribute_math::mix4 ( const float4 & weights,
const T & v0,
const T & v1,
const T & v2,
const T & v3 )