Designing a Physics Engine in 5 minutes

Поделиться
HTML-код
  • Опубликовано: 4 ноя 2024

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

  • @ciberman
    @ciberman 3 года назад +451

    "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 года назад +4

      i exist too!

    • @mathusuthanvenkatesan
      @mathusuthanvenkatesan 3 года назад +5

      and hence your statement is wrong

    • @caboose2718-i6c
      @caboose2718-i6c 3 года назад +12

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

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

      instablaster.

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

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

  • @_general_error
    @_general_error 3 года назад +90

    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 3 года назад +118

    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 3 года назад +53

    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 3 года назад +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 3 года назад +18

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

  • @FlareGunDebate
    @FlareGunDebate 4 года назад +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  4 года назад +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 4 года назад

      @@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
    @alexismandelias 2 года назад +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

  • @Fiolsthu95
    @Fiolsthu95 4 года назад +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  4 года назад +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

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

    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  3 года назад +1

      Glad I could help :)

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

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

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

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

  • @dingalong14
    @dingalong14 3 года назад +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  3 года назад +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 4 года назад +4

    Great video. Keep uploading this juicy stuff. Subbed.

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

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

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

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

  • @amop2250
    @amop2250 3 года назад +11

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

  • @Dominik-K
    @Dominik-K 2 года назад +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  2 года назад +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

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

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

  • @finnbuhse4775
    @finnbuhse4775 3 года назад +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  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

  • @CaioAletroca
    @CaioAletroca 3 года назад +5

    That's was really good man!!

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

    Bro this video was great, keep it up!

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

    Only 2.5k subs? Criminally underrated channel

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

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

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

    Dude amazing subbed with notifications!

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

    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
    @rmt3589 Год назад +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?

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

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

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

      Thanks! It looks like its chosen me for today lol

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

    Excellent video! Thanks for sharing

  • @ne0ck237
    @ne0ck237 3 года назад +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  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 года назад +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)

  • @dandymcgee
    @dandymcgee 3 года назад +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.

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

      I'd check out the EPA one :p

  • @ubuntujackson9133
    @ubuntujackson9133 Год назад +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  Год назад +1

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

    • @ubuntujackson9133
      @ubuntujackson9133 Год назад +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

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

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

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

    great vid

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

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

    • @Winterdev
      @Winterdev  3 года назад +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!

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

    This channel is a godsend. Thank you.

  • @FromLake
    @FromLake 7 месяцев назад

    Wow. Thank you very much for this video!❤

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

    Great video! loved it

  • @dodo-js5gw
    @dodo-js5gw 3 года назад +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  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 😂

  • @ItsaDigitalHamster
    @ItsaDigitalHamster 3 года назад +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  3 года назад +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 3 года назад

      @@Winterdev Thanks I’ll try it.

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

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

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

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

  • @puddleglum5610
    @puddleglum5610 2 года назад +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 2 года назад +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  2 года назад +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

  • @DontfallasleeZZZZ
    @DontfallasleeZZZZ 2 года назад +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  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.

  • @mmmbackwheelbates
    @mmmbackwheelbates 3 года назад +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  3 года назад

      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

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

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

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

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

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

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

    • @Winterdev
      @Winterdev  2 года назад +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 3 года назад +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  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 года назад +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!

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

    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

  • @dynamagon
    @dynamagon 2 месяца назад +1

    Uh, that's not a solar system, it's a bunch of balls floating in space. A solar system is a collection of masses orbiting a star. ._.

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

      maybe the star is behind the camera :p

  • @kallehed6330
    @kallehed6330 Год назад +1

    Don't forget quadtrees!

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

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

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

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

  • @P-G-77
    @P-G-77 Год назад

    Very interesting... thanks

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

    Cool. What programming language are u using?

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

      Thanks! And I used C++ for this

  • @Umblizm
    @Umblizm 2 года назад +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  2 года назад +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 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

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

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

  • @Mostafa-cv8jc
    @Mostafa-cv8jc 3 года назад +1

    thank you very much for this vide!

  • @GenericInternetter
    @GenericInternetter Год назад +1

    The Cherno sent me here.

  • @micmaci9343
    @micmaci9343 4 месяца назад

    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?

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

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

    • @Winterdev
      @Winterdev  3 года назад +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

  • @Necronlord2011
    @Necronlord2011 4 года назад +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  4 года назад

      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 Год назад

    ...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  Год назад

      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

  • @simeonbeckford-tongs9391
    @simeonbeckford-tongs9391 Год назад

    Thank you

  • @delofon
    @delofon 3 года назад +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  3 года назад

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

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

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

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

    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 года назад +1

      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 года назад +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  3 года назад +1

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

    • @thebutterappletutorials6553
      @thebutterappletutorials6553 3 года назад +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  3 года назад +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.

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

    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

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

    Please dive deeper into the maths behind the implementations.

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

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

  • @nolram
    @nolram 3 года назад +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  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.

  • @itsME-dc4vm
    @itsME-dc4vm 3 года назад +2

    Nice ;D

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

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

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

      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

  • @sergodobro2569
    @sergodobro2569 4 месяца назад

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

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

      you need board phase with some spatial hashing

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

    What about next video?

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

      Funny enough, it's going up tomorrow :)

  • @yizhang7027
    @yizhang7027 3 года назад +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  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 :)

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

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

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

      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

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

    yeah imma just stick to using a physics library

  • @bianchialex
    @bianchialex 3 года назад +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  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 года назад +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  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 года назад +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  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.

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

    what program is this?

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

      many lines of C++ called wEngine

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

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

    Hi, can we use GJK collision detection

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

      Yes I did a video on it :)

  • @s3vster
    @s3vster 3 года назад +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  3 года назад

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

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

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

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

    Can you provide the source code for this?

    • @Winterdev
      @Winterdev  3 года назад +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

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

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

  • @Johnny-tw5pr
    @Johnny-tw5pr 2 года назад +1

    Where is the source?

    • @Winterdev
      @Winterdev  2 года назад +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.

  • @elibildman422
    @elibildman422 4 года назад +7

    meaty voice :weary:

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

      (;´༎ຶД༎ຶ`)

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

    you OOPed that code too much.

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

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

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

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

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

    dive!!!!!

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

    i love you

  • @bity-bite
    @bity-bite 3 года назад +1

    Too much stuff to understand for my small brain.

  • @DasAntiNaziBroetchen
    @DasAntiNaziBroetchen 3 года назад +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  3 года назад

      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.

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

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

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

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

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

    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

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

    The link of your blog is dead

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

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

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

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

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

    I hate Minkowski