I had trouble with a careless bug for 2 days. Maybe you will laugh at my careless troubles. Or, that may be a good lesson for me and you.
I developed the mathematics function which calculate the rotation from a normal vector to another normal vector. By that, a object can turn toward the specified point. This common function is useful for beasts to lock on the player and attack him. On this my working, I tied the new way which doesn’t need the angle between these two normal vectors. In this way, the quaternion is calculated by dot product and cross product only, without arccosine. This way is famous, but it’s my first challenge to implement actually for me.
Implementing was finished. I and co-workers were very pleased with the reformed method ‘Look at’. But, after a bit, we noticed that an object turned by this method show its back to the target point. Another programer inverted the basic vector indicating the front direction. He solved this first problem, and adjusted some points. I didn’t know his fixing and I encountered another trouble soon. When I gave ‘go forward’ to objects, objects started backward.
We had a meeting and assume that the cause of this bug was mixing of difference coordinate systems. We had used right-handed coordinate system. Therefore, we just had to find buggy code including calculation code with left-handed coordinate system. But, we could not get the bug point.
Next day, a designer noticed the option item of the mesh data exporter had been switched to convert the data as left-handed coordinate system. We didn’t validate whether the data is correctly for our test. Because I wrote alien code which we didn’t understand perfectly, we decided that the cause was a programming bug…