[video output=day314 member=cmuratori stream_platform=twitch stream_username=handmade_hero project=code title="Breaking Sprites into Layers" vod_platform=youtube id=I3pW6bQcxWE annotator=Miblo]
[0:43][Recap and set the stage for the day]
[3:01][Run the game and see where we're at]
[5:20][handmade_entity.cpp: Stop UpdateAndRenderEntities() from calling ConvertToLayerRelative() and instead calculate the RelativeLayer as worked out yesterday]
[8:08][handmade_entity.cpp: Make UpdateAndRenderEntities() get a WorldPos from MapIntoChunkSpace() in order to compute that RelativeLayer]
[10:29][Run the game and see that we're in much better shape]
[11:02][Consider introducing a concept in the render of the layer Z and the actual Z value]
[12:44][handmade_render.h: Add ChunkZ to the sprite_bound struct]
[13:14][handmade_render.cpp: Make IsInFrontOf() test that ChunkZ]
[15:07][handmade_render_group.h: Add ChunkZ to the object_transform struct]
[15:40][handmade_render_group.cpp: Make GetBoundFor() set the ChunkZ]
[16:04][Run the game and see that that doesn't affect anything]
[16:21][handmade_entity.cpp: Make UpdateAndRenderEntities() set that ChunkZ]
[16:43][See how that affects the sort]
[18:21][handmade_entity.cpp: Make UpdateAndRenderEntities() expand the bounds of the traversables to draw them like actual tiles]
[19:34][Run the game and consider our cycling situation]
[20:52][handmade_render.cpp: Shrink the sizes passed to the RectanglesIntersect() call in BuildSpriteGraph()]
[22:03][handmade_debug.cpp: Make DEBUGStart() set the ChunkZ for the debug elements]
[23:13][Run the game and toggle on the debug groups]
[24:55][Consider how to leverage the layer data in the renderer]
[28:11][handmade_entity.cpp: Simplify UpdateAndRenderEntities() so that it only knows about the alpha and the fog levels]
[32:25][handmade_entity.cpp: Turn off the Alpha]
[33:35][handmade_render_group.cpp: Make StoreColor() take a pointer to an object_transform and change all other functions to take a pointer to it]
[40:43]["In theory this is a computer, yes?"][quote 507]
[41:08][handmade_entity.cpp: Make UpdateAndRenderEntities() set the Color and tColor for the top layer and the far fog]
[43:00][Run the game, break into UpdateAndRenderEntities() and inspect the EntityTransform values]
[43:57][handmade_entity.cpp: Make UpdateAndRenderEntities() reverse the TestAlpha computation]
[44:40][handmade_world_mode.cpp: Make AddStandardRoom() generate multiple layers of rooms]
[45:00][Run the game, see how those layers of rooms look and consult the profiler]
[45:39][build.bat: Switch to -O2, run the game and consult the profiler again]
[46:16]["Oh my god! Why are there so many heads following me?"][quote 508]
[48:41][Consider always rendering everyone with the ChunkZ they started with]
[50:34][Blackboard: Sort Barriers]
[53:02][handmade_render.h: #define SPRITE_BARRIER_OFFSET_VALUE]
[53:57][handmade_render.cpp: Make BuildSpriteGraph() take and return NodeIndexA, which SortEntries() will pass to it]
[57:07][Run the game and see that we have no change]
[57:22][build.bat: Switch back to -Od, run the game and enable the sort groups]
[58:15][Q&A][:speech]
[58:44][@Miblo][Where are all those familiars coming from?!]
[1:01:15][@jheringa][Snake looks broken?]
[1:06:47][Wrap it up][:speech]
[/video]
