cinera_handmade.network/cmuratori/hero/code/code092.hmml

68 lines
4.1 KiB
Plaintext
Raw Permalink Normal View History

[video output=day092 member=cmuratori stream_platform=twitch stream_username=handmade_hero project=code title="Filling Rotated and Scaled Rectangles" vod_platform=youtube id=kVU_QIxm3AA annotator=Miblo annotator=dspecht annotator=ZedZull]
[0:23][Recap of people egging Casey on to do some weird sine-cosine-theta stuff][quote 50]
[1:36][Blackboard: Introduce effects]
[4:39][Blackboard: How do we do this rotation and scaling?]
[5:29][Run the game]
[5:51][Clip away all this ridiculousness]
[6:32][Look at the coordinate system]
[7:13][Blackboard: We need to know which pixels will be included as a result of rotating a rectangle]
[8:35][Blackboard: How the collision detection system may be applicable to pixel filling]
[9:51][Blackboard: Ignoring rotation and scaling for now]
[12:34][Blackboard: Iterating over the pixels]
[13:44][Look at the DrawRectangle routine]
[14:22][Write a function, DrawRectangleSlowly, that does DrawRectangle in the least efficient way possible]
[16:43][Draw a rectangle that's at the origin of the CoordinateSystem]
[18:11][See the results in-game]
[18:23][Stop it rotating for the moment]
[18:41][Check the scaling of the axes]
[19:54][DrawRectangle after the fact in a different Color]
[20:31][Note that the rectangle is not properly clipping to its max bounds, and rectify this]
[21:11][Moment of realisation: We were adding Entry->Origin twice]
[21:27][We're filling correctly but inefficiently]
[21:58][Consider restricting the area that DrawRectangleSlowly marches over]
[22:21][Blackboard: How does that help us do our rotation and scaling?]
[23:25][Blackboard: Can't we just test against four corners of our rectangle?]
[24:35][Blackboard: How we could have done that without Casey's help]
[28:55][Implement one of these edge tests]
[29:50][Make DrawRectangleSlowly take all of the coordinate system information]
[30:57][Make DrawRectangleSlowly do the edge tests using the dot product]
[32:18][Blackboard: Rephrase these edge tests]
[32:57][Turn the test around]
[34:03][Notice that, because we're not doing the dot product, the sign doesn't flip]
[34:33][Make greater-than be our standard]
[35:03][Blackboard: Think of the surface normals pointing outwards]
[35:20][Change all of those edge functions to be negative]
[36:10][Get the dot product in there]
[36:43][Blackboard: What are the vectors of those perpendiculars?]
[37:29][Implement those vectors]
[38:40][Now we're doing the full test, see how it looks in-game]
[38:59][Consider changing the edge tests to use the edges of the rotating coordinate system]
[39:20][Blackboard: How to use those edges]
[39:42][Get rid of vMin and vMax in readiness to use those edges]
[39:57][Blackboard: Our tests]
[40:35][Implement those tests]
[42:11][Compile and view the results in-game]
[42:48][Change the scale over time]
[43:04][Blackboard: Optimising these tests]
[44:12][Implement optimised exclusion tests]
[50:20][Fix a couple of things, but not before filling everywhere in the bounding region]
[50:58][Check the code]
[51:40][Find our typo and restore our buffer pre-step]
[52:15][Re-enable our edge test and consider further work]
[53:08][Q&A][:speech]
[53:54][@d7samurai][What are your computer specs?]
[55:14][@powerc9k][Is it weird that I got really excited once the rotated fill got faster?]
[56:06][@wardinsc][Would skewing the axes still work?]
[57:37][Implement a proper perpendicular]
[59:38][Blackboard: How we want the Perp to work]
[1:00:26][Make that Perp work]
[1:01:13][@ttbjm][Is downscaling bitmaps correctly slower than upscaling (more colour points to blend)?]
[1:01:45][Blackboard: Downsampling and upsampling bitmaps]
[1:04:05][Blackboard: Mipmaps]
[1:05:33][@cubercaleb][Eventually, will you implement anti-aliasing into the rendering of the rectangle, or is that too much for the CPU?]
[1:06:07][Blackboard: Texture sampling handles anti-aliasing for the alpha'd bitmaps]
[1:07:57][Check out our hilarious little shape and review our progress]
[1:09:37][@garlandobloom][Historically, did we ever do anti-aliasing with CPU rendering?]
[1:11:52][Postpone anything more until tomorrow, with a potential plan of action][:speech]
[/video]