I think ".has" has been removed from newer versions of EnTT. m_scene->m_registry.all_of( m_entity_handle ); or (...).any_of are the functions to use now. I'd image that since they're template parameters the compiler would optimize them down to exactly the same thing for just one component but you'd have to benchmark both to be sure. Either way, I don't imagine that they're different enough to matter.
you should use entt::null instead of 0 to default init your entity handle. From the docs: Be aware that entt::null and entity 0 aren't the same thing. Likewise, a zero initialized entity isn't the same as entt::null
I had to watch these few EnTT videos a few times to get it but I feel like it was worth it to get a full understanding and now my code actually compiles which is a plus
2:40 But you're definitely one the smartest I've encountered, and you teach in a really awesome way, so at least for me, you are pretty up there with the best of the best c:
This entity class is great with one exception - if you want a component to store an entity (i.e storing parent entity), now you a storing 16 bytes instead of 4.
7:20 I couldn't agree more. And in general, code is for human, I took me some years to understand that but code is for human and should be written with readability in mind. Creating stuff that the CPU can understand is the goal of the compiler
registry.has is renamed to registry.all_of Around ninteen mark templated entity to Add component with any kind of args, example glm vec4 with parameters!
The raw pointer "m_Scene" on the x64 platform is 8bytes. Not 12bytes (11:53) If "m_EntityHandle" is UInt32 (4bytes) in size, your Entity class will get padded, and it will end up in 16bytes.
I might be drunk (as a fellow Aussie I have written the bestest stuff and the worstest stuff whilst under the influence) and a c# programmer who has little c/c++ experience but I was yelling "brackets!" at the screen at the end there. Also thanks for helping me navigate entities in my far inferior engine for my game (well restoration of a classic) that will likely never see daylight but it keeps my brain ticking an me occupied.
11:50 that should be 16 bytes, because pointers are 8-aligned. On a more serious note, aren't you worried that the indirection to the scene on every entity access is gonna be too taxing?
Why would you switch to a intrusive ref counting system? When using make_shared the count shares the allocation, which is the only really compelling use of intrusive refs I can think of.
Trying to implement EnTT to my project I stumbled upon one design problem I could not find the way to solve myself. What to do if we have two components that should have some parts in similar and an entity that should have both these components? For example, two components: Physical and something like Geometrical. Both of them should have, for example, position of type vec3, they both describe position of entity in space. And we have en entity Player that must have both Physical and Geometrical components. What to do with these positions now? My thoughts on that led me to just pulling out vec3 position from both of components and making one more that contains only position vector. But is this the right workaround the problem (I guess it's not) or are there some better solutions?
So if i understood those three last videos right; we have an ECS where the back end is data oriented like the new Unity's ECS minus the burst compiler and Jobs system but on the front end it still functions like the classic Unity's scripting api with components and gameObjects. If it i got this right i don't understand why Unity is enforcing the data oriented workflow because i find cruelly hard
is there any way to have like, entity templates, like instead of creating every entity by adding all the components every time just making a entity that has certain components by default?
This is to Cherno. Can you do a video on xbox series x system like you done on the ps5. I think it be cool to here in your own words what you think. Like the ps5 3 part video you done
2:37 I don't need to know whether you are the best programmer in the world or not. For me, you are the best mentor to teach modern C++, OpenGL, and Game Programming. The way you organize the code and abstract them in several layers with a long term vision I don't like to follow any other approach apart from yours. Eagerly waiting if you could start a tutorial on volume rendering. Thanks a lot for being my best programming guide.
I am a bit disappointed that hazel uses entt, it is what it is doe :(. Fortunately, Benny's got ecs series, but with components that inherit from a base class which I do not hate, but also am not too much into.
Do you want TransformComponents and TagComponents to be removable? Because at the moment they still can be removed. Also, do you not plan on supporting multiple components of the same type in a single entity? I know that Unity allows this for certain component types and I personally find it useful for colliders, audio sources and such things. It is however also common practice to create child entities for a single component in that case.
@@jamesmnguyen This is not very good software architecture/programming practice. You probably want to treat all components the same with the editor in mind. What for example if you later on decide to add another audio source component. Now you either have to remove the previous audio source and create it new or you need some new functionality to clone/move components or data therein between normal component types and multi-component types (i.e. the list type).
@@sebastianzander87 Okay, the another approach is to divide your entity into child entities that contain unique components. In game design this would make sense as long as the entities have a transform hierarchy. Adding and removing audios sources is slightly more annoying but performance wise, nothing is lost. Trying to support multiple components would add some overhead.
@@jamesmnguyen Yes, that is another common option. One that makes the software design elegant and efficient. I thought about your list approach a little more and I guess you could implement multi-component types to always use the lists. Even if they only hold a single component. One could use object orientation and generics to create a generic list base class. But still you would need to handle those component types differently when displaying/editing in the editor.
1:40 "it seems to be the trend these days that everyone hates on OOP". I'm personally not involved in any programming communities so I had no idea this was a thing. How are these people creating big projects without OOP then? What are the alternatives to OOP?
Well standard procedural is still very powerful (see Linux written in c) , but oop definitely makes it easier especially when considering large codebades
Functional is generally argued as the "competitor" but it doesn't really make sense to compare them directly. How I look at it though, is that the main problem that classes actually solve is modularity, eg you can see everything that can touch some value in one place so you can reason about it and safely make changes. For an alternative solution to this, in JavaScript you can return an object that is a bag of local functions that have access to local state, but don't need or use a "this" parameter, so you can split up and pass around the functions themselves, or in C you can define an opaque pointer and a set of functions that use in the header, so the implementation can be changed safely, etc., but all of these depend on whatever quirks of the language to support hiding details you can find. If classes are the best option, then great, use that, just don't get dogmatic about it. The bigger problem is that classes tie inheritance, specifically of state, to subtyping. This is a huge problem as systems get larger, for example you get more and more pressure to push functionality into a base class so it can be used in multiple sub classes, which then requires pushing state it uses into the base class, which can easily end up with "God" classes that try to do everything and are larger than the rest of the application! This is always solvable with enough effort, discipline and cleverness, but the point of a paradigm is to not need those. There are a lot of other more specific complaints I won't get into, but you can find long arguments on both sides with easily if you're interested. Keep an open mind, but a healthy skepticism: the best thing in any specific case doesn't have to follow any general rule, but knowing a little of different styles will help you think about the best option. Really, you're better off spending your mental effort learning about type theory (specifically about how they approach state management) and different languages approaches to it, but unfortunately I don't think there are many good collected resources for programmers on it, ironically.
So a game engine is 'coded referential flow reference of active depiction projecting world fantasies'? It's building a world with code, make it dense or complex enough to be able to get logic simple... ah it is needed, abstraction to be able to simply reference. Great!
Please do a video on halo infinite graphic "problems" and the other problems it had like how the shadows would pop into place etc, and what should be to make it better.
Could you react on Bolt, after Unity buy it and make it free, and what's your opinion about visual scripting and make programming easy for normal users
26:20 what's the difference between assigning the name to TagComponent directly (what Cherno did) and forward the name to entt emplace (put inside the AddComponent function)?
I pick up programming along the way if a class is good then i use it, gives freedom to resolve problems. Use class or not depends... Same as split up server in many files doing different things, makes sense. Is graph card incorporated or not yet like Directx 12 Ultimate in the future. Hm nooo not yet but then Hazel should be convertible to any system?
Why do you think that entity by default should have a transform, there could be entity which lifetime is tied to the scene, but doesn't need to be rendered. Like all kind of manager type entity that manages in game event shouldn't have (imo) useless data tied to it with a transform component.
Because my definition of an “Entity” is something with a transform. Of course there can be other behaviours and functions that exist within a scene (eg. a meta game script), but I wouldn’t necessarily classify those as “entities”... at least not in Hazel
@@TheCherno I would describe an entity as something that can be used to manage the lifetime of systems and components (in ECS terms). This way, disposing an entity would also dispose of the attached systems (lifecycle) and components (data) of the given entity. It depends on the use-cases and requirements of the engine, of course.
Guys if you have a has function error, just change with "all_of" like below template bool HasComponent() { return m_Scene->m_Registry.all_of(m_EntityHandle); }
I think you shouldn't build transform as a fixed component, if I use entites for something else, then you still have all the transform components. That just needs unnecessary memory. Unity new ECS has no fixed components, because entities can also be something else. As example an inventory does not need a transform.
So what do y'all recommend me to do? Stop watching his channel? Because I don't have a full hd monitor so I can't read anything (specially on the phone). I just see some pixelated lines.
@@UnidayStudio It's well readable at 360p and more. If you go below, then sorry, text has problems in general in so small of definitions and I doubt sizing up would help much.
2:38 Maybe but you are the most lovely one :)
looks like somebody slept well judging from the hair...
We are very glad he did
I think ".has" has been removed from newer versions of EnTT.
m_scene->m_registry.all_of( m_entity_handle );
or (...).any_of are the functions to use now. I'd image that since they're template parameters the compiler would optimize them down to exactly the same thing for just one component but you'd have to benchmark both to be sure. Either way, I don't imagine that they're different enough to matter.
i appreciate your effort i was lost for a moment
Noticed the same thing. I chose any_of for now.
you should use entt::null instead of 0 to default init your entity handle. From the docs: Be aware that entt::null and entity 0 aren't the same thing. Likewise, a zero initialized entity isn't the same as entt::null
Yep, my bad. I’ll change it next episode!
Thank you kind sir!
The way that the entity component system works is so different to what I initially thought. This video and this series have taught me so many things
Really enjoying the “explain as you write” approach! Was concerned it wouldn’t be as good as the old prepared vids but it has worked out great!
I had to watch these few EnTT videos a few times to get it but I feel like it was worth it to get a full understanding and now my code actually compiles which is a plus
I really like your API and the way you write it
@@JinskuKripta Which basically have interfaces that you interact with.
@@JinskuKripta
As Joshua said, that's exactly what an API is 😊
What a nice chapter of game development to learn, was looking forward for this one for a long time. Thank you very much for it!
He does so much for us bring us quality content even for free. Thanks Cherno I am surely going to support your channel from next year asap.
registry.has is renamed to registry.all_of in the latest version
i looked into the comments first instead of goin to google to see if it was renamed.
and im glad i did cuz its the second comment i see
2:40 But you're definitely one the smartest I've encountered, and you teach in a really awesome way, so at least for me, you are pretty up there with the best of the best c:
This entity class is great with one exception - if you want a component to store an entity (i.e storing parent entity), now you a storing 16 bytes instead of 4.
Thank you for introducing me to the idea of 'thinking about how I would want my API to look'.
I like to watch your videos even if I don't understand anything... you are the best.
You are my best programmer at least! Love your videos :)
FYI, love the new code zoom ... now I can sit on my couch and still see what you're doing!
YESS! omg im so exciteddd
7:20 I couldn't agree more. And in general, code is for human, I took me some years to understand that but code is for human and should be written with readability in mind. Creating stuff that the CPU can understand is the goal of the compiler
The rant about APIs is such a true story man
perfect refresh of the youtube page to get this with no views and 22 seconds of it being uploaded!
Next video: "Letting my wife giving me a haircut" ;)
registry.has is renamed to registry.all_of
Around ninteen mark templated entity to Add component with any kind of args, example glm vec4 with parameters!
The raw pointer "m_Scene" on the x64 platform is 8bytes. Not 12bytes (11:53) If "m_EntityHandle" is UInt32 (4bytes) in size, your Entity class will get padded, and it will end up in 16bytes.
I meant 12 bytes for both members - but yes I didn't count the padding
I might be drunk (as a fellow Aussie I have written the bestest stuff and the worstest stuff whilst under the influence) and a c# programmer who has little c/c++ experience but I was yelling "brackets!" at the screen at the end there. Also thanks for helping me navigate entities in my far inferior engine for my game (well restoration of a classic) that will likely never see daylight but it keeps my brain ticking an me occupied.
Thanks a lot for your awesome videos :). I have learnt a lot of from your videos
0:22
*Windows notif alert on my Ubuntu* lmao.
Great series sir!
it's really nice! Fr Fr.
thanks!!
its really nice
11:50 that should be 16 bytes, because pointers are 8-aligned.
On a more serious note, aren't you worried that the indirection to the scene on every entity access is gonna be too taxing?
You could just use entt::handle which basically does the same thing
Nice video, I like it, and I could to follow...
It seems that the latest version of ETT from Github has deprecated entt::entity::has function, in favor of all_of.
Thank you, I was trying to figure out why this wouldn't compile for me and that was it.
Instead of asserting whether we have the component in AddComponent, its possible to use emplace_or_replace instead of emplace
is it possible to have a vector of entities? And like loop through and run commands on the components?
Now do a getter for a multiple components :)
auto&& [tag, transform] = entity.GetComponents()
Why would you switch to a intrusive ref counting system? When using make_shared the count shares the allocation, which is the only really compelling use of intrusive refs I can think of.
Trying to implement EnTT to my project I stumbled upon one design problem I could not find the way to solve myself. What to do if we have two components that should have some parts in similar and an entity that should have both these components? For example, two components: Physical and something like Geometrical. Both of them should have, for example, position of type vec3, they both describe position of entity in space. And we have en entity Player that must have both Physical and Geometrical components. What to do with these positions now?
My thoughts on that led me to just pulling out vec3 position from both of components and making one more that contains only position vector. But is this the right workaround the problem (I guess it's not) or are there some better solutions?
"Idk why u watch my videos" hahahahaha i love u
So if i understood those three last videos right; we have an ECS where the back end is data oriented like the new Unity's ECS minus the burst compiler and Jobs system but on the front end it still functions like the classic Unity's scripting api with components and gameObjects. If it i got this right i don't understand why Unity is enforcing the data oriented workflow because i find cruelly hard
when cherno needs to watch his c++ videos xDDD
entt::handle already exists to add components directly to the entity.
is there any way to have like, entity templates, like instead of creating every entity by adding all the components every time just making a entity that has certain components by default?
Which books do you use to make engine?
How are you going to treat the ScriptComponent, since you can have more than one on an entity, right?
I think he is the best programmer in the world
This is to Cherno. Can you do a video on xbox series x system like you done on the ps5. I think it be cool to here in your own words what you think. Like the ps5 3 part video you done
if you somehow include ,then it will conflict with std::max() inside entt.hpp . #define NOMINMAX before including the
Hi Cherno, Is there any other video available for your Patreon? I want to join your patreon.
2:37 I don't need to know whether you are the best programmer in the world or not. For me, you are the best mentor to teach modern C++, OpenGL, and Game Programming. The way you organize the code and abstract them in several layers with a long term vision I don't like to follow any other approach apart from yours. Eagerly waiting if you could start a tutorial on volume rendering. Thanks a lot for being my best programming guide.
When will Hazel 'split'? I mean it makes more sense having different modules due to complexity?
nice
When are you making a 3d game engine
When is the channel for the hair launching ?
What happen to your java game series 5 years ago
Is there such thing as an entity that can exist without a Transform Component?
Dude wake up! we need the Microsoft Xbox reaction especially the Halo reaction that's been criticized by the world.
-28:58-- This doesn't compile with gcc and there's a much better way of doing it using -*-entt::null-* Nevermind fixed in next episode xD
I am a bit disappointed that hazel uses entt, it is what it is doe :(. Fortunately, Benny's got ecs series, but with components that inherit from a base class which I do not hate, but also am not too much into.
Just curious, what are your hangups with entt?
@@KarkleM hangups? I think entt is great, but I believed that cherno would implement its own ecs.
Do you want TransformComponents and TagComponents to be removable? Because at the moment they still can be removed. Also, do you not plan on supporting multiple components of the same type in a single entity? I know that Unity allows this for certain component types and I personally find it useful for colliders, audio sources and such things. It is however also common practice to create child entities for a single component in that case.
For multiple components, you can just bundle them into one component. (A component with a list of audio, or colliders, or etc.)
@@jamesmnguyen This is not very good software architecture/programming practice. You probably want to treat all components the same with the editor in mind. What for example if you later on decide to add another audio source component. Now you either have to remove the previous audio source and create it new or you need some new functionality to clone/move components or data therein between normal component types and multi-component types (i.e. the list type).
@@sebastianzander87 Okay, the another approach is to divide your entity into child entities that contain unique components. In game design this would make sense as long as the entities have a transform hierarchy. Adding and removing audios sources is slightly more annoying but performance wise, nothing is lost.
Trying to support multiple components would add some overhead.
@@jamesmnguyen Yes, that is another common option. One that makes the software design elegant and efficient.
I thought about your list approach a little more and I guess you could implement multi-component types to always use the lists. Even if they only hold a single component. One could use object orientation and generics to create a generic list base class. But still you would need to handle those component types differently when displaying/editing in the editor.
@@sebastianzander87 The list idea was a quick and dirty method. The level of indirection seems really taxing on the cache.
1:40 "it seems to be the trend these days that everyone hates on OOP".
I'm personally not involved in any programming communities so I had no idea this was a thing. How are these people creating big projects without OOP then? What are the alternatives to OOP?
Well standard procedural is still very powerful (see Linux written in c) , but oop definitely makes it easier especially when considering large codebades
Functional is generally argued as the "competitor" but it doesn't really make sense to compare them directly.
How I look at it though, is that the main problem that classes actually solve is modularity, eg you can see everything that can touch some value in one place so you can reason about it and safely make changes. For an alternative solution to this, in JavaScript you can return an object that is a bag of local functions that have access to local state, but don't need or use a "this" parameter, so you can split up and pass around the functions themselves, or in C you can define an opaque pointer and a set of functions that use in the header, so the implementation can be changed safely, etc., but all of these depend on whatever quirks of the language to support hiding details you can find. If classes are the best option, then great, use that, just don't get dogmatic about it.
The bigger problem is that classes tie inheritance, specifically of state, to subtyping. This is a huge problem as systems get larger, for example you get more and more pressure to push functionality into a base class so it can be used in multiple sub classes, which then requires pushing state it uses into the base class, which can easily end up with "God" classes that try to do everything and are larger than the rest of the application! This is always solvable with enough effort, discipline and cleverness, but the point of a paradigm is to not need those.
There are a lot of other more specific complaints I won't get into, but you can find long arguments on both sides with easily if you're interested. Keep an open mind, but a healthy skepticism: the best thing in any specific case doesn't have to follow any general rule, but knowing a little of different styles will help you think about the best option.
Really, you're better off spending your mental effort learning about type theory (specifically about how they approach state management) and different languages approaches to it, but unfortunately I don't think there are many good collected resources for programmers on it, ironically.
26:34 "Emptity"
thats genius, im gonna use that in my version of the engine xD
So a game engine is 'coded referential flow reference of active depiction projecting world fantasies'? It's building a world with code, make it dense or complex enough to be able to get logic simple... ah it is needed, abstraction to be able to simply reference. Great!
I love you
I need you to talk about halo infinite...
Please do a video on halo infinite graphic "problems" and the other problems it had like how the shadows would pop into place etc, and what should be to make it better.
Could you react on Bolt, after Unity buy it and make it free, and what's your opinion about visual scripting and make programming easy for normal users
Yes it's free
you are not "the" best programmer in the world.
you are "one of the" best programmers in the world. :-)
Not even close, sorry
@@iristech810 😂🤣
Cherno do a video on the Halo Infinite gameplay reveal. It's absolutely mind blowingly bad.
26:20 what's the difference between assigning the name to TagComponent directly (what Cherno did) and forward the name to entt emplace (put inside the AddComponent function)?
26:20 why aren't you just using const std:.string& name = "Entity" as a default parameter in the constructor
345th, lets gooooooo
I pick up programming along the way if a class is good then i use it, gives freedom to resolve problems. Use class or not depends... Same as split up server in many files doing different things, makes sense. Is graph card incorporated or not yet like Directx 12 Ultimate in the future. Hm nooo not yet but then Hazel should be convertible to any system?
Why do you think that entity by default should have a transform, there could be entity which lifetime is tied to the scene, but doesn't need to be rendered. Like all kind of manager type entity that manages in game event shouldn't have (imo) useless data tied to it with a transform component.
Because my definition of an “Entity” is something with a transform. Of course there can be other behaviours and functions that exist within a scene (eg. a meta game script), but I wouldn’t necessarily classify those as “entities”... at least not in Hazel
@@TheCherno I would describe an entity as something that can be used to manage the lifetime of systems and components (in ECS terms). This way, disposing an entity would also dispose of the attached systems (lifecycle) and components (data) of the given entity.
It depends on the use-cases and requirements of the engine, of course.
@@TheCherno ty for the reply
why not just put Entity as default tag in your create method
Guys if you have a has function error, just change with "all_of" like below
template
bool HasComponent()
{
return m_Scene->m_Registry.all_of(m_EntityHandle);
}
Can you show us your Game Engine's UI?
He shows it in one of the recent Dev Logs on this channel
@@supersquare Can I have the link?
@@jahin_hossain Just go on his channel and watch the latest hazel dev log
and second
how tf do you type so fast
hey this is not related to the video but when you get time can you please react to the mafia definitive edition gameplay reveal thank you
174th
lul
I think you shouldn't build transform as a fixed component, if I use entites for something else, then you still have all the transform components. That just needs unnecessary memory.
Unity new ECS has no fixed components, because entities can also be something else. As example an inventory does not need a transform.
ентт
I don't like object oriented programming only because of impure functions. Otherwise classes don't bother me
I first)
Man, ZOOM IN the code, I can't read it. Best regards!
no
no
So what do y'all recommend me to do? Stop watching his channel? Because I don't have a full hd monitor so I can't read anything (specially on the phone). I just see some pixelated lines.
@@UnidayStudio how can it be pixelated at 240% zoom, everything is absolutely massive
@@UnidayStudio It's well readable at 360p and more. If you go below, then sorry, text has problems in general in so small of definitions and I doubt sizing up would help much.
Зачем тебе рус, ты говришь по русски? )