[video output=day204 member=cmuratori stream_platform=twitch stream_username=handmade_hero project=code title="Unprojecting the Mouse Cursor" vod_platform=youtube id=FkDJL8zmVFY annotator=Miblo]
[0:08][Announcement: Miblo's Patreon]
[3:04][Recap and set the stage for the day]
[4:16][Run the game and see where we're at]
[5:41][Consider moving away from explicitly constructing the debug hierarchy]
[8:51][On writing the usage code and then unifying the systems]
[10:14][handmade_sim_region.cpp: Look at how the entities are currently handled]
[11:09][Implement the ability to click on an entity in order to inspect it]
[13:11][Run the game and illustrate what we'd like to do]
[15:48][handmade.cpp: Introduce DEBUGUI_DrawEntityOutlines]
[18:05][Run the game and see the new outlines]
[18:34][handmade_render_group.cpp: Make PushRectOutline additionally take a Thickness]
[19:06][Run the game and see the thinner magenta outlines]
[19:59][Consider the problem of the perspective transform]
[21:49][handmade_render_group.cpp: Look at Unproject]
[23:19][Blackboard: Why we need the distance from the camera]
[25:26][Blackboard: Conceptualising this entity picking]
[27:08][handmade.cpp: Unproject the MouseP]
[29:26][handmade.cpp: Test the LocalMouseP against the 2D entity Volume->Dim]
[32:45][handmade.cpp: Do a PushRect of the mouse's location]
[33:40][handmade.cpp: Do an Orthographic call to draw the MouseP]
[36:27][handmade_render_group.cpp: Add OffsetP and Scale to Orthographic]
[37:36][Run the game and see the mouse]
[38:12][Debugger: Step into GameUpdateAndRender and inspect the MouseP]
[39:09][handmade.cpp: Try and draw the LocalMouseP]
[40:37][Run the game and don't see the LocalMouseP]
[41:02][handmade.render_group.cpp: Investigate why we're not seeing the LocalMouseP]
[43:44][handmade.cpp: Multiply the mouse's Transform by PixelsToMeters]
[45:42][Run the game and see that the rects aren't correctly positioned \[tl;dw: see 1:39:32\]]
[46:19][handmade.cpp: Investigate why rects aren't correctly positioned]
[48:17][handmade.cpp: Pass the entity's Transform to the Unproject call]
[49:07][Run the game and see that we're getting a little closer]
[51:07][handmade.cpp: Pick one entity to consider]
[51:28][Run the game and see that the mouse's rectangle is incorrectly placed and scaled]
[52:16][handmade.cpp: Try doing Unproject without the subtract]
[52:52][Run the game and see that it's surprisingly in the right place]
[54:23][handmade.cpp: Consider the possibility that Unproject may be fundamentally busted]
[54:47][handmade.cpp: Add OffsetP.z to LocalZ]
[55:09][Run the game and suggest that that's more correct]
[56:59][handmade_render_group.cpp: Study our routines]
[1:02:15][handmade.cpp: Try putting that subtract back in to the Unproject]
[1:05:28][Run the game and try to determine how far off we are]
[1:06:00][handmade.cpp: Try hardcoding values]
[1:07:32][Run the game and don't see a MouseP rectangle]
[1:08:20][handmade.cpp: Pass WorldMouseP to PushRect]
[1:08:57][Run the game and see that it's okay, but not great]
[1:09:17][handmade.cpp: Set LocalZ to 1.0f]
[1:11:21][handmade.cpp: Add RenderGroup->Transform.DistanceAboveTarget to PushRect]
[1:14:17][handmade_render_group.cpp: Introduce CompleteUnproject]
[1:22:27][Run the game and conclude that we'll want to clean up what's happening in the projection]
[1:23:49][Q&A][:speech]
[1:24:18][@ijustwantfood][The lag is real]
[1:24:44][@conloncs][How will the focal length factor in? Will you have FOV stuff?]
[1:26:03][@insobot][Elvin?]
[1:26:20][@conloncs][Semi related: What do you think about using different types for Points and Vectors?]
[1:26:52][@Zamar037][Does the screen center need to be involved? It was used in CompleteUnproject]
[1:27:10][@StarchyPancakes][Is part of the problem that the code isn't normalizing the motion between the mouse and the entity relative to the screen dimensions in world coordinates at the different levels?]
[1:28:03][handmade.cpp: Try doing the MetersToPixels after the fact]
[1:28:43][handmade_render_group.cpp: Check that there weren't any other transforms happening to PushRect]
[1:29:37][@abnercoimbre][Mm. We seem to have run out of questions]
[1:29:40][@cmuratori][What is the problem with this Unproject?]
[1:30:21][handmade_render_group.cpp: Investigate the problem]
[1:32:26][Meta-point: On the potential features of a development tool that would help with these types of problems]
[1:36:11][Debugger: Inspect a bunch of values and copy them to a scratch buffer]
[1:39:32][Owl of Shame Moment: We took out Z movement relative to the basis P]
[1:40:48][handmade.cpp: Correctly set Transform.OffsetP]
[1:41:11][Run the game and find it in the right place]
[1:44:17][On getting bitten by a feature][quote 272]
[1:44:39][Lament this 2.5D nonsense][:speech]
[1:45:15][Glimpse into the future and wrap it up][:speech]
[/video]
