Designing a Physics Engine in 5 minutes

Sdílet
Vložit
  • čas přidán 11. 07. 2024
  • Physics is a part of games that has always amazed me. I find it funny how impossible it seemed to do correctly when I was younger. While making a custom game engine, it was finally demystified!
    The full article: winter.dev/articles/physics-e...
    Full source: github.com/IainWinter/IwEngin...
    0:00 Intro
    0:26 Dynamics
    1:30 Collision Detection
    4:16 Collision Response
    5:19 More Options
  • Věda a technologie

Komentáře • 193

  • @ciberman
    @ciberman Před 3 lety +440

    "This is the easy part and that's not what you've came for"... this guy really knows what is his target audience haha

  • @_general_error
    @_general_error Před 2 lety +87

    This is a really good approach for a code tutorial without telling the audience, which button they are supposed to press next. I love it!

  • @TheSunCatZeCat
    @TheSunCatZeCat Před 3 lety +117

    Found this video per chance while searching for physics engines after giving up on writing my own.
    Now I'm almost finished writing it. Thanks for the very well-explained overview! Definitely earned a sub from me.

  • @whoshotdk
    @whoshotdk Před 3 lety +50

    Just came from The Cherno who says "use PhysX". Nah, my boy Winterdev don't need that.
    Thanks for the truly excellent video!

  • @hereticstanlyhalo6916
    @hereticstanlyhalo6916 Před 2 lety +29

    In all seriousness, this is gonna help me a lot, especially the part at 1:15, I've been making a game engine and wanted to fiddle with my own physics but didn't know how I should first mold it, and something basic like that (although translating it into a component) is perfect. Thanks so much.

  • @jonathanfeller
    @jonathanfeller Před 3 lety +19

    Hey! I've been working on a rendering + physics engine for about 7 years now, not it takes that long to make it, but I went in and out of it as time passed and life allowed me to work on it. I'm definitely inspired by this video to create my own physics engine. Looking forward to the next video! :-).

  • @alexismandelias
    @alexismandelias Před 2 lety +4

    I love the pacing and presentation! One of the very few videos that I had to slow down and rewatch at parts instead of speeding up

  • @testosteroneoverdose
    @testosteroneoverdose Před 2 lety +6

    Great video! Very well edited and easy to understand!

  • @tarapogancev
    @tarapogancev Před 3 lety +4

    Your videos are amazing. Very informative, easy to follow, and well thought through! :D Amazing job!

    • @Winterdev
      @Winterdev  Před 3 lety

      Thanks! I'm glad you find them clear :)

  • @fieti
    @fieti Před 3 lety +2

    Can't wait for your next vid in this topic, amazing design & explanations!

    • @Winterdev
      @Winterdev  Před 3 lety +1

      Thanks! Next vid should be up in the next week or so, but it's about sand lol

  • @curtispreston4400
    @curtispreston4400 Před 2 lety +8

    this is an amazing explanation I'm working on my own 'game engine' (more of a library than anything ) and I wanted to make a physic engine as a fun task, and this video explains things so well

  • @FlareGunDebate
    @FlareGunDebate Před 4 lety +12

    I think you should do both. Continue with more videos on design and dive deeper into the math in another set of videos. I wish I had a video like this when I was pulling apart physics engines for the first time. This is a quality overview. Great job.

    • @Winterdev
      @Winterdev  Před 4 lety +2

      Thanks! You know what, I think that might just be the way. I could cover some of the algorithms that have few concise explanations. I bet I could make a good GJK video...

    • @FlareGunDebate
      @FlareGunDebate Před 3 lety

      @@Winterdev GJK is an advanced and often poorly explained distance algorithm. To be meaningful it also requires an understanding of linear algebra and affine geometry. I'd like to see how you handle it.

  • @dingalong14
    @dingalong14 Před 3 lety +2

    I wish your videos had existed back when I started writing my own engines! I love how clean and neatly compartmentalised everything is!

    • @Winterdev
      @Winterdev  Před 3 lety +2

      Haha thanks, that is my goal, to make the tutorials that I needed. It seems I'm not the only one that wished there was clearer info on these topics! :)

  • @rishabhkumrawat8258
    @rishabhkumrawat8258 Před 3 lety +4

    Great video. Keep uploading this juicy stuff. Subbed.

  • @Fiolsthu95
    @Fiolsthu95 Před 4 lety +22

    I did not know it was possible to show code in a video and keep it understandable, but you did it! Very nice video.
    I'm a bit more interested in the math of e.g. what happens after a collision, or how to prevent errors in the simulation from building up and sending the spheres flying. But honestly I'll definitely watch the next video in the series, whatever it is!

    • @Winterdev
      @Winterdev  Před 4 lety +6

      Thanks! I'll get into that in the next part about physics. I don't have it planned, but when I get to it I'll lean a little bit more into the math. If you want to check out the code for the response, it's here and decently readable: github.com/IainWinter/IwEngine/blob/master/IwEngine/src/physics/Dynamics/ImpulseSolver.cpp

  • @JuliusLiu
    @JuliusLiu Před 2 lety +1

    This video is gold, thanks for breaking down your reasoning so well

  • @CaioAletroca
    @CaioAletroca Před 3 lety +5

    That's was really good man!!

  • @MindFuelDrive
    @MindFuelDrive Před 3 lety +4

    Dude amazing subbed with notifications!

  • @amop2250
    @amop2250 Před 3 lety +10

    After watching the entire video, I remembered I don't know how to program.

  • @ramosrodriguezjheisson7822

    Bro this video was great, keep it up!

  • @finnbuhse4775
    @finnbuhse4775 Před 3 lety +2

    Brilliant video, I would love to see a video on the ECS you mentioned as I'm currently implementing my second iteration of a ECS and am curious to see how accomplish it. Keep up the good work

    • @Winterdev
      @Winterdev  Před 3 lety

      Thanks, I'll note that to do next after these sand vidz. That's prob not going to be for a while, but if you want to get some ideas the source code is here and not too messy, I think this was also my 2nd or 3rd go at it github.com/IainWinter/IwEngine/tree/master/IwEngine/include/iw/entity

  • @heavencanceller1863
    @heavencanceller1863 Před 2 lety +1

    Great video! loved it

  • @bailey7078
    @bailey7078 Před rokem

    How do you not have more subs??? Quality Content!

  • @filcondrat
    @filcondrat Před 3 lety +1

    great explanation!
    will be cool to see more

    • @Winterdev
      @Winterdev  Před 3 lety

      Thanks! More videos coming soon, a new semester just started and I am bogged down with work though :

  • @codewithnacho
    @codewithnacho Před 3 lety +1

    Excellent video! Thanks for sharing

  • @FromLake
    @FromLake Před 4 měsíci

    Wow. Thank you very much for this video!❤

  • @delofon
    @delofon Před 2 lety

    This channel is a godsend. Thank you.

  • @Dominik-K
    @Dominik-K Před 2 lety +1

    Great video, this may get very useful. Making a physics engine seems a bit overkill, but I did already notice how it gives you a lot of freedom

    • @Winterdev
      @Winterdev  Před 2 lety +1

      Yeah plus a couple As in final school projects haha. And it’s fun to have a system that you know every detail of

  • @P-G-77
    @P-G-77 Před 10 měsíci

    Very interesting... thanks

  • @Mostafa-cv8jc
    @Mostafa-cv8jc Před 3 lety +1

    thank you very much for this vide!

  • @acatisfinetoo3018
    @acatisfinetoo3018 Před rokem +1

    I found this extremely helpful in writing my own physics engine.

  • @RomaineRC
    @RomaineRC Před 3 lety +7

    I got algorthmed here. Don't know who you are yet but this is great!

    • @Winterdev
      @Winterdev  Před 3 lety +2

      Thanks! It looks like its chosen me for today lol

  • @cumhilo
    @cumhilo Před 2 lety

    you are a legend, ty so much

  • @dandymcgee
    @dandymcgee Před 3 lety +2

    Pretty cool overview, at least of the basics. Would be neat to see you integrate your GJK video with this video to create something a bit more realistic and useful than simple sphere vs. plane.

  • @blackflame_
    @blackflame_ Před 2 lety

    Only 2.5k subs? Criminally underrated channel

  • @ItsaDigitalHamster
    @ItsaDigitalHamster Před 3 lety +1

    Love the video! Can you do a full tutorial / code walkthrough of the impulse or position solver? I would love to know more of the math details

    • @Winterdev
      @Winterdev  Před 3 lety +2

      Thanks! Yes, I think I am going to throw that in with angular stuff when I get back to physics. The code is decently clear if you want to look at it github.com/IainWinter/IwEngine/blob/master/IwEngine/src/physics/Dynamics/ImpulseSolver.cpp

    • @testosteroneoverdose
      @testosteroneoverdose Před 2 lety

      @@Winterdev Thanks I’ll try it.

  • @mmmbackwheelbates
    @mmmbackwheelbates Před 3 lety +1

    Great work on explaining this in such a simple way! Would you mind clarifying what you meant by Position Solver and Impulse Solver? I didn't understand this part. Thanks!!

    • @Winterdev
      @Winterdev  Před 3 lety

      Thanks! They inhreit from 'Solver' and process each CollisionPoints. The idea is that the impluse one solves for the force of each collision, and the position once corrects the position directly for some error correction. You can check out the source of these here github.com/IainWinter/IwEngine/tree/master/IwEngine/src/physics/Dynamics

  • @Bonfere
    @Bonfere Před 3 lety +3

    great vid

  • @itsME-dc4vm
    @itsME-dc4vm Před 3 lety +2

    Nice ;D

  • @rmt3589
    @rmt3589 Před 9 měsíci +1

    That... explains a lot... A while back, was trying to figure out why all the collision detection stuff was reactive to objects clipping together. Apparently, this is the norm.
    I wonder if I can make it more proactive. Maybe with a raycast?

  • @rvoros
    @rvoros Před 3 lety +2

    it's rare when someone talks about the real issues
    excellent material, well done!

  • @ne0ck237
    @ne0ck237 Před 3 lety +1

    When I made a physics engine as a university project I came up with a very similar structure myself. Code was a lot more mess) but the principle of collision solving was the same. The most challenging part btw was an angular motion

    • @Winterdev
      @Winterdev  Před 3 lety

      Really? I was under the impression that was only going to involve some slight edits lol. Looking forward to it now... :)

    • @ne0ck237
      @ne0ck237 Před 3 lety +1

      @@Winterdev Maybe it actually is a slight edit, I just could have done it extremely wrong xD Looking forward to your video about it to find that out)

  • @ironduck2
    @ironduck2 Před rokem

    Great video! But I have a question, how did you do the graphycs of the video? Like the dynamics title and those trancitions. I want to do videos like this, but I don't know how to make them visually apealing

  • @dodo-js5gw
    @dodo-js5gw Před 3 lety +2

    Hey thanks a lot for your video ! I have two question :p
    First: For the motion equation when you write [x=vt+x0] with [v=F/m*t + v0] I didn't get why when you integrate the velocity you don't have the 1/2 for the position.
    because x should be equal to [x=F/m*t²/2+v0*t+x0] so you can't write [x=v*t+x0] or am I stupid ^^
    Second: What do you use do make your formula and code animation ? :)

    • @Winterdev
      @Winterdev  Před 3 lety

      This was talked about quite a bit over on the hn page here news.ycombinator.com/item?id=24016718#up_24018883. It's a pretty interesting read. I've been using HTML and CSS for these 😂

  • @sdsdfdu4437
    @sdsdfdu4437 Před 3 lety +2

    I wish you could go over collisions a bit more, specifically broad phase collision detection

    • @Winterdev
      @Winterdev  Před 3 lety +2

      I am running into the limits of testing everything against everything right now, so once I make my version I can make a vid on that for sure!

  • @simeonbeckford-tongs9391

    Thank you

  • @marofe
    @marofe Před 2 lety +1

    Nice video! How are you creating this presentation? Are you using some specific software?

    • @Winterdev
      @Winterdev  Před 2 lety

      I just use a js file that switches classes around each ‘key frame’ and then I built another web tool that generates it

  • @DontfallasleeZZZZ
    @DontfallasleeZZZZ Před 2 lety +1

    Thanks for the cool video. Just curious, what are the reasons for writing your own physics engine rather than using open-source engines such as Bullet or Mujoco? Not saying you shouldn't do it, even out of interest, but are there any objective reasons to do it?

    • @Winterdev
      @Winterdev  Před 2 lety

      It started as a project for a physics class and then I realized I could use it for the simple games I was making. Over time I got invested in it :) I think other than coding exercises you should use a library, but I think it’s important to understand what the computer is doing so it’s def worth it to try and make one yourself.

  • @ubuntujackson9133
    @ubuntujackson9133 Před rokem +1

    Winterdev: Codes a physics engine in 5 minutes, provides glimpses of classes but doesn't provide the source code
    Me: Can I see the full source code, so that I can run and experiment with it?
    Winterdev: NOOOOO, don't you know how much TIME and hard work went into this??? How can you put such high expectations on me???

    • @Winterdev
      @Winterdev  Před rokem +1

      It’s in the article :p github.com/IainWinter/IwEngine/tree/master/IwEngine/src/physics

    • @ubuntujackson9133
      @ubuntujackson9133 Před rokem +1

      @@Winterdev Thank you, and sorry for the harsh comment, I just see a lot of bait on YT nowadays, trying to give ppl the false sense they've learned something when they've just made eyecandy for viewers

  • @suppressinglight1007
    @suppressinglight1007 Před 2 lety +3

    Question is that vector3 a thing in c++ or did you already create it or used a library?

    • @Winterdev
      @Winterdev  Před 2 lety +1

      No I made that myself. This didn’t need anything complicated math wise so I just made my own

    • @suppressinglight1007
      @suppressinglight1007 Před 2 lety +1

      @@Winterdev Oh is there the source code, or tutorial on how to do it?

    • @Winterdev
      @Winterdev  Před 2 lety +1

      There was but I’ve changed it form what it was for this project. For this all it was an x y z and operator+. In the collisions the dot product is used I think.

  • @katkollare809
    @katkollare809 Před 3 lety +1

    Your video is brilliant, it was a great pleasure to finally find someone explaining all that stuff in such a simple to understand format. I do have a stupid question for you, though. Don't get me wrong, but how did you get [ x = x0 + v∆t ] when describing uniformly accelerated motion? I mean, for that to be true, [ ∆x = v∆t ] would have to be true too, but [ ∆x = v0∆t + a∆t^2 / 2 ] (as was shown in the video)? I don't get why we calculate [ obj->Velocity += obj->Force / obj->Mass * dt ] and at the same time [obj->Position += obj->Velocity * dt]. Could you, please, at least briefly explain it in a reply to my comment, please? Thank you very much in advance

    • @Winterdev
      @Winterdev  Před 3 lety

      Thanks for the comment! Someone in the hacker news discussion was talking about that on similar lines news.ycombinator.com/item?id=24019099. My understanding is if you update the velocity then the position in the code, ∆x = ∆vt and ∆v = at. When you take the derivative you get ∆x = ∆v + a∆t^2 / 2. I think in the code if it were too update the position then the velocity, this would be an issue, but because the velocity gets updated then the position, those equations are equivalent.

    • @katkollare809
      @katkollare809 Před 3 lety +2

      @@Winterdev Thanks! Yeah, I guess the key is that we expect ∆t to be so small that we can afford getting some measurement error by calculating ∆x as if the object were moving uniformly without acceleration whatsoever. Also, like you said, this would be an issue if we calculated ∆x first, since then we would not really use acceleration anywhere at all. Thanks for clearing that up!

  • @gutzimmumdo4910
    @gutzimmumdo4910 Před 3 lety +1

    nice discovery, you should do tutorial on how to design a game engine bro

    • @Winterdev
      @Winterdev  Před 3 lety +1

      That's the long term goal! First I gotta finish this sand mini arc and then I want to go library by library and make vids like the first one

  • @micmaci9343
    @micmaci9343 Před 20 dny

    Can you explain why 3:06 for SphereToPlane you pass a *tb Transform pointer as Plane Transform struct ? I cannot find this part of engine on github?

  • @nolram
    @nolram Před 3 lety +1

    So I was trying to follow along this, however I quickly ran into the issue of there being no vector3's (or vector 2's) in the std library or anywhere else, where are those coming form ? When trying to create them as a struct I can't do the needed maths with floats later on.

    • @Winterdev
      @Winterdev  Před 3 lety

      It’s a little unclear but those come from me. All you need for this are structs with 2 or 3 floats for x, y, z and maybe a length / dot product function which are both 1-2 lines so I didn’t cover that. I might add a small gist to the description

    • @nolram
      @nolram Před 3 lety

      @@Winterdev A gist about it would be greatly appreciated, I for now created my own PhysVectors with the required coordinates and operators that should do for now.

  • @kallehed6330
    @kallehed6330 Před rokem +1

    Don't forget quadtrees!

  • @malandr1
    @malandr1 Před 3 lety

    Could you please make the explanation but for Lagoa multiphysics algorithm? It's seems so much better than Bullet

  • @puddleglum5610
    @puddleglum5610 Před 2 lety +1

    Great video! I’d love to know how all of this polymorphism affects performance. While it has a great design, I’m not sure that it will be performant, lots of dereferencing and dynamic function lookups. I’d think this would have terrible cache coherence.

    • @MisterFanwank
      @MisterFanwank Před 2 lety +1

      The performance will be trash for more than the reasons you listed. Consider that every static object will need a collision test between every other static object, which is ridiculous. Which objects collide with which objects is something you need to tightly control (say, should a bullet interact with a gravity volume?) for performance and behavior reasons, and the approach in this video isn't good enough.

    • @Winterdev
      @Winterdev  Před 2 lety +1

      @@MisterFanwank Yeah one of my biggest regrets with this design was the double dispatch call. I later found a Valve pdf (page 33) that describes a 2d array of function pointers, then you use a ColliderType enum to index it. This lets you define all the possible collisions in one place and effectively centralizes the virtual function table. You could add another enum and follow this pattern for the object collision masks. The performance worked for my tiny games, but you definitely need a form of broad phase check/data structure for anything larger.
      valve: pdf media.steampowered.com/apps/valve/2015/DirkGregorius_Contacts.pdf

  • @delofon
    @delofon Před 2 lety +1

    I noticed in the source of PositionSolver that you're displacing both colliding objects by resolution. Wouldn't it make more sense both objects only by half of it?

    • @Winterdev
      @Winterdev  Před 2 lety

      Yes that was a dumb mistake! Thanks for catching that :)

  • @Umblizm
    @Umblizm Před 2 lety +1

    So I’m researching physics engines for racings games and I have a question if everyone can answer it (I haven’t fully watched the vid yet so bear with me) when it comes to making a racing game, for the cars to of course drive and drift. Is that done purely from coding in, the gravity, and friction from the wheels? So that once you brake the physics would cause the wheels to loose friction causing them to drift? I know that the wheels have their own collision, allowing the vehicles to drive. I just have no idea how it makes the car move and the thing that confuses me the most, drifting.

    • @Winterdev
      @Winterdev  Před 2 lety +1

      Well it depends on how realistic you want it. I’ve never made a racing game but you could do what you described or you could just have a simple obj following a path like Tube Slider

    • @Umblizm
      @Umblizm Před 2 lety

      @@Winterdev I did some digging after leaving that comment and that is a common way to do it apparently when making physics for racing games. By having the wheels separate objects from the body, still attached of course, and giving them physics like friction and then just change them depending on what you want wether it’s a drag, drifter, or off-roader

  • @thebutterappletutorials6553

    If you could, I would love to see a tutorial on implementing these things! The dynamic part was pretty easy but I've been trying the collision for days and it's constant errors and nothings working. I tried using the engine you're developing as a reference but its way ahead of where I'm at xD Im just not sure where to put the classes and stuff, any help is appreciated!

    • @Winterdev
      @Winterdev  Před 3 lety +2

      I don't know your specific code, but I'd try and start with something as simple as possible to get an idea for how it should come together/what the issues are.
      You could start with making a 'Collider' that is just the sphere one because it's the more basic . Then you could store these in a list, really anywhere, and loop over them getting the responses if there is one and moving them by that response.
      I might make a version of this with impl, but not for a while as I am trying out some other topics besides physics. gl with your code :)

    • @thebutterappletutorials6553
      @thebutterappletutorials6553 Před 3 lety +1

      @@Winterdev Thanks! I ended up getting it working but the plane collider is infinite along the x and z coordinates, did you run into that?

    • @Winterdev
      @Winterdev  Před 3 lety +1

      @@thebutterappletutorials6553 Yes that's what I have. Nice job!

    • @thebutterappletutorials6553
      @thebutterappletutorials6553 Před 3 lety +1

      @@Winterdev Thank you!!! Gonna move onto the Mesh Collider stuff next! (GJK and EPA) Would love to see videos going into the math (how to attach it to a custom model and have it work!)

    • @Winterdev
      @Winterdev  Před 3 lety +1

      Oh nice good luck!! When you say attaching it to a custom mesh, is that from a visible mesh to a physics one? Or any type of collider attached to whatever game object so they move together.

  • @green_quadrix
    @green_quadrix Před 2 lety +1

    Cool. What programming language are u using?

    • @Winterdev
      @Winterdev  Před 2 lety

      Thanks! And I used C++ for this

  • @GenericInternetter
    @GenericInternetter Před rokem +1

    The Cherno sent me here.

  • @antixdevelopment1416
    @antixdevelopment1416 Před 6 měsíci

    Pretty neat but a little info and code on optimisation would have been really good.

  • @Necronlord2011
    @Necronlord2011 Před 3 lety +3

    Very good video, I know you want to keep them short but feedback point I have is you are almost going a bit too fast (at least for my foreigner ears)

    • @Winterdev
      @Winterdev  Před 3 lety

      Thanks, I'm still getting that down, there are written versions as well so I don't really know if I should made fast videos or not... Here is the article if you're interested: blog.winter.dev/2020/designing-a-physics-engine/

  • @TinyDeskEngineer
    @TinyDeskEngineer Před 10 měsíci

    ...Is collision detection between primitives really as simple as separate functions for each possible interactions between all the different shapes? Is there not a better, more easily extended way to do this?

    • @Winterdev
      @Winterdev  Před 10 měsíci

      I changed it to be a table of function pointers later on which was much easier to work with. I don’t like the double dispatch at all looking back

  • @ccbotics6410
    @ccbotics6410 Před 2 lety

    I would love to see how rigid body constrains work

    • @Winterdev
      @Winterdev  Před 2 lety

      Not a vid but here is a “3 fold poster” I made for a class final project. winter.dev/physics/ it’s not complete but a good start

  • @byzantiumgaming
    @byzantiumgaming Před 2 lety +1

    What's this coded in (like visual studio or vscode, etc)?

    • @Winterdev
      @Winterdev  Před 2 lety

      I use visual studio but in theory you could use notepad lol. The build tools kinda abstract that away but I haven’t tested it with anything else

  • @paraxodondev
    @paraxodondev Před 10 měsíci

    i love you

  • @dynamagon
    @dynamagon Před rokem

    how do you construct your vector3 union/struct/class?

    • @Winterdev
      @Winterdev  Před rokem

      It’s just 3 floats and you pass it x,y,z or it defaults to 0,0,0

  • @ederamin9697
    @ederamin9697 Před 2 lety +1

    this was a good video, but you could've explained more on colliders

    • @Winterdev
      @Winterdev  Před 2 lety

      Thanks, if you watched my recent dev log I have these asteroids flying around that need the rotational collision response so I’ll make a vid covering colliders when I talk about that in a couple weeks

  • @fabiankracher3695
    @fabiankracher3695 Před 3 lety +1

    dive!!!!!

  • @wjrasmussen666
    @wjrasmussen666 Před rokem

    Going to make any more videos? How about a github link?

  • @thegoldenguy8203
    @thegoldenguy8203 Před 2 lety

    Hi, can we use GJK collision detection

  • @captainbanglawala2031
    @captainbanglawala2031 Před 5 měsíci

    Please dive deeper into the maths behind the implementations.

  • @sergodobro2569
    @sergodobro2569 Před 20 dny

    What is the best way to resolve 20k objects' collisions?

  • @bianchialex
    @bianchialex Před 3 lety +1

    Ok so I get the math of the physics engine, but how do you visualize it? I tried setting up OpenGL but now I am hours into getting that to run and take a simple input when i wanted to build a physics engine for fun lol.

    • @Winterdev
      @Winterdev  Před 3 lety

      Lol I feel your pain. OpenGL is as complex if not way more than the physics engine and impossible to debug if you don’t know where to look. I’d lookup GLFW which wraps all the nonsense (window/input/update loop) up for you, but you still need to pass a mesh by hand and have shaders setup. Maybe look for a renderer library that is made to be as simple as possible

    • @bianchialex
      @bianchialex Před 3 lety +1

      @@Winterdev yeah in using GLFW. I'm a first year undergraduate computer science student. I built a ray Tracer and thought "all this math was cool, I should make a simple little physics engine." I think I'm gonna be able to understand GLFW and the physics but combining them might be problematic, I will figure it out! Or not, I have an internship starting next week so bit of a time crunch.

    • @Winterdev
      @Winterdev  Před 3 lety

      You should make a Transform struct that has a position, scale, rotation and a function to get the transformation mat4 from those. Then the physics engine can take this too and the colliders can stay in relative cords along with the meshes (or sdfs?)

    • @BonktYT
      @BonktYT Před 3 lety +1

      ​@@Winterdev Hello, Thanks for this great video. I'm a big noob on both OpenGL and c++ but this inspired me a lot. Regarding your answer above, I have a question. When rendering say circles or spheres, the renderer will need both the position of that object, and the colliders 'center', and add them together, right? But I can't reach the variables radius and center from the class SphereCollider In my renderer as it simply interprets them as the base class "collider". Would I have to create a similar function-structure as you did with the colliders for the rendering or how does this work? any tips? Thanks, John.
      Edit: I mean, why is the "center" variable in the SphereCollider needed? can't it all be handled from the position in the transform? And the plane, can't it just be implicitly oriented with normal (1, 0, 0) and then let it's transform take care of any further rotations?

    • @Winterdev
      @Winterdev  Před 3 lety

      The trick is that the rendering world is separate from the physics world. You need to have some sort of object that represents the position and pass it to both, then they both add it to the colliders center and mesh verts. So everything is relatively positioned to a shared position.

  • @elibildman422
    @elibildman422 Před 4 lety +7

    meaty voice :weary:

  • @sucukluomlet4665
    @sucukluomlet4665 Před 2 lety +3

    But where can we design a physic engine;Scratch, unity?

    • @Winterdev
      @Winterdev  Před 2 lety

      If you’re asking where to make something like this? Anywhere you can see the results! So you could print to console or use unity to easily display, tho that’s in C# not C++

  • @torque8047
    @torque8047 Před 2 lety +1

    I come from the algorithm, and i must say. Yes me likey applied math

  • @pyrytheburger3869
    @pyrytheburger3869 Před 2 lety

    yeah imma just stick to using a physics library

  • @heartsickaus
    @heartsickaus Před 3 lety +1

    Can you provide the source code for this?

    • @Winterdev
      @Winterdev  Před 3 lety +1

      The frozen code is in the article here blog.winter.dev/2020/designing-a-physics-engine/. And the working code is in the git repo here github.com/IainWinter/IwEngine/tree/master/IwEngine/src/physics

  • @TheQDeathNick
    @TheQDeathNick Před 3 lety +3

    What about next video?

    • @Winterdev
      @Winterdev  Před 3 lety

      Funny enough, it's going up tomorrow :)

  • @michaelrenon6884
    @michaelrenon6884 Před 2 lety +1

    what program is this?

    • @Winterdev
      @Winterdev  Před 2 lety

      many lines of C++ called wEngine

  • @s3vster
    @s3vster Před 2 lety +1

    f += m * g
    This only works if you zero f at the beginning, how it looks like in the code snippet, it should be f = m * g, small bug

    • @Winterdev
      @Winterdev  Před 2 lety

      Aa it does get 0’ed I don’t think I mentioned that tho. Good catch

  • @embereve-chan
    @embereve-chan Před 3 lety +1

    This is why I'm not a programmer and never will be.

  • @Johnny-tw5pr
    @Johnny-tw5pr Před 2 lety +1

    Where is the source?

    • @Winterdev
      @Winterdev  Před 2 lety +2

      It's edited now, but here is the live code.
      github.com/IainWinter/IwEngine/tree/master/IwEngine/include/iw/physics
      github.com/IainWinter/IwEngine/tree/master/IwEngine/src/physics
      You can step back in time in the commits to find the og code.

  • @yizhang7027
    @yizhang7027 Před 3 lety +1

    Does youtube keep deleting my comments? I'll try one more time.
    Dynamics is more complicated than that. What you described here is the explicit euler method, which is unstable and unusable in physics engine. You might want to check out Erin Catto's 2015 GDC talk where he demonstrated the semi-implicit euler method, which most modern physics engines use.

    • @Winterdev
      @Winterdev  Před 3 lety

      Someone else was having their comments deleted too, idk why sorry. I watched that video and it looks like that I am using what's called semi-implicit Euler, which Eric concludes is the most common. That makes since to me because it's what you naturally end up with when translating the kinematic equations directly to code without thinking about it. Let me know if I missed something, thanks for the comment :)

  • @samhsmith6998
    @samhsmith6998 Před 3 lety +3

    you OOPed that code too much.

    • @Winterdev
      @Winterdev  Před 3 lety +1

      I'm far too deep in the mindset to turn back now lol :(

  • @christopherpetrov2355

    I might sound silly but can we have a python version of this😅

  • @RoidoStuff
    @RoidoStuff Před 3 lety

    I always wanted to be a developer but mom can't afford to get me to a teacher

    • @Winterdev
      @Winterdev  Před 3 lety

      :(

    • @RoidoStuff
      @RoidoStuff Před 3 lety

      @@Winterdev I'm trying to teach myself programming and makinga game in roblox and I learned basic scripting like scripting a part and achoring them some simple scripting but still its realy hard to understand I tried it but it didn't worked I got discouraged and now I ended up giving up.

    • @ahmedaghadi8281
      @ahmedaghadi8281 Před 3 lety

      @@RoidoStuff there are many tutorials available in CZcams. Learn c# and then use unity game engine or learn java and use android studio to make android apps and all.

    • @RoidoStuff
      @RoidoStuff Před 3 lety

      @@ahmedaghadi8281 yeah I've been working on many games rn on roblox and I also learned some basic scripts

  • @qxb348
    @qxb348 Před 2 lety +1

    If you see this comment before this video have a million views you are a legend!

  • @empireempire3545
    @empireempire3545 Před 3 lety

    Eeeh, you forget about response to continous field...

    • @Winterdev
      @Winterdev  Před 3 lety

      If you're talking about applying forces, you'd do that in game logic with some collision event from a trigger for whatever region you wanted the force field in. Not too sure what you mean by 'response to continuous field' though

  • @bity-bite
    @bity-bite Před 3 lety +1

    Too much stuff to understand for my small brain.

  • @DasAntiNaziBroetchen
    @DasAntiNaziBroetchen Před 3 lety +1

    I haven't watched the whole video yet, but your "pointer approach" to storing the physics objects is an obliteration of CPU cache and should not be used in production code.

    • @Winterdev
      @Winterdev  Před 3 lety

      Yeah it’s up to you to allocate them efficiently. I’m not sure what box2d is doing with proxies but that might be cool to look at for a 3rd option.

  • @quentinquadrat9389
    @quentinquadrat9389 Před 2 lety +1

    The link of your blog is dead

  • @pajeetsingh
    @pajeetsingh Před 3 lety +1

    I hate Minkowski

  • @thinkandmove479
    @thinkandmove479 Před měsícem

    Good video, and I could understand it. But... However... Why are you speaking as fast as possible without any space between your sentences?