[video member=cmuratori stream_platform=twitch stream_username=handmade_hero project=code title="Debugging Attachment Point Transforms" vod_platform=youtube id=Ip3NiJ7ojN8 annotator=Miblo] [0:00][Recap and set the stage for the day snapping cat heads onto bodies][:"asset system" :speech :ui] [0:50][Showcase the asset editing :UI, with thoughts on scaling asset pieces][:"asset system" :run] [5:24][Storing and transforming alignment points of entities on-demand][:"asset system" :"entity system" :speech] [8:26][Make UpdateAndRenderEntities() store PieceX, PieceY and PieceP as the basis in which we interpret alignment points][:"asset system" :"entity system"] [9:43][Set up to break out PushBitmap() into utility functions that provide alignment information for our snapping procedure to use][:"asset system" :"entity system" :rendering :research] [11:11][Note the imprecision of our 2D sprite vs 3D geometry picking][:"asset system" :"entity system" :run :ui] [12:36][Prepare to split up PushBitmap() and PushQuad()][:"entity system" :rendering :research] [19:49][Create handmade_renderer_geometry.cpp and .h, introducing WriteQuad() based on PushQuad()][:rendering] [28:29][Introduce sprite_values and accompanying functions][:rendering] [35:15][Implement PFromAlignP() and SpriteValuesForUpright() based on GetBitmapDim() and PushBitmap(), introducing SpriteDimFromWorldHeight()][:rendering] [42:46][Introduce SpriteDimFromWorldHeight(), with a few words on extracting pieces of code into their own functions to be called in whatever combination necessary][:api :rendering] [45:04][Reimplement SpriteValuesForUpright() based on PushUpright()][:rendering] [48:37][Consider the problem of computing the Z-Bias of rotating sprites][:geometry :speech] [50:24][Add a fourth dimension to the sprite_values axes][:geometry] [52:18][Z-Bias of Rotated Sprites][:blackboard :geometry] [54:12][Z-biasing sprites, respecting their suggested depth (i.e. ones whose lowermost point in Z is some way in from their bottom edge)][:blackboard :geometry] [1:01:02][The :mathematics of correct 2D sprite Z-biasing along the :camera vector][:blackboard :geometry] [1:11:29][Consider rolling the Z-bias projection from CompileZBiasProgram() into the vertex shader][:geometry :research] [1:12:41][Constructing the Z-bias projection inside the vertex shader][:blackboard :geometry :mathematics] [1:16:31][Simply sliding sprites forwards along the tile to simulate Z-alignment][:blackboard :geometry :mathematics] [1:19:30][Continue to implement SpriteValuesForUpright(), postponing our Z-bias story for now][:rendering] [1:29:38][Make UpdateAndRenderEntities() use our new geometric :rendering functions][:"entity system"] [1:32:42][:Run the game to see everything :rendering as before] [1:32:55][Prevent PushSprite() from taking a Size and instead take scaled axes][:"asset system" :"entity system" :rendering] [1:40:23][See that the :UI all looks fine][:run] [1:40:43][Change UpdateAndRenderEntities() to use PushSprite() rather than PushBitmap()][:"asset system" :"entity system" :rendering] [1:42:24][Find that our sprites are misplaced][:"asset system" :"entity system" :rendering :run] [1:43:01][Investigate our sprite alignment bug][:geometry :rendering :research] [1:46:36][Fix the MinP computation in SpriteValuesForUpright()][:geometry :rendering] [1:46:58][Find that our sprite placement is much better, pointing out our Z-bias problem][:geometry :rendering :run] [1:47:48][Decrease the pitch of our :camera in UpdateAndRenderWorld()] [1:49:28][Traverse the world with our lower pitched :camera, to find that it doesn't correctly interpolate between rooms][:run] [1:51:31][Increase our :camera's Z-offset from the room in GetCameraOffsetZForDim()] [1:53:51][Speed up our build by commenting out some compilation lines] [1:54:38][Traverse the world, with our room interpolation working again, but not the :lighting region][:camera :run] [1:56:57][Set up to implement sprite snapping][:"asset system" :"entity system" :run :ui] [1:58:16][Make UpdateAndRenderEntities() snap sprites together based on alignment points set in the :UI, introducing FindAlign()][:"asset system" :"entity system"] [2:09:06][:Run the game to find that our cat hero's body oscillates between two locations][:"asset system" :"entity system"] [2:09:30][Enable UpdateAndRenderEntities() to handle snapping of pieces with no parent alignment point][:"asset system" :"entity system"] [2:12:27][Find that our cat hero's body now correctly stays still][:"asset system" :"entity system" :run] [2:12:43][Investigate our alignment issue in UpdateAndRenderEntities()][:"asset system" :"entity system" :research] [2:15:11][Make AddCat() connect the Body piece to the world, introducing ConnectPieceToWorld()][:"asset system" :"entity system"] [2:20:48][Step through UpdateAndRenderEntities() and inspect the bitmap pieces of our cat][:"asset system" :"entity system" :run] [2:24:00][Realise that the cat (not the cat hero) is showing up][:"asset system" :"entity system" :run] [2:25:38][Try snapping the regular cat's head to its body successfully, again noting our Z-bias problem][:"asset system" :"entity system" :run :ui] [2:28:17][Q&A][:speech] [2:30:05][@xxthebigfoxx][Q: Do you know anything about the state of the series ~Bitwise? We haven't heard anything from [@pervognsen Per] in the last two months] [2:30:39][@morglod][Q: Why not render with the projection matrix + WM matrices to position?][:rendering] [2:31:42][@centhusiast][Q: Is wait-free multithreading as difficult as lock-free multithreading?[ref site="Maurice Herlihy" page="Wait-Free Synchronization" url=https://cs.brown.edu/~mph/Herlihy91/p124-herlihy.pdf]][:threading] [2:37:41][@morglod][Q: Why not render sprites with the projection matrix resetting its rotation (facing) towards camera?][:rendering] [2:38:45][Demo the sprite Z-biasing][:camera :rendering :run] [2:41:25][@pythno][Q: Can you explain again briefly how you might want to solve the problem of sprites penetrating the ground? Maybe the sprites have to be at a lower angle to the floor so they won't intersect that easily and distort the texture so it looks correct again?][:rendering] [2:42:11][@techzone707][Q: Have you read Communicating Sequential Processes by Tony Hoare?[ref author="Tony Hoare" title="Communicating Sequential Processes" url=http://usingcsp.com/cspbook.pdf]] [2:42:15][@garryjohanson][Q: Would you mind posting that multithreading paper[ref site="Maurice Herlihy" page="Wait-Free Synchronization" url=https://cs.brown.edu/~mph/Herlihy91/p124-herlihy.pdf] in chat?][:threading] [2:42:50][@omfgcookies][Q: Are you planning on allowing :camera rotation in the final game? You could reface after certain angles so it still gives you some of what you want] [2:43:49][Close it up][:speech] [/video]