Making My Physics Engine 10x Faster and Simulating Trusses

แชร์
ฝัง
  • เผยแพร่เมื่อ 25 มิ.ย. 2024
  • Head to squarespace.com/angethegreat to save 10% off your first purchase of a website or domain using code angethegreat
    In this video, I optimize the physics engine that powers Engine Simulator and discuss some iterative techniques for solving systems of linear equations.
    Conjugate gradient method: en.wikipedia.org/wiki/Conjuga...
    Gauss-Seidel method: en.wikipedia.org/wiki/Gauss%E...
    The paper about vectorizing the Gauss-Seidel method shown in the video: www.ncbi.nlm.nih.gov/pmc/arti...
    Support Engine Simulator 3D on Patreon!
    / atg_engine_simulator
    Download the OG Engine Simulator for free!
    github.com/Engine-Simulator/e...
    Join the Official Engine Simulator Discord Server!
    / discord
    Join my channel community Discord!
    / discord
    00:00 Master Mechanics
    00:14 Squarespace [Sponsored Segment]
    00:59 Engine Simulator Roadmap
    02:05 Physics Engine Overview
    02:55 Gauss-Seidel Method
    04:16 Optimizing the Gauss-Seidel Solver
    06:34 Conjugate Gradient Method
    07:43 Tension/Compression Demo
    10:06 Pre-emptively Addressing the Haterz
    10:34 Shout-out to Patrons and Outro
    #physics #simulation #gamedev
    FTC Disclaimer: This video was sponsored by Squarespace.
    Thanks for watching!
  • บันเทิง

