Designing a Physics Engine in 5 minutes

Ғылым және технология

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

Пікірлер: 191

  • @ciberman
    @ciberman3 жыл бұрын

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

  • @mathusuthanvenkatesan

    @mathusuthanvenkatesan

    3 жыл бұрын

    i exist too!

  • @mathusuthanvenkatesan

    @mathusuthanvenkatesan

    3 жыл бұрын

    and hence your statement is wrong

  • @ksuyft5226

    @ksuyft5226

    3 жыл бұрын

    but i exactly came for that...im trying to make a solar system simulation xD

  • @jaggercarson8832

    @jaggercarson8832

    2 жыл бұрын

    instablaster.

  • @nullbeyondo

    @nullbeyondo

    Жыл бұрын

    He just said that cause the title is about physics engines not engineless plain n-body simulations.

  • @_general_error
    @_general_error2 жыл бұрын

    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!

  • @Winterdev

    @Winterdev

    2 жыл бұрын

    Thanks!

  • @TheSunCatZeCat
    @TheSunCatZeCat3 жыл бұрын

    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
    @whoshotdk3 жыл бұрын

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

  • @Winterdev

    @Winterdev

    3 жыл бұрын

    Hell yeah! tyty

  • @hereticstanlyhalo6916
    @hereticstanlyhalo69162 жыл бұрын

    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
    @jonathanfeller2 жыл бұрын

    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! :-).

  • @Fiolsthu95
    @Fiolsthu953 жыл бұрын

    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

    3 жыл бұрын

    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

  • @FlareGunDebate
    @FlareGunDebate3 жыл бұрын

    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

    3 жыл бұрын

    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

    3 жыл бұрын

    @@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.

  • @alexismandelias
    @alexismandelias2 жыл бұрын

    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

  • @chopstix9093

    @chopstix9093

    2 жыл бұрын

    Well said

  • @testosteroneoverdose
    @testosteroneoverdose2 жыл бұрын

    Great video! Very well edited and easy to understand!

  • @tarapogancev
    @tarapogancev3 жыл бұрын

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

  • @Winterdev

    @Winterdev

    3 жыл бұрын

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

  • @fieti
    @fieti3 жыл бұрын

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

  • @Winterdev

    @Winterdev

    3 жыл бұрын

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

  • @curtispreston4400
    @curtispreston44002 жыл бұрын

    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

  • @Winterdev

    @Winterdev

    2 жыл бұрын

    Glad I could help :)

  • @amop2250
    @amop22503 жыл бұрын

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

  • @dingalong14
    @dingalong143 жыл бұрын

    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

    3 жыл бұрын

    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! :)

  • @finnbuhse4775
    @finnbuhse47753 жыл бұрын

    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

    3 жыл бұрын

    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

  • @JuliusLiu
    @JuliusLiu2 жыл бұрын

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

  • @rishabhkumrawat8258
    @rishabhkumrawat82583 жыл бұрын

    Great video. Keep uploading this juicy stuff. Subbed.

  • @Winterdev

    @Winterdev

    3 жыл бұрын

    Thanks! I'll try

  • @ramosrodriguezjheisson7822
    @ramosrodriguezjheisson78222 жыл бұрын

    Bro this video was great, keep it up!

  • @CaioAletroca
    @CaioAletroca3 жыл бұрын

    That's was really good man!!

  • @MindFuelDrive
    @MindFuelDrive3 жыл бұрын

    Dude amazing subbed with notifications!

  • @bailey7078
    @bailey7078 Жыл бұрын

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

  • @FromLake
    @FromLake3 ай бұрын

    Wow. Thank you very much for this video!❤

  • @filcondrat
    @filcondrat3 жыл бұрын

    great explanation! will be cool to see more

  • @Winterdev

    @Winterdev

    3 жыл бұрын

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

  • @rmt3589
    @rmt35898 ай бұрын

    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?

  • @codewithnacho
    @codewithnacho3 жыл бұрын

    Excellent video! Thanks for sharing

  • @Winterdev

    @Winterdev

    3 жыл бұрын

    Thanks

  • @delofon
    @delofon2 жыл бұрын

    This channel is a godsend. Thank you.

  • @heavencanceller1863
    @heavencanceller18632 жыл бұрын

    Great video! loved it

  • @Dominik-K
    @Dominik-K2 жыл бұрын

    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

    2 жыл бұрын

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

  • @acatisfinetoo3018
    @acatisfinetoo3018 Жыл бұрын

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

  • @dandymcgee
    @dandymcgee3 жыл бұрын

    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.

  • @Winterdev

    @Winterdev

    3 жыл бұрын

    I'd check out the EPA one :p

  • @mmmbackwheelbates
    @mmmbackwheelbates2 жыл бұрын

    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

    2 жыл бұрын

    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

  • @ItsaDigitalHamster
    @ItsaDigitalHamster3 жыл бұрын

    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

    3 жыл бұрын

    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

    2 жыл бұрын

    @@Winterdev Thanks I’ll try it.

  • @ironduck2
    @ironduck211 ай бұрын

    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

  • @P-G-77
    @P-G-779 ай бұрын

    Very interesting... thanks

  • @RomaineRC
    @RomaineRC3 жыл бұрын

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

  • @Winterdev

    @Winterdev

    3 жыл бұрын

    Thanks! It looks like its chosen me for today lol

  • @ne0ck237
    @ne0ck2373 жыл бұрын

    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

    3 жыл бұрын

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

  • @ne0ck237

    @ne0ck237

    3 жыл бұрын

    @@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)

  • @blackflame_
    @blackflame_2 жыл бұрын

    Only 2.5k subs? Criminally underrated channel

  • @dodo-js5gw
    @dodo-js5gw3 жыл бұрын

    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

    3 жыл бұрын

    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
    @sdsdfdu44372 жыл бұрын

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

  • @Winterdev

    @Winterdev

    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!

  • @Mostafa-cv8jc
    @Mostafa-cv8jc2 жыл бұрын

    thank you very much for this vide!

  • @marofe
    @marofe2 жыл бұрын

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

  • @Winterdev

    @Winterdev

    2 жыл бұрын

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

  • @cumhilo
    @cumhilo2 жыл бұрын

    you are a legend, ty so much

  • @DontfallasleeZZZZ
    @DontfallasleeZZZZ2 жыл бұрын

    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

    2 жыл бұрын

    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.

  • @katkollare809
    @katkollare8093 жыл бұрын

    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

    3 жыл бұрын

    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

    3 жыл бұрын

    @@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!

  • @simeonbeckford-tongs9391
    @simeonbeckford-tongs939111 ай бұрын

    Thank you

  • @malandr1
    @malandr13 жыл бұрын

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

  • @rvoros
    @rvoros3 жыл бұрын

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

  • @suppressinglight1007
    @suppressinglight10072 жыл бұрын

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

  • @Winterdev

    @Winterdev

    2 жыл бұрын

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

  • @suppressinglight1007

    @suppressinglight1007

    2 жыл бұрын

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

  • @Winterdev

    @Winterdev

    2 жыл бұрын

    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.

  • @delofon
    @delofon2 жыл бұрын

    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

    2 жыл бұрын

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

  • @green_quadrix
    @green_quadrix2 жыл бұрын

    Cool. What programming language are u using?

  • @Winterdev

    @Winterdev

    2 жыл бұрын

    Thanks! And I used C++ for this

  • @nolram
    @nolram3 жыл бұрын

    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

    3 жыл бұрын

    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

    3 жыл бұрын

    @@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.

  • @puddleglum5610
    @puddleglum56102 жыл бұрын

    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

    2 жыл бұрын

    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

    2 жыл бұрын

    @@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

  • @RileyB1648
    @RileyB16482 жыл бұрын

    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

    2 жыл бұрын

    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

  • @RileyB1648

    @RileyB1648

    2 жыл бұрын

    @@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

  • @TinyDeskEngineer
    @TinyDeskEngineer9 ай бұрын

    ...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

    9 ай бұрын

    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

  • @ubuntujackson9133
    @ubuntujackson9133 Жыл бұрын

    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

    Жыл бұрын

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

  • @ubuntujackson9133

    @ubuntujackson9133

    Жыл бұрын

    @@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

  • @kallehed6330
    @kallehed6330 Жыл бұрын

    Don't forget quadtrees!

  • @antixdevelopment1416
    @antixdevelopment14165 ай бұрын

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

  • @wjrasmussen666
    @wjrasmussen666 Жыл бұрын

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

  • @dynamagon
    @dynamagon Жыл бұрын

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

  • @Winterdev

    @Winterdev

    Жыл бұрын

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

  • @byzantiumgaming
    @byzantiumgaming2 жыл бұрын

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

  • @Winterdev

    @Winterdev

    2 жыл бұрын

    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

  • @thebutterappletutorials6553
    @thebutterappletutorials65533 жыл бұрын

    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

    3 жыл бұрын

    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

    3 жыл бұрын

    @@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

    3 жыл бұрын

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

  • @thebutterappletutorials6553

    @thebutterappletutorials6553

    3 жыл бұрын

    @@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

    3 жыл бұрын

    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.

  • @itsME-dc4vm
    @itsME-dc4vm3 жыл бұрын

    Nice ;D

  • @Bonfere
    @Bonfere3 жыл бұрын

    great vid

  • @Winterdev

    @Winterdev

    3 жыл бұрын

    Thank you!

  • @CandyKeane

    @CandyKeane

    3 жыл бұрын

    Trash you rud

  • @gutzimmumdo4910
    @gutzimmumdo49103 жыл бұрын

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

  • @Winterdev

    @Winterdev

    3 жыл бұрын

    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

  • @thegoldenguy8203
    @thegoldenguy8203 Жыл бұрын

    Hi, can we use GJK collision detection

  • @Winterdev

    @Winterdev

    Жыл бұрын

    Yes I did a video on it :)

  • @ccbotics6410
    @ccbotics64102 жыл бұрын

    I would love to see how rigid body constrains work

  • @Winterdev

    @Winterdev

    2 жыл бұрын

    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

  • @bianchialex
    @bianchialex3 жыл бұрын

    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

    3 жыл бұрын

    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

    3 жыл бұрын

    @@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

    3 жыл бұрын

    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

    3 жыл бұрын

    ​@@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

    3 жыл бұрын

    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.

  • @heartsickaus
    @heartsickaus3 жыл бұрын

    Can you provide the source code for this?

  • @Winterdev

    @Winterdev

    3 жыл бұрын

    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

  • @michaelrenon6884
    @michaelrenon68842 жыл бұрын

    what program is this?

  • @Winterdev

    @Winterdev

    2 жыл бұрын

    many lines of C++ called wEngine

  • @Necronlord2011
    @Necronlord20113 жыл бұрын

    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

    3 жыл бұрын

    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/

  • @GenericInternetter
    @GenericInternetter Жыл бұрын

    The Cherno sent me here.

  • @sucukluomlet4665
    @sucukluomlet46652 жыл бұрын

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

  • @Winterdev

    @Winterdev

    2 жыл бұрын

    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++

  • @Johnny-tw5pr
    @Johnny-tw5pr2 жыл бұрын

    Where is the source?

  • @Winterdev

    @Winterdev

    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.

  • @captainbanglawala2031
    @captainbanglawala20314 ай бұрын

    Please dive deeper into the maths behind the implementations.

  • @TheQDeathNick
    @TheQDeathNick3 жыл бұрын

    What about next video?

  • @Winterdev

    @Winterdev

    3 жыл бұрын

    Funny enough, it's going up tomorrow :)

  • @ederamin9697
    @ederamin96972 жыл бұрын

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

  • @Winterdev

    @Winterdev

    2 жыл бұрын

    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
    @fabiankracher36953 жыл бұрын

    dive!!!!!

  • @pyrytheburger3869
    @pyrytheburger38692 жыл бұрын

    yeah imma just stick to using a physics library

  • @s3vster
    @s3vster2 жыл бұрын

    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

    2 жыл бұрын

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

  • @paraxodondev
    @paraxodondev9 ай бұрын

    i love you

  • @yizhang7027
    @yizhang70273 жыл бұрын

    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

    3 жыл бұрын

    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 :)

  • @torque8047
    @torque80472 жыл бұрын

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

  • @elibildman422
    @elibildman4223 жыл бұрын

    meaty voice :weary:

  • @Winterdev

    @Winterdev

    3 жыл бұрын

    (;´༎ຶД༎ຶ`)

  • @embereve-chan
    @embereve-chan3 жыл бұрын

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

  • @samhsmith6998
    @samhsmith69983 жыл бұрын

    you OOPed that code too much.

  • @Winterdev

    @Winterdev

    3 жыл бұрын

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

  • @christopherpetrov2355
    @christopherpetrov2355 Жыл бұрын

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

  • @Winterdev

    @Winterdev

    Жыл бұрын

    nay you should try it ;)

  • @quentinquadrat9389
    @quentinquadrat93892 жыл бұрын

    The link of your blog is dead

  • @Winterdev

    @Winterdev

    2 жыл бұрын

    Thanks for point that out, it’s back up!

  • @quentinquadrat9389

    @quentinquadrat9389

    2 жыл бұрын

    @@Winterdev Ok I confirm it's working back :)

  • @empireempire3545
    @empireempire35453 жыл бұрын

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

  • @Winterdev

    @Winterdev

    3 жыл бұрын

    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

  • @RoidoStuff
    @RoidoStuff3 жыл бұрын

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

  • @Winterdev

    @Winterdev

    3 жыл бұрын

    :(

  • @RoidoStuff

    @RoidoStuff

    3 жыл бұрын

    @@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

    3 жыл бұрын

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

  • @RoidoStuff

    @RoidoStuff

    3 жыл бұрын

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

  • @bity-bite
    @bity-bite3 жыл бұрын

    Too much stuff to understand for my small brain.

  • @DasAntiNaziBroetchen
    @DasAntiNaziBroetchen3 жыл бұрын

    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

    2 жыл бұрын

    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.

  • @qxb348
    @qxb3482 жыл бұрын

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

  • @Winterdev

    @Winterdev

    2 жыл бұрын

    spotted

  • @thinkandmove479
    @thinkandmove47925 күн бұрын

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

  • @pajeetsingh
    @pajeetsingh3 жыл бұрын

    I hate Minkowski

Келесі