Camera Work

Published March 28, 2011
Advertisement
I spent a few hours tonight cleaning up the camera movement code. There were badly named variables; old code, from other revisions, that no longer did anything; magic numbers; code to figure things for which D3DX already provides functions; and undocumented formulae. Fun times.

I started looking at this code in order to squash a bug: when moving to the maze side above or below the current one, there's a sudden shift because the view's up vector changes. When the camera followed the player precisely, it didn't matter, because the camera was aligned with the side's axial plane bisecting the view left and right* when the player was moving up or down to the neighboring side; but now that the camera accelerates, it's rarely aligned well enough for the shift to be unnoticeable.

The only real solution, of course, is to update the up vector every frame and have it be a true up vector, rather than update it when the player moves to the side above or below, and have it pointing in whichever axial direction is "up" based on the current camera orientation. But I got sidetracked looking at the horrendous code and didn't do it.

And I won't.

Not tonight, anyway. Partly because I'm still considering how best to approach it (even though I know myself well enough to know that I won't be able to think through it all until I'm halfway through implementing the change), and partly because I'm going to bed as soon as I post this.

I shall likely tackle the problem tomorrow. But for now: Good night.

*I hesitate to say Y-Z plane because the maze can be at any arbitrary rotation. Rather, it would be the axial plane most closely aligned with the camera's Y-Z plane
Previous Entry Considering the Chomp
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement