How to get ajusted getSwingZAngle() to compare to Swing1Limit in ue4 PxJoint?


I have a hand with rootbone and index1 bone. They both have initial Transforms and are not zeroed out. When I then add a constraint to the index1 finger I already get like -8.9 degree from getSwingZAngle(). Then comparing it to the swing1limit I am always 8.9 over or under the limits.

Now I wanted to find a way to compare the getSwingZAngle() to the Swing1Limit withouth those -8.9 and withouth storing the intial value at each initialization.

I tried a lot of transform inversion from root to index bodies, like for example comparing the angle between the forward vector of the reference frame PriAxis2 to FVector(1,0,0) in ue, but I never get this -8.9 degree I would like to cancel out.

Joint->getRelativeTransform() gives me the -8.9 degree I am looking for on the swing1, but it also changes in realtime, so I can not use it for ajustment. I also tried to invTransform it to various poses provided by physx.

Thank you very much for an answer.

I tried a new approach again, or maybe I tried it before but already forgot… :) Still this doesnt give me the initial swing1angle.

//For test there is only one constraint, so first element of USkeletalMesh Constraint Array
FConstraintInstance* CurConstraintInstance = TargetMesh->Constraints[0];

//Reference Frame from where swing angles are calculated from? Frame 2 is the parent body in unreal
FTransform RefFrame = CurConstraintInstance->GetRefFrame(EConstraintFrame::Frame2);

//Unreal Transform to PhysX Transform
PxTransform RefFramePx = U2PTransform(RefFrame);

//Get the initial angle of swing1?
float angledegree = FMath::RadiansToDegrees(RefFramePx.q.getBasisVector0().dot(PxVec3(1, 0, 0)));

The last part to get the angle was from this forum thread: