GTcreyon / SM63Redux

Code base for Super Mario 63 Redux
https://sm63redux.com
Mozilla Public License 2.0
199 stars 28 forks source link

Background terrain support #182

Closed Koopa1018 closed 1 year ago

Koopa1018 commented 1 year ago

Description of changes

Modifies terrain system to support background terrain layers.

NOTE: This PR is branched from #181. New changes start on May 30th.

To make background terrain, two features are required: disable-able collision, and changeable Z-order. Collision was dead simple to connect to a checkbox, so the bulk of the changes here went into Z-sorting.

See, the system was designed to render the top border, then bottom, then sides, and use Z-sorting to put them at the right depth relative to each other. The problem was, this meant a terrain object was on no less than three Z-layers (body, sides, top+bottom). If you wanted to put a terrain in the background, it had to move no fewer than 3 steps at a time in order to stay together--which seems both inconvenient and counterintuitive!

With that in mind, I redesigned the system so the draw steps could be reordered in code (surprisingly non-trivial!), then set it up to draw the different borders from back to front--sorting via draw order rather than Z-order. This means entire terrain objects now only take up one Z-layer, which means they can step backwards and forwards easily (and fit between other layers 😉).

Issue(s)

N/A - wanted to get this workable so I know how to make my grass background look its best.

jaschutte commented 1 year ago

Due to the branch this was based on now having merged with main, could you rebase/merge this branch from main again? Hopefully that resolves some of the merge conflicts.

Small nitpick: For in the future, if you make a branch based of another branch, please make a pull request trying to merge into that original branch. Not into main. That prevents conflicts like these.

I'll review it after you thought this branch up to date with main!

Koopa1018 commented 1 year ago

Huh! I've tried PR'ing into branches before and I thought it wasn't possible. Looks like I somehow just didn't get far enough before.

Koopa1018 commented 1 year ago

@jaschutte Update has been accomplished.

jaschutte commented 1 year ago

Looks great!