Currently I am trying to set things up in this way:
1.) Cursor enters a button's area/surface.
2.) Enter-area-event triggers GrowButton animation, which causes button to grow by 10%.
3.) Cursor leaves button area.
4.) Exit-area-event triggers ShrinkButton animation, which causes button to shrink to original size.
Very simple in theory. I want the animation affector to interpolate between (BASE-SIZE * 1) and (BASE-SIZE * 1.1)
So my GrowButton animation code looks like this:
Code: Select all
// Size (grow)
{
CEGUI::Affector* affector = pButtonMousedOverAnim->createAffector("Size", "USize");
affector->setApplicationMethod(CEGUI::Affector::AM_RelativeMultiply);
affector->createKeyFrame(0.0f, "{{1.0, 1.0}, {1.0, 1.0}}");
affector->createKeyFrame(0.3f, "{{1.1, 1.0}, {1.1, 1.0}}", CEGUI::KeyFrame::P_QuadraticAccelerating);
}
The above code snippet should give the effect I desire. A ten percent widget expansion on width and height. (Scalar component multipliers interp from 1.0 to 1.1, offset component multipliers fixed at 1.0 ).
But what actually happens is the button's size becomes {{0,0},{0,0}} on the first call to affector->apply().
On tracing into the animation system I've discovered the problem. It is because the interpolateRelativeMultiply() function within TPIInterpolators.h can only properly handle discrete float properties.
Basically, that interpolator only works correctly for discrete 'float' values (such as 'Alpha').
And utterly fails with higher types like 'USize' (required for Position/Size/Rotation properties).
For instance, in my example of wanting to interpolate the size of a button/widget, the following code goes wrong inside interpolateRelativeMultiply():
Code: Select all
typename PropertyHelper<float>::return_type val1 = PropertyHelper<float>::fromString(value1);
typename PropertyHelper<float>::return_type val2 = PropertyHelper<float>::fromString(value2);
This always results in 'val1' and 'val2' being 0.0f. As the USize values are being handled as discrete 'float' values. Which in turn causes all interpolated values between them to be zero (obviously).
I will look into modding the interpolateRelativeMultiply() code to resolve this issue locally so that it can handle USize values properly.
(I will then do a pull-request and all of that integration stuff, etc).
BUT: Before I get around to fixng this locally (real-life-shit keeps getting in the way), does anybody have any higher insights/knowledge on this topic to throw my way?