IndexedGradientSampler< T_ModeNone, T_ModeLinearKnot, T_ModeSmoothKnot, T_ModeBlend, T_ModeCubicKnot, T_ModeCubicBias > Class Template Reference

#include <gradientmath.h>

Detailed Description

template<UInt T_ModeNone = 0, UInt T_ModeLinearKnot = 1, UInt T_ModeSmoothKnot = 2, UInt T_ModeBlend = 3, UInt T_ModeCubicKnot = 4, UInt T_ModeCubicBias = 5>
class maxon::IndexedGradientSampler< T_ModeNone, T_ModeLinearKnot, T_ModeSmoothKnot, T_ModeBlend, T_ModeCubicKnot, T_ModeCubicBias >

This class implements the gradient blending operation for a series of knots with different interpolation modes. For performance reasons interpolation modes are handled as unsigned integers.

Template Parameters
T_ModeNoneThe index of constant / stairstep interpolation of 1 knot.
T_ModeLinearKnotThe index of linear interpolation between 2 knots.
T_ModeSmoothKnotThe index of the smooth-stepped linear interpolation between 2 knots.
T_ModeBlendThe index of the box-stepped linear interpolation between 2 knots.
T_ModeCubicKnotThe index of the cubic interpolation between 4 knots.
T_ModeCubicBiasThe index of the cubic interpolation between 2 knots.

Public Member Functions

template<typename ValueType , typename SortedKnotsType , typename GetKnotValueFunc , typename GetKnotInterpolationModeFunc , typename GetKnotBiasFunc >
Result< ValueType > Sample (typename SortedKnotsType::FloatType absolutePosition, const SortedKnotsType &sortedKnots, const GetKnotValueFunc &getKnotValue, const GetKnotInterpolationModeFunc &getKnotInterpolationMode, const GetKnotBiasFunc &getKnotBias) const
 

Static Private Member Functions

template<typename FloatType >
static FloatType GetBiasedWeight (FloatType weight, FloatType bias)
 
template<typename FloatType >
static Vec4< FloatType > GetCubicBlendWeights (FloatType a)
 
template<typename ValueType , typename FloatType , typename IntType , typename GetKnotValueFunc >
static Result< ValueType > BlendTwoValuesLinear (IntType leftIndex, IntType rightIndex, FloatType weight, const GetKnotValueFunc &getKnotValue)
 
template<typename ValueType , typename FloatType , typename IntType , typename GetKnotValueFunc >
static Result< ValueType > BlendTwoValuesCubic (IntType leftIndex, IntType rightIndex, FloatType biasLeft, FloatType biasRight, const Vec4< FloatType > &cubicWeights, const GetKnotValueFunc &getKnotValue)
 
template<typename ValueType , typename FloatType , typename IntType , typename GetKnotValueFunc >
static Result< ValueType > BlendFourValues (IntType index0, IntType index1, IntType index2, IntType index3, FloatType weight, const GetKnotValueFunc &getKnotValue)
 

Static Private Attributes

static const UInt InterpolationNone
 
static const UInt InterpolationLinearKnot
 
static const UInt InterpolationSmoothKnot
 
static const UInt InterpolationBlend
 
static const UInt InterpolationCubicKnot
 
static const UInt InterpolationCubicBias
 

Member Function Documentation

◆ GetBiasedWeight()

static FloatType GetBiasedWeight ( FloatType  weight,
FloatType  bias 
)
staticprivate

Applies the bias blending to a weight.

Template Parameters
FloatTypeThe type of real number.
Parameters
[in]weightThe original unbiased weight.
[in]biasThe bias to apply.
Returns
The biased weight.

◆ GetCubicBlendWeights()

static Vec4<FloatType> GetCubicBlendWeights ( FloatType  a)
staticprivate

Computes the four blend weights of cubic interpolation.

Template Parameters
FloatTypeThe type of real number.
Parameters
[in]aThe original weight.
Returns
The cubic blend weights.

◆ BlendTwoValuesLinear()

static Result<ValueType> BlendTwoValuesLinear ( IntType  leftIndex,
IntType  rightIndex,
FloatType  weight,
const GetKnotValueFunc &  getKnotValue 
)
staticprivate

Linearly interpolates between two values.

Template Parameters
ValueTypeThe type of value to interpolate.
FloatTypeThe type of real number.
IntTypeThe type of index.
GetKnotValueFuncThe type of value sample function.
Parameters
[in]leftIndexThe index of the left knot.
[in]rightIndexThe index of the right knot.
[in]weightThe interpolation weight between the 2 knots.
[in]getKnotValueThe value sample function.
Returns
The interpolated value on success.

◆ BlendTwoValuesCubic()

static Result<ValueType> BlendTwoValuesCubic ( IntType  leftIndex,
IntType  rightIndex,
FloatType  biasLeft,
FloatType  biasRight,
const Vec4< FloatType > &  cubicWeights,
const GetKnotValueFunc &  getKnotValue 
)
staticprivate

Computes the biased cubic interpolation between two values.

Template Parameters
ValueTypeThe type of value to interpolate.
FloatTypeThe type of real number.
IntTypeThe type of index.
GetKnotValueFuncThe type of value sample function.
Parameters
[in]leftIndexThe index of the left knot.
[in]rightIndexThe index of the right knot.
[in]biasLeftThe bias towards the left knot.
[in]biasRightThe bias towards the right knot.
[in]cubicWeightsThe cubic weights.
[in]getKnotValueThe value sample function.
Returns
The interpolated value.

◆ BlendFourValues()

static Result<ValueType> BlendFourValues ( IntType  index0,
IntType  index1,
IntType  index2,
IntType  index3,
FloatType  weight,
const GetKnotValueFunc &  getKnotValue 
)
staticprivate

Computes the interpolation between four values.

Template Parameters
ValueTypeThe type of value to interpolate.
FloatTypeThe type of real number.
IntTypeThe type of index.
GetKnotValueFuncThe type of value sample function.
Parameters
[in]index0The index of the first knot.
[in]index1The index of the second knot.
[in]index2The index of the third knot.
[in]index3The index of the fourth knot.
[in]weightThe interpolation weight.
[in]getKnotValueThe value sample function.
Returns
The interpolated value on success.

◆ Sample()

Result<ValueType> Sample ( typename SortedKnotsType::FloatType  absolutePosition,
const SortedKnotsType &  sortedKnots,
const GetKnotValueFunc &  getKnotValue,
const GetKnotInterpolationModeFunc &  getKnotInterpolationMode,
const GetKnotBiasFunc &  getKnotBias 
) const

Samples the gradient at the requested position.

Template Parameters
ValueTypeThe type of value to sample.
SortedKnotsTypeThe type of sorted knot sequence.
GetKnotValueFuncThe type of value sample function.
GetKnotInterpolationModeFuncThe type of interpolation mode sample function.
GetKnotBiasFuncThe type of bias sample function.
Parameters
[in]absolutePositionThe position to sample in the gradient.
[in]sortedKnotsThe sorted knot sequence.
[in]getKnotValueThe value sample function..
[in]getKnotInterpolationModeThe interpolation mode sample function.
[in]getKnotBiasThe bias sample function.
Returns
The sampled value on success, error otherwise.

Member Data Documentation

◆ InterpolationNone

const UInt InterpolationNone
staticprivate

◆ InterpolationLinearKnot

const UInt InterpolationLinearKnot
staticprivate

◆ InterpolationSmoothKnot

const UInt InterpolationSmoothKnot
staticprivate

◆ InterpolationBlend

const UInt InterpolationBlend
staticprivate

◆ InterpolationCubicKnot

const UInt InterpolationCubicKnot
staticprivate

◆ InterpolationCubicBias

const UInt InterpolationCubicBias
staticprivate