2D Collision Response | C Game + Engine From Scratch 09

preview_player
Показать описание

If you would like to know more, here are the sources I used in no particular order:

* Real-Time Collision Detection by Christer Ericson

Рекомендации по теме
Комментарии
Автор

Was doing this part this weekend on my engine, was nice to see we came around very closely to the same solution. I do like the exact step for when the collision time is equal and you solve the higher velocity axis first. 👍

AlexHicks_Tutorials
Автор

2:38 C does have a sign function in the form of copysign(1, x) which compiles to just 2 instructions (andps with -0.0, orps with 1.0). In the case of x=0 it behaves differently than the method in the video (it returns 1 instead of 0) but that should be ok for the case in the video

stillww
Автор

2:58 would it be reasonable to get rid of the if-statement and write

hit.normal[(px < py)] = (px < py)((dx > 0) - (dx < 0)) + (px >= py)((dy > 0) - (dy < 0))

to make it branchless?

ashrasmun
Автор

If we're calling sweep_response and static_response `iterations` times per physics_update() and and physics_update() is called once per frame isn't the true tick rate fps * iterations??

bricksnbuttons
Автор

Can you push this part's code to Git? Thanks!

m.hosseinmahmoodi
Автор

Are you sure you need stationary response? I remade this in Rust and I commented out my stationery response and I don’t have any issues with tunneling or glitchyness it’s as smooth as can be. Perhaps i am missing something or I am not hitting some edge case?

mr.treefrog
Автор

beautiful, now consider rotated ellipses 😈

nobodyinparticular