ความคิดเห็น • 439

  • @AngeTheGreat
    @AngeTheGreat  ปีที่แล้ว +2098

    i don't get why this guy doesn't just use box2d and unity smh

    • @Lemmskii
      @Lemmskii ปีที่แล้ว +85

      ikr smh

    • @Blitz_Protogen
      @Blitz_Protogen ปีที่แล้ว +38

      Exactly bro!!!

    • @Stork2204
      @Stork2204 ปีที่แล้ว +82

      Cause ange only trusts his own incredible coding brain

    • @notanengineer
      @notanengineer ปีที่แล้ว +9

      Yeh fr that would solve everything

    • @melonenstrauch1306
      @melonenstrauch1306 ปีที่แล้ว +42

      Also he pronounced Seidel wrong, I'm probably the only one who noticed tho

  • @jakobbb6405
    @jakobbb6405 ปีที่แล้ว +637

    8:55 This is actually a really common thing in engineering regarding basically everything. If you have a simple axle and it is held in place with 2 bearings one of them is fixed on the axle and the "casing" whie the other needs to be a floating bearing to compensate for any sort of length changes due to for example heat. Its a huge pain if you are currently studying this lol.

    • @racercowan
      @racercowan ปีที่แล้ว +64

      In relations to truss's specifically, I believe that bridges (especially longer ones) are even designed with a "floating" end that can move by a small amount.

    • @JorgetePanete
      @JorgetePanete ปีที่แล้ว

      It's*

    • @jakobbb6405
      @jakobbb6405 ปีที่แล้ว +32

      @@racercowan i think not even small. I ain't no bridge man but I think they can move about 10m or something. It's really interesting

    • @gabrielenitti3243
      @gabrielenitti3243 ปีที่แล้ว +34

      ​@@racercowan most bridges are built in "small" pieces to allow room for expansion and contraction due to temperature. The same applies to cement pours, they have relief cuts to allow for it.

    • @dovos8572
      @dovos8572 ปีที่แล้ว +25

      @@racercowan the only bridges that don't have the floating end are bridges with a bowed pavement like old river bridges out of stone. these bridges don't need the floating end becaus they expand up into the bow and not to the side.

  • @oblivion_2852
    @oblivion_2852 ปีที่แล้ว +765

    Bruh... not too much to show?? This is HUGE. Please don't undersell your adventures into simulation and also your educational content. Love the explanation of different types of solvers. I now know where to look if I wanna get into this.

    • @rebus_x5313
      @rebus_x5313 ปีที่แล้ว +15

      He: *not too much to show*
      Me: dude i wish i could do this stuff in 5 years if i started like now

    • @whannabi
      @whannabi ปีที่แล้ว +3

      ​@@rebus_x5313 I wonder what we would get if he considered something as a lot to show

    • @senboy9002
      @senboy9002 11 หลายเดือนก่อน

      @@whannabi Accurate simulation of the entire Earth

  • @Chillin4030
    @Chillin4030 ปีที่แล้ว +37

    I'm so glad the Beam devs are in on it. I cant wait to see what that entails.

  • @actuallydaneel
    @actuallydaneel ปีที่แล้ว +125

    This really does remind me of polybridge, and i'm so into it. physics visualizations are just so satisfying

  • @orthodynamicstereonails
    @orthodynamicstereonails ปีที่แล้ว +74

    I love it when computer science youtubers talk about optimization! Both you and Acerola do a great job talking about it.

    • @nixel1324
      @nixel1324 ปีที่แล้ว

      Have you checked out Kaze Emanuar? He's doing incredible things to optimize the Super Mario 64 source code. He's making a rom hack (which he tests on actual hardware), and the things he can get the N64 to render interactively in real time are insane.

    • @oliverer3
      @oliverer3 7 หลายเดือนก่อน

      I'm terrible at it and hate doing it but it's so fascinating watching other people do it and explain their motivations.

  • @cpli7783
    @cpli7783 ปีที่แล้ว +15

    Whilst i love reinventing the wheel, there's an old passage that one can take from all the other physics engines i.e. that: "linear algebra? that belongs on the GPU". using a compute shader to do your SIMD for you every frame could possibly allow for much more complex simulations.

    • @AngeTheGreat
      @AngeTheGreat  ปีที่แล้ว +12

      I'll leave that to a future video lol but yes, offloading some of the physics to GPU would be very interesting to try

  • @felixurbanov3438
    @felixurbanov3438 ปีที่แล้ว +29

    You are awesome Ange!

  • @jfyllipy
    @jfyllipy ปีที่แล้ว +81

    Hello! I’m a structural engineer and that is exactly what we do. It’s called finite element method and we solve pretty much a very similar matrix (but the global matrix elements are in bar’s terms (based on elastic properties of material and it's geometry) and not about the nodes, although we solve it for nodes displacements). The matrix is called “stiffener matrix”. Polybridge uses this very same method (as far as I’m concerned). I even developed an web app for structure (we call it frame) solution (first and second order solver. P-Delta for the win!). I don’t know if I can post the link here but if I can please let me know. (It’s is in my mother tong (Portuguese) however. But it’s very intuitive and I’m planing to release an English version).

    • @jbritain
      @jbritain ปีที่แล้ว +2

      You can absolutely put links in TH-cam comments as far as I know

    • @Inf1e
      @Inf1e ปีที่แล้ว +1

      Most populat CADs (AutoCAD, SolidWorks, etc) use this very method to simulate.

    • @jfyllipy
      @jfyllipy ปีที่แล้ว +2

      @@Inf1e I dont know if CAD does simulation but definitely Solidworks, ANsys, Catia, Abaqus, etc uses it. However they do it with another technic. While I (and AngeTheGreat uses a variation of) use a technic called "Displacement Method", all these simulations softwares discretize the elements even more, where a mesh can have thousands and thousands of nodes (called vertices), solving for a matrix of order 6*n (n is the number of vertices). They even compute results in between vertices solving, by many iterations, an equation that needs to converge (the convergence is a very important measurement for accuracy). This means that a normal model (2000 vertices) can have a matrix of 144 millions elements and need to be solved multiple times to converge! It requires a good computer indeed. This technic is not used only for mechanics, however. CFD, magnetism, heat transfer, soil mechanics... All of them uses this technic, changing only the way they build the global matrix.

    • @annakquinn7084
      @annakquinn7084 ปีที่แล้ว +6

      This is not FEM, this is Matrix Stiffness Method. In FEA we use shape functions to approximate discrete displacements at the elements.

    • @jfyllipy
      @jfyllipy ปีที่แล้ว

      @@annakquinn7084 ooooops. You are completely right

  • @first9279
    @first9279 ปีที่แล้ว +68

    I love that you've written "Danke" at the end of the thing with "Seidel", Im a native German speaker and I dont mind it when you pronounce it wrong :)

    • @seritools
      @seritools ปีที่แล้ว +1

      Since I can't comment on the wrong pronounciation anymore imma replace it with "um actually, it's '3 fewer instructions', not '3 less instructions'"

    • @kem0n0.kokomo
      @kem0n0.kokomo ปีที่แล้ว +1

      @hello Skill issue

    • @dieSpinnt
      @dieSpinnt 9 หลายเดือนก่อน

      The correct pronunciation of "Seidel" is only important when visiting the Oktoberfest. That's what the stone beer mugs are called, hehehe.
      With Philipp Ludwig von Seidel, Ritter von Seidel it is simpler: he has been DEAD since 1896 and can no longer defend himself against the butchering of his name. But I would be careful with living people. "We're Americans(for example) and that's how we pronounce XYZ here ...", like Ange told in the video, is far from good manners or respect. Just by the way;) And yes, all of this doesn't matter here. It's a video about science and not a love letter:) Danke auch!:)

  • @mrkosmos9421
    @mrkosmos9421 ปีที่แล้ว +31

    This man started with engines and is going with PolyBridge...
    But the progress is incredible, can't wait to see what's next
    Anyway, the licensing options are endless, from engine sound simulation for EVs to games to anything else
    And the trebuchet just takes me back to old flash games about destroying medieval castles... ah, good times
    Makes me wonder if there is the possibility of making a puzzle sandbox game about creating your own engine under a certain budget/limitation for a certain purpose, like PolyBridge, KSP or Besiege to name a few
    You know what, maybe I'll make something like that

  • @finneggers6612
    @finneggers6612 ปีที่แล้ว +3

    I have written my own FEM simulation software for 3d problems and I figured out that iterative methods for solving sparse systems at low degrees of freedom (anything below 500k) is actually way way slower than direct methods. I recommend direct methods. Since your problem is probably symmetric positive definite, this should be simple.

    • @AngeTheGreat
      @AngeTheGreat  ปีที่แล้ว +2

      Thanks for the suggestion. Do you know of any papers/sources about these methods?

    • @finneggers6612
      @finneggers6612 ปีที่แล้ว +1

      @@AngeTheGreat Yes sure. I think the list of solution strategies is almost infinite here. I also thought abou tthis once more. So.
      Using direct solvers is 100% faster for your problems here. We are talking about magnitudes. For 1000 DOF the direct methods are magnitudes faster (maybe a factor 100-1000).
      Now when using iterative methods like CG, you never ever want to use plain CG. CG converges faster the better the condition number of your problem is. The condition number is basically a scalar describing how difficult it is to numerically solve your problem. for linear symmetric positive definite systems it is k = max(lambda) / min(lambda) (IIRC). Multiple things. The higher k, the longer CG will take to converge. I am 90% sure your k value is absurdly high. One method if you want to stick with indirect methods is using preconditioning. Sadly preconditioning is hard to implement yourself. (technically preconditioning is a direct solver which you just stop in the middle). A common preconditioner here is the incomplete cholesky (again, hard to implement yourself).
      When using direct methods for these type of problems, the probably best way is doing a simple LDL* decomposition. Understanding the decomposition is easy. Implementing it is stupidly hard. I have tried some of these and it gets incredibly complex for sparse matrices.
      There are a few things to consider here:
      A) what sparse matrix format you use, CSR may not be the best
      B) For C/C++ there are free libraries. At some point I was so annoying by implementing this myself, that I went with Eigen.
      I can give you a link where I used Eigen for:
      LDLT: github.com/Luecx/FFES/blob/main/src/solver/LDLT.cpp
      PCG: github.com/Luecx/FFES/blob/main/src/solver/CG.cpp
      Eigen: eigen.tuxfamily.org/index.php?title=Main_Page
      If you really want to write this yourself:
      condition number: en.wikipedia.org/wiki/Condition_number
      pcg: en.wikipedia.org/wiki/Conjugate_gradient_method (scroll down to pcg)
      positive definite: en.wikipedia.org/wiki/Definite_matrix
      I can give you more resources. Its easier to read on this on wikipedia initially.

  • @MedicMainDave
    @MedicMainDave ปีที่แล้ว +9

    3:04 as a german I am very happy you wrote this, not because I really mind that much about how something is pronounced, cause I'd also say it the same way when speaking english, but rather because of the "Danke" you put there lol
    Danke mein Friend :)

  • @zachogdahl210
    @zachogdahl210 ปีที่แล้ว +210

    The integration discussion is interesting, Having the audio simulation working natively in unreal would be incredible.
    Excellent work as always

    • @AngeTheGreat
      @AngeTheGreat  ปีที่แล้ว +65

      When I get the time I'll probably look into implementing something into Unreal, or I might find someone with more Unreal skills than I have to help lol

    • @orthodynamicstereonails
      @orthodynamicstereonails ปีที่แล้ว +14

      i guess you could say it would be... unreal

    • @Avetho
      @Avetho ปีที่แล้ว

      @@orthodynamicstereonails Darn you beat me to it!

    • @EPICGameGuy493
      @EPICGameGuy493 ปีที่แล้ว +7

      I've been working on integrating Engine Simulator inside of unreal, and I uploaded a video on my account demonstrating it. Everything works natively but the audio is unfiltered, and I'm working on getting it working with Metasounds rn

    • @MihaiZavoian
      @MihaiZavoian ปีที่แล้ว

      someone also integrated it into assetto

  • @HiImKyle
    @HiImKyle ปีที่แล้ว +40

    Wow BeamNG is supporting you? The official BeamNG? That's pog. Would love to see the engine sim in BeamNG.

    • @auxencefromont1989
      @auxencefromont1989 ปีที่แล้ว +16

      yes that's the real one

    • @MetroidChild
      @MetroidChild ปีที่แล้ว +8

      Probably partially the reason they support it, since it sounds like Ange will be going to GDC alongside BeamNG.

    • @notarobotto
      @notarobotto ปีที่แล้ว +4

      they're supporting a lot of people doing this kindof stuff, i'm happy seeing that they're supporting others and not suppressing competitors

    • @elfferich1212
      @elfferich1212 ปีที่แล้ว +6

      Yes. Beam team really loves what ange is doing. I could actually could see them hiring him.

  • @Propulus
    @Propulus ปีที่แล้ว +10

    Playing BeamNG while watching the last couple of videos and seeing them support you and show interest is just insane levels of hype. It's already my driving sim of choice, but if it get's even a fraction of your engine sound simulation too, it'd probably become THE driving sim for just driving. I love the work that team does, and it keeps getting better so all of this is fantastic news.

  • @perplxxd
    @perplxxd ปีที่แล้ว +79

    this man is singlehandedly changing the history of racing videogames
    edit: just videogames in general tbh

    • @manitoba-op4jx
      @manitoba-op4jx ปีที่แล้ว +3

      the next half life is gonna use this for the engine sounds in the vehicle section

    • @ChaoticNeutralMatt
      @ChaoticNeutralMatt ปีที่แล้ว

      Writing history?

    • @enorazza
      @enorazza ปีที่แล้ว

      Geoff Crammond.
      Robert Scawen.
      May be it is time for a new one ;)

  • @hi_its_jerry
    @hi_its_jerry ปีที่แล้ว +25

    engine sim + beamng confirmed??? im drooling at the thought

    • @YannickBo
      @YannickBo ปีที่แล้ว +7

      And now we can even play Poly Bridge in Engine Sim :P

  • @BI4ck_J
    @BI4ck_J ปีที่แล้ว +5

    this is getting more and more exciting as time pass by!

  • @dsagman
    @dsagman ปีที่แล้ว +174

    have you considered simplex for solving? it can work very well on sparse matrices and there are available libraries

    • @AngeTheGreat
      @AngeTheGreat  ปีที่แล้ว +163

      I've heard of it but when I looked into it in the past I couldn't wrap my head around it lol. Maybe now I could actually understand it given the knowledge I've accumulated

    • @windowsxseven
      @windowsxseven ปีที่แล้ว

      @@AngeTheGreat holy fuck... you couldn't understand simplex?

    • @AngeTheGreat
      @AngeTheGreat  ปีที่แล้ว +7

      @@windowsxseven Uh maybe? I never said I was smart lol

    • @windowsxseven
      @windowsxseven ปีที่แล้ว +4

      @@AngeTheGreat got DAMN

    • @ffff-od3jb
      @ffff-od3jb ปีที่แล้ว +1

      @@AngeTheGreat 🤓

  • @hcmcnae
    @hcmcnae ปีที่แล้ว

    this is so sick. Found you today and I'm looking forward to seeing your progression!

  • @saar5947
    @saar5947 ปีที่แล้ว +8

    You should do a collab with Sebastian Lague

  • @erikziak1249
    @erikziak1249 ปีที่แล้ว +2

    Thank you for this video and all your work.

  • @Swaggie255
    @Swaggie255 ปีที่แล้ว +5

    I love watching this series!

  • @DrNabeel20
    @DrNabeel20 ปีที่แล้ว

    This actually amazing! great video

  • @slightlyinsaneraf
    @slightlyinsaneraf ปีที่แล้ว +4

    So enjoyable to watch these videos

  • @DasParedes
    @DasParedes ปีที่แล้ว

    maaan, this is incredible, Thank you for showing us that!

  • @fazbeark1ng
    @fazbeark1ng ปีที่แล้ว

    im really excited for the engine sim to be complete! it already awesome

  • @gedaliakoehler6992
    @gedaliakoehler6992 ปีที่แล้ว +1

    Great video again! Fun stuff. One idea (could be interesting) is to save off some of your large sparse matrices and try different already implemented solvers on them in (with numpy or package you like) to play around with different techniques and their performance. Then once you know a technique is better for performance you can implement it.

  • @KanzakiZD
    @KanzakiZD ปีที่แล้ว +41

    if your works will be included in beamng, that'll be extremely amazing 😳

  • @redship7532
    @redship7532 ปีที่แล้ว

    this is crazy, very good job!

  • @Radi0he4d1
    @Radi0he4d1 ปีที่แล้ว

    Looking forward to the gdc talk!

  • @Velkanis
    @Velkanis ปีที่แล้ว +4

    with the readmap out im never leaving this dev log train again, something tells me this will be real fun! also grats on getting dragged along beamNG to gdc! do have yourself a great load of fun there fam!

  • @GuildOfCalamity
    @GuildOfCalamity ปีที่แล้ว

    Awesome video and very educational!

  • @joancasals4365
    @joancasals4365 ปีที่แล้ว

    Very interesting video, keep going!

  • @Gimble_Gamble
    @Gimble_Gamble ปีที่แล้ว

    Your content is so cool! I am really inspired by you, keep up the good work!

  • @emirozturk3462
    @emirozturk3462 ปีที่แล้ว +1

    Good job! As a side note, you might consider Newton-Raphson or Fast Decoupled methods to solve non-linear equations. For Newton-raphson, computation time won’t be increasing as much as Gauss-Seidel as the size of the matrix increases and it is very robust. However, Fast decoupled will be the fastest but It won’t be as robust. These options might help you.
    As an electrical engineer, we are using these methods to solve power flow equations on large systems.

  • @CharlesVanNoland
    @CharlesVanNoland ปีที่แล้ว +4

    I've never been able to employ SIMD intrinsics in my code that performs better than what the compiler optimizations can do, especially when link-time optimizations and 'expensive optimizations' are enabled. GCC's auto-vectorization is legit, as long as pointer indirection and whatnot don't throw it off, which just means conforming code to the optimization 'templates' (that's how I think of them as) that it employs to determine when/where the vectorization should happen.

    • @AngeTheGreat
      @AngeTheGreat  ปีที่แล้ว +6

      I can relate. I actually had a few hours of recordings showing how I did the SIMD optimization but I thought it would be too boring to watch for most people. After first adding SIMD, the code was actually 2x SLOWER. But by looking at the disassembly I was able to find the places where MSVC was not producing optimal SIMD code and guide the compiler by massaging the C++ code. Maybe GCC is better but I haven't really used it's auto-vectorization features much.

    • @empireempire3545
      @empireempire3545 ปีที่แล้ว +1

      I also work with GCC. I had a case at work, my colleague has rewritten one piece using intrinsics and got something like 2-3 times improvement. The thing about intrinsics is, they will only help you if you optimized memory access in the first place - most of the people don't know what that means, much less do that. And memory access is much more potent optimization anyway.
      Whether the compiler will or will not employ intrinsics is very, very hard to predict.

  • @luukvanoijen7082
    @luukvanoijen7082 ปีที่แล้ว +6

    Holy shit I cannot tell you how excited I am that BeamNG is supporting you. I really hope something incredible will come out of this partnership :D

  • @heisenburgeronthetoilet
    @heisenburgeronthetoilet ปีที่แล้ว +5

    this is really awesome that a big game developing team knows that you have a really good idea. I hope that the steam realese is not far away. Excellent work!!

  • @amukh1_dev274
    @amukh1_dev274 ปีที่แล้ว

    I used to watch your videos in the past, and I never really understood the physics or math, but today I clicked on this video and was met with a pleasant surprise.

  • @logtrimmer
    @logtrimmer ปีที่แล้ว

    Your explanations go way over my head since I am not that familiar with coding, but I can understand the optimization thanks to the time it takes per iteration.

  • @vuvu7005
    @vuvu7005 ปีที่แล้ว

    insanly cool video !

  • @jakubpollak2067
    @jakubpollak2067 ปีที่แล้ว +6

    I hope you will make next gen Algodoo simulator with sounds
    I'll would definitely pay for that!
    Seeing these truss constructions reminds me of university :D

  • @sjeses
    @sjeses 11 หลายเดือนก่อน

    Please keep reinventing the wheel, and take as much time as the process needs. It's fascinating!

  • @WoolieOG
    @WoolieOG ปีที่แล้ว

    fascinating video, loved dive into algorithm and their flaws

  • @fasogoss
    @fasogoss ปีที่แล้ว

    I get performance aware programming vibes here, Great work man!

  • @houseisforthesoul
    @houseisforthesoul ปีที่แล้ว

    oh my lord - this is a fantastic project

  • @shahars3134
    @shahars3134 ปีที่แล้ว +1

    Amazing video as always! Seriously engine simulator updates are one of my favorite things on the internet right now.
    I'm wondering about the implementation of the CG method. How much can it be optimized?

  • @turbinia
    @turbinia ปีที่แล้ว +4

    8:40 The reason for needing a roller support instead of two fixed supports is that it makes the truss statically determinate. It's much more difficult to analyse the internal forces of a truss if you can't assume that the sums of forces and moments are zero. If it is statically determinate, you can use basic statics equations to get the forces in each member. A statically determinate structure should agree with the equation M + R = 2J, where M is the number of members in the truss, R is the number of external reaction forces, and J is the number of joints. If M + R < 2J, the structure is unstable (effectively a mechanism), and if M + R > 2J, the structure is statically indeterminate and cannot be analysed just by geometry alone and you need to start taking material properties and member design into account. Note that while the equation being satisfied is a necessary condition for stability, it is not sufficient in itself, as the members of the truss also need to be arranged properly.
    In your example truss there, you have 21 members, 3 external reactions, (x and y at the pin joint, y only at the roller) and 12 joints, so that is statically determinate. Changing the roller joint for a pin joint adds a reaction force in the x axis, and M + R becomes 25 which is greater than 2 x 12 =24, so it becomes statically indeterminate.

    • @AngeTheGreat
      @AngeTheGreat  ปีที่แล้ว +3

      Yep, you know your stuff!

  •  ปีที่แล้ว +1

    As a mechanical engineer it's a joy to watch this video.
    I work with fluid simulations, where approximation methods are a must. The stability is an issue as well, but depending on what program you use for the simulations it might be handled with an ever increasing relaxation factor. XD
    Keep up the awesome work!

  • @scrambledmandible
    @scrambledmandible ปีที่แล้ว

    Thank you Beamng for chipping in, you're really cool for that!

  • @codesymphony
    @codesymphony ปีที่แล้ว

    nice. keep me updated

  • @ardaokay6862
    @ardaokay6862 ปีที่แล้ว

    At least you said Danke at the end... I'll allow it 👍🏻
    You are great

  • @aSpyIntheHaus
    @aSpyIntheHaus 2 หลายเดือนก่อน

    Oh i love this idea!

  • @amirsayfiddinov
    @amirsayfiddinov ปีที่แล้ว +1

    Love the ending. "Watch me reinvent the wheal" 😂

  • @danielpalecek4090
    @danielpalecek4090 ปีที่แล้ว +1

    shaking explosions or "kraken attack" are in every physics game on every physics setting, you won't avoid it

  • @sebleaf8433
    @sebleaf8433 ปีที่แล้ว

    Really cool. You could also experiment using gauss seidel as a preconditioner for your conjugate solver

  • @user-ep4dr2tu2w
    @user-ep4dr2tu2w ปีที่แล้ว +1

    impressive stuff. I should look into reinventing the wheel myself

  • @nikbivation
    @nikbivation ปีที่แล้ว

    golden content!!

  • @felipeferreira00
    @felipeferreira00 8 หลายเดือนก่อน +1

    @RealCivilEngineerGaming
    This, this is the future, and i love it.

  • @CubeAtlantic
    @CubeAtlantic ปีที่แล้ว

    This looks kind of detailed but it's still alive & with optimized physics/engineering i like this honestly.

  • @tensevo
    @tensevo ปีที่แล้ว

    Great, i cant fully appreciate what is going on but will look forward to seeing the final product and maybe integrating in other sims.

  • @ulyssesmoura4890
    @ulyssesmoura4890 ปีที่แล้ว

    My final course work in civil engineer i did a python program for construct a matrix like this one using cholesky decomposition to solve the equations. It's so cool watch this and remember my college years. Hello from Brazil

  • @danielmachado4389
    @danielmachado4389 ปีที่แล้ว

    Not sure if could be of help, but for that stiffness of the transmission you could use the value of a beam like element in tortion:
    k=G*pi(R^4-r^4)/2/L where G id the shear modulus of the material (steel or whatever), R is the outer radius of the shaft, r is the inner radius of a hollowed shaft (typically r=0) and L is the shaft length

  • @davidvargas7651
    @davidvargas7651 ปีที่แล้ว

    You should check out algebraic multigrid (AMG) for solving the linear system. I think it could work well for your systems, and it is super fast. You can also use AMG as a precondioner for CG and it can greatly reduce the number of iterations required.

  • @Teflora
    @Teflora ปีที่แล้ว +1

    idk how reasonable it is, but having a VST of this in the future would be awesome! Good work!

  • @charliemw333
    @charliemw333 ปีที่แล้ว +1

    I'm sure you already know about this, but you may want to look into the numerical methods that are used for computer fluid dynamics simulations or finite element method simulations. Sparse matrices pop up all the time, and you may be able to use some of the info you find in ur game.

  • @ScarlettStunningSpace
    @ScarlettStunningSpace ปีที่แล้ว

    I'm loving what I see

  • @PBOZAI
    @PBOZAI ปีที่แล้ว

    For linkages that are supposed to be perfectly rigid, you could use maximum cliques to group “trussed”/“triangluated” sturctures and treat them as a single object within the simulation.

  • @sebastianojeda5283
    @sebastianojeda5283 ปีที่แล้ว

    bro this is the best channel ever, love this, keep the good work, somehow you are doing God's job

  • @stinkytoby
    @stinkytoby ปีที่แล้ว +2

    Hah
    When you mentioned the tension/compression right after stability, I immediately remembered how PolyBridge 2 had much more deterministic physics than its prequel

  • @ZeldaACFan17
    @ZeldaACFan17 ปีที่แล้ว +6

    For the damage thing, maybe have it as an option that can be enabled or disabled 🙂 Some people might not want the damage simulation, like someone who is just starting with Engine Sim, or a returning user who's been away for a while and wants to gradually come back in, so they can refresh their memory on how Engine Sim works 😉

    • @AngeTheGreat
      @AngeTheGreat  ปีที่แล้ว +12

      Good idea! I imagined having something like "unbreakable mode" in PolyBridge.

    • @ZeldaACFan17
      @ZeldaACFan17 ปีที่แล้ว +5

      @@AngeTheGreat Thanks 😉 But I've noticed something about BeamNG too... The way I like to play it is like a standard driving or racing sim, not like the crash simulator type videos that I see a lot of... I think BeamNG should have a reduced damage mode or something like a damage sensitivity slider, so for racing scenarios like I like to do, the damage would be less sensitive globally, or even turned off entirely if I just want to drive for fun (I mostly play Beam for the driving physics portion, trying *not* to crash 😂)

    • @ZeldaACFan17
      @ZeldaACFan17 ปีที่แล้ว +5

      Now don't get me wrong, I do like how realistic the crashes look in Beam. It's just that I don't only play it for the crashing itself. I play Beam for the driving aspect, and creating my own custom car configs to drive on my favorite maps, which are racing maps. Drag strips, offroad, or standard circuit style 🙂🏁🏎️

  • @sterlingmakara
    @sterlingmakara ปีที่แล้ว

    I just had an idea while in the bathroom. A slider that can change the spark timing. You can slide it to the left to delay the timing a bit and slide it right to advance the timing. This will especially play a big role in how a diesel engine sounds when you get around to that. Would be neat to see.

  • @Doct
    @Doct ปีที่แล้ว

    4 days after this video released I started a Numerical Analysis class here at uni. I (thought) I had no idea what it was but then they mentioned the Gauss-Seidel method, and I was like oooooooooooooooh so that's what this is about lol

  • @somelaser5906
    @somelaser5906 ปีที่แล้ว

    Ange, I love your videos... but, I'll be damned if I understood anything in this video besides Poly Bridge hahahaha. For real though I really enjoy a lot of in depth commentary videos regarding physics and coding so this hits the spot real good. Keep it up 👍

  • @shanegonzales
    @shanegonzales ปีที่แล้ว

    this reminds me of that bridge builder cellphone game. so much fun.

  • @pavelperina7629
    @pavelperina7629 ปีที่แล้ว

    Quite interesting. I would likely use Eigen library for this, but it's always good to know there are other methods and when they are more useful than first one that comes into mind (despite both are in Eigen).
    Sometimes experimenting and deeply understanding the problem is better than using any library. Sometimes it's arguable, cause spending extra four months on problem that's already solved costs a lot - more than double of your income.

  • @iancunnyngham7120
    @iancunnyngham7120 ปีที่แล้ว +1

    You know you want to just go ahead and build a complete racing simulator :D Get all the important physics extremely accurate, make it super mod-able, don't worry about it being pretty. Bonus for me and my few dozen closest friends: make it able to run just the physics as fast as possible headless so we can trail reinforcement learning drivers!!

  • @louispender9347
    @louispender9347 ปีที่แล้ว

    The method I cover in my degree is to remove parts of the structure (constraints or beams) until the structure can solved trivially. Then finding the orthogonal states of self stress representing unit forces in the locations where beams/constraints were removed. Virtual work is used to impose geometric constraints and solve for the self stress coefficients. This method, as far as I know, only works for static structures but may be worth looking at.

  • @sxkwa
    @sxkwa ปีที่แล้ว

    wow, very impressive!

  • @g.paudra8942
    @g.paudra8942 ปีที่แล้ว +2

    You may get more real-time performance and lower computation cost using CUDA (GPU), there's a CUDA version of Gauss-Seidel method btw.

    • @AngeTheGreat
      @AngeTheGreat  ปีที่แล้ว +3

      "Possibly" but there are costs to this as well and for smaller matrices the performance advantages may not be that significant. In any case, I'd need to test this to confirm whether there are any real benefits to using the GPU.

    • @empireempire3545
      @empireempire3545 ปีที่แล้ว

      @@AngeTheGreat Be careful with the test. One of the biggest bottlenecks for GPU is transfer of data between RAM and VRAM. So, for small systems, CPU implementation may be better simply because of the latency of just shuttling the data to/from the GPU memory. But for bigger systems the raw computational power of the GPU may take over.

  • @johannesssssssss
    @johannesssssssss ปีที่แล้ว

    First time seeing a dev optimizing before release 😳

  • @toyoboi
    @toyoboi ปีที่แล้ว

    This is absolutely incredible. I spent a couple hours last weekend just playing around in engine sim and my girlfriend was very confused why I was spending time "playing a game" where nothing happens.

  • @t4g2s
    @t4g2s ปีที่แล้ว

    I would love to hear about how do you construct given matrix that we are solving!

  • @raptorjeezus2607
    @raptorjeezus2607 ปีที่แล้ว +1

    man its like you read my comment on compute intensity for a beamng implementation. Great work!

  • @rwilson4073
    @rwilson4073 ปีที่แล้ว +1

    Babe wake up, new engine sim vid just dropped

  • @appalling22
    @appalling22 ปีที่แล้ว

    Awesome video! Have you looked into Verlet (really 'Velocity Verlet') integration? It's not always going to be applicable as it gradually loses energy, but it's brain-dead simple to implement and extremely fast.

  • @raztaz826
    @raztaz826 ปีที่แล้ว +4

    You could also try the XPBD method which is on the 10 Minute Physics channel

    • @MetroidChild
      @MetroidChild ปีที่แล้ว +1

      It's actually fairly similar, both uses conjugate gradients (edit: you don't need to, but most implementations do). The main difference is that XPBD can produce a vastly more stable result for low iteration counts and stiffness coefficients (but costs the same as increasing iterations).
      For problems which can be simplified to pure rigid bodies such as simulating the engine itself it doesn't make that much of a difference, except perhaps valve springs if they are not programed as their own special entities.

  • @chrismofer
    @chrismofer ปีที่แล้ว

    there may be plenty of times in simulating the physics of an engine where a simple look up table or curve fitting function is as good as a more complex calculation but saves runtime

  • @samuelpierce2.088
    @samuelpierce2.088 ปีที่แล้ว

    With regards to your future plans for engine simulator and integrating it into other games, I have two questions:
    1. Is there any way to use engine simulator to create engine note audio files for an arcade racing game (Burnout, as an example), and extract those files directly from engine simulator?
    2. Alternatively, do you have any plans to put together a program that would allow for engine simulator’s “.mr” file format to be converted into something that can be used in a game without integrating engine simulator itself into the game?
    I’m an aspiring indie game developer, and have been looking for a way to get realistic-sounding engine notes in my future game projects without having to spend a whole bunch of money to go out and physically record the engine sounds using expensive equipment. And so far, engine simulator looks to be exactly what I’ve been looking for.

  • @_XoR_
    @_XoR_ ปีที่แล้ว +6

    Have you considered using graph neural networks (GNNs) for solving the systems, there are many already proven SOTAs used for industrial grade FEMs. I myself might be interested in the topic.

    • @JustSayin24
      @JustSayin24 ปีที่แล้ว

      Real-time video game and FEM solver are wildly different constraints

    • @_XoR_
      @_XoR_ ปีที่แล้ว

      Yes and no, I don't see why you can't make the models inference time realtime in tandem with the scene updates

    • @JustSayin24
      @JustSayin24 ปีที่แล้ว

      @@_XoR_ Admittedly I have never used GNNs before, but the engineering challenge of getting inference latency of a NN down to real-time seems significant. I suppose DLSS exists, so there's that. Do you have any interesting resources you could share on the topic?

    • @_XoR_
      @_XoR_ ปีที่แล้ว

      TH-cam won't let me post links but look up Graph Network-based Simulators, PyG, DeepXDE (for non GNN PDE/ODE deeplearning approaches), unfortunately idk many C++ libs in this regard at least for GNNs. The challenge indeed will be the lower level aspect of gpu scheduling in cuda, not sure if triton could be used for a higher level solution.

  • @-nac
    @-nac ปีที่แล้ว +1

    i hope you can get fat stacks from selling this technology to racing game studios, not even counting the standalone game on steam. you deserve it 100% man.

  • @_general_error
    @_general_error ปีที่แล้ว

    Man, you became my idol. You are a proof, that when I quit my demanding life, I might be able to give my life a purpose and start coding what really matters!

  • @grabasandwich
    @grabasandwich ปีที่แล้ว

    10:14 gave me a much needed laugh. Thanks 😂

  • @kshysztof9649
    @kshysztof9649 ปีที่แล้ว +3

    If you are going to realease an actual game, in 3D, with car models and stuff, will you still make like a "base" program, that looks like the prototype ? I honestly like it a lot, and many people propably do as well

    • @AngeTheGreat
      @AngeTheGreat  ปีที่แล้ว +5

      Haha that IS what I'm working on. The car game I showed in my last video was just for fun, the final game might include a mini-game like that just to try out engines

  • @Eidachsans
    @Eidachsans ปีที่แล้ว

    If you are interested in improving efficiency you may want to look into recursive methods for evaluating the equations of motion. These algorithms create a graph based on the structure of the joints and bodies and evaluate all relevant terms in a very efficient manner recursively. This scales as O(n) instead of O(n^3) where n is the number of motion bodies. You may look into the code from the library simbody. There also have a great theory manual describing all the relevant math. Be warned, the recursive approach is quite a bit more involved.
    Also consider using a different time stepping algorithm. An explicit method like the RK4 typically requires very small timesteps to achieve good stability. Implicit methods or even mutltistep methods like BDF or some PECE methods are more common in the field.
    Are you using contraint stabilization technique like Baumgarte or projection methods? Since you only satisfy the contraints on a acceleration level there will be some drift for velocities and positions which can accumulate if the simulation runs longer.
    Otherwise I am very impressed with your project, keep up the good work!

  • @joshdingle930
    @joshdingle930 11 หลายเดือนก่อน

    i want to have this physics engine to just mess around in it sounds so fun

  • @fiery_transition
    @fiery_transition ปีที่แล้ว +7

    Honest question, would you normally use a math library (NOT game libraries/engines) which does the numerical and linear solving? EVEN when you are implementing things like this from scratch? It's more a question of, is it necessary to have complete control of the simulation, all the way to the numerical methods, or could a fast math library be used at the cost of it being blackboxed, and would that create issues further down wrt. mismatches in how the numerical methods behave?

    • @AngeTheGreat
      @AngeTheGreat  ปีที่แล้ว +9

      As I said in this video, this is 100% about gaining knowledge and not necessarily about having complete control. I would barely even understand what a linear equation solver even is if I hadn't implemented one myself and having this knowledge would allow someone to use third party libraries more effectively since you'd actually understand it. Would I consider using one? If it was really a slam dunk performance-wise and I was under time pressure, possibly. But at the end of the day both of those things are not really true, I'd like to create entertaining and engaging content for people to watch and I personally enjoy the process of writing things from scratch and that's ultimately the most important thing to me

    • @fiery_transition
      @fiery_transition ปีที่แล้ว +2

      @@AngeTheGreat I totally can get behind just doing it for learning, one of my great memories of learning was implementing numerical solving methods for integral equations. Sometimes the different numerical methods converge differently or lose precision at an earlier or later stage in the iteration count. I thought it might be hard to debug making your own physics engine, while at the same time, using a blackbox math library which might have all sorts of behavior which one does not know about, due to not having implemented it yourself, and then having problems when the solvers converge and behave differently, in the same program. So I was wondering if it even was realistic using another library, since it could create all sorts of weird issues, since the solver math might be different? But I totally get the educational/learning perspective, and do really enjoy your videoes!

  • @MikeM8891
    @MikeM8891 ปีที่แล้ว +2

    Did you consider Jacobi method for solving the matrix. It is not as computational efficient as Guass-Seidel but is very parallel and could be implemented on the GPU. A bespoke spare matrix data structure might help skip the massive amount of zero entries.

    • @AngeTheGreat
      @AngeTheGreat  ปีที่แล้ว +7

      I tried it and found that it was pretty unstable and definitely wouldn't be able to compete with the conjugate gradient method anyway. It's unfortunate though because if it wasn't for its poor convergence/stability properties, it would have been much easier to parallelize than the Gauss-Seidel method.