Physics Engine from Scratch

preview_player
Показать описание
I built a constraint-based 3D rigid body physics engine and an ECS (entity-component-system) from scratch in C and C++. The physics engine runs on the ECS and uses constraints to model collision, joints, and motors.

This video gives a very high-level overview of the most critical pieces of the engine: the constraint solver, collision pipeline, ECS, and the editor. Everything mentioned in this video is open source, check out the links below!

Check out Slingshot on GitHub!

Checkout T-RECS on GitHub!

Sander Mertens' blog

Entity Component System wiki

Mathy bits generated with manim

Monster foot steps - Sound Effect by LordSonny on Pixabay

Meow - Sound Effect from Pixabay
Рекомендации по теме
Комментарии
Автор

Fabulous! To not only be able to make a physics engine, but to present it well, that's a rare combination of brains and beauty. Very well done.

MarcusOttosson
Автор

Superb work!
For anyone looking to delve more into the physics check out the paper: Detailed Rigid Body Simulation with Extended Position Based Dynamics.
I implemented some of the features described in the paper and I must admit is trickier than it seems. For you to have implemented all of that is incredible.

eduardom
Автор

As someone from engineering background, I am a sucker for physics engines. Thank you for this video.

loukitmyname
Автор

Physics engines are so cool. This video is worth a sub!

mumblety
Автор

Amazing work, very impressive. What's the peformance like with ridiculous amounts of objects, are you using a BVH to cull collision checks, and have you considered adding convex mesh shapes?

tokyospliff
Автор

Cool stuff man. Trying to achieve stable stack of boxes in my end. This is inspiring.

shawarmagames
Автор

god damn, that's sooo good. I recently created my own too, and it's so much slower and worse. I will definitely come back to this video and comment section for resources once I'm ready to improve mine.

mmiisshhaa
Автор

i was wondering if you had any references for building up a contact manifold from EPA or did you use another algorithm?

paperomo
Автор

I saw your comment on one of my videos and decided to check out your channel. I've got to say...this is amazing! I'm dabbling into physics for my horror game and this is so inspirational! I look forward to more of your content :)

Wannabuh
Автор

Hello! What about energy and momentum conservation. Does it works with those simple constrains? I mean imagine a real 2 rigid body pendulum. It will keep the total energy and follow the correct velocity patern? Thanks a lot!!!

samsara
Автор

This is fantastic ! Bravo 👏I'm super impressed by how stable and modular it looks. Amazing 😁

valet_noir
Автор

It is been a while since I had enjoyed a video this much. Congratulations for your engine, you did something that very few people are able to do.

nahuelfernandez
Автор

Hello! Maybe u can clarify a bit obtain distance when I know current velocity and time in seconds where object will decelerate to 0 speed but from max speed, like if we stops 0.2s from 4000 velocity to 0 then from 2000 we should do it in 0.1s accordingly? Classic acceleration formulas seems not consider I compute it in between integrating steps like velocity is not that big or mapped as dt pos += velo * dt, instead a full second range and it provide distance that too much longer than when I integrate with RK4 or velocity verlet 😅 something like 20-25 times longer. Example max speed 4000 and time to full stop 0.2s, i apply deceleration amount as MaxSpeed / decelTime with inverted to velocity direction and I stops something like braking length 500-600 position units, when I try compute somewhere length when in motion for current speed or even on full speed for such time 0.2s via classic newton formulas I get braking distance 2700 something like that. So thought maybe just multiply to dt to obtain intermediate fraction so this will be kinda meaning of what dynamic acceleration equation deriving may looks like, but then values is 5-6 units in position, like 100 times smaller 😢 or I miss something dunno.

protasov-by
Автор

Awesome project. I'm new to programming and wanted to ask :
1) C++ has no inherent graphics capabilities. How did you implement graphics into your project?

aarfeenanees
Автор

Very cool, thanks for sharing! How difficult was it for you to understand and implement these algorithms?

gedaliakoehler
Автор

Thank you for sharing your knowledge.
Can you list some resources you used to study game physics?

p.a.minerva
Автор

that intro was hilarious! Very impressive work, I know building a physics engine is not an easy feat.

cmedia
Автор

This is very impressive. I'm still trying to figure out how to make my AABB game physics work properly with gravity and pushing against each other (lol). Maybe one day I will get to implement not-axis-aligned box colliders for my game: that is "my dream". :D

developerdeveloper
Автор

A physics engine with real time shadows, that is fancy.

developerdeveloper