Prevent updating the current transformation matrix when the stateStack is empty

Fixes #3925.