Forum rules - please read before posting.

Evil optimalisation in ActionTransform

Hi Chris.

Just want to report what I believe to be a curious optimization I found.
 
I was rotating an Object using the 'Object > Transform > Rotate' By Action.

Then I found that at some point is was gimbal locking!
So I looked at the source and found this in ActionTransform.cs

else if (transformType == TransformType.Rotate)
{
if (toBy == ToBy.By){
int numZeros = 0;
if (targetVector.x == 0f) numZeros ++;
if (targetVector.y == 0f) numZeros ++;
if (targetVector.z == 0f) numZeros ++;

if (numZeros == 2){
targetVector = SetRelativeTarget (targetVector, isSkipping, linkedProp.transform.eulerAngles);
}else{
Quaternion currentRotation = linkedProp.transform.localRotation;
linkedProp.transform.Rotate (targetVector, Space.World);
targetVector = linkedProp.transform.localEulerAngles;
linkedProp.transform.localRotation = currentRotation;
}
}
}


Always using quaternions, even if rotating over 1 axis solved the problem. Are there any serious (performance) implications of me turning this optimization off? 

Comments

  • Can't think of any - this gimbal locking has long been a source of frustration, so if it works - make the change.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.