[video output=day633 member=cmuratori stream_platform=twitch stream_username=handmade_hero  project=code title="Narrowing in on a Collision Scheme" vod_platform=youtube id=8-qq8FANzhs annotator=Miblo]
[0:00][Recap and set the stage for the day][:speech]
[0:25][Demo the current state of :movement][:run]
[1:00][Simple and stable :collision detection and resolution][:speech]
[2:14][Re-enable the MoveEntityLocally() loop in MoveEntity()][:collision]
[2:23][We lack :collision][:run]
[2:37][Double-check MoveEntity()][:collision :research]
[3:07][Our glove penetrates the wall][:collision :run]
[3:17][Make MoveEntityLocally() draw occupation state][:collision :"debug visualisation"]
[3:29][We detect :collision but then tunnel through the familiar][:run]
[3:41][Double-check MoveEntityLocally()][:collision :research]
[4:55][Increase the StepCount from 5 to 10 in MoveEntity()][:collision]
[5:03][We clearly see :collision detection in red][:run]
[5:21][Reacquaint ourselves with MoveEntityLocally() and MoveEntity()][:collision :research]
[8:29][The utility of stating a universally minimum thickness, as MOTION_DISPLACEMENT_SIZE][:collision :geometry :speech]
[10:39][Reacquaint ourselves with MoveEntityLocally() and MoveEntity() (cont.)][:collision :research]
[11:52][Prevent MoveEntity() from capping the StepCount][:collision]
[12:02][We still detect collisions, but tunnel][:collision :run]
[12:14][Scour MoveEntityLocally() for bugs][:collision :research]
[16:19][Delete VoxelI from MoveEntityLocally()][:collision]
[16:34][Scour MoveEntityLocally() for bugs (cont.)][:collision :research]
[16:43][Disable the BestP computation loop in MoveEntityLocally()][:collision]
[16:58][Entities can erroneously move][:collision :run]
[17:26][Scour MoveEntity() for bugs][:collision :research]
[18:08][Prevent MoveEntity() from modifying Entity->P][:collision]
[18:28][Entities can no longer move, as desired][:collision :run]
[18:34][Re-enable the BestP computation loop in MoveEntityLocally()][:collision]
[18:45][Entities now collide, but can get embedded][:collision :run]
[20:16][Conceptualising the voxelised :collision search, to prevent / recover from embedding][:research]
[28:06][Make MoveEntityLocally() test the occupation state of only the one voxel en route to the target][:collision]
[31:15][Non-embedded entities collide nicely][:collision :run]
[33:32][A familiar has got stuck underground][:collision :run]
[34:02][Consider pathfinding our :collision through a stack of voxels][:collision :research]
[37:22][Enable MoveEntityLocally() to detect and resolve embedding][:collision]
[39:05][Our initially embedded glove may now move, but can tunnel][:collision :run]
[39:44][Investigate our tunneling issue][:collision :research]
[40:47][Make MoveEntityLocally() test the occupation state of all eight surrounding voxels][:collision]
[40:58][We still tunnel][:collision :run]
[41:05][Consider drawing more :collision information][:"debug visualisation" :research]
[42:24][Make MoveEntityLocally() test the occupation state of only the one voxel en route to the target][:collision]
[42:46][Consider drawing more :collision information (cont.)][:"debug visualisation" :research]
[44:15][Take a closer look at our glove vs familiar :collision][:run]
[44:57][Wonder why it fails our AnyOpen check][:collision :research]
[45:45][Make MoveEntityLocally() test the occupation state of all eight surrounding voxels][:collision]
[46:02][We still tunnel][:collision :run]
[46:15][Prevent MoveEntityLocally() from using the target position if embedded][:collision]
[46:25][We can't test tunneling][:collision :run]
[46:32][Make AddPlayer() elevate the glove][:"entity system"]
[47:14][We can test it, and no longer tunnel][:collision :run]
[49:29][Let MoveEntityLocally() use the target position if embedded][:collision]
[49:43][We tunnel trivially][:collision :run]
[49:55][Make MoveEntityLocally() set AnyOpen using an OccupiedCount][:collision]
[51:35][We still tunnel][:collision :run]
[51:50][Wonder how MoveEntityLocally() detects embedding so often][:collision :research]
[53:04][Increase the ApronSize to the full MOTION_DISPLACEMENT_SIZE in MoveEntityLocally()][:collision]
[53:11][We still tunnel, but less easily][:collision :run]
[54:20][How are two frames disagreeing on which :collision volumes are occupied?][:research]
[56:41][Make MoveEntity() only allow one micro-move, i.e. one call to MoveEntityLocally()][:collision]
[57:11][We still tunnel][:collision :run]
[57:58][Delete VolumeDim and VolumeP from MoveEntityLocally()][:collision]
[58:08][Consider drawing more :collision information][:"debug visualisation" :research]
[1:01:20][Should we start visualisation now?][:"debug visualisation" :speech]
[1:01:45][@suspect__zero][The game looks like it lags hard when the punch flies around. Is that because of the debugging tools being active?][:performance]
[1:04:55][Compile in -Od]
[1:05:16][Show off the :performance in -Od][:run]
[1:05:32][Use #pragma optimize("gt", on) and #pragma optimize("", on) around handmade_lighting.cpp][:language :lighting :performance]
[1:07:28][ComputeLightPropagationWork() takes 78% of our frame time][:lighting :performance :run]
[1:07:52][Toggle off MoveEntity()][:collision]
[1:08:25][Gauge our :performance in -Od][:lighting :run]
[1:09:03][Use #pragma optimize("gt", on) and #pragma optimize("", on) around handmade_light_atlas.cpp][:language :lighting :performance]
[1:10:23][Gauge our :performance in -Od][:lighting :run]
[1:10:45][Remove the #prama optimize() and re-enable MoveEntity()][:collision :language :performance]
[1:11:52][Step through MoveEntityLocally()][:collision :run]
[1:12:48][Initialise a TestP in MoveEntityLocally()][:collision]
[1:13:29][Step through MoveEntityLocally() watching the TestP and other values][:collision :run]
[1:15:24][Set a break point in the !AnyOpen path][:collision :run]
[1:16:47][Tunnel through, without hitting that break point][:collision :run]
[1:18:18][Compile in -O2]
[1:18:27][@bearexplicit][It pushed the skeleton up over the glove?][:collision]
[1:18:36][The glove is not tunneling, but passing beneath the familiar][:collision :run]
[1:21:09][Make MoveEntityLocally() test the occupation state of only the one voxel en route to the target][:collision]
[1:21:27][Our glove and familiar are stuck][:collision :run]
[1:22:16][Enable MoveEntityLocally() to clip away the voxel search directions behind our direction of motion][:collision]
[1:26:48][Our glove may be blocked from moving upwards, but may perhaps move sideways][:collision :run]
[1:27:11][Consider clipping the :collision box][:research]
[1:31:35][Start to make MoveEntityLocally() clip the :collision box]
[1:35:52][Consider making MoveEntityLocally() permit movement within the voxel interior][:collision :research]
[1:36:46][Enable MoveEntityLocally() to (dis)allow movement on a direction-by-direction basis][:collision]
[1:43:23][Our glove and familiar get unstuck][:collision :run]
[1:43:39][Make a note to pathfind through the voxel][:collision]
[1:44:09][@macielda][Q: The second if has a problem: it should be Dir.y not Dir.z][:collision]
[1:44:27][Our :movement is slow][:collision :run]
[1:44:52][Let MoveEntity() allow all micro-moves, i.e. multiple calls to MoveEntityLocally()][:collision]
[1:45:00][Our :movement is normal][:collision :run]
[1:45:44][That's it for today][:speech]
[1:46:16][Q&A][:speech]
[1:47:08][@mindmark42][Q: Can you explain this direction check a bit more?][:collision]
[1:48:33][@ommos61][Q: Have you forgotten to upload Day 632 to YouTube?]
[1:49:06][@mindmark42][Q: So it can't move backwards?][:collision]
[1:50:07][@gheoan][After discovering the glove was moving under the skull you are now trying to prevent that?][:collision]
[1:50:19][@sagian2005][Q: If you're trapped and have the vector in, why can't you just follow the vector back out?][:collision]
[1:51:57][@thesandvichmaker][Q: (Semi off-topic) With the live code reloading, I made a thing where global variables in the dll can be saved and restored when you reload the dll. Have you tried that before? I thought it's kind of neat][:"hot reloading"]
[1:53:16][Wrap it on up][:speech]
[/video]
