Thought I'd mention something that popped into my mind while watching, a while ago I watched a vid where it mentioned 2d collisions are usually handled by square root because of the fixed z position but not on 3d collisions because of too many calls, I say bull on that, here's how I would do it with just 2 sqrt() calls: 1. Get difference between x,y & z positions of both objects - for example o.x - p.x or p.x - o.x 2. Square root with y & z and then y & x 3. Divide the results by z and x, do not use y here 4. We now have normalised square roots between 0 and 2, multiply them together 5. If the final value is more than or equal to 1.0 a collision occurred, obviously no collision occurred if below 1 **Edit:** maybe the reverse on that last statement, haven't expanded my code to physics yet since I'm struggling to fix depth handling of my *.png code (plan to take total control over memory management so I can dump Lua in as the scripting environment since it's so popular)
@@nexovec Depends on how many objects your try to detect collisions with, for example if you know the main direction you're going is down then you can skip most of the objects around by simply checking if the normalisation of both x & z axis vs difference between the p.x/p.z and o.x/o.z is below 0.5, then you only have to check a few plus the objects directly below in same distance
I currently don't need physics in any of my projects but if I ever need to implement Box2D I know there's a great video waiting for me, thanks for making this Cherno!
@@irishbruse There are many games out there that don't have physics nor collision, but I'll answer your question. my first game was literally just a shoot 'em up and the framework I was using allowed for pixel perfect collisions (not part of the library but someone wrote a function for it) so I just used that because the only kind of collision I needed is one where both objects that collided would get deleted. My second project was a bit more complex but when I failed to setup Box2D with the framework I was using I just used the previous function to detect collision and then some simple algorithm that moves the object to it's previous position upon detecting collision to simulate solid objects. It wasn't perfect but got the job done. My current projects are a cellular-automata based game that has no collision, and some application that isn't a game. Hope that answers your question.
@@stickguy9109 I mean, the very point of this series is to build your own engine as a learning experience. I'm using a framework to handle graphics since I'm not read to learn that yet, but, you know... So yeah to answer your question, I make games to better learn C++, and an engine is not the best tool for that since it does most of the work for you.
@@stickguy9109 I am planning on starting gamedev for real so I'll be switching to an engine soon enough. Good luck with C++, it can be a pain in the ass at the start.
me who wrote my own 2D physics engine: _cries in shitty buggy physics engine that I didn't even finish_ also _smiles in having had fun while making it and having learned a lot while making it_
Same for me, but 3d. That thing was a mess, didn't even have features like constraints or IK, destabilized often, and wasn't very fast, but dang, it felt great to learn how to do it myself, and it worked pretty well for the small project I was doing at the time. I'm ultimately glad I didn't go with a library.
@@Drillgon That's the next thing I'm gonna do lol a 3D physics engine, a after that an nD physics engine right after I write a geometric algebra library
At 28:03, you can use unique pointer with incomplete types very well. However the destructor of your class must be defined in a place where it is complete, so doing `~Scene() = default` won't work, you have to define your destructor in the cpp file, as you already do. It took me a while to understand that.
Awesome video! Really helpful, even if a bit "rushed" (could use some extra explanation on the details or some tutorial walkthrough type of deal). :) Have you considered using ReSharper or similar tooling to generate boilerplate / switch-statements / use machine-learning to type stuff for you? Or do you maybe not like them and like to do things manually to "keep a hold of the reins" so to speak?
code is actually a command. So for the application u need to type vscode. And if you are in a folder in command prompt. You can type code . To open the folder. A quick little tip
Wait, does the error not tell you which files included the header? I use clang and when there's errors (any kind) in a header, it tells me all the includes from the source file to the error (eg "error in foo.h, included from bar.h included from main.cpp")
You know what, one of these days it might be nice to make people aware of the risks of carpal tunnel and techniques to avoid injuring yourself. If your hands are your living its very important to avoid injuring them. Im a concert pianist / software engineer with developing carpal tunnel :(
unique_ptr can absolutely be used for forward declarations, but you need to do the forward declaration outside the template. class b2World; std::unique_ptr m_World; // works std::unique_ptr m_World; // doesn't work There's also some specificity that depends on the destructors of the owning class not being inlined but yeah. Come to think of it for the sake of your video it's probably easier to just say you can't use them ;) A virtual ~Scene() = default; will be enough to allow std::default_delete to know enough to do the right thing.
if there is any possible to create a time-line of your video on the description zone where below the video? it will be more efficient to watch (like just jump to the time which I'm interest in) ^^ Sorry for my bad english :)
Because as he said, he likes being explicit with such things. And I honestly agree with him. They don't even have the same enum values and might be expanded later so it is confusing to mix them together.
PLEASE add softbody support actually there might be softbody support, i havent watched the whole video yet, but if there isnt softbody support you should add it
if you have separate 32-bit RGBA lighting buffer per pixel, color + light, total 64-bit, then you have more dynamic range, not messing up the color below
I wander? Would it be practical to dump a "clean project with include - lib and project - solution" in Dropbox ant would inporting it in an empty dev folder work as a valid startup solution for youself and any other aspiring coders out here?
For most languages, no, that wouldn't be a good solution. The problem C++ has is there are no standard package managers so generally I think most people just download libraries and set them up on a project by project basis. If there's a library you use very often like boost, I think it'd make sense to just keep it saved on your system somewhere. Other than that, setting up any specific library configuration would only take about 10 minutes or so, especially when that library utilizes CMake
Neat trick, but it's really nice when the compiler (here, gcc, but clang does similar) does it for you: In file included from ../include/QF/progs.h:37, from ../nq/include/sv_progs.h:35, from ../nq/include/server.h:41, from ../nq/source/sv_ded.c:43: As for ensuring code compiles before committing: that's a little much (probably doable), but before pushing has saved me a lot of pain, just use a pre-push hook: $ cat .git/hooks/pre-push #! /bin/sh cd ~/src/qf/quakeforge/o.o make -j
Hope you guys enjoy this absolute _banger_ of an episode! ❤️
thank you, Cherno!
Thought I'd mention something that popped into my mind while watching, a while ago I watched a vid where it mentioned 2d collisions are usually handled by square root because of the fixed z position but not on 3d collisions because of too many calls, I say bull on that, here's how I would do it with just 2 sqrt() calls:
1. Get difference between x,y & z positions of both objects - for example o.x - p.x or p.x - o.x
2. Square root with y & z and then y & x
3. Divide the results by z and x, do not use y here
4. We now have normalised square roots between 0 and 2, multiply them together
5. If the final value is more than or equal to 1.0 a collision occurred, obviously no collision occurred if below 1
**Edit:** maybe the reverse on that last statement, haven't expanded my code to physics yet since I'm struggling to fix depth handling of my *.png code (plan to take total control over memory management so I can dump Lua in as the scripting environment since it's so popular)
@@zxuiji too expensive.
@@nexovec Depends on how many objects your try to detect collisions with, for example if you know the main direction you're going is down then you can skip most of the objects around by simply checking if the normalisation of both x & z axis vs difference between the p.x/p.z and o.x/o.z is below 0.5, then you only have to check a few plus the objects directly below in same distance
What would it matter, subscriber interaction is virtually non existent in this channels comments. :P
I currently don't need physics in any of my projects but if I ever need to implement Box2D I know there's a great video waiting for me, thanks for making this Cherno!
What in the world are you making that doesnt need box2D it isnt just used for physics its most used for collision handling too
@@irishbruse There are many games out there that don't have physics nor collision, but I'll answer your question.
my first game was literally just a shoot 'em up and the framework I was using allowed for pixel perfect collisions (not part of the library but someone wrote a function for it) so I just used that because the only kind of collision I needed is one where both objects that collided would get deleted.
My second project was a bit more complex but when I failed to setup Box2D with the framework I was using I just used the previous function to detect collision and then some simple algorithm that moves the object to it's previous position upon detecting collision to simulate solid objects.
It wasn't perfect but got the job done.
My current projects are a cellular-automata based game that has no collision, and some application that isn't a game.
Hope that answers your question.
@@stickguy9109 I mean, the very point of this series is to build your own engine as a learning experience.
I'm using a framework to handle graphics since I'm not read to learn that yet, but, you know...
So yeah to answer your question, I make games to better learn C++, and an engine is not the best tool for that since it does most of the work for you.
@@stickguy9109 I am planning on starting gamedev for real so I'll be switching to an engine soon enough.
Good luck with C++, it can be a pain in the ass at the start.
@@stickguy9109
me who wrote my own 2D physics engine: _cries in shitty buggy physics engine that I didn't even finish_ also _smiles in having had fun while making it and having learned a lot while making it_
Those sound like happy tears 😊
@@KevinDay haha it's both happy and sad, but more so happy than sad
I am also guilty of this
Same for me, but 3d. That thing was a mess, didn't even have features like constraints or IK, destabilized often, and wasn't very fast, but dang, it felt great to learn how to do it myself, and it worked pretty well for the small project I was doing at the time. I'm ultimately glad I didn't go with a library.
@@Drillgon That's the next thing I'm gonna do lol a 3D physics engine, a after that an nD physics engine right after I write a geometric algebra library
honestly the troubleshooting is what makes watching these videos so much better then watching someone who doesn't explain debugging or error fixing.
At 28:03, you can use unique pointer with incomplete types very well. However the destructor of your class must be defined in a place where it is complete, so doing `~Scene() = default` won't work, you have to define your destructor in the cpp file, as you already do. It took me a while to understand that.
19:05 static body
20:10 collider
29:30 gravity
31:10 create body
Really enjoying the "redone" coding sessions and the way you explain the code you write line by line.
Congrats on 400k subs! You deserve it! ❤️
You are the best developer. I never seen like you before. You did make your own graphics and physics engine. congratulations bro!
Thank you so much, this helped me implement Box2D so easily, this is the best resource on implementing it I could find
Guy in Australia actually got arrested for interacting with a headerphile.
Awesome video! Really helpful, even if a bit "rushed" (could use some extra explanation on the details or some tutorial walkthrough type of deal). :)
Have you considered using ReSharper or similar tooling to generate boilerplate / switch-statements / use machine-learning to type stuff for you? Or do you maybe not like them and like to do things manually to "keep a hold of the reins" so to speak?
There's a bug in the UI for the box collider. The property size in the UI is binded to the offset of the component.
So close to 400k!
another great video , keep it up!
OMG SO EXCITED FOR THIS. HERE WE GO!
I'm not very knowledgeable in C++ nor graphics/physics programming but these videos are bangers
I love them
Thanks!
Damn was expecting this tomorrow
I see my mans been getting himself into some chess!
Whoa this is amazing
Awesome stuff
code is actually a command. So for the application u need to type vscode. And if you are in a folder in command prompt. You can type code . To open the folder. A quick little tip
thanks!
Noicee game engine episode
Wait, does the error not tell you which files included the header? I use clang and when there's errors (any kind) in a header, it tells me all the includes from the source file to the error (eg "error in foo.h, included from bar.h included from main.cpp")
You know what, one of these days it might be nice to make people aware of the risks of carpal tunnel and techniques to avoid injuring yourself. If your hands are your living its very important to avoid injuring them. Im a concert pianist / software engineer with developing carpal tunnel :(
love it!
unique_ptr can absolutely be used for forward declarations, but you need to do the forward declaration outside the template.
class b2World;
std::unique_ptr m_World; // works
std::unique_ptr m_World; // doesn't work
There's also some specificity that depends on the destructors of the owning class not being inlined but yeah. Come to think of it for the sake of your video it's probably easier to just say you can't use them ;)
A virtual ~Scene() = default; will be enough to allow std::default_delete to know enough to do the right thing.
29:47 "Meters per second per second" or "meters per second square"
You say about strings for enums, but is you projectionType still saved as an enum or a string?
When visual studio starts getting slow clear it's cache. It's speeds up SO MUCH.
if there is any possible to create a time-line of your video on the description zone where below the video?
it will be more efficient to watch (like just jump to the time which I'm interest in) ^^
Sorry for my bad english :)
2D is Cool!
Why would a string cast include dual quaternion? String cast seems to pull in a _lot_ of stuff.
is hazel now open to contribute? or still for patreons only?
That H looks like a hostinger logo, not exactly the same but very close. Very very close.
2D or not 2D. That is the question!
Underrated pun.
Alt title: Australian man teaches the web about forking
can you make a tutorial for java about box2D?
hey, is there any way to download your syntax coloring or your settings??
It’s a modified version of Visual Assist X’s syntax highlighting colour scheme
Thanks, preciate that
MR Viva Your welcome.
4:41 how is this extension called?
Why is it not fixed timestep?
RigidBodyToBox2D thing why not replace it with a cast overload?
Because as he said, he likes being explicit with such things. And I honestly agree with him. They don't even have the same enum values and might be expanded later so it is confusing to mix them together.
Are you developing this engine by yourself?
If you just added encode/decode to all your component types, then new types would be much easier to add serialisation for.
We've tried to implement box2d on our engine but miserably failed
What did you fail
Who's betting he's gonna pull in another library? I can understand doing it for physics but gizmos and the like come on!
You can go a step beyond this and just use a game engine too!
@@Chimponaut
#include
Thanks for watching everyone this is the end of the Hazel engine
@@irishbruse From what i know Unity also uses Box2d for its 2d physics engine
@@gommitoHuh. REALLY?
Oh no, box 2d
why use a custom build solution? all the including and compiling with dependencies is CMake's job.
Hey!
PLEASE add softbody support
actually there might be softbody support, i havent watched the whole video yet, but if there isnt softbody support you should add it
Box 2D doesn't support soft bodies
yes over an hour lol
multithreading support for all components, no actual main logic loop, only delegate calls()
if you have separate 32-bit RGBA lighting buffer per pixel, color + light, total 64-bit, then you have more dynamic range, not messing up the color below
what is a transparent of a transparent light, or just white light, un-colored light, all colors, bloom light, so you have RGB+A+L-RGB+W
I wander? Would it be practical to dump a "clean project with include - lib and project - solution" in Dropbox ant would inporting it in an empty dev folder work as a valid startup solution for youself and any other aspiring coders out here?
For most languages, no, that wouldn't be a good solution. The problem C++ has is there are no standard package managers so generally I think most people just download libraries and set them up on a project by project basis. If there's a library you use very often like boost, I think it'd make sense to just keep it saved on your system somewhere. Other than that, setting up any specific library configuration would only take about 10 minutes or so, especially when that library utilizes CMake
I like to collide my own polygons, so I'm gonna pass on Box2D.
Subscribed in case you decide to document it in videos
This is the way.
As a side note, Erin Catto (guy who made box2d) has some great presentations and papers on implementing physics.
hi
;)
;)
You should sort alphabetically. Always.
Neat trick, but it's really nice when the compiler (here, gcc, but clang does similar) does it for you:
In file included from ../include/QF/progs.h:37,
from ../nq/include/sv_progs.h:35,
from ../nq/include/server.h:41,
from ../nq/source/sv_ded.c:43:
As for ensuring code compiles before committing: that's a little much (probably doable), but before pushing has saved me a lot of pain, just use a pre-push hook:
$ cat .git/hooks/pre-push
#! /bin/sh
cd ~/src/qf/quakeforge/o.o
make -j