Episode 48 - Line Segment Intersection Collisions

Hello everyone!

So I've just ended watching episode 48 and I think what it was causing the assertion on line 165/166 on handmade_tile.cpp:

1
2
Assert(*TileRel > -0.5f*TileMap->TileSideInMeters);
Assert(*TileRel < 0.5f*TileMap->TileSideInMeters);


was that after the collision detection code, when updating the new player position, I think Casey forgot to assign the recanonicalized position to the entity position.

So at line 451 on handmade.cpp:

1
2
Entity->P = NewPlayerP;
NewPlayerP = RecanonicalizePosition(TileMap, NewPlayerP);


should be:

1
Entity->P = RecanonicalizePosition(TileMap, NewPlayerP);


I know floating point math is problematic but in this case that could be causing the assertion and that 0.0001f epsilon is not needed?

Cheers!

Edited by Jonathan García on
Ack! Yes. That could totally be the problem. I was actually looking for that and somehow didn't notice (again, it's hard on the stream, I make a lot of typos...) I'll fix it tonight.

- Casey
Hi!

I just watched episode 48, and I was wondering why that epsilon only was needed when a collision was detected. It could be that the player would be right next to a wall at t=1.

Well I guess the collision detection is about to get rewritten anyway.

/Kim