MCPcopy Create free account
hub / github.com/carbonengine/trinity / GetAutoClamppedTangent

Function GetAutoClamppedTangent

trinity/Curves/Tr2CurveScalar.cpp:46–66  ·  view source on GitHub ↗

--------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

44
45// --------------------------------------------------------------------------------
46float GetAutoClamppedTangent( float prevTime, float prevValue, float time, float value, float nextTime, float nextValue )
47{
48 if( ( value < prevValue && value < nextValue ) || ( value > prevValue && value > nextValue ) )
49 {
50 return 0;
51 }
52
53 float valueDiff = std::abs( prevValue - nextValue );
54
55 if( valueDiff == 0 )
56 {
57 return 0;
58 }
59
60 float keyDistance = std::abs( value - prevValue ) / valueDiff;
61 keyDistance = std::min( 1.f, std::min( keyDistance, 1 - keyDistance ) * 6 );
62
63 float autoTangent = ( nextValue - prevValue ) / ( nextTime - prevTime );
64
65 return autoTangent * keyDistance;
66}
67
68}
69

Callers 1

OnKeysChangedMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected