A few months back, I tested with version 1.8.9 capes to make it more natural and this is one issue I looked at because clamping itself makes the cape have a hard stop which, in my perspective is unnatural, I found that using a logistic function of sorts to "smooth" out the values, though what I have used is a rough function and static numbers are used, it is not production level, but I will throw it out here as information.
[media][media]
{*}{*}
"y" as in the output and "x" as in the swing/f2 variable per the comment, "M" as the "max height", the static number of 6 is a sort of speed of how sloped the curve be, I.E 1 is a steeper slope and 10 is a gradual slope.
Here is my used case for my example in version 1.8.9:
publicvoid doRenderLayer(...) {
if (...) {
// ...float min = ...;
swing = MathHelper.clamp_float(logiFunc(swing, 170), min, 150.0F);
if (swing < 0.0f) {
swing = 0.0f;
}
// ...
}
}
privatefloat logiFunc(float swing, int height) {
// y = x / (sqrt(6 + (x/M)^2))return swing / ((float) Math.sqrt(6 + (Math.pow(swing / height, 2))));
}
There is a flaws in this function, such as "M" the "max height" the more gradual the slope is the "lower" the height is (hence why in my case I used a higher number for the max then my preferred 150).
It will never exceed the "M" value so using a clamp in this case was redundant protection for over 150 and also clamp the value from going under 0.
I am in any way not a mathematician and this is just from researching, just wanted to put this out to see if someone can improve and perhaps even have it implemented in a similar fashion.
A few months back, I tested with version 1.8.9 capes to make it more natural and this is one issue I looked at because clamping itself makes the cape have a hard stop which, in my perspective is unnatural, I found that using a logistic function of sorts to "smooth" out the values, though what I have used is a rough function and static numbers are used, it is not production level, but I will throw it out here as information.
[media][media]{*}{*}
"y" as in the output and "x" as in the swing/f2 variable per the comment, "M" as the "max height", the static number of 6 is a sort of speed of how sloped the curve be, I.E 1 is a steeper slope and 10 is a gradual slope.
Here is my used case for my example in version 1.8.9:
There is a flaws in this function, such as "M" the "max height" the more gradual the slope is the "lower" the height is (hence why in my case I used a higher number for the max then my preferred 150).
It will never exceed the "M" value so using a clamp in this case was redundant protection for over 150 and also clamp the value from going under 0.
Test: https://youtu.be/4K0fd63xLdc
I am in any way not a mathematician and this is just from researching, just wanted to put this out to see if someone can improve and perhaps even have it implemented in a similar fashion.