Making My Physics Engine 10x Faster and Simulating Trusses

  Рет қаралды 148,287

AngeTheGreat

AngeTheGreat

Күн бұрын

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!

Пікірлер: 440
@AngeTheGreat
@AngeTheGreat Жыл бұрын
i don't get why this guy doesn't just use box2d and unity smh
@Lemmskii
@Lemmskii Жыл бұрын
ikr smh
@Blitz_Protogen
@Blitz_Protogen Жыл бұрын
Exactly bro!!!
@Stork2204
@Stork2204 Жыл бұрын
Cause ange only trusts his own incredible coding brain
@notanengineer
@notanengineer Жыл бұрын
Yeh fr that would solve everything
@melonenstrauch1306
@melonenstrauch1306 Жыл бұрын
Also he pronounced Seidel wrong, I'm probably the only one who noticed tho
@oblivion_2852
@oblivion_2852 Жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
​@@rebus_x5313 I wonder what we would get if he considered something as a lot to show
@senboy9002
@senboy9002 10 ай бұрын
@@whannabi Accurate simulation of the entire Earth
@jakobbb6405
@jakobbb6405 Жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
@@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 Жыл бұрын
​@@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 Жыл бұрын
@@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.
@cpli7783
@cpli7783 Жыл бұрын
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 Жыл бұрын
I'll leave that to a future video lol but yes, offloading some of the physics to GPU would be very interesting to try
@Chillin4030
@Chillin4030 Жыл бұрын
I'm so glad the Beam devs are in on it. I cant wait to see what that entails.
@actuallydaneel
@actuallydaneel Жыл бұрын
This really does remind me of polybridge, and i'm so into it. physics visualizations are just so satisfying
@HiImKyle
@HiImKyle Жыл бұрын
Wow BeamNG is supporting you? The official BeamNG? That's pog. Would love to see the engine sim in BeamNG.
@auxencefromont1989
@auxencefromont1989 Жыл бұрын
yes that's the real one
@MetroidChild
@MetroidChild Жыл бұрын
Probably partially the reason they support it, since it sounds like Ange will be going to GDC alongside BeamNG.
@notarobotto
@notarobotto Жыл бұрын
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 Жыл бұрын
Yes. Beam team really loves what ange is doing. I could actually could see them hiring him.
@orthodynamicstereonails
@orthodynamicstereonails Жыл бұрын
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.
@MedicMainDave
@MedicMainDave Жыл бұрын
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 :)
@jfyllipy
@jfyllipy Жыл бұрын
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 Жыл бұрын
You can absolutely put links in KZbin comments as far as I know
@Inf1e
@Inf1e Жыл бұрын
Most populat CADs (AutoCAD, SolidWorks, etc) use this very method to simulate.
@jfyllipy
@jfyllipy Жыл бұрын
@@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 Жыл бұрын
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
@perplxxd
@perplxxd Жыл бұрын
this man is singlehandedly changing the history of racing videogames edit: just videogames in general tbh
@manitoba-op4jx
@manitoba-op4jx Жыл бұрын
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 ;)
@first9279
@first9279 Жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
@hello Skill issue
@dieSpinnt
@dieSpinnt 8 ай бұрын
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 Жыл бұрын
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
@hi_its_jerry
@hi_its_jerry Жыл бұрын
engine sim + beamng confirmed??? im drooling at the thought
@YannickBo
@YannickBo Жыл бұрын
And now we can even play Poly Bridge in Engine Sim :P
@felixurbanov3438
@felixurbanov3438 Жыл бұрын
You are awesome Ange!
@AngeTheGreat
@AngeTheGreat Жыл бұрын
You're awesome 🙏
@cemgecgel4284
@cemgecgel4284 Жыл бұрын
You meant great.
@zachogdahl210
@zachogdahl210 Жыл бұрын
The integration discussion is interesting, Having the audio simulation working natively in unreal would be incredible. Excellent work as always
@AngeTheGreat
@AngeTheGreat Жыл бұрын
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 Жыл бұрын
i guess you could say it would be... unreal
@Avetho
@Avetho Жыл бұрын
@@orthodynamicstereonails Darn you beat me to it!
@EPICGameGuy493
@EPICGameGuy493 Жыл бұрын
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
@dsagman
@dsagman Жыл бұрын
have you considered simplex for solving? it can work very well on sparse matrices and there are available libraries
@AngeTheGreat
@AngeTheGreat Жыл бұрын
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 Жыл бұрын
@@windowsxseven Uh maybe? I never said I was smart lol
@windowsxseven
@windowsxseven Жыл бұрын
@@AngeTheGreat got DAMN
@ffff-od3jb
@ffff-od3jb Жыл бұрын
@@AngeTheGreat 🤓
@Propulus
@Propulus Жыл бұрын
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.
@scrambledmandible
@scrambledmandible Жыл бұрын
Thank you Beamng for chipping in, you're really cool for that!
@finneggers6612
@finneggers6612 Жыл бұрын
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 Жыл бұрын
Thanks for the suggestion. Do you know of any papers/sources about these methods?
@finneggers6612
@finneggers6612 Жыл бұрын
@@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.
@BI4ck_J
@BI4ck_J Жыл бұрын
this is getting more and more exciting as time pass by!
@hcmcnae
@hcmcnae Жыл бұрын
this is so sick. Found you today and I'm looking forward to seeing your progression!
@erikziak1249
@erikziak1249 Жыл бұрын
Thank you for this video and all your work.
@emirozturk3462
@emirozturk3462 Жыл бұрын
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.
@saar5947
@saar5947 Жыл бұрын
You should do a collab with Sebastian Lague
@CharlesVanNoland
@CharlesVanNoland Жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
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.
@slightlyinsaneraf
@slightlyinsaneraf Жыл бұрын
So enjoyable to watch these videos
@Swaggie255
@Swaggie255 Жыл бұрын
I love watching this series!
@DrNabeel20
@DrNabeel20 Жыл бұрын
This actually amazing! great video
@gedaliakoehler6992
@gedaliakoehler6992 Жыл бұрын
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.
@danielpalecek4090
@danielpalecek4090 Жыл бұрын
shaking explosions or "kraken attack" are in every physics game on every physics setting, you won't avoid it
@Gimble_Gamble
@Gimble_Gamble Жыл бұрын
Your content is so cool! I am really inspired by you, keep up the good work!
@AngeTheGreat
@AngeTheGreat Жыл бұрын
Thanks man 🙏
@fazbeark1ng
@fazbeark1ng Жыл бұрын
im really excited for the engine sim to be complete! it already awesome
@Radi0he4d1
@Radi0he4d1 Жыл бұрын
Looking forward to the gdc talk!
@DasParedes
@DasParedes Жыл бұрын
maaan, this is incredible, Thank you for showing us that!
@GuildOfCalamity
@GuildOfCalamity Жыл бұрын
Awesome video and very educational!
@redship7532
@redship7532 Жыл бұрын
this is crazy, very good job!
@Velkanis
@Velkanis Жыл бұрын
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!
@KanzakiZD
@KanzakiZD Жыл бұрын
if your works will be included in beamng, that'll be extremely amazing 😳
@ZeldaACFan17
@ZeldaACFan17 Жыл бұрын
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 Жыл бұрын
Good idea! I imagined having something like "unbreakable mode" in PolyBridge.
@ZeldaACFan17
@ZeldaACFan17 Жыл бұрын
@@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 Жыл бұрын
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 🙂🏁🏎️
@joancasals4365
@joancasals4365 Жыл бұрын
Very interesting video, keep going!
@shahars3134
@shahars3134 Жыл бұрын
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?
@luukvanoijen7082
@luukvanoijen7082 Жыл бұрын
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
@amirsayfiddinov
@amirsayfiddinov Жыл бұрын
Love the ending. "Watch me reinvent the wheal" 😂
@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.
@heisenburgeronthetoilet
@heisenburgeronthetoilet Жыл бұрын
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!!
@WoolieOG
@WoolieOG Жыл бұрын
fascinating video, loved dive into algorithm and their flaws
@user-ep4dr2tu2w
@user-ep4dr2tu2w Жыл бұрын
impressive stuff. I should look into reinventing the wheel myself
@sjeses
@sjeses 11 ай бұрын
Please keep reinventing the wheel, and take as much time as the process needs. It's fascinating!
Жыл бұрын
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!
@jakubpollak2067
@jakubpollak2067 Жыл бұрын
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
@fiery_transition
@fiery_transition Жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
@@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!
@sebleaf8433
@sebleaf8433 Жыл бұрын
Really cool. You could also experiment using gauss seidel as a preconditioner for your conjugate solver
@houseisforthesoul
@houseisforthesoul Жыл бұрын
oh my lord - this is a fantastic project
@codesymphony
@codesymphony Жыл бұрын
nice. keep me updated
@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.
@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
@fasogoss
@fasogoss Жыл бұрын
I get performance aware programming vibes here, Great work man!
@vuvu7005
@vuvu7005 Жыл бұрын
insanly cool video !
@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.
@felipeferreira00
@felipeferreira00 7 ай бұрын
@RealCivilEngineerGaming This, this is the future, and i love it.
@charliemw333
@charliemw333 Жыл бұрын
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.
@aSpyIntheHaus
@aSpyIntheHaus Ай бұрын
Oh i love this idea!
@iancunnyngham7120
@iancunnyngham7120 Жыл бұрын
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!!
@ardaokay6862
@ardaokay6862 Жыл бұрын
At least you said Danke at the end... I'll allow it 👍🏻 You are great
@_XoR_
@_XoR_ Жыл бұрын
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_ Жыл бұрын
KZbin 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.
@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.
@stinkytoby
@stinkytoby Жыл бұрын
Hah When you mentioned the tension/compression right after stability, I immediately remembered how PolyBridge 2 had much more deterministic physics than its prequel
@Teflora
@Teflora Жыл бұрын
idk how reasonable it is, but having a VST of this in the future would be awesome! Good work!
@MihaiZavoian
@MihaiZavoian Жыл бұрын
the Engine Fattner
@nikbivation
@nikbivation Жыл бұрын
golden content!!
@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
@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.
@rwilson4073
@rwilson4073 Жыл бұрын
Babe wake up, new engine sim vid just dropped
@raztaz826
@raztaz826 Жыл бұрын
You could also try the XPBD method which is on the 10 Minute Physics channel
@MetroidChild
@MetroidChild Жыл бұрын
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.
@g.paudra8942
@g.paudra8942 Жыл бұрын
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 Жыл бұрын
"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.
@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.
@CubeAtlantic
@CubeAtlantic Жыл бұрын
This looks kind of detailed but it's still alive & with optimized physics/engineering i like this honestly.
@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.
@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.
@shanegonzales
@shanegonzales Жыл бұрын
this reminds me of that bridge builder cellphone game. so much fun.
@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
@MikeM8891
@MikeM8891 Жыл бұрын
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 Жыл бұрын
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.
@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!
@leflavius_nl5370
@leflavius_nl5370 Жыл бұрын
Just out of curiosity, did you have any background in mechanical engineering at all before starting this project? It's a very cool project and i love seeing stuff from my field of education (mech eng) being applied more broadly than i ever knew it could be!
@AngeTheGreat
@AngeTheGreat Жыл бұрын
I studied computer engineering and as part of my degree I had to take some very basic statics and dynamics courses in my first year but that's about it as far as formal education. The rest is mainly self-study and just a knowledge of physics
@hfitfxhfhfufgugugu6589
@hfitfxhfhfufgugugu6589 Жыл бұрын
In Seidel (and many other german words like Sohn=son Sonne=sun Seide=silk Sieben=seven so=so Säge=saw Seife=soap.....) jus pronounce the s like a bee Zzzz (like in desining=deZzzzining, not like in signing) , we call it ein weiches s=a soft s. Ein Scharfes s=a sharp s would often, if not always be in st like in Stiefel=boot (the big shoe, not booting up your computer, that would be hochfahren as a verb). There is ß for a scharfes s as well. It is used to make sure it should be scharf eventhough, there is a vowel after it. In Was=What it is scharf btw. I think that is because it is at the end. PS: Sch=sh
@sebastianojeda5283
@sebastianojeda5283 Жыл бұрын
bro this is the best channel ever, love this, keep the good work, somehow you are doing God's job
@MrHaggyy
@MrHaggyy Жыл бұрын
CPU's are cool but if you want really fast calculations with matricies you want to use the GPU for calculation as well. Also you can (LU or QR) factor your matrix into two smaller once. Helps with the O(n^3) as well as storing and moving the matrix around in memory.
@Alexander_Sannikov
@Alexander_Sannikov Жыл бұрын
in my experience the converge that you gain from conjugated gradients applied to linearized system of your constraints should be less than convergence (and stability) of nonlinear gauss seidel. in your examples nonlinear gauss seidel with a simple verlet integrator should be unconditionally stable and should converge in microseconds, not milliseconds. i suggest trying nonlinear gauss seidel, that amounts to simply solving each individual distance constraint multiple times: there's no matrix to be stored, no fancy maths involved, it's so simple that getting anything to converge better is extremely hard.
@AngeTheGreat
@AngeTheGreat Жыл бұрын
Do you know any good papers/sources about this? I find that getting decent information on this is the most challenging part for me
@Alexander_Sannikov
@Alexander_Sannikov Жыл бұрын
@@AngeTheGreat in literature this approach is simply callex position-based dynamics. you literally just satisfy constraints in random order independently from each other. just push particles of each constraint to their resting position closest to the current configuration. it's the dumbest thing you can do and it works annoyingly well when coupled with verlet integrator. unconditionally stable for rigid link constraints. the reason why it works is because it's a projection-based relaxation scheme. the reason why it works better than anything linear is because each constraint keeps its nonlinearity during the entire solving process: contrast this to conjugated gradients where you have to linearize constraints in the beginning of a time step and then crucially assume that constraints don't rotate during the entire time step. the test case where everything linearized will fail (including analytical solution) is just a rigid rope with a 100 links sustaining a heavy weight: it will develop zigzag-shaped instabilities regardless of your solver, as long as you linearize your system.
@AngeTheGreat
@AngeTheGreat Жыл бұрын
@@Alexander_Sannikov hmm I've implemented a system like that in the past and I didn't find that it worked very well for precise machines, maybe I missed something
@Alexander_Sannikov
@Alexander_Sannikov Жыл бұрын
@@AngeTheGreat systems like in this video should be trivial for it, however, there can be some dampening. i'm not sure how important energy conservation in your case is, but often in game physics some amount of dampening is desirable.
@AngeTheGreat
@AngeTheGreat Жыл бұрын
@@Alexander_Sannikov For my use-case, dampening and energy-loss in general is extremely undesirable. I might play around with position-based dynamics again but based on experiments I've done in the past, I don't think it would be the best option when simulating engines since I need very precise object positions and velocities even at high engine speeds
@t4g2s
@t4g2s Жыл бұрын
I would love to hear about how do you construct given matrix that we are solving!
@microcolonel
@microcolonel Жыл бұрын
It's kinda fun that popular games and toys are now based on nonlinear finite element analysis.
@Larslegos
@Larslegos Жыл бұрын
I'm loving what I see
@raptorjeezus2607
@raptorjeezus2607 Жыл бұрын
man its like you read my comment on compute intensity for a beamng implementation. Great work!
@sxkwa
@sxkwa Жыл бұрын
wow, very impressive!
@bbqgiraffe3766
@bbqgiraffe3766 Жыл бұрын
As a reinvent the wheel guy myself I totally understand, although my physics engines are usually way more janky
@joshdingle930
@joshdingle930 11 ай бұрын
i want to have this physics engine to just mess around in it sounds so fun
@flankana
@flankana Жыл бұрын
1:42 seeing this in Richard burns rally would be interesting
@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.
@kshysztof9649
@kshysztof9649 Жыл бұрын
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 Жыл бұрын
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
@johannesssssssss
@johannesssssssss Жыл бұрын
First time seeing a dev optimizing before release 😳
How Particle Life emerges from simplicity
10:16
Tom Mohr
Рет қаралды 320 М.
MOM TURNED THE NOODLES PINK😱
00:31
JULI_PROETO
Рет қаралды 12 МЛН
ПЕЙ МОЛОКО КАК ФОКУСНИК
00:37
Masomka
Рет қаралды 10 МЛН
WHY IS A CAR MORE EXPENSIVE THAN A GIRL?
00:37
Levsob
Рет қаралды 9 МЛН
I'm Coding an Entire Physics Engine from Scratch
9:19
Gonkee
Рет қаралды 1,6 МЛН
My Dumb Steam Game Got 90,000 Downloads in 30 Days
14:14
AngeTheGreat
Рет қаралды 704 М.
Simulating a Steam Engine with C++ (with sound)
18:41
AngeTheGreat
Рет қаралды 359 М.
I Optimised My Game Engine Up To 12000 FPS
11:58
Vercidium
Рет қаралды 485 М.
Giving Personality to Procedural Animations using Math
15:30
t3ssel8r
Рет қаралды 2,4 МЛН
In Video Games, The Player Never Moves
19:21
Josh's Channel
Рет қаралды 458 М.
Coding Challenge 180: Falling Sand
23:00
The Coding Train
Рет қаралды 737 М.
2D water magic
10:21
Steve Mould
Рет қаралды 505 М.
Multicylinder Engine Simulation - Engine Simulator Devlog 6
20:26
AngeTheGreat
Рет қаралды 214 М.
How principled coders outperform the competition
11:11
Coderized
Рет қаралды 1,5 МЛН
🍁 Годный билет
0:10
Ка12 PRODUCTION
Рет қаралды 4,9 МЛН