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

45 lines
4.0 KiB
Plaintext
Raw Permalink Normal View History

[video output=day338 member=cmuratori stream_platform=twitch stream_username=handmade_hero project=code title="Simulation-space Particles" vod_platform=youtube id=lG3j32DTo1E annotator=Miblo]
[0:08][Recap and set the stage for the day]
[1:22][Blackboard: Particle Cache]
[6:07][handmade_particles.h: Remove the notion of a particle system cache]
[7:37][handmade_particles.cpp: Remove GetOrCreateParticleSystem(), TouchParticleSystem() and InitParticleSystem(), rename PlayAround() to UpdateAndRenderFire() and rework InitParticleCache()]
[11:49][Run the game and see that this is all fine, although slower than it should be]
[13:52][handmade_particles.cpp: Consider why UpdateAndRenderFire() is so slow]
[16:31][handmade_particles.h: Introduce particle_4x, simplify particle_system and remove particle_v3, particle_v4 and the operator*()]
[17:55][handmade_particles.cpp: Remove GetParticle() and make UpdateAndRenderFire() work on particle_4x]
[20:23][handmade_particles.h: Introduce operator+=() for v3_4x]
[21:22][Run the game and see that we are now running as fast as expected]
[22:43][handmade_particles.h: Introduce operator*(), operator+() and operator+=() for v4_4x]
[24:48][Run the game and see that we're still good]
[26:05][Reflect on the importance of the profiler]
[28:49][handmade_particles.cpp: Make UpdateAndRenderFire() take a dt and FrameDisplacementInit]
[31:03][handmade_particles.h: Introduce ToV34x()]
[31:57][handmade_particles.cpp: Enable UpdateAndRenderFire() to render particles through the standard path]
[44:04][Run the game, note that we are theortically generating particles and investigate why we aren't seeing them]
[47:09][handmade_world_mode.cpp: Prevent everything but the particles from being rendered, run the game and see them]
[47:42][handmade_particles.cpp: Introduce SpawnFire()]
[49:54][handmade_entity.cpp: Make entities call SpawnFire() when they land]
[50:43][Run the game and see no spawning occurring]
[51:40][handmade_world_mode.cpp: Reduce ScreenIndex to 1, run the game and see that the particle spawning is working just fine]
[52:15][handmade_world_mode.cpp: Generate two horizontally aligned screens, run the game and see what happens to the particles upon leaving a room]
[55:15][handmade_particles.cpp: Make UpdateAndRenderParticleSystems() take the FrameDisplacement]
[56:28][handmade_world_mode.h: Add LastCameraP to the game_mode_world struct and make UpdateAndRenderWorld() compute that LastCameraP]
[58:06][Run the game, see that the particles are not being displaced correctly and investigate why]
[1:01:51][Blackboard: Calculating that displacement]
[1:02:33][handmade_world_mode.cpp: Correctly compute the FrameToFrameCameraDeltaP and LastCameraOffset]
[1:04:34][Run the game and see that our particles may now be correctly displaced]
[1:04:58][handmade_particles.cpp: Tweak SpawnFire() to shorten the lifetime of the particles, run the game and check them out]
[1:06:37][handmade_world_mode.cpp: Remove LastCameraOffset and displace the particles with the WorldTransform]
[1:09:51][Run the game and admire the particles]
[1:10:33][Q&A][:speech]
[1:11:20][@mmozeiko][gcc & clang don't have m128_f32 member for __m128. They need _mm_store_ps or something like ((float*)&A->P.x)\[index\] (or union with float array)]
[1:12:05][handmade_particles.cpp: Use the M macro for rendering the particles and introduce handmade_simd.h]
[1:16:04][@nxsy][soysaucethekid was suggesting to slow down the time to make sure it is now right]
[1:19:52][@thesizik][Not too long ago, you changed world coordinates to be s32 instead of u32. I think they were unsigned originally so that overflow would work correctly to have the world wrap around]
[1:20:27][@cyberpunkhobo][Does the Z position of the particles not get affected by the perspective transform?]
[1:22:58][@thesizik][But when your position goes from INT_MIN to INT_MAX, won't it cause undefined behavior?]
[1:23:49][todo.txt: Update the TODO list]
[1:24:16][@thesizik][Signed integer overflow?]
[1:25:45][Lament the absence of real 3D and close things down][:speech]
[/video]