[video output=day303 member=cmuratori stream_platform=twitch stream_username=handmade_hero project=code title="Trying Separate Y and Z Sorts" vod_platform=youtube id=93NKevv-n6k annotator=Miblo]
[0:50][Be our own code fairy][quote 496]
[1:16][Recap and set the stage for the day]
[1:57][Z-buffering is not a good idea for 2D stuff]
[4:08][quartertron's sorting suggestion, or potentially using an insertion sort to make a poor man's binary space partition[ref
    site="Twitter"
    page="@cmuratori I'm probably missing cases but this makes sense to me and gives good results in current game"
    url="https://twitter.com/quartersdg/status/744583290766581761"]]
[7:04][Blackboard: Separately sorting Z-sprites and Y-sprites, then merge sorting those sorted sprites]
[14:23][handmade_sort.cpp: Introduce versions of MergeSort() for MergeSortY() and MergeSortZ()]
[19:29][handmade_sort.cpp: Introduce versions of IsInFrontOf() for IsInFrontOfY() and IsInFrontOfZ()]
[20:51][Consider how to separate the Y- and Z-sprites]
[23:26][handmade_sort.cpp: Make MergeSort() separate the Y- and Z-sprites]
[24:12][Blackboard: Separating and compacting an array]
[25:14][handmade_sort.cpp: Continue making MergeSort() separate out those sprites]
[27:55][Blackboard: The sizes of the two arrays]
[29:08][handmade_sort.cpp: Make MergeSort() call MergeSortY() and MergeSortZ()]
[31:01][Blackboard: Copies of the sorted stuff]
[31:57][handmade_sort.cpp: Consider making MergeSortZ() copy to the Temp buffer]
[33:24][handmade_sort.cpp: Make MergeSort() copy to the Temp buffer if there are 1 or 2 Z-sprites to be sorted]
[39:16]["It's no skin off our back"][quote 494]
[39:18][handmade_sort.cpp: Clean up compile errors]
[41:21]["We probably need to go through this code more carefully"][quote 495]
[42:14][Run the game and see that we are sort of anywhere close]
[42:51][Run the game and hit the assertion in SortEntries()]
[43:41][Debugger: Break into MergeSort() and inspect the YCount and ZCount]
[45:02][handmade_sort.cpp: Give MergeSort() some verification tests]
[45:31][handmade_sort.cpp: Introduce IsZSprite()]
[46:27][handmade_sort.cpp: Continue giving MergeSort() these tests]
[47:05][Debugger: Break into MergeSort() and find that it passed the tests]
[47:19][handmade_sort.cpp: Introduce VerifyBuffer() to verify the type of sprites in that buffer, and make MergeSort() call it]
[49:23][Debugger: Break into MergeSort() again and find that everything is in the right place]
[49:58][Consider making a better merge]
[51:38][Blackboard: What the sort is doing]
[53:10][handmade_sort.cpp: Look at what IsInFrontOf() is doing]
[55:28][handmade_sort.cpp: Make VerifyBuffer() verify that the sprites are correctly sorted]
[56:26][Debugger: Run the game and hit the assertion in VerifyBuffer()]
[56:53][A few words on "test driven development"]
[58:02][Debugger: Break into VerifyBuffer() and inspect the positions of the sprites upon failing]
[59:38][handmade_sort.cpp: Turn MergeSortY() into MergeSort() in order to do IsInFrontOf() in both cases]
[1:00:37][handmade_sort.cpp: Rename MergeSort() to SeparatedSort(), and remove MergeSortZ() entirely]
[1:01:17][Debugger: Run the game and catch some sprites that our test thinks are incorrectly sorted]
[1:02:39][handmade_sort.cpp: Temporarily toggle SortEntries() to do only the partial ordering check]
[1:02:54][Run the game and see the visual results]
[1:03:12][Q&A][:speech]
[1:05:37][@roam00010011][I'm trying to take a different approach, using the projected sprites on the screen to sort, and using the min / max y values (up) as a depth sorting key]
[1:06:19][@roam00010011][Working on it]
[1:07:24][@staythirsty90][What is a full stack developer?]
[1:10:08][@poohshoes][Won't sorting fail because a lower Z sometimes needs to be drawn on top of a higher Z if a Y-sprite overlaps them?]
[1:11:05][Blackboard: PoohShoes's diagram]
[1:12:52][@Miblo][At the start you mentioned "insertion sort" and potentially automatically getting a binary tree representation of the sprites. What happened to that idea, assuming I roughly understand correctly what you've done?]
[1:13:11][Blackboard: Graph sort]
[1:14:49][@roam00010011][How do you transform the sprites from world to screen coordinates?]
[1:15:11][That's it for today][:speech]
[/video]
