Writing a Physics Engine from scratch - collision detection optimization

Поділитися
Вставка
  • Опубліковано 23 гру 2024

КОМЕНТАРІ •

  • @MrSprinkles
    @MrSprinkles Рік тому +669

    Your original verlet integration video is what got me more interested in C++ & physics simulation, so excited to see this new one come out!

    • @PezzzasWork
      @PezzzasWork  Рік тому +54

      I hope you will like it :)

    • @firexgodx980
      @firexgodx980 Рік тому +9

      I would try out rust if I were you. It's like C++, but has a first party build system and package manager. It's also memory safe without a garbage collector!

    • @tyrendel
      @tyrendel Рік тому +1

      @@firexgodx980 +1 and SFML is being (ported to Rust) -> wrapped in rust 🙂

    • @firexgodx980
      @firexgodx980 Рік тому

      @@tyrendel awesome, where can I follow the progress?

    • @gunchimssakdone
      @gunchimssakdone Рік тому

      how about mojo? grammar and library of python and speed of C++

  • @dakeyras4146
    @dakeyras4146 Рік тому +264

    Thanks for the new video! I've not done much related to programming, but collision optimization has been an interest of mine for quite a while. It's great to see such an easy explanation into spacial partitioning.

  • @Rodzorex
    @Rodzorex Рік тому +101

    Great work as always. You're one of the few channels that actually excites me when a new upload appears in my feed.

  • @bookshop7337
    @bookshop7337 Рік тому +87

    Back when I was growing up, Black and White 2 by Lionsgate was my jam. In the screen before the main menu, a bunch of particles streamed into a box and made the Lionsgate logo.... but you could also mess around with them using your mouse and screw the whole thing up. But if you didn't, it always ended up perfectly. I used to wonder how on earth they managed to implement a physics engine that kept producing the same result over and over, and now almost a decade later you've answered that lingering question. Keep up the amazing work!

    • @Gregzenegair
      @Gregzenegair Рік тому +3

      Do not use floats and only integers, and you'll be fine.

    • @chrisrichfield8906
      @chrisrichfield8906 Рік тому +9

      Lionhead. Lionsgate is the film production company.

    • @official-obama
      @official-obama 8 місяців тому +3

      @@Gregzenegairintegers also have rounding errors, floats are also deterministic, floats also do not spontaneously change

    • @JTtheking134
      @JTtheking134 6 місяців тому +1

      @@official-obama are float rounding errors deterministic? if so then it's fine, because the simulation will end up the same both times, even if the math may be wrong behind the scenes

    • @official-obama
      @official-obama 6 місяців тому

      @@JTtheking134 yeah probably, randomizing the rounding would probably be useless
      but it might be different on different systems

  • @steviousmusic
    @steviousmusic Рік тому +1093

    I'll never regret subscribing.
    Edit: POG almost 1K likes

  • @S-K.
    @S-K. Рік тому +33

    I love seeing the grains appear in the crystal lattices that appear. I'd love to see this applied with more physics rules to simulate microstructures to create visual aids for understanding alloys, solid state chemistry, etc.

    • @zagmongor
      @zagmongor 10 місяців тому +2

      Totally agree, I flipped when I saw the grain boundaries forming with minimal physics incorporated

  • @GabeRundlett
    @GabeRundlett Рік тому +97

    Amazing video as always!! I love how you show a simple version of the code as a demonstration tool. Very similar to Sebastian Lague, I really hope I could get this good at video making at some point.

  • @thefunbunns
    @thefunbunns Рік тому +3

    You always outdo youself on the outro, love your work and knowledge! Thanks for sharing it with all of us!

  • @erinkarp
    @erinkarp Рік тому +1778

    The fact that multi-threading made it not deterministic was really interesting

    • @TheRainHarvester
      @TheRainHarvester Рік тому +319

      Only because threads can vary in their timing of when they run because they can be used by the OS. But if you write the code correctly, it will be deterministic because the objects won't vary according to which got updated first.

    • @ateslabattery115
      @ateslabattery115 Рік тому +93

      @@TheRainHarvester but from the outside, you never know which will be used until you check... sounds familiar

    • @rorymax
      @rorymax Рік тому +33

      Technically still deterministic though :p

    • @pascha4527
      @pascha4527 Рік тому +68

      @@rorymax yeah but an entire os could be considered chaotic. Some process depend of the internet. The system is so complex it will never be deterministic unless unplugged from the internet and the code is running without an OS. Still an interesting topic tho, I want to dig deeper.

    • @rorymax
      @rorymax Рік тому +61

      @@pascha4527 oh it’ll still be deterministic, there would just be so many variables that you’d never be able to replicate or even know all the starting conditions. But if you had all those variables, and enough time and computation power, you’d be able to determine the outcome

  • @eboatwright_
    @eboatwright_ Рік тому +10

    Wow. Your videos are so technically impressive! Great job

  • @maticz3923
    @maticz3923 Рік тому +6

    I've been having problems trying to multithread my sim, that idea to use 2 passes is genius! Thank you so much

  • @glumpfi
    @glumpfi Рік тому +51

    This is so satisfying :)
    It would be interestig to see how the chicken picture changed if you re-run the simulation with the exact same settings, except slightly changing the settings of one single object. Like i depiction of the butterfly effect. The more complex the interaction is, the more warping of the chicken should be visible.

    • @leonhardolaye-felix8811
      @leonhardolaye-felix8811 Рік тому +4

      That would’ve been awesome

    • @Pauly421
      @Pauly421 Рік тому +6

      @@leonhardolaye-felix8811 Thank you for using the apostrophe correctly :D

  • @NaviaryMusic
    @NaviaryMusic Рік тому +16

    Watching the objects construct the image is so satisfying!! I'm sure if you made videos dedicated to showcasing more images being filled, and even made shorts, they would be very successful!

  • @spowrei
    @spowrei 11 місяців тому +2

    your videos are really inspiring. whenever i watch your videos i find myself while codding

  • @nightwolf6233
    @nightwolf6233 Рік тому +8

    I absolutely love how well you demonstrated the issues of multithreading in a very visual manner by showing how multiple threads could not produce the same deterministic result if overlaps between threads are not properly handled. I really feel like I learned some valuable things from this video. Thanks, it was awesome!

  • @JackAllpikeMusic
    @JackAllpikeMusic Рік тому +1

    I'd absolutely love to see more of this. This is fantastic.

  • @RayznGames
    @RayznGames Рік тому +16

    Such a joyful video dude. (I scrambled myself around 2 months ago to optimise an application with thousands of collidable objects , couldn't get the multithreading tho) Awesome job!

  • @nandakoryaaa
    @nandakoryaaa Рік тому +4

    This is mind blowing. I always thought fluid/particle simulation is something very complicated, but here it is effortless. Thanks for the sources! I'll try to make my own engine using platform-independent compiler and graphic library.

  • @mogyoros
    @mogyoros Рік тому +5

    I know the acronym STEAM is a bit of a reach (STEM + Arts), but this work is truly at the intersection of science and art. Well done - and beautifully explained!

  • @Tinkerer_Red
    @Tinkerer_Red 3 місяці тому

    So I've been pretty addicted to your work, such great visuals, always helpful information, typically open source code, each concept well segmented. It's been a real treat watching you. I've been curious to see your implementation on a few things, but recently the concept of falling sand engines like MARF's here on youtube, which supply much more realistic physics then a simple 'fall, fall left, fall right' simulation. I'd be really fascinated to see your approach, and the evolution of the process when it comes to levels of optimization.

  • @rim7961
    @rim7961 Рік тому +196

    man, this is depressing and impressive at the same time. I've spent a whole year in last year of my BSc making a 2d physics engine and its still was wonky af to a point that its an embarrassment to show anyone, and here you whoop it up in like 2 months that is effectively a perfection

    • @abrahamdomingo8239
      @abrahamdomingo8239 Рік тому +59

      tbf, it's not like he made the physics engine from scratch, he just found a great way to calculate collisions in a very efficient way

    • @kartonrad
      @kartonrad Рік тому +36

      You also have to concede that thr yter only uses 2d circles, whose collisions are veryy easy to check and require much less work!
      Dont beat yourself up about it

    • @maxfofax5471
      @maxfofax5471 Рік тому +20

      You're going to learn a lot by trying, failing, then either figuring it out or seeing how someone else did it. The older you get, you don't stop failing when you try something new or difficult, you just know how much time to give yourself to figure it out. I get why it's depressing and impressive, but I hope that you're still excited to solve these interesting problems just so you can feel your own brain grow, you'll get there before you realize!

    • @Creaform003
      @Creaform003 Рік тому +34

      Each improvement increases the probability of the next improvement.
      You didn't spend a year making a 2d physics engine.
      You spent a year improving the quality of all future physics engines you will go on to build.

    • @stevea.b.9282
      @stevea.b.9282 Рік тому +5

      also he can only do this in two minutes because he spent years working on improving his skills and understanding. Keep going and you'll be amazed at how much progress you make.

  • @weeblewonder
    @weeblewonder Рік тому

    The visualisations in this video are amazing. They communicate the problem space so effectively. Nice work!

  • @sollybunn
    @sollybunn Рік тому +4

    This led me on my own rabbit hole for vertlet physics, and each step you did took me hours to do. Your videos are amazing!

  • @julienpeter5263
    @julienpeter5263 3 місяці тому

    incroyable.
    Ca fait une 1h30 que je suis scotché à vos vidéo.
    Elle est tellement qualitative.
    Bravo pour votre travail vraiment, et merci pour le voyage :)

  • @basmeuwissen8644
    @basmeuwissen8644 Рік тому +8

    I would be really interested to see the addition of other shapes to the simulation. Adding polygons or even non convex shapes would be a lot more challenging but very interesting.

  • @acreatorqads
    @acreatorqads Рік тому

    I LOVE YOUR VIDEOS!!! Your code is so elegant in so many ways, and your videography is perfect, plus your voice, just everything man, seriously awesome!

  • @puppergump4117
    @puppergump4117 Рік тому +12

    The chicken is now a symbol of success

  • @soorenapars
    @soorenapars Місяць тому

    you nailed it, really like your content , hope to see your channel's fast growth SOON , thanks

  • @khatharrmalkavian3306
    @khatharrmalkavian3306 Рік тому +7

    Here's an interesting problem I ran into some months ago. I'd like to propose it to you and see if you come up with something cool, if you're interested.
    Imagine a 2D plane populated by entities with circular colliders, not dissimilar to what you're doing here. There is also an attractor entity which moves around arbitrarily. Each simulation step, the entities find the direction of the attractor as a normalized vector and store it as an intended direction of motion. They then check for collision with one another, and when overlaps are found, they add the response vector to their stored vector, so that they end up with a sum of all their desired motion vectors. This vector is then normalized and multiplied by the desired speed of the entity, so that they will move toward the attractor while repelling one another if they get too close.
    So far so good. The issue arose when I started using SIMD to accelerate the simulation and allow for more active entities. The SIMD radically improved the rate at which they can all find the direction toward the attractor, but for collision I ran into the problem that the data for the SIMD was not sorted into regions in order to accomplish the grid optimization like you did here. It's possible to sort them by their x positions, but it seemed like rearranging them this way for every update would take up more time than the SIMD calculation would save.
    Unfortunately, I set that project down because of some life issues and now I don't know if I still have it around, but I'd be interested to hear if you have any ideas about to deal with this kind of problem.
    Thank you for the great videos!

    • @andreyrumming6842
      @andreyrumming6842 Рік тому

      A fascinatingly complex issue. So effectively the whole problem is unsorted data every frame?

    • @khatharrmalkavian3306
      @khatharrmalkavian3306 Рік тому

      @@andreyrumming6842 Mainly, yes. The SIMD registers hold four 32-bit values, so I would select an entity to test and load it into a register twice (x,y,x,y) and then have a pointer to the other entities that would be used to load the other registers, then increment by 4 and continue loading, etc. By interleaving the loads and the math it was possible to get good performance from this, because one register could be working while the next is loading, and each register is doing the math for two entities at a time. This required the position vectors to be serialized, so each entity had an index into an array of x,y pairs. This meant that sorting the pairs would also require updating the indices in the owning entities, which was another layer of complexity.
      I'm certain that big game companies with fancy physics engines have some way that they're able to cheaply sort entities so they don't have to do On^2 collision tests every frame. I just don't know what that method is. Alternatively, they may all just be doing this kind of thing in CUDA or something.

  • @sierpinskibrot
    @sierpinskibrot Рік тому +1

    This is one of your best videos so far man I can tell you spent a lot of time on this and it payed off well

  • @devindykstra
    @devindykstra Рік тому +22

    This is an awesome video!
    It seems to me if you wanted to simulate objects with an arbitrary radius you would need each cell to be the size of the largest object. I'm not sure if there's a better way to do it, but maybe that's a good idea for a follow up video?

    • @user-sl6gn1ss8p
      @user-sl6gn1ss8p Рік тому +22

      you could make the object register into multiple cells and also read a larger neighborhood.
      That being said, as far as I know there are other space partitioning techniques which don't use a fixed grid and are more adaptable

    • @MrDelusive
      @MrDelusive Рік тому +5

      Quad Tree for 2D and OctTree for 3D is pretty much that

  • @TheBarretNL
    @TheBarretNL Рік тому

    I keep coming back to these video's because they are such good learning subjects, thanks for making them Pezza! you are an absolute legend.

  • @eamonburns9597
    @eamonburns9597 Рік тому +9

    That has got to be the coolest "thanks for watching" screen I have ever seen

  • @Bari_Khan_CEng_CMarEng
    @Bari_Khan_CEng_CMarEng Рік тому

    I love this, the start of a computer game engine!
    The background music is great, adds audible depth to learning about the computing techniques

  • @CelestialityRW
    @CelestialityRW Рік тому +9

    i would pay money for a thing that lets you generate an image with thousands of circles, honestly the coolest coding thing i've seen in a while!

  • @SuperWabo
    @SuperWabo 4 місяці тому

    This is beautiful. I am so happy I found this. Elegant. Exact. Optimised. Well explained. Shared source. 10/10. Thank you. ❤

  • @eigentensor
    @eigentensor Рік тому +21

    Great video, it was already clear from your previous ones but you underscored it well here :)
    Also I think you should switch the order of y and x loops at 5:00 for better memory access in canonical order

    • @comeinhendy8931
      @comeinhendy8931 Рік тому

      I don't know how 2d Arrays are implemented in the language he's working with, but it makes sense. It should help with the cache.

    • @PezzzasWork
      @PezzzasWork  Рік тому +7

      I am not using 2D arrays (which are indeed row major). I use column major because it allows for better load balancing between threads since in the simulations of the video objects are horizontally spread

  • @jaafartheking153
    @jaafartheking153 Рік тому

    Your channel is too good to be real. That was fascinating. Keep the clean work.

  • @rentierriche2873
    @rentierriche2873 Рік тому +3

    La meilleure chaîne qui me vend du rêve, encore un super programme comme d'habitude 🙂

  • @IamUAV
    @IamUAV Рік тому

    This is so fascinating. I'm going to school so that I can work on stuff like this and it makes me so excited when I see videos like this. Thanks for all the insight.

  • @lisyarus
    @lisyarus Рік тому +4

    A great tutorial! I usually just do a dt step followed by N collision steps, gotta try your substepping method sometime :)
    I've once made a similar tutorial, without threading but with friction, damped springs, and ball-stick collisions.

    • @PezzzasWork
      @PezzzasWork  Рік тому +10

      The big advantages with sub steps is that, since objects travel smaller distances in one physics frame, errors are a lot easier to handle for the solver and it also greatly mitigate the tunneling effect, leading to way more stable simulations

    • @funnyduck4568
      @funnyduck4568 Рік тому

      @@PezzzasWork what is the tunneling effect?

  • @xingzhexin8843
    @xingzhexin8843 Рік тому

    It's been a long time since the last time I paused a video and go down to intentionally click sub+like before I finish a video because I don't want to forget about it. More content this quality sir and you're on top of UA-cam.

  • @skippytheelder
    @skippytheelder Рік тому +13

    Are you interested in chemestry? Because I would love to see your interpretation of an atomic-level physics simulator.

    • @tetryds
      @tetryds Рік тому +3

      This is pretty cool but it is just a standard collision simulation

    • @debuggers_process
      @debuggers_process Рік тому +3

      @@tetryds I've done some chemistry simulation in Lennard-Jones potential, it's pretty fun to play with, trying out different combinations of interaction parameters. I have several videos on this topic on my channel.

    • @Kycilak
      @Kycilak Рік тому +1

      @@tetryds Molecular simulations are not exactly difficult though. There is much to do in implementation but the principles are not much more difficult than this.

    • @pietrotettamanti3183
      @pietrotettamanti3183 3 місяці тому

      The problem with chemistry is, reactions cannot be described classically by collisions in an "ab initio" way.
      You'll end up with random results unless you introduce some "unphysical" parameters, like the parameters of a given interaction potential between atoms. But these parameters can only be determined by fitting onto experimental data. So we're back to square one basically.
      The only way to accurately reproduce chemical reactions through physics simulations is quantum mechanical algorithms, which are much more computationally expensive, and can handle *at most* tens of atoms for a good computer before they start to really stutter. And they aren't real time simulations either, they have to be computed over the course of days or weeks.
      What can be done somewhat successfully is describing diffusion dynamics, or maybe crystallization, using this kind of physics engine. But not chemical reactions sadly.

    • @julienpeter5263
      @julienpeter5263 3 місяці тому

      ​ @pietrotettamanti3183
      Your comment may be the most underrated one i've ever read.
      i give you a cookie, because no one did.
      WORLD! GIVE THIS MAN A COOKIE JAR, NOW....
      But ... quantum application might give you no cookie, or maybe a plenty jar... Who know...

  • @tiotio3666
    @tiotio3666 Рік тому +2

    Checking for a collision between grid cells can be done only for half of the neighbouring cells. For example you can only check left, top-left, top and top-right neighbours. All other collisions for examle between current cell and right neighbour, will be checked once that neighbour becomes current cell

    • @PezzzasWork
      @PezzzasWork  Рік тому +1

      Yes absolutely, I still do the full check since it is like doing 2 solver iterations but faster that really doing 2 iterations and it help a lot with stability

  • @lennarth.6214
    @lennarth.6214 Рік тому +4

    Very nice! Have you tried k-d-trees yet? If you have, what performance gains were there

    • @GrumpDog
      @GrumpDog Рік тому +2

      I'm curious about that too.. For something like this, I'm not sure how much further benefit could be obtained by using k-d trees. Tho I'm by no means an expert on them, in this case I wouldn't think the empty space would cost much different, and the objects are all the same size, so not much dynamic adjustment is needed in that regard.
      The one time I tried implementing them, it cost more in performance to manage the kd-tree, than it took to just run everything in a fixed-grid like this video used. Tho again, I probably wasn't using them as expertly as other people might.. heh

    • @PezzzasWork
      @PezzzasWork  Рік тому +4

      Never tried them but I tend to think that very simple / straightforward and cache efficient structures generally win, specially if the world size isn’t huge

    • @user-dh8oi2mk4f
      @user-dh8oi2mk4f Рік тому

      @@GrumpDog What algorithm did you use for adjustments/refitting?

    • @GrumpDog
      @GrumpDog Рік тому

      @@user-dh8oi2mk4f I don't remember, it was years ago and I was barely comprehending tutorials on it at the time, as it was.
      I just remember the feeling like it was the programming equivalent of chasing after a perpetual motion machine, or teetering on the edge of "The Tyranny of the Rocket Equation".. lol

  • @professionalnerd1095
    @professionalnerd1095 Рік тому

    Your physics simulation videos are absolutely mesmerizing... and so educational! I've been following along implementing my own physics engine!

  • @Krazylegz42
    @Krazylegz42 Рік тому +5

    Awesome as always! I'm curious if the grid-iterating approach causes any kind of bias in the physics? Like if updating the collisions left-to-right in the grid adds any kind of preference for stuff moving to the right?

    • @official-obama
      @official-obama 8 місяців тому

      every collision moves the objects in opposite directions, so the center of mass doesn't change

  • @daonlyowner6631
    @daonlyowner6631 Рік тому

    The ideas are so easy, but I never would have even thought about them. So good!

  • @manjitsingh-jj5wi
    @manjitsingh-jj5wi Рік тому +3

    Dude I am a high schooler and i wanted to make a thread pool for multithreaded collision detection and i even thought there would be issue with 2 threads writing to the same Ram adress and i would have fixed it in the same way.i am feeling proud that I thought of all the same optimisation as you.i first thought of a qaud tree but couldn't find a way to multithread it

  • @dragonfire4356
    @dragonfire4356 Рік тому

    your videos always make my day. and every time they blow my mind

  • @brickisao2999
    @brickisao2999 Рік тому +22

    Now write a physics system ON scratch

  • @mimisaiko
    @mimisaiko Рік тому

    I like how your "Thanks for watching" being always pretty long, it feels like really sincere.

  • @SLPCaires
    @SLPCaires Рік тому +3

    woooo!

  • @PanicAtTehCisco
    @PanicAtTehCisco Рік тому +1

    I liked seeing the grain boundaries between the particle "crystals"

  • @dandymcgee
    @dandymcgee Рік тому +1

    Loved the multi-threading aspect. Fun stuff!

  • @shallowdive
    @shallowdive Рік тому

    That's awesome! The overall structure looks like a polycrystal and those imperfections - like dislocations. The hexagonal planar structures look exactly like graphene.

  • @abigweed1811
    @abigweed1811 Рік тому

    Insanely enjoyable and well made video!
    This is all stuff I've seen in Game Dev school, ah the nostalgia

  • @A..T..M..
    @A..T..M.. Рік тому +2

    7:22 Curious fact, the formation that the particles had at that time is the same as that of a glass-type material (if we assume that each particle is an atom of course), that is, hundreds of tiny crystals (periodic formation of atoms or molecules) arranged in different directions, that is exactly why they are seen as "cracks" in said simulation
    10:11 That would already be a more precise vision of what happens in reality, with each crystal having thousands or even millions of atoms arranged in a certain way.
    by the way PezzzasWork , You could do this same type of simulation but in 3D, and by the way, make it voxel type ?to avoid potential performance issues when using polygons

    • @TheRainHarvester
      @TheRainHarvester Рік тому +1

      You May like the crystalline forms that emerged on on my PPS videos. Even beating hearts!

  • @pietrotettamanti3183
    @pietrotettamanti3183 3 місяці тому

    7:24 is so cool, for unrelated reasons haha. It's a perfect visual explaination of why crystallites and grain boundaries form in crystalline materials with fast crystal growth. The actual mechanism is actually a bit different but the deeper concept holds very well.

  • @EpicVideoGamer7771
    @EpicVideoGamer7771 Рік тому +1

    This is so cool! You are such an inspiration to me, as someone who is learning raylib for C++

  • @n4rzul
    @n4rzul Рік тому

    Wow. That was amazing. Best video about coding I've ever seen! Subbed on the spot!

  • @lievenpetersen
    @lievenpetersen Рік тому

    I've recently been struggling with this exact problem, this has given me some new ideas, thanks!

  • @thelastdankbender4353
    @thelastdankbender4353 Рік тому

    I like how your video quality is increasing with every video. Awesome stuff

  • @Zytron
    @Zytron Рік тому +1

    That outro was S-Tier, loved it.

  • @JoshuaHoltz
    @JoshuaHoltz Рік тому

    The worst part of yoir channel is that it's so high quality that we don't get frequent videos. Keep it up! Love the content.

  • @Loerad
    @Loerad Рік тому

    Watching you write code is so satisfying.

  • @sudo4582
    @sudo4582 Рік тому

    I thought you'd use OpenMP to manage threads, but you actually programmed the communication, thanks for sharing such amazing piece of work!

  • @PrimeGym01
    @PrimeGym01 Рік тому

    C'est tellement impréssionant! Continue avec les vidéos incroyable mon gars.

  • @djentinga3267
    @djentinga3267 Рік тому

    Extremely satisfying, awesome work!

  • @stevea.b.9282
    @stevea.b.9282 Рік тому

    that's a very cool effect, and thanks for explaining so clearly.

  • @Arkensor
    @Arkensor Рік тому

    Very well made video. Love the animations during the explaination at the beginning

  • @DanWills
    @DanWills Рік тому

    Wow! So cool! I have loved the idea of known-future-simulation-states for 'formation' effects (I work in vfx) and this really did that in a superb way, top work Pezzza!

  • @craftminerCZ
    @craftminerCZ Рік тому

    If you pause at 5:12 and look at the code closely, this algorithm doesn't find collision between the objects of the border cells.
    This is because we're iterating only over the inner part of the grid without the borders - which is responsible for what is stored in "current_cell". So even if neighbour iteration includes "current_cell", effectively ensuring each inner cell of the grid is checked for collisions with itself, the same cannot be said about "other_cell".
    In no situation do you ever call check_cells_collisions(other_cell, other_cell) because the cell collisions are only ever checked in the context of "current_cell"

    • @PezzzasWork
      @PezzzasWork  Рік тому

      Yes, this is on purpose. I placed constraints to ensure that no object are going to these border cells meaning that no checks are required

  • @mitchstilborn
    @mitchstilborn Рік тому

    Dude that outtro image was just pure swag. Well played

  • @YoghurtKiss
    @YoghurtKiss Рік тому

    Wow, this is a super nice physics engine, and it's so simple that even I understand the code.

  • @CartoType
    @CartoType Рік тому

    This made me smile. Watched some boring stuff tonight and then found something creative and amusing. Bonus points for using a code indent scheme that lines up brackets, unlike the insane lopsided system that has been popular for most of this century.

  • @simaocharpentier2046
    @simaocharpentier2046 Рік тому

    Incredible work! I'm not into programming, yet you managed to make it really interesting, even for me. Worth a lil' subscription imo.
    Also, your accent sounds like you're french.
    Edit: just checked and yep you are

  • @ChipboardDev
    @ChipboardDev Рік тому

    bro your content is insane and very inspiring, keep it up

  • @gustavoadolfomelindres
    @gustavoadolfomelindres Рік тому

    If this isn't quality content, I don't what is.
    Thanks for another perfect video.

  • @baltakatei
    @baltakatei Рік тому

    The partitioning of the grid into thread groups (“causal domains”) effectively creates a “speed of causality” for your cosmos which is like the speed of light for our cosmos.

  • @dazcarrr
    @dazcarrr Рік тому +2

    i know exactly why and how it happens, but it still feels like magic when the circles line up like that

  • @dragonminz602
    @dragonminz602 Рік тому

    Realy intresting video! Thanks for showing the code and your progress

  • @Dominik-K
    @Dominik-K Рік тому +1

    Very interesting video, I've actually been thinking about implementing my own basic physics checker for a really tiny multiplayer game to increase the efficiency and lower the server requirements (though I'm using C#11, but the algorithmical / threading issues apply all the same) thanks a bunch for this very interesting video

  • @freevbucks8019
    @freevbucks8019 Рік тому

    4:12 - Also, to support multiple sizes, you can resize the grid to accomodate the biggest object

  • @xXstealseekerXx
    @xXstealseekerXx Рік тому

    This has to be one of the best outros for a video i have seen

  • @realbrickbread
    @realbrickbread Рік тому

    This is so cool! The last simulation really resembled saturn with its rings :)

  • @busy_beaver
    @busy_beaver Рік тому

    Fantastic! Really beautiful simulation!
    I have also invented the same technique by myself (I know that I'm not the first who though about it but at least I figured it out by myself), but never got to realize it. Glad to see how well it actually works! Probably it will run a couple dozen times faster if you run it with CUDA.

  • @Gwilo
    @Gwilo Рік тому +1

    your videos are so under-appreciated!
    try taking snippets of the videos and either uploading them to UA-cam Shorts, or upload a summary to Reddit. maybe even make a 2-minute summary and put it on UA-cam Shorts too! so many views to be had there

    • @PezzzasWork
      @PezzzasWork  Рік тому +1

      That’s a great suggestion, I will try to make shorter versions of my videos :)

  • @ciCCapROSTi
    @ciCCapROSTi Рік тому

    This video gave me the push the ditch a physics engine for my project and write my own. They are way too smart for my needs, and a simpler one like this (with some additions that fit my needs, like grouping objects or base displacement on weight) will provide a much better base for the logic.

  • @Skeffles
    @Skeffles Рік тому

    Fantastic video and great explanation behind everything!

  • @xetlas5938
    @xetlas5938 Рік тому

    7:45 the fact that you have a French accent but said "et voilà " like a english person would, bro you got me

  • @communism8037
    @communism8037 Рік тому +1

    Помню как в тетради себе разрабатывал решение для оптимизированной физики. Точно также меня не устраивало проверять коллизию между каждой парой обьектов и я рисовал себе сетки. Жаль, что я в программировании делетантом был :)
    А на шейдерах в Unity делал симуляцию частиц, которая несмотря на многопоточность, была детерминированной, засчет расчета физики в 2 шага. Как в шахматах считалась физика сначала у белых клеток, затем у черных. И забагованной симуляция тоже была, но всё равно крутой.
    И радость и тоска от этого видео, что подобные вещи рассказываю не я, а автор видео. Когда-нибудь обязательно дорасту до такого уровня, я работаю над этим.

  • @LukeAps
    @LukeAps Рік тому

    Yes. Spatial partitioning and multithreading, the keys to good performance.

  • @carlomaggiolo2180
    @carlomaggiolo2180 Рік тому

    10:49
    Small particular: you missed a column. You divided in 5 and 3.
    But the message not change, is incredible

  • @neoqueto
    @neoqueto Рік тому

    The world needs more 2D physics tools. In gamedev, in motion graphics... Great work and very informative

  • @gustavosalmeron2013
    @gustavosalmeron2013 Рік тому

    That was art. Congratulations, gentleman.

  • @harshans7712
    @harshans7712 Рік тому

    This was really awesome, I really loved the video and was really interesting and Informative, thank you!

  • @chubbybunny6272
    @chubbybunny6272 Рік тому

    Kind of unrelated but I like how your simulation also can show lattice structures and lattice imperfections. Pretty cool.

  • @ItsIdaho
    @ItsIdaho Рік тому

    That sunglass chicken image is so simple yet it blows my mind. Love this

  • @justaboringperson
    @justaboringperson Рік тому +1

    very cool i wish i could do cool things like you