The ENTITY Class | Game Engine series

Поділитися
Вставка
  • Опубліковано 13 тра 2024
  • Patreon ► / thecherno
    Instagram ► / thecherno
    Code ► github.com/TheCherno/Hazel
    Twitter ► / thecherno
    Discord ► thecherno.com/discord
    Series Playlist ► thecherno.com/engine

КОМЕНТАРІ • 128

  • @mohammednihad6755
    @mohammednihad6755 3 роки тому +28

    2:38 Maybe but you are the most lovely one :)

  • @maki9876
    @maki9876 3 роки тому +72

    looks like somebody slept well judging from the hair...

  • @goshisanniichi
    @goshisanniichi 2 роки тому +50

    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.

    • @Zero-id1yy
      @Zero-id1yy Рік тому +1

      i appreciate your effort i was lost for a moment

    • @dr.benway1892
      @dr.benway1892 8 місяців тому

      Noticed the same thing. I chose any_of for now.

  • @Gmitbotw
    @Gmitbotw 3 роки тому +49

    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

    • @TheCherno
      @TheCherno  3 роки тому +23

      Yep, my bad. I’ll change it next episode!

    • @RootsterAnon
      @RootsterAnon 3 роки тому +3

      Thank you kind sir!

  • @vector4games960
    @vector4games960 3 роки тому +8

    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

  • @wesleythomas6858
    @wesleythomas6858 3 роки тому +7

    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!

  • @jmac217x
    @jmac217x Рік тому +2

    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

  • @mohammednihad6755
    @mohammednihad6755 3 роки тому +12

    I really like your API and the way you write it

    • @joshuarowe8410
      @joshuarowe8410 3 роки тому +1

      @@JinskuKripta Which basically have interfaces that you interact with.

    • @mohammednihad6755
      @mohammednihad6755 3 роки тому +1

      @@JinskuKripta
      As Joshua said, that's exactly what an API is 😊

  • @user-tr2hc2xx3b
    @user-tr2hc2xx3b 3 роки тому

    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!

  • @zuhail339
    @zuhail339 3 роки тому +2

    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.

  • @stinabohmig5483
    @stinabohmig5483 2 роки тому +6

    registry.has is renamed to registry.all_of in the latest version

    • @not_halls
      @not_halls Місяць тому

      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

  • @NefKamerzon
    @NefKamerzon 3 роки тому +6

    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:

  • @user-qz4ut9mw5b
    @user-qz4ut9mw5b 3 роки тому +2

    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.

  • @dkthehunter596
    @dkthehunter596 3 роки тому

    Thank you for introducing me to the idea of 'thinking about how I would want my API to look'.

  • @moranero5910
    @moranero5910 3 роки тому

    I like to watch your videos even if I don't understand anything... you are the best.

  • @williamtetlie4274
    @williamtetlie4274 3 роки тому +2

    You are my best programmer at least! Love your videos :)

  • @WarrenMarshallBiz
    @WarrenMarshallBiz 3 роки тому +2

    FYI, love the new code zoom ... now I can sit on my couch and still see what you're doing!

  • @catinwall4256
    @catinwall4256 3 роки тому +2

    YESS! omg im so exciteddd

  • @DridriLaBastos
    @DridriLaBastos 3 роки тому

    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

  • @nexovec
    @nexovec 3 роки тому

    The rant about APIs is such a true story man

  • @GabeRundlett
    @GabeRundlett 3 роки тому

    perfect refresh of the youtube page to get this with no views and 22 seconds of it being uploaded!

  • @giladreich810
    @giladreich810 3 роки тому +24

    Next video: "Letting my wife giving me a haircut" ;)

  • @GohersWay
    @GohersWay 3 місяці тому

    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!

  • @rawgame
    @rawgame 3 роки тому +6

    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.

    • @TheCherno
      @TheCherno  3 роки тому +4

      I meant 12 bytes for both members - but yes I didn't count the padding

  • @spazbog123
    @spazbog123 3 роки тому +1

    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.

  • @amankaushik5833
    @amankaushik5833 3 роки тому +1

    Thanks a lot for your awesome videos :). I have learnt a lot of from your videos

  • @YashPandey_the_emperor
    @YashPandey_the_emperor 3 роки тому

    0:22
    *Windows notif alert on my Ubuntu* lmao.
    Great series sir!

  • @locomotivere4497
    @locomotivere4497 3 роки тому

    it's really nice! Fr Fr.

  • @sam_is_people1170
    @sam_is_people1170 2 роки тому

    thanks!!

  • @satvikreddy8662
    @satvikreddy8662 3 роки тому

    its really nice

  • @lorenzobolis5166
    @lorenzobolis5166 3 роки тому +4

    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?

  • @oliverpinder7221
    @oliverpinder7221 2 роки тому +3

    You could just use entt::handle which basically does the same thing

  • @MrLight_001
    @MrLight_001 3 роки тому

    Nice video, I like it, and I could to follow...

  • @charlesz88
    @charlesz88 3 роки тому +13

    It seems that the latest version of ETT from Github has deprecated entt::entity::has function, in favor of all_of.

    • @Matt23488
      @Matt23488 2 роки тому

      Thank you, I was trying to figure out why this wouldn't compile for me and that was it.

  • @armaanc.684
    @armaanc.684 Рік тому

    Instead of asserting whether we have the component in AddComponent, its possible to use emplace_or_replace instead of emplace

  • @thebutterapple6011
    @thebutterapple6011 3 роки тому

    is it possible to have a vector of entities? And like loop through and run commands on the components?

  • @oreostastegoods
    @oreostastegoods 3 роки тому +1

    Now do a getter for a multiple components :)
    auto&& [tag, transform] = entity.GetComponents()

  • @SimonBuchanNz
    @SimonBuchanNz 3 роки тому +1

    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.

  • @user-tr2hc2xx3b
    @user-tr2hc2xx3b 3 роки тому

    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?

  • @ShermanDev
    @ShermanDev 3 роки тому +1

    "Idk why u watch my videos" hahahahaha i love u

  • @OddStare
    @OddStare 3 роки тому +1

    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

  • @syne1456
    @syne1456 3 роки тому +1

    when cherno needs to watch his c++ videos xDDD

  • @embeddedbastler6406
    @embeddedbastler6406 Рік тому

    entt::handle already exists to add components directly to the entity.

  • @Zero-id1yy
    @Zero-id1yy Рік тому

    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?

  • @logiclegend8219
    @logiclegend8219 3 роки тому +1

    Which books do you use to make engine?

  • @hututudor
    @hututudor 3 роки тому

    How are you going to treat the ScriptComponent, since you can have more than one on an entity, right?

  • @turkia9254
    @turkia9254 3 роки тому

    I think he is the best programmer in the world

  • @yulaw760ify
    @yulaw760ify 3 роки тому

    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

  • @xxela_studio
    @xxela_studio Рік тому

    if you somehow include ,then it will conflict with std::max() inside entt.hpp . #define NOMINMAX before including the

  • @zhihuazhong9804
    @zhihuazhong9804 3 роки тому

    Hi Cherno, Is there any other video available for your Patreon? I want to join your patreon.

  • @subhrajyotimaji
    @subhrajyotimaji 2 роки тому

    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.

  • @jesseburstrom5920
    @jesseburstrom5920 3 роки тому

    When will Hazel 'split'? I mean it makes more sense having different modules due to complexity?

  • @justanormalperson
    @justanormalperson 3 роки тому

    nice

  • @adityapetkar3062
    @adityapetkar3062 3 роки тому

    When are you making a 3d game engine

  • @samiezaurus7541
    @samiezaurus7541 3 роки тому

    When is the channel for the hair launching ?

  • @drcatd1756
    @drcatd1756 3 роки тому

    What happen to your java game series 5 years ago

  • @dkthehunter596
    @dkthehunter596 3 роки тому

    Is there such thing as an entity that can exist without a Transform Component?

  • @teezy13500
    @teezy13500 3 роки тому +1

    Dude wake up! we need the Microsoft Xbox reaction especially the Halo reaction that's been criticized by the world.

  • @miguelg.s.1246
    @miguelg.s.1246 3 роки тому

    -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

  • @sc5shout
    @sc5shout 3 роки тому +2

    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.

    • @KarkleM
      @KarkleM 3 роки тому

      Just curious, what are your hangups with entt?

    • @sc5shout
      @sc5shout 3 роки тому

      @@KarkleM hangups? I think entt is great, but I believed that cherno would implement its own ecs.

  • @sebastianzander87
    @sebastianzander87 3 роки тому +1

    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
      @jamesmnguyen 3 роки тому

      For multiple components, you can just bundle them into one component. (A component with a list of audio, or colliders, or etc.)

    • @sebastianzander87
      @sebastianzander87 3 роки тому

      @@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).

    • @jamesmnguyen
      @jamesmnguyen 3 роки тому

      @@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.

    • @sebastianzander87
      @sebastianzander87 3 роки тому

      @@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.

    • @jamesmnguyen
      @jamesmnguyen 3 роки тому

      @@sebastianzander87 The list idea was a quick and dirty method. The level of indirection seems really taxing on the cache.

  • @shreddymetal
    @shreddymetal 3 роки тому

    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?

    • @link8290
      @link8290 3 роки тому

      Well standard procedural is still very powerful (see Linux written in c) , but oop definitely makes it easier especially when considering large codebades

    • @SimonBuchanNz
      @SimonBuchanNz 3 роки тому +1

      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.

  • @c.codyflick2210
    @c.codyflick2210 3 роки тому +1

    26:34 "Emptity"

    • @NoName-ui5ou
      @NoName-ui5ou 2 роки тому

      thats genius, im gonna use that in my version of the engine xD

  • @jesseburstrom5920
    @jesseburstrom5920 3 роки тому

    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!

  • @Tal__Shachar
    @Tal__Shachar 3 роки тому

    I love you

  • @jaleman19881
    @jaleman19881 3 роки тому +1

    I need you to talk about halo infinite...

  • @itjamesey6387
    @itjamesey6387 3 роки тому +1

    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.

  • @omaral-afa8879
    @omaral-afa8879 3 роки тому

    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

  • @jayasribhattacharya2048
    @jayasribhattacharya2048 3 роки тому +8

    you are not "the" best programmer in the world.
    you are "one of the" best programmers in the world. :-)

  • @Gavhouse
    @Gavhouse 3 роки тому

    Cherno do a video on the Halo Infinite gameplay reveal. It's absolutely mind blowingly bad.

  • @tonychu1998
    @tonychu1998 3 роки тому

    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)?

  • @NoName-ui5ou
    @NoName-ui5ou 2 роки тому

    26:20 why aren't you just using const std:.string& name = "Entity" as a default parameter in the constructor

  • @PrinceGupta-jo8lo
    @PrinceGupta-jo8lo 3 роки тому +1

    345th, lets gooooooo

  • @jesseburstrom5920
    @jesseburstrom5920 3 роки тому

    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?

  • @Legendarior
    @Legendarior 3 роки тому +6

    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.

    • @TheCherno
      @TheCherno  3 роки тому +3

      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

    • @dealloc
      @dealloc 3 роки тому +1

      @@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.

    • @Legendarior
      @Legendarior 3 роки тому

      @@TheCherno ty for the reply

  • @bartoszjot1472
    @bartoszjot1472 3 роки тому

  • @Madsycode
    @Madsycode 3 роки тому

    why not just put Entity as default tag in your create method

  • @yusufketen4674
    @yusufketen4674 2 роки тому +1

    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);
    }

  • @jahin_hossain
    @jahin_hossain 3 роки тому

    Can you show us your Game Engine's UI?

    • @supersquare
      @supersquare 3 роки тому +1

      He shows it in one of the recent Dev Logs on this channel

    • @jahin_hossain
      @jahin_hossain 3 роки тому

      @@supersquare Can I have the link?

    • @sablanex
      @sablanex 3 роки тому

      @@jahin_hossain Just go on his channel and watch the latest hazel dev log

  • @user-nr1qz3jc2y
    @user-nr1qz3jc2y 3 роки тому

    and second

  • @TheButtDr
    @TheButtDr 3 роки тому

    how tf do you type so fast

  • @RAFID
    @RAFID 3 роки тому

    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

  • @samuelrasquinha6712
    @samuelrasquinha6712 3 роки тому

    174th
    lul

  • @therunnerproject
    @therunnerproject 3 роки тому +2

    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.

  • @sysInt64
    @sysInt64 3 роки тому +1

    ентт

  • @HolyMethWizard
    @HolyMethWizard 2 роки тому

    I don't like object oriented programming only because of impure functions. Otherwise classes don't bother me

  • @user-nr1qz3jc2y
    @user-nr1qz3jc2y 3 роки тому

    I first)

  • @UnidayStudio
    @UnidayStudio 3 роки тому

    Man, ZOOM IN the code, I can't read it. Best regards!

    • @sablanex
      @sablanex 3 роки тому +2

      no

    • @whythosenames
      @whythosenames 3 роки тому +2

      no

    • @UnidayStudio
      @UnidayStudio 3 роки тому +1

      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.

    • @sablanex
      @sablanex 3 роки тому +1

      @@UnidayStudio how can it be pixelated at 240% zoom, everything is absolutely massive

    • @Alche_mist
      @Alche_mist 3 роки тому +1

      @@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.

  • @user-pm2ru6ir6n
    @user-pm2ru6ir6n 3 роки тому +2

    Зачем тебе рус, ты говришь по русски? )