@astroid 5698 That's often why a lot of older games get open sourced and parts are still missing. They've used a third party library and don't have the rights to distribute that code. For that reason one of the old Civ games went open source but with no audio capabilities whatsoever.
Assuming you have yours that we can use now open source, the building blocks and the intricates of physics can really overwhelm a seasoned physicists head, and yours is blown but still in there clear headed giving upper cuts to procrastinating doing something requiring this kind of effort, congratulations, liked to watch your introduction!
I think you should try resolving collisions instead of pushing them or moving both apart. There are a few algorithms I would suggest like the Separating Axis Theorem or GJK. This will make it so objects don't intersect with each other. Another thing would be a spacial partitioning tree for faster collision detection. I could go on about physics engines as I made a 2D one myself and will make a 3D one in the future with all the features. For buoyancy you can check the volume of the intersection between the plane and sphere and add a buoyant force * volume.
I did do collision resolution. Just explained it differently in the video because I thought people would understand more easily. As for the spacial partitioning tree I'll check it put as I've never heard of it before. And that's awesome that you've made one before I might give a 2d on a go at some point 😄
@@ZygerGFXwould definitely recommend doing a 2d one. The maths are mostly the same just quite a bit simpler, and everything is just nicer to work on. You get to do all the cool physicsy stuff without the pain of OpenGL. Also spatial partitioning is awesome! I’ve used quadtrees for collision detection in my particle simulations quite a few times
I really like this, been meaning to do the same. build out some more primitive functionality from scratch to see how game engines work. But alas, as a web developer all the maths go over my head. thank you for the video documenting your experience on this.
As long as you can subdivide the problem into small enough parts, you can probably manage. You also don't really need to know a formula to apply it, you just need to know which one to use. Approximations and substitutions are often good enough or even better too.
Great video. It's interesting to see someone building physics engines from scratch. I also tried to make my own, however I never figured out how to calculate amount of torque applied to an object during collisions. I am still thinking about it from time to time...
I want to point out that if you neglect water friction, a body will oscillate if you put it in the water because of the boyancy. Maybe that is what's happening in your code
I keep making stuff like this, and its hilarious how all the engine devs are like 'No no but it doesnt help me!!!' its funny how you constantly justify when really, its fine to use libraries and stuff to do things
Oh my god this gave me ptsd flashbacks. Back in the days in university we also had to create a physics engine in 3d. Have support for slopes, spheres, cubes, rectangles and then created a 'simple' pinball game to show that the engine works. We had a deadline of 6 weeks, and you were not allowed to use any libraries or whatsoever except for DirectX or equivalent, as long as you wrote all the math yourself, and collisions, responses, et cetera. No other sources or pre-finished things were allowed, you had to understand everything you wrote, document it and then have an exam on the mathematics. Worst thing I ever had in my life. Can't believe you'd just do this for fun 🤣 Edit: I failed the class hard and redid that class a year later, after 3 months of hardcore studying before it even begins. I thankfully passed.
4:07 too complex to check if two spheres intersect. You can just check if the distance between centers is less than or equal the sum of both radii. If it's equal then there's only one point of intersection exact at both radii in the direction towards each other spheres Edit: There's an exact formula given at 3:16
ngl I'd watch more of these. Did you implement continuous collision detection or just discrete? Is implementing continuous collision detection way harder than discrete?
I dont think she coded continous its just an unnecessary complexity that only has some benefits in very specific cases. Its just not worth it and there are more interesting things about physics engines than that to focus on.
no unfortunately I didn't do continuous. Would probably give it a go next time but didn't think it was necessary here. also when I read into it it required a lot more work that I didn't really want to do lol. also thanks for the feedback.
CCD (continuous collision detection) is very difficult to implement correctly. The simplest one might be a sweep algorithm, but it gets more complex when you add in rotation or want it accurate. Erin Catto, the creator of Box2D, did a GDC talk about his physics engine where he explained in depth how he did it with a kind of binary search. Also, it's only really worth it if you have very fast-moving objects, like projectiles, and at that point it's a lot better to use a ray cast. Most tunneling problems (when an object moves fast enough to pass through another object without touching) can be solved with substeps.
@@mariovelez578 Thanks! I will check that GDC talk. Do you know if implementing 3D collision detection is too hard compared to 2D collision detection? (I'm just curious about it, I don't plan to craft my own physics engine)
"the first step of making this physics engine is rendering things on the screen" nah, that's a renderer. You've built both a 3D renderer and a physics engine. Two huge things. Don't undersell yourself my dude
The correct model of collisions is to conserve the 3D momentum before and after, and to conserve X% of the kinetic energy incoming and outgoing to each collision (you could make X depend on the materials involved in the collision, or have some random element). Also you wrote a = v0 - v t but you probably meant v = v0 + at.
It was quite interesting hearing you learning those concepts. It looks like your integrator isn't correct, though, which would explain why bouncing the spheres off of each other looked janky. When things fall, you should be able to see their velocity build up over time. A simple integrator would be the leap-frog algorithm. It assumes that acceleration is only a function of position and time, but it can be written in a few lines of code and it only has a quadratic error term.
Nice video; you should learn how to use reference for performance reasons, especially in a physic engine, like, bool CollisionHandler::CheckCollision(const BoundingBox &box1, const BoundingBox &box2) { const Vector3d &box1Min = box1.GetMin(); .... Ok, first, the reference, then learn the const; it's nice to have. ;) In c# class is a reference by default, and the struct is a copy. In c++, by default, class, and struct are passed as copy, which is helpful in some cases, but both class and struct should be given to another function (or returned, when possible) as a ref or pointer (ref has the advantage of having a friendlier interface . instead of ->) In the case of this function, you create (temporary) 2 copies of BoundingBox, then 4 more at the start. A lot of time is lost for a function that can be called millions of times per second ;p I hope that will help you; keep up the excellent work.
Great video! I do exactly the same stuff in my free time :) Wait, you said you're using DirectX, but then I saw a wikipedia page about VBOs in OpenGL. So which one did you pick?
So refreshing to see a woman doing this, makes me go on. Fellow girlie here trying to make a physics simulator, and got overwhelmed by all the manly men giving manly advice and being condescending. Love ya!
As well as 4:03 where you check collision of sphere against the cube. You can just check if the distance between sphere center and at least one of 8 points of the cube is less than the radius. If at least one is smaller or equal, consider it intersection and stop further processing check. IMO it's much simplier to understand than dot product stuff
love the idea, but you should improve your physics's skill. you should devide the force by combined mess of objects, rather than applying the same acceleration to it.
Making Your self known or saying that You did something in life with this would be putting this information out there in most readable form on some sort of blog, with all known crack perspectives, such as operating system etc
You can do things in life without posting online to others about it. The only reason someone would do that is to make their work more known, and let other people learn from it. But not posting about it doesn't make you not accomplish great things in life. People spend their lives on passions and don't post about it, that doesn't mean they didn't do something in life. It just means it's only known to them and that's okay. I don't care if others don't know how I did this or simple don't know I've made something like this. It was fun and that's all the validation I need.
@@ZygerGFX this makes me do a phylosophy about purpose of our gadgets... everyday, till next century, if You are poor or have signs of not being productive or advanced in Your life, somebody will say to You to stop wasting Your time, and move on... when it's really unbelievably unimportant, unless the goal is material wealth or status... i really like that You found this as validation for Your time, as it could be an iQ point in general conversation, due to fact, artificial is based on all kinds of computer mechanics...
Great visual explanations in this video! I found it interesting that you chose to use Direct X for this project. I haven't worked with it myself, but I put together a crappy little game engine in C with OpenGL. So I know how much work goes into building just the graphics side of things. Great work! I might take some notes from this for future videos.
thanks yeah I don't know much about graphics programming and got recommended DirectX by someone so just gave it a shot. I also tried OpenGL before and yeah it can take a lot of effort to get something working. also props to you for using C and OpenGl. :D
Endless enigmatic book in all languages. You can write a book with mirrors in all languages of the world. You can speak two languages at once, you just need to find the perfect reflection, same content, different translation. Infinite Mirrors. Pi 3.14 XBooks. Hybrid language!!!!! One content, two languages. What I have now written may have a perfect mirror in another language.!!!!!!!!!!!!
This one took like a month maybe slightly longer, but I wasn't working on it all the time and took time of in between so hard to tell how long it really took.
I'm trying to make my own physics engine for 2D & 3D. Amazing work btw. I do have a question though: why do people say x game engine has better "physics" than y engine? Wouldn't they all basically use the same equations for things? I'd love to know the difference between the most popular game engines' physics engines. Maybe there's something I don't know yet, but I think that'd be an interesting video idea.
The title "I AM LOSING MY MIND" definitely sounds accurate when trying to build a physics engine from scratch
why are you here
@@object-official really isnt that weird
@@allanwernermusic yeah it's really not
No, just when doing it in C++. Physics engines in general are pretty easy to make conceptually.
"they" actually say it takes a week to write a physics engine and one year to fine tune it
Sometimes you gotta do it to appreciate game engines even more
All the time*
Game Engines too mostly just integrate some third party solution like PhysX, Bullet etc. They definitely do not make everything themselves.
@@astroid-ws4py it's still great to have all those tools kindly bundled for you
@astroid 5698 That's often why a lot of older games get open sourced and parts are still missing. They've used a third party library and don't have the rights to distribute that code.
For that reason one of the old Civ games went open source but with no audio capabilities whatsoever.
Unity doesn't need appreciation now
Assuming you have yours that we can use now open source, the building blocks and the intricates of physics can really overwhelm a seasoned physicists head, and yours is blown but still in there clear headed giving upper cuts to procrastinating doing something requiring this kind of effort, congratulations, liked to watch your introduction!
"ParticleModel::ParticleModel::ParticleModel()"
My brain is hurting
I'm also making a physics engine, and I can say that the window title "I AM LOSING MY MIND" is in fact relatable
Your voice is sooooooooo calming
dude thats so freaking cool.
I like the works you do
I think you should try resolving collisions instead of pushing them or moving both apart. There are a few algorithms I would suggest like the Separating Axis Theorem or GJK. This will make it so objects don't intersect with each other. Another thing would be a spacial partitioning tree for faster collision detection. I could go on about physics engines as I made a 2D one myself and will make a 3D one in the future with all the features. For buoyancy you can check the volume of the intersection between the plane and sphere and add a buoyant force * volume.
I did do collision resolution. Just explained it differently in the video because I thought people would understand more easily. As for the spacial partitioning tree I'll check it put as I've never heard of it before. And that's awesome that you've made one before I might give a 2d on a go at some point 😄
@@ZygerGFXwould definitely recommend doing a 2d one. The maths are mostly the same just quite a bit simpler, and everything is just nicer to work on. You get to do all the cool physicsy stuff without the pain of OpenGL.
Also spatial partitioning is awesome! I’ve used quadtrees for collision detection in my particle simulations quite a few times
@@ZygerGFX Octrees!
@@ZygerGFX You might have heard of a quadtree or an octtree instead. They're comparable to binary trees
Reasons to make your own physics engine:
1. Masochism
2. ???
i like the maple story sound effects, very nice.
oh and the engine showcase was cool too I guess
Glad I found your channel. Subbed!
Really good video, keep this style of content going!!
people doing this kind of thing from 0 is amazing, so I'm going to that side of the thing
Really Cool ("But WHY?") how do you have the time for this stuff
I don't know sometimes lol. Mind you I made this a few months back haha :D
this video is amazing...i love how good u explain the theory!
Nice video, and nice narration.
that mushroom death sound from maplestory at 0:45 hahaha that triggered some nostalgia :')
I feel good at code then I see these videos and I’m like “oh” 😂
I really like this, been meaning to do the same. build out some more primitive functionality from scratch to see how game engines work. But alas, as a web developer all the maths go over my head. thank you for the video documenting your experience on this.
lol same I'm an embedded systems eng and even tho I work with more obscure tech everything that goes into game dev is like arcane magic to me.
As long as you can subdivide the problem into small enough parts, you can probably manage. You also don't really need to know a formula to apply it, you just need to know which one to use. Approximations and substitutions are often good enough or even better too.
Same lol.
It's all about linear algebra and linear interpolation. It's not that complicated (let's ignore quaternions tho)
Mad respect. You used the DirectX Logo from the DxDiag program. I do the same for my Win32 C++ DX applications as well.
0:20 why is the S capitalised? is it just an accident?
Nice work! You learned a lot in a short amount of time.
5:54 "I AM LOOSING MY MIND" cutee
Great video. It's interesting to see someone building physics engines from scratch. I also tried to make my own, however I never figured out how to calculate amount of torque applied to an object during collisions. I am still thinking about it from time to time...
Honestly I love this content, it may not be a super complicated physics engine, but it’s fun and simple
I want to point out that if you neglect water friction, a body will oscillate if you put it in the water because of the boyancy. Maybe that is what's happening in your code
Not only did you make a physics engine, you made a rendering engine. Nice.
Epic engine! I made something similar for my game engine video, except mine was probably worse. Good job!
Oh cool I'll check out your video
I keep making stuff like this, and its hilarious how all the engine devs are like 'No no but it doesnt help me!!!' its funny how you constantly justify when really, its fine to use libraries and stuff to do things
"So I now have this and I'm never gonna use it" typical programmer things
Amen brother
Writing your own physics engine is actually a lot of fun. But doing the rendering with DirectX 11 without libs. Oh my lordy -.-
I didn't blink while seeing this video.
That was sooooo interesting.
This hurts. A physics engine is quit a bit more than this baby stuff.
So for what you made this? It's very hard and stressful...
Oh my god this gave me ptsd flashbacks. Back in the days in university we also had to create a physics engine in 3d. Have support for slopes, spheres, cubes, rectangles and then created a 'simple' pinball game to show that the engine works. We had a deadline of 6 weeks, and you were not allowed to use any libraries or whatsoever except for DirectX or equivalent, as long as you wrote all the math yourself, and collisions, responses, et cetera. No other sources or pre-finished things were allowed, you had to understand everything you wrote, document it and then have an exam on the mathematics. Worst thing I ever had in my life. Can't believe you'd just do this for fun 🤣
Edit: I failed the class hard and redid that class a year later, after 3 months of hardcore studying before it even begins. I thankfully passed.
Oh that's brutal
that's definitely brutal, 6 weeks????
and they wanted you to use the bare minimum, omg i wouldn't be able to do that, it sounds like a huge hassle.
That's really cool, I've been interested in trying something simliar but haven't gotten around to it. Great video!
thanks a lot. yeah you definitely should its a lot of fun and stress at the same time :D
Best. Particle. System. Ever! 😂
pain simulator 2023
GG and underrated
You definitely should collab with Gonkee! You guys would be amazing together!!
Great job!
By the way, I like the video style, and the material. Keep it up!
4:07 too complex to check if two spheres intersect. You can just check if the distance between centers is less than or equal the sum of both radii. If it's equal then there's only one point of intersection exact at both radii in the direction towards each other spheres
Edit: There's an exact formula given at 3:16
I have this and I'm never gonna use it again.
I can relate.
MapleStory sound effects I like :))
ngl I'd watch more of these. Did you implement continuous collision detection or just discrete? Is implementing continuous collision detection way harder than discrete?
I dont think she coded continous its just an unnecessary complexity that only has some benefits in very specific cases. Its just not worth it and there are more interesting things about physics engines than that to focus on.
@@gommito thanks for pointing it out! I'm very new when it comes to game engine developement
no unfortunately I didn't do continuous. Would probably give it a go next time but didn't think it was necessary here. also when I read into it it required a lot more work that I didn't really want to do lol. also thanks for the feedback.
CCD (continuous collision detection) is very difficult to implement correctly. The simplest one might be a sweep algorithm, but it gets more complex when you add in rotation or want it accurate. Erin Catto, the creator of Box2D, did a GDC talk about his physics engine where he explained in depth how he did it with a kind of binary search. Also, it's only really worth it if you have very fast-moving objects, like projectiles, and at that point it's a lot better to use a ray cast. Most tunneling problems (when an object moves fast enough to pass through another object without touching) can be solved with substeps.
@@mariovelez578 Thanks! I will check that GDC talk. Do you know if implementing 3D collision detection is too hard compared to 2D collision detection? (I'm just curious about it, I don't plan to craft my own physics engine)
And i would love to see how you would continue with an game engine from the point where u ended your video.
I need to study this
Finding this video after struggling all day with unity physics:
Why?? How do you have so much free time?
And I love math and code but...
I love how you just named the game "I am losing my mind"
haha :D
"the first step of making this physics engine is rendering things on the screen"
nah, that's a renderer.
You've built both a 3D renderer and a physics engine.
Two huge things. Don't undersell yourself my dude
You are Awesome 😎🤠, really !
Awesome video!!!
I will like and watch later for sure!
Yeah you have some guts for sure
Actually that is exactly what Gravity is, Space is pushing us down. but any continue continue...
I'm pretty sure unity uses NVIDIA PhysX (At least on my PC)
Tried to make a game engine in opengl and java before but soon gave up, I'll try again with rust and vulkan.
Oooh yeah it can be quite difficult. I heard vulkan can be hard too
You can try with WGPU, It is a cross platform graphics abstraction library for Rust, Really a high quality one.
Thank you for sharing this. :-)
Sick.
Next video: "I hacked into NASA and made a game IRL using their rockets..."
The correct model of collisions is to conserve the 3D momentum before and after, and to conserve X% of the kinetic energy incoming and outgoing to each collision (you could make X depend on the materials involved in the collision, or have some random element). Also you wrote a = v0 - v t but you probably meant v = v0 + at.
Awe, I was hoping to see the typical chain, box pyramid, or cloth simulation - that physics engines seem to cut their teeth on.
It was quite interesting hearing you learning those concepts.
It looks like your integrator isn't correct, though, which would explain why bouncing the spheres off of each other looked janky. When things fall, you should be able to see their velocity build up over time.
A simple integrator would be the leap-frog algorithm. It assumes that acceleration is only a function of position and time, but it can be written in a few lines of code and it only has a quadratic error term.
Verlet integrator is also good probably better even
Haha, I read the bio, and you are making a game called ‘Project Jude’. Thanks 4 using my name 😅
I am curious about the math level required and used to make this? Such as calculating the spin.
That was hard to hear after that humongus amount of work "Even tho i have this i am never going to use it again"
Girl made a physics engine in code... Awesome...
Nice video; you should learn how to use reference for performance reasons, especially in a physic engine, like,
bool CollisionHandler::CheckCollision(const BoundingBox &box1, const BoundingBox &box2)
{
const Vector3d &box1Min = box1.GetMin();
....
Ok, first, the reference, then learn the const; it's nice to have. ;)
In c# class is a reference by default, and the struct is a copy.
In c++, by default, class, and struct are passed as copy, which is helpful in some cases, but both class and struct should be given to another function (or returned, when possible) as a ref or pointer (ref has the advantage of having a friendlier interface . instead of ->)
In the case of this function, you create (temporary) 2 copies of BoundingBox, then 4 more at the start. A lot of time is lost for a function that can be called millions of times per second ;p
I hope that will help you; keep up the excellent work.
Great video! I do exactly the same stuff in my free time :) Wait, you said you're using DirectX, but then I saw a wikipedia page about VBOs in OpenGL. So which one did you pick?
I ended up using DirectX. If I got the wrong wiki page my bad 😂
So refreshing to see a woman doing this, makes me go on. Fellow girlie here trying to make a physics simulator, and got overwhelmed by all the manly men giving manly advice and being condescending. Love ya!
i remember having a uni unit on this, it killed me
Composition over inheritance
As well as 4:03 where you check collision of sphere against the cube. You can just check if the distance between sphere center and at least one of 8 points of the cube is less than the radius. If at least one is smaller or equal, consider it intersection and stop further processing check. IMO it's much simplier to understand than dot product stuff
love the idea, but you should improve your physics's skill. you should devide the force by combined mess of objects, rather than applying the same acceleration to it.
6:02 IM LOSING MY MIND try making a game engine
Making Your self known or saying that You did something in life with this would be putting this information out there in most readable form on some sort of blog, with all known crack perspectives, such as operating system etc
You can do things in life without posting online to others about it. The only reason someone would do that is to make their work more known, and let other people learn from it. But not posting about it doesn't make you not accomplish great things in life. People spend their lives on passions and don't post about it, that doesn't mean they didn't do something in life. It just means it's only known to them and that's okay. I don't care if others don't know how I did this or simple don't know I've made something like this. It was fun and that's all the validation I need.
@@ZygerGFX this makes me do a phylosophy about purpose of our gadgets... everyday, till next century, if You are poor or have signs of not being productive or advanced in Your life, somebody will say to You to stop wasting Your time, and move on... when it's really unbelievably unimportant, unless the goal is material wealth or status... i really like that You found this as validation for Your time, as it could be an iQ point in general conversation, due to fact, artificial is based on all kinds of computer mechanics...
Holy fuck, I love the comic sans
Great visual explanations in this video! I found it interesting that you chose to use Direct X for this project. I haven't worked with it myself, but I put together a crappy little game engine in C with OpenGL. So I know how much work goes into building just the graphics side of things. Great work! I might take some notes from this for future videos.
thanks yeah I don't know much about graphics programming and got recommended DirectX by someone so just gave it a shot. I also tried OpenGL before and yeah it can take a lot of effort to get something working. also props to you for using C and OpenGl. :D
@@ZygerGFX Thanks. I started reading up on C++ after that project. Not fun in C lol
@@ZygerGFX OpenGL is a lot easier to work with but DirectX is more powerful from what I've heard
@@mariovelez578 oh fair enough I had no idea.
Endless enigmatic book in all languages. You can write a book with mirrors in all languages of the world. You can speak two languages at once, you just need to find the perfect reflection, same content, different translation. Infinite Mirrors. Pi 3.14 XBooks. Hybrid language!!!!!
One content, two languages. What I have now written may have a perfect mirror in another language.!!!!!!!!!!!!
Damn impressive stuff. How long did it take to make your engine
This one took like a month maybe slightly longer, but I wasn't working on it all the time and took time of in between so hard to tell how long it really took.
@@ZygerGFX Mine took just as much but I didn't even have textures or multiple objects
You should try Raylib out. It’s a library that simplifies that process
Oh okay ill check it out thanks
raylib is great
Bro all I wanna know is why VSCode refuses to acknowledge my g++ compiler man.
is that sound effect come from maple story snail die sound effect.
Maybe
Looks really cool. Is it on github?
No unfortunately not maybe I should at some point lol
@@ZygerGFX expect your project link!
Cool but physics is complicated lol. I wonder if you could add support for differential equations easily.
Where did you go to uni in the UK where you used DirectX11??
so cool!
Good job. But if you know nothing in how about physics engines works maybe you wanna make a 2D physics engine like Box 2D.
It's more easy.
Very very nice project and impressive results but gurl why did you do it in directx and c++ (I am a linux enthusiast)
question 1: does it conserve energy?
question 2: no, seriously, how well does it conserve energy
Hey, great video what website is that with the white background and all the explanations?
Which one ? the collision one is this one: developer.mozilla.org/en-US/docs/Games/Techniques/3D_collision_detection
Fantastic
Definitely the best Lady programmer on RUclips, I'm impressed, subscribed immediately
You're so cool!!! 😭😭😭
now do it in pure functional or imperative
I'm trying to make my own physics engine for 2D & 3D. Amazing work btw. I do have a question though: why do people say x game engine has better "physics" than y engine? Wouldn't they all basically use the same equations for things? I'd love to know the difference between the most popular game engines' physics engines. Maybe there's something I don't know yet, but I think that'd be an interesting video idea.
Nice
You should learn higher mathematics, too. Formulas you use don't let the movements of objects be soft enough
But nice start, keep going 👏