How the Compile Time ECS works In my Minecraft Clone? + Templates

Поделиться
HTML-код
  • Опубликовано: 6 янв 2025

Комментарии • 40

  • @pine_and_appl
    @pine_and_appl 8 месяцев назад +3

    I’m highly recommend you release part of this separately as a tutorial on templates as it explains them really well. Cleared up all confusion with them I had.

  • @Ddos2212
    @Ddos2212 8 месяцев назад +18

    Click the right mouse button on your video and then stats for nerds. There you will see content loudness -10.6dB. This means the audio is too low. Try to keep it close to 0. -0.5 is okay too. Above 0 is too loud. Just so you know

    • @ExplosionPower1387
      @ExplosionPower1387 8 месяцев назад +2

      -10.6dB❌
      -6.8db✅

    • @Ddos2212
      @Ddos2212 8 месяцев назад

      @@ExplosionPower1387 What do you mean

    • @ExplosionPower1387
      @ExplosionPower1387 8 месяцев назад

      @@Ddos2212 ABOUT LOUDNESS YOU TALKING

    • @Juanao-nk3vu
      @Juanao-nk3vu 7 месяцев назад

      ​@ExplosionPower1387 no need to scream random youtube user

  • @3DWithLairdWT
    @3DWithLairdWT 8 месяцев назад +3

    Compile time composition > inheritance based ECS built in C++
    I love that!
    Please do more on the set up for keeping your arrays of entities & components contiguous over runtime and multiple updates?
    I've found this to be one of the most complicated parts of grasping ECS at it's most efficient form

    • @lowlevelgamedev9330
      @lowlevelgamedev9330  8 месяцев назад +1

      well I just store each entity in its own array so things are kinda well placed in memory

    • @arandomguythatdoesntpost
      @arandomguythatdoesntpost 8 месяцев назад

      ​@@lowlevelgamedev9330why not do vector

    • @arandomguythatdoesntpost
      @arandomguythatdoesntpost 8 месяцев назад

      why not a vector of Entity

    • @3DWithLairdWT
      @3DWithLairdWT 8 месяцев назад

      @@lowlevelgamedev9330 iirc the "Entity" in an ECS is just the ID used to index into the arrays of components that it has. Such that when you update "Position" for example, you traverse the array of all positions to update them, and the data is all contiguous in memory - hence the performance gain.
      If each object has its own data, and you have an array of objects, I'm pretty sure it's not really an ECS at that point. That's just OOP with good use of composition over inheritance, but you don't gain the cache coherence benefits of contiguous memory = much less cache misses

    • @3DWithLairdWT
      @3DWithLairdWT 8 месяцев назад +1

      @@arandomguythatdoesntpost That's not how an ECS works, it's a bit complicated to say. Contiguous memory is what makes ECS fast. The "Entity" part is just an ID that knows which arrays (components) it has.
      Cache coherence is why ECS is fast, using contiguous arrays.

  • @nicholastheninth
    @nicholastheninth 8 месяцев назад

    Ah yes, templates.
    I’ve done some cursed things with those, like creating a non-template lambda wrapper that can be directly created from any kind of lambda (as long as the lambda isn’t templated), so I can just use it in function parameters. Super useful.

  • @its_code
    @its_code 7 месяцев назад

    ❤❤❤❤

  • @rogerbusquetsduran5596
    @rogerbusquetsduran5596 5 месяцев назад

    I think this implementation is very limited. Have you ever checked entt or flecs? Entities for data oriented ECS are normally indexes, and compoenents are plain data stored in contiguous memory, in fact it the reason why ecs is so performant.

    • @lowlevelgamedev9330
      @lowlevelgamedev9330  5 месяцев назад

      I mean I also store things in contiguous memory so I don't have a problem, also its not limited by anything since I basically can make my entity however I want almost

    • @rogerbusquetsduran5596
      @rogerbusquetsduran5596 5 месяцев назад

      @@lowlevelgamedev9330 How would you add components at runtime? Probably your implementation will be faster, and of course if it is enough for what you need it's perfect then, since everything is figured out at compile time.
      Just my programmer mind trying to find ways to make it more flexible XD

  • @Broom-fz2gm
    @Broom-fz2gm 8 месяцев назад

    *This comment is quite long*
    Can you please do a C++ tutorial series for beginners who don't know how to use it? It would be nice to them if you made one. Yes, I know that you made C++ tutorials and an April Fools C++ tutorial series (which was just a joke), but I don't think those have all the things that beginners should know. I know that I can look for C++ tutorial series on RUclips, but this project you created is (very) complex, and your tutorials are perfect and they can avoid people making mistakes in C++ programming, so I think you're the perfect one to make a C++ tutorial series.

    • @lowlevelgamedev9330
      @lowlevelgamedev9330  8 месяцев назад

      I don't plan on making a cpp tutorial

    • @lowlevelgamedev9330
      @lowlevelgamedev9330  8 месяцев назад

      maybe later, rn I don't plan one because it takes a lot of time and it doesn't make that many views

    • @lowlevelgamedev9330
      @lowlevelgamedev9330  8 месяцев назад

      but I will make some beginner topics tutorials like the pointers one 💪

    • @Broom-fz2gm
      @Broom-fz2gm 8 месяцев назад

      @@lowlevelgamedev9330 Oh... but hey! I know how to make it get views!

  • @nickst2797
    @nickst2797 8 месяцев назад

    Very clean code.

  • @arandomguythatdoesntpost
    @arandomguythatdoesntpost 8 месяцев назад

    for the add example, why not do:
    int addi(...) { ... }
    float addf(...) { ... }

    • @tuhkiscgibin6627
      @tuhkiscgibin6627 8 месяцев назад

      Because C++...

    • @lowlevelgamedev9330
      @lowlevelgamedev9330  8 месяцев назад +1

      well that's not the point, the point of templates is to be able to do what I showed in the end, make a function that can work with anything, if you just need float and int yes you would do that

    • @tuhkiscgibin6627
      @tuhkiscgibin6627 8 месяцев назад

      @@lowlevelgamedev9330 sadly that's how they are used in some codebases

  • @bluesillybeard
    @bluesillybeard 8 месяцев назад +1

    C does has templates. They're called "macros", and if you thought C++ templates were hard, C "template" macros are about 10 times worse.
    Anyway, this system seems really nice, and is quite similar to what I'm developing for my own game project. The only fundamental difference is that mine is written in Zig.

    • @lowlevelgamedev9330
      @lowlevelgamedev9330  8 месяцев назад +1

      well they are totally different and I know how to use both and I would say that templates are worse simply becausw they have a ton of rules with move semantics and decay and forwarding and stuff,
      yes zig is better for this kinda stuff 💪

  •  8 месяцев назад

    And with templates you can use concepts to restrict what you do (saner than SFINAE) and you can be very stupid with templates. I love templates but they also drive me crazy

    • @lowlevelgamedev9330
      @lowlevelgamedev9330  8 месяцев назад

      yes tho I have never tried concepts, fortunatelly, for what I do here I don't need concepts or sfinae, so things are rather simple

    •  8 месяцев назад

      @@lowlevelgamedev9330 Concepts are great to limit your template parameter options or to create interfaces that don't use virtual polymorphism, so I would strongly argue anybody that uses virtual polymorphism should look at them

    •  8 месяцев назад

      @@lowlevelgamedev9330 Concepts are great for limiting the allowed inputs into your templates (much easier than with SFINAE), and they are fantastic for creating interfaces instead of using pure virtual methods that you override, which are more expensive (and again, easier than SFINAE).
      For example: say that you have an IAnimal interface with the methods Speak and Move, simple stupid, but it works, you could do:
      class IAnimal
      {
      public:
      virtual ~IAnimal() = default;
      virtual auto Speak() -> void = 0;
      virtual auto Move() -> void = 0;
      };
      class Dog : public IAnimal
      {
      public:
      auto Speak() -> void final
      {
      std::cout void final
      {
      std::cout Speak();
      animal->Move();
      }
      int main()
      {
      IAnimal* dog = new Dog();
      GiveMeAnimal(dog);
      delete dog;
      }
      Or you can simply use concepts and do even better, and using the stack instead of the heap:
      template
      concept IAnimal = requires(T a) {
      { a.Speak() } -> std::same_as;
      { a.Move() } -> std::same_as;
      };
      class Dog
      {
      public:
      auto Speak() const
      {
      std::cout

  • @brockdaniel8845
    @brockdaniel8845 8 месяцев назад +1

    that noise cancelation

  • @Felix-att
    @Felix-att 8 месяцев назад +1

    Ok then, First!😂

  • @ThatOneGuy-dc2xe
    @ThatOneGuy-dc2xe 8 месяцев назад

    I will not say “first” I will not say “first”..