.panAngleToUpdate EQUB 20 \ Direction 0 (pan right, scroll left) EQUB -8 \ Direction 1 (pan left, scroll right) EQUB 4 \ Direction 2 (pan up, scroll down) EQUB -12 \ Direction 3 (pan down, scroll up)Name: panAngleToUpdate [Show more] Type: Variable Category: Drawing the landscape Summary: Pitch and yaw angles for panning the landscape view, so the output of DrawLandscapeView will be the bit we add when updating the viewContext: See this variable in context in the source code References: This variable is used as follows: * PanLandscapeView uses panAngleToUpdate
This table contains the angles through which we need to pitch or yaw the landscape view when we need to scroll the landscape view during a pan. The DrawLandscapeView routine always renders the full view, and its output is clipped to the size of the screen or screen buffer. This clipping is done on the screen x- and y-coordinates, and the clipping is done from the right or bottom edges of the screen. This means that when we pan the screen, we effectively redraw the whole view, which is 20 yaw angles wide and 12 pitch angles tall, and then use the newly drawn portion from the top-left corner of that redrawn view for the new part that we scroll into the screen to complete the pan. When panning left, we can simply subtract 8 from the player's current yaw angle to rotate the player's view to the left. This moves the player's gaze to the left, so when we draw the new landscape view into the screen buffer, the portion on the left of the view is the new part that the player is now seeing, so clipping the left portion of the view into the screen buffer will give us the content that we need to scroll in from the left to perform the pan. Things are different when panning right. If we simply add 8 to the player's current yaw angle, then the new part of the landscape view will be on the far right of the newly drawn view, so it will be clipped when drawing into the screen buffer. So instead we add 20 to the player's yaw angle to rotate the view to the right by an entire screen's width, so when the view is drawn and clipped, the new portion will be on the left of the newly drawn view, just as it was when panning left. As long as we make sure to set the player's yaw angle correctly after we have finished drawing - by subtracting 12 from the player's yaw angle, leaving them with a net rotation of 8 to the right - then this approach ensures that the new portion of the screen is drawn into the screen buffer correctly. The same approach is applied when panning vertically. If we pan up, then we simply add 4 to the player's yaw angle so they look up higher. This moves the player's gaze up, so when we draw the new landscape view into the screen buffer, the portion at the top of the view is the new part that the player is now seeing, so clipping the top portion of the view into the screen buffer will give us the content that we need to scroll in from the top to perform the pan. However, if we are panning down then we need to jump down a whole screen's height, so we subtract 12 from the player's pitch angle, as this is the height of the screen. We then draw the new view, which puts the new portion of the view into the screen buffer. We then fix the player's pitch angle by adding 8, so the net result is a pitch rotation of -4, as required.