-
DolphinDream создал
* Add new Mix Numbers node - WIP * Adopt the SV easing functions into the MixNumbers node Ditch the easing functions copied from AnimationNodes add-on and replace them with the SV equivalents (sv_easing_functions.py) Notes: * the SV easing functions are currently buggy and will be updated in the next commits. * keep the AN easing code accessible via interpolate1 for comparision * the code is not yet optimized as far as the interpolator switch goes (will optimize in next commits) * Minor comment and default edits to MixNumbers node - get rid of the "AUTO" easing. Not sure what this is used for in blender. - set default easing to IN-OUT instead of AUTO (since auto was IN-OUT) - increased node width to better display the node UI elements to avoid some text cropping. * Optimize MixNumbers code to use interpolator Instead of if/else/else for every interpolated value now the interpolator is selected once before the loop via getInterpolator * Minor updates to sv_easing_functions Minor update to make the function mirroring/inversion definitions consistent (e.g. 1-p, 1-f etc) Note: slightly increase in speed with no other computation penalty QuadraticEaseInOut - go from 2 +/- and 3 * to 2 +/- and 2 * (slightly faster) - consistent with the inversion pattern 1 - A CubicEaseInOut - go from 2 +/- and 4 * to 2 +/- and 3 * (slightly faster) - consistent with the inversion pattern 1 - A QuinticEaseInOut - go from 2 +/- and 6 * to 2 +/- and 5 * (slightly faster) - consistent with the inversion pattern 1 - A * Expose some easing parameters with some same defaults in sv_easing_functions In order to prepare for the "mix numbers" node that will allow for the currently hard coded parameters of some of the easing functions to be changed by the user, some easing functions are parametrized keeping the current default values. Note: adding the extra parameters with defaults ensures other nodes or current node setups depending on these easing functions will break after this update. ExponentialEase* - this now takes b (base) and e (exponent) with the defaults b=2 and e=10 as extra parameters ElasticEase* - this now takes n (number of oscillations), b (attenuation base) and e (attenuation exponent) with the defaults 13, 2, and 10. BackEase* - this now takes an extra s (scale) parameter with default = 1 to scale the amount of overshooting Notes: - No parametrization was added to the Bounce functions since these will be re-written from ground up to allow full parametrization - The SV Elastic, Exponential, Sine functions are incorrect even before this parametrization update (will be fixed in the next commit.. stay tuned) * Fixing sinusoidal, elastic and exponential easing functions - re-purpose M_PI_2 to be pi/2 and defined M_2_PI to be 2*pi (cached values) SineEase* - fix sine ease in/out functions since they were incorrect. Both have to start from 0 and end at 1 with proper ease in and ease out. f(p) = 0 -> 1 for p = 0 -> 1. ExponentialEase* - for p=0 in easeIn or p=1 in easeOut the exponential is pow(b, -e) which is a very small value given the default b=2 and e=10, which is the reason why the if statement tried to snap the interpolated values to 0 or 1, however for different values of b and e this snap conditions are artificial (and visually noticeable as a sharp jump in the exponential curve). The correct way to handle this is to scale the exponential function f=e(b,-e*p) when p = [0,1] to span f=[0,1] and for this you do: f = (e(b,-e*p) - e(b,-e) ) / (1 - e(b,-e)) (where p=[0,1]) e(b,-e) is the minimum value of the exponential function (corresponding to p=1) Note: since the exponential operation is expensive we can optimize by caching this minimu value as m = e(b,-e). An even better optimization is to pre-calculate this once before calling this functions for all p (to be done in the next commit). In summary, the exponential ease functions behave correctly now for all b & e although at a slight penalty: an extra addition/subtraction and a divion/multiplication ops. ElasticEase* - The elastic ease functions did not end up at 1 (for p=1). We must have f(p) = 0 -> 1 for p = 0->1. This update shifts the oscillations by pi/2 to make the end of the interpolation reach its ONEness :) * Add experimental fully parametrized bounce easing function Add fully parametrized bounce easing function to let user adjust number of bounces & attenuation. The derived formula is based on geometric progression series combined with a parabolic function for each bounce (see code comments) Note: this is likely to be somewhat slower than the cryptic, simplistic version with hardcoded version from before, but it's comparable in speed, with the benefit of being fully parametrized. * Connect extra parameters to the easing functions in MixNumbers node Extra parameters for elastic, exponential, back and bounce are fed into the easing functions. * Optimize easing functions via pre calcualted derived settings Certain derived values within the easing functions dependent on the main parameters and do not change with p and thus can be cached before calling these functions for all values of p. This update introduces the prepare*Settings and default*Settings to be used to pre calculate these parameters. The default values ensure compatibility with nodes using the easing functions relying on default behavior. - update MixNumber node to use the optimized easing function version - cleanup mixNumber node to remove old NA easing functions * Simplify the getInterpolator in MixNumbers node - shaved off about 100 lines of code by simplifying the getInterpolator function in MixNumbers node - remove unused callback functions - change node icon with IPO icon - update easing_dict function order in sv_easing_function to match the blender's built-in interpolation function order (which also matches the order of the interpolations types in mixNumbers node :) This makes it easy to match the MixNumbers interpolation ID & easing ID to a function ID in the dictionary. * Revert sv easing function reordering and create new dict in mixNumbers Reordering of the sv easing dictionary keys was not the prefered way to do things, thus I revert the changes to keep the previous key order and add a separate easing function dictionary to the mixNumbers node with the desired order. * Simplify the interpolator selection in MixNumbers node Redefined the interpolator dictionary to take string = "interpolation-easing" as the key to avoid having to search for IDs to do the function mapping. * Further simplify the interpolator getter in MixNumbers node Squeezing the last bit interpolator getter :) using some zeffii magic ;) - remove the extra dictionary and replace it by converting the interpolation-easing string into a function (with sine and linear as special cases: sinusoidal is sine and linear has no easing). * Rename mixNumber.py mix_numbers.py - rename file to match sv filename rule - minor comment edit * Add docs for the mix-number node * Compact the props line in mix numbers node to reduce vertical spread Shaved off 30 more lines
2c4cb007