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

47 lines
3.9 KiB
Plaintext
Raw Permalink Normal View History

[video output=day336 member=cmuratori stream_platform=twitch stream_username=handmade_hero project=code title="Adding a Particle System Cache" vod_platform=youtube id=RBNjzGeaB_M annotator=Miblo]
[0:05][Set the stage for working on the particle system]
[3:15][Blackboard: Sim Regions and a Persistent Particle System]
[6:43][Blackboard: Deterministic f(t) Particle System]
[9:50][Blackboard: f(delta*t) Particle System]
[10:57][Blackboard: The expense of a persistent f(t) particle system]
[14:50][Blackboard: Cached particles]
[19:57][Set the stage for tomorrow]
[22:38][Run the game and see our current situation, before taking a look at the sim_region stuff]
[25:12][Create handmade_particles.h and handmade_particles.cpp, and talk a little about writing the usage code first]
[27:14][handmade_sim_region.cpp: Make BeginSim() assert that we have a Source]
[28:41][handmade_sim_region.cpp: Start to add the calling site code for the particle system to BeginSim()]
[32:49][Blackboard: Shutting down the particle code]
[36:31][handmade_sim_region.cpp: Make BeginSim() activate the particle system upon unpacking]
[37:56][handmade_entity.cpp: Make UpdateAndRenderEntities() initialise the particle_cache and call UpdateAndRenderParticleSystem()]
[40:54][handmade_particles.cpp: Introduce UpdateAndRenderParticleSystem(), GetOrCreateParticleSystem() and TouchParticleSystem()]
[43:57][handmade_world_mode.cpp: Make UpdateAndRenderWorld() rather than UpdateAndRenderEntities() call UpdateAndRenderParticleSystem()]
[44:48][handmade_particles.cpp: Pluralise UpdateAndRenderParticleSystems()]
[46:07][handmade_particles.h: Introduce particle_system and particle_cache structs]
[48:09][handmade_particles.cpp: Implement TouchParticleSystem()]
[50:14][Calculate the number of cache lines required by our scheme]
[51:51][handmade_particles.cpp: Start to implement GetOrCreateParticleSystem()]
[55:06][handmade_particles.cpp and *.h: Introduce InitParticleSystem() and particle_spec struct]
[56:03][handmade_sim_region.cpp: Make it optional to pass a ParticleCache to BeginSim() and do general clean-up]
[58:13][handmade_entity.h: Introduce a version of IsEqual which takes entity_id]
[58:46][handmade_particles.cpp: Slightly flesh out TouchParticleSystem() and UpdateAndRenderParticleSystems()]
[1:00:36][handmade_entity.h: Add particle data to the entity struct and finish bookkeeping]
[1:02:54][handmade_world_mode.cpp: Make PlayWorld() initialise the ParticleCache]
[1:05:08][Run the game and crash and tie up some loose ends]
[1:07:25][handmade_particles.cpp: Introduce InitParticleCache()]
[1:08:53][Run the game, crash in EndSim() and investigate why]
[1:11:03][handmade_particles.cpp: Make UpdateAndRenderParticleSystems() assert that the Cache is the correct size]
[1:13:58][Investigate whether or not we're reclaiming the ParticleCache memory]
[1:20:03][Spot the bug in GameUpdateAndRender() with our needed memory arena being closed]
[1:23:51][todo.txt: Add "Arena upgrade!"]
[1:25:05][handmade_world_mode.cpp: Make PlayWorld() allocate the ParticleCache from the ModeArena for now]
[1:26:20][Run the game and see that it's fine now]
[1:26:48][Q&A][:speech]
[1:27:34][@greenish__][I think you should be searching for MaxFramesSinceTouched instead of MinFramesSinceTouched]
[1:27:49][handmade_particles.cpp: Make GetOrCreateParticleSystem() test on the MaxFramesSinceTouched]
[1:28:21][@gene_victor][So was the problem that the transient memory vaporized per frame, while the particle cache needs to stay across frame?]
[1:31:15][@snoringtortoise][Not sure if this has been answered on a previous stream (still trying to catch up). When you introduced the threading model, you mentioned that we would want one thread per core, but since the OS creates threads for us (so helpful) for things like audio, does it matter then that we end up with more threads than cores?]
[1:33:36][@chibin][Do you know if he fully swapped out of emacs?]
[1:34:06][Demo and plug (in-development) 4coder features]
[1:41:17][Wrap it up][:speech]
[/video]