I’m looking at the ikfk2Bone.cpp to look for the code snippet controlling the softness algorithm. Seems I found it and maybe some folks could chime in what could potentially be causing the issue. I’m guessing it’s possibly the if statement but I’m not entirely sure how the rest of the code below is being calculated. I don’t see any other calls to the softness.
// Distance with MaxStretch ---------------------
double restLength = (data.lengthA * data.scaleA + data.lengthB * data.scaleB) * global_scale;
double distance = rootEffDistance;
double distance2 = distance;
if (distance > (restLength * data.maxstretch))
distance = restLength * data.maxstretch;
// Adapt Softness value to chain length --------
data.softness = data.softness * restLength * .1;
// Stretch and softness ------------------------
// We use the real distance from root to controler to calculate the softness
// This way we have softness working even when there is no stretch
double stretch = std::max(1.0, distance / restLength);
double da = restLength - data.softness;
if ((data.softness > 0) && (distance2 > da)){
double newlen = data.softness*(1.0 - exp(-(distance2 -da)/data.softness)) + da;
stretch = distance / newlen;
}
data.lengthA = data.lengthA * stretch * data.scaleA * global_scale;
data.lengthB = data.lengthB * stretch * data.scaleB * global_scale;
It seems the Length A and B are entirely dependent on the Stretch being added into the variable. And the softness is only if the if statement is true.
double newlen = data.softness*(1.0 - exp(-(distance2 -da)/data.softness)) + da;
stretch = distance / newlen;
My understanding, looking at the logic of the original algorithm may be something more like this.
RestLength - Length of joint chain (Joint A) + (Joint B)
RestLength = (JointA) + (JointB)
softAmount = (Whatever 1.0)
SoftDistance = RestLength - softAmount
distance = (Distance between Joint A and Joint B)
if (distance > SoftDistance)
IKHandle = SoftDistance + softAmount * (1-exp( -(distance - SoftDistance))
else
IKHandle = distance
I have no idea if what I wrote makes sense, it’s not any specific language just what i found from reading and researching. Any thoughts?