[video output=day464 member=cmuratori stream_platform=twitch stream_username=handmade_hero project=code title="Applying Asset Types and Tags to Imported PNGs" vod_platform=youtube id=afBjVoBhvOM annotator=Miblo]
[0:00][Recap and set the stage for the day plumbing in the :"asset loading"][:speech]
[1:05][Review CheckForArtChanges() in terms of over-imported asset avoidance][:"asset loading" :research]
[3:32][Review WriteModificationsToHHA() with the determination to extract information from, and tag, assets][:"asset loading" :research]
[4:36][Enable WriteModificationsToHHA() to insert assets into the .hha files][:"asset loading"]
[12:20][Make WriteModificationsToHHA() tag assets with their existing tags][:"asset loading"]
[17:50][Provide the option for the Win32OpenFile callback to conditionally open files with read or write access[ref
    site="Microsoft Docs"
    page="CreateFileA function"
    url=https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-createfilea]][:"file io" :"platform layer"]
[25:21][Consider consolidating down the platform_api][:"platform layer" :speech]
[28:22][Make all necessary functions use our new Win32OpenFile options][:"file io" :"platform layer"]
[29:43][:Run the game and determine to embark on the new tagging scheme][:"asset loading"]
[30:36][Set up to assign tags to assets, introducing ReserveTag()][:"asset loading"]
[33:14][Consider using the old school tags for now, with thoughts for the new tagging scheme][:"asset loading" :"entity system"]
[35:14][Introduce the notion of an Asset_Hand, and begin by enabling CheckForArtChanges() to import just hands and append them to a dummy file][:"asset loading" :"entity system"]
[43:44][Break in to CheckForArtChanges() to see that it skips because there's nowhere to append data][:"asset loading" :run]
[44:25][Step in to GameUpdateAndRender() and note that the dtForFrame being a whopping 14 seconds is the cause of our :camera bug][:run :simulation]
[45:39][Make GameUpdateAndRender() clamp the dtForFrame to relieve it of doing an excessive amount of updating after stalls][:simulation]
[47:29][:Run the game to see that the :simulation updates tractably after having been "stalled" by CheckForArtChanges()]
[48:28][Consider the .hha file naming and creation scheme for newly imported assets][:"asset loading" :speech]
[55:57][Setup to conditionally create local.hha if we're in a HANDMADE_INTERNAL build][:"asset loading"]
[1:01:03][Create hhaedit.cpp as a dedicated asset creation utility][:"asset loading"]
[1:06:56][Note the ability to do magic values as strings enclosed in single-quotes][:speech]
[1:07:58][:Run hhaedit to see how it all works][:"asset loading"]
[1:08:36][:Run the game and hit the AssetCount mismatch assertion in AllocateGameAssets()][:"asset loading"]
[1:13:52][Enable AllocateGameAssets() to handle TagCount and AssetCount of 0][:"asset loading"]
[1:14:56][Step into CheckForArtChanges() and follow hand_skeleton.png down the import pipeline][:"asset loading" :run]
[1:20:49][Step back through CheckForArtChanges() to see that we already have errors on entering Win32WriteDataToFile][:"asset loading" :"file io" :run]
[1:23:47][Make AllocateGameAssets() only read in an .hha file if the TagCount != 0][:"asset loading"]
[1:24:29][Step through AllocateGameAssets() to the success of WriteAssetData()][:"asset loading" :"file io" :run]
[1:27:51][Introduce SetAssetType()][:"asset loading"]
[1:32:02][Embark on the tagging problem, introducing import_grid_tags for ProcessTiledImport() and CheckForArtChanges() to use][:"asset loading"]
[1:46:27][Try making AddPlayer() add an Asset_Hand][:"entity system"]
[1:47:01][:Run the game to see that it doesn't find our Asset_Hand][:"asset loading" :"entity system"]
[1:47:29][Test the entire asset import process, to see that it works, but we have RGB flipped][:"asset loading" :"entity system" :run]
[1:48:22][Try reloading the game to hit our AssetCount mismatch assertion in AllocateGameAssets()][:"asset loading" :run]
[1:48:46][Delete local.hha and successfully :run the game][:"asset loading"]
[1:49:16][Q&A][:speech]
[1:49:55][@psychomaniactv][Q: I've been looking into existing approaches to assign items to cells for clustered shading. I've already implemented two of them, but now I'd like to try iD's approach. They mention in their SIGGRAPH slides that an item shape can be an OBB or a frustum and they test its planes against the cells in clip space since a cell will simply be an AABB there. I should really improve my math knowledge / skills but I currently don't know how to do this. Can you point me in the right direction?][:rendering]
[1:53:11][Understanding perspective projection and clip coordinates][:blackboard :rendering]
[1:58:23][Performing operations in clip space][:blackboard :rendering]
[2:01:21][Describe PerspectiveProjection()][:mathematics :rendering :research]
[2:02:54][@jacksonbanan][Q: Is the warning in the ctime code supposed to be taken lightly? How would it delete files, format my hard drive, etc? Has there been any instance of any of that thus far?]
[2:03:33][@sopvop][Q: I see that transient_state has only four task_with_memory, and game uses much more threads. So the threads may sit there without work because you can only submit at most four such tasks per frame to queue. Isn't four tasks a bit low, or am I missing something here?][:threading]
[2:04:03][Show the profiler's thread view][:performance :run :threading]
[2:04:52][@psychomaniactv][Q: Thanks for answering. The way I understand their slides is they have a convex shape defined by its boundary planes (either a 6-plane OBB or a 5-plane frustum) and they test it against an AABB in clip space. The AABB is already in clip space and the planes come from world space. I have no idea how to test for intersection in clip space. What even happens to the planes when they are transformed?][:rendering]
[2:07:52][Plane transformation][:blackboard :mathematics :rendering]
[2:10:27][Close down with a plug of the site[ref
    site="Handmade Hero"
    url=https://handmadehero.org/] and glimpse into the future][:speech]
[/video]
