Это видео недоступно.
Сожалеем об этом.

EPA Explanation & Implementation

Поделиться
HTML-код
  • Опубликовано: 31 июл 2024
  • GJK tells us if there is a collision, but doesn't give enough information to respond to it. In this video I cover a supplemental algorithm called the Expanding Polytope algorithm that uses the pieces from GJK to give us this info. With it we can respond to collisions between any two convex polygons.
    Check out the full article: winter.dev/articles/epa-algor...
    GJK Tool: winter.dev/articles/gjk-algor...
    Intro: 0:00
    Explanation: 0:23
    2D Implementation: 1:36
    3D Implementation: 2:55
    Demos: 5:25

Комментарии • 49

  • @meeharbin4205
    @meeharbin4205 3 года назад +20

    Bruh, I was looking at GJK and EPA 2 yrs ago. I've looked at these algorithms so much that I remember these algorithms better than the sorting algorithms I learned at school.

    • @Winterdev
      @Winterdev  3 года назад +4

      lol after those videos me too, thanks for the comment

  • @philippst.8543
    @philippst.8543 3 года назад +12

    Amazing video, I find it very impressive that you can explain a topic like this as well as the 1 hour long talks can, but only in a couple minutes.

    • @Winterdev
      @Winterdev  3 года назад +7

      Thanks! You always gotta rewatch/read things to get an understanding well enough to implement, so might as well have that be like 5 mins instead of an hour :)

  • @aelsi2
    @aelsi2 3 года назад +16

    I've been researching on collision detection algorithms lately, reading various docs, articles, etc. and then I found your videos. The explanations are simply amazing! I'm also trying to figure out how to do ray casting with GJK. Any plans on doing an video about that?

    • @Winterdev
      @Winterdev  3 года назад +6

      Thanks, there is a good chance that I am going to need ray casts myself, I'll make a video when I do that. Probably, 2-3 videos out though. I want to cover some rendering next

  • @br-zhou
    @br-zhou 3 года назад

    i greatly appreciate these videos

  • @Paalui
    @Paalui Год назад +3

    Hello Winterdev.
    Thanks for the great Video. When checking what faces to delete you check if the normal of the triangle and the supportpoint are in the same direction. This only works for some cases. Since you want to check if the support point is on one side of the triangle you want to use the supportpoint relative to the triangle.
    So the check would look like this
    if (SameDirection(normals[i], support-polytope[faces[i*3]])

    • @NTSHOni
      @NTSHOni Год назад

      Just found this comment and it solved the issue I was on for hours, thanks a lot!

  • @MrNathanShow
    @MrNathanShow 3 года назад +2

    10/10 amazing work

  • @matyasconstans4013
    @matyasconstans4013 2 года назад +2

    Great video! One thing to keep in mind; if delta is large enough, your objects can essentially go through each other. This might occur during a frame-drop or the like (unless your engine has a fixed timestep). A sweep check can fix that though (in the case of arbitrary convex sets a simple gjk pass should be enough)

    • @Winterdev
      @Winterdev  2 года назад +3

      Yeah I have a fixed time step but the issue I was running into was if that was larger than the regular delta time everything would grind to a halt. I wana look into sweep checks but none of my projects have needed that so I haven’t looked into it yet :)

  • @banscheygrey7436
    @banscheygrey7436 3 года назад +1

    Keep doing, it's brilliant !

  • @jviper2004
    @jviper2004 2 года назад

    Came here from the channel Reducible. 3Blue1Brown also a good channel. Nice visualizations.

  • @hereticstanlyhalo6916
    @hereticstanlyhalo6916 2 года назад +3

    Wow, very cool, I'll try implementing this into my engine after I get project loading and drag and drop file loading.

    • @Winterdev
      @Winterdev  2 года назад

      I wish you good luck!

  • @ultima_maxima
    @ultima_maxima 21 день назад

    I'm confused on the part where you reverse the distance and normal if the face is facing toward the origin. There is an edge case where if I have two cubes that are aligned on two axes and they collide, reversing the normal seems to be causing problems giving me the wrong normal. That's because the smallest normal becomes largest normal I guess, but I don't want to just cut the code out without understanding why it was there to begin with.

  • @myelinsheathxd
    @myelinsheathxd 3 года назад +3

    Amazing ! Can y make a video about inertia, and some complex rotation physics. I found an crazy cool effect called "Dzhanibekov effect" . To simulate it, there must be solid rotation physics background !

    • @Winterdev
      @Winterdev  3 года назад

      After a couple videos I plan to get back to physics, but I am going to go in a slightly different direction for the next few. That would be cool to try and simulate though, I wonder if it would work right off the bat, or if it needs more subtle detail that a physics engine optimized for speed would drop. Will keep in mind!

  • @keldwikchaldain9545
    @keldwikchaldain9545 2 года назад +1

    One question I have is how you resolve situations where one or both colliders aren't properly polytopes, but are surfaces/curves?
    For example the support function for a sphere will always return a further point along the normal of any face made from points on its surface than any existing point on its surface. That means if a sphere collides with the corner of another object, the EPA could go into a theoretically infinite loop. How do you handle this? Do you just cut it off after a fixed number of iterations or a maximum size of polytope?

    • @Winterdev
      @Winterdev  2 года назад +1

      Yeah you got it I put a max iterations of 30 in my code. There is probably a proper way to do that, but I didn’t look into it. You could prob use a different method for curves and store shapes as a series of edges / splines and do something dif for each combo

  • @damdal1837
    @damdal1837 3 года назад +3

    Great video 👍 any plans on doing a video on conservative advancment or bilateral advancment using gjk?

    • @Winterdev
      @Winterdev  3 года назад +2

      Thanks! If that's to do with continuous time steps, I was thinking about doing that or rotational stuff next. I might take a little break from physics though and do some rendering videos but we'll see what comes up.

    • @damdal1837
      @damdal1837 3 года назад +1

      @@Winterdev Thanks for the reply, yeah I was thinking about continous detection. Been trying to implement it myself but it hasnt been going well. Thanks for making all these videos they are very helpful 👍

    • @Winterdev
      @Winterdev  3 года назад +2

      hmm yeah If I were to make a video I'd also be starting from scratch on that one. There is a cool talk that the creator of box2d did a few years back where he gives a high level view of it, ruclips.net/video/7_nKOET6zwI/видео.html. Also while finding that video I found this funny tweet where he links source code if you're interested, twitter.com/erin_catto/status/1315505365086216192

    • @aelsi2
      @aelsi2 3 года назад +3

      @@Winterdev Also interested in bilateral advancement. Btw, Erin tweeted about BA right after I asked a question about it on the box2d discord server...

  • @zentroftw853
    @zentroftw853 2 года назад +2

    For some reason it's not working with sphere-sphere collisions I think

    • @Winterdev
      @Winterdev  2 года назад +1

      It will get into a inf loop with sphere v sphere, so you can either add a max iteration loop. Or the real solution is to only use this for mesh v mesh and have a separate function for sphere v sphere. In my testing it works with sphere v mesh.

  • @InfernoTNT
    @InfernoTNT 2 года назад +1

    Great channel. What did you use for collision resolution?

    • @Winterdev
      @Winterdev  2 года назад +1

      There are ‘solvers’ that change the velocity and position. You can find them here github.com/IainWinter/IwEngine/blob/master/IwEngine/src/physics/Dynamics/ImpulseSolver.cpp

  • @captainbanglawala2031
    @captainbanglawala2031 5 месяцев назад

    Don't you also need the full set of contact points?

  • @andrewc2802
    @andrewc2802 2 года назад +1

    Hey loving this series and I've got a kind of working implementation that works mathematically (don't have a renderer just yet) what license is this code under? I'd like to use your physics engine or a very modified version in my own engine. Mine would stay open source under MIT, or ZLib or something. Is that something you'd be willing to give permission for?

    • @andrewc2802
      @andrewc2802 2 года назад

      Also just to clarify, I'd obviously give credit in the code and github page if that's something you'd prefer

    • @Winterdev
      @Winterdev  2 года назад

      Yes go ahead anyone can use the code in these videos for whatever purpose. These are all hobby projects so go ahead. I do need to get an actual license on the GitHub tho, I’ll pick one soon. Feel free to use the code :)

  • @matanmigdal7108
    @matanmigdal7108 3 года назад +2

    where is the class CollisionPoints on the article? and now just need aabb dynamic tree

    • @Winterdev
      @Winterdev  3 года назад

      Oh good catch, I added that to the video last second.
      And yeah things start to get a littttttle slllow after about 70 objects without any broad phase. I'll make a vid at some point, I wanna try a rendering one first though

    • @matanmigdal7108
      @matanmigdal7108 3 года назад +1

      @@Winterdev btw what math lib do you use?

    • @Winterdev
      @Winterdev  3 года назад +1

      ​@@matanmigdal7108 none other than IwMath! github.com/IainWinter/IwEngine/tree/master/IwEngine/include/iw/math. I made it to initially learn C++ :)

  • @hussainbhavnagarwala2596
    @hussainbhavnagarwala2596 10 месяцев назад

    To implement the EPA, do we need to have all the possible Minkowski difference points?

    • @Winterdev
      @Winterdev  10 месяцев назад

      Nope just the last simplex from gjk and the support function

  • @DavidsKanal
    @DavidsKanal 2 года назад +1

    Hey Winterdev, question, how does one get the two collision points from this algorithm?

    • @Winterdev
      @Winterdev  2 года назад

      Hey sorry for late reply, if you read the chain between DANISH AMIN and I, I cover this. Basically you need to do some more projections from the normal based on the distances from the origin

    • @DavidsKanal
      @DavidsKanal 2 года назад

      @@Winterdev Alright perfect thanks. I figured it out myself by now because one of my colliders was a sphere, which makes it easier. Anyway, great tutorials! If you ever want to, a dedicated video on collision response would also be kewl. I find there's a lack of resources on that online

    • @BioAbner
      @BioAbner 2 года назад

      @@Winterdev Where can I find this chain? This is the last piece I need for my physics engine.

  • @br-zhou
    @br-zhou 3 года назад +1

    do you have the time to make a third video explaining rotational physics?

    • @Winterdev
      @Winterdev  3 года назад +2

      Yes I plan to. I am on vacation coming back soon, hopefully with scripts in hand :)

    • @br-zhou
      @br-zhou 3 года назад

      Awesome! thanks so much!

  • @Shadowblitz16
    @Shadowblitz16 2 года назад +1

    uggh rust is so hard to read. EDIT: oh this is javascript. still don't know why the different language tho.

    • @Winterdev
      @Winterdev  2 года назад

      I put the first gjk in JavaScript cus I made that tool in the description that you can see the iterations. Mostly for debugging :)