Saving and Loading Scenes! | Game Engine series

Поділитися
Вставка
  • Опубліковано 22 жов 2020
  • Patreon ► / thecherno
    Instagram ► / thecherno
    Live Stream ► / thecherno
    Hazel ► github.com/TheCherno/Hazel
    Twitter ► / thecherno
    Discord ► thecherno.com/discord
    Series Playlist ► thecherno.com/engine
    #Hazel

КОМЕНТАРІ • 89

  • @TheDarkSide11891
    @TheDarkSide11891 3 роки тому +100

    Honestly my favourite programming series on the internet. I wouldn't even expect this level of quality from a paid course, never mind a free UA-cam series. Thanks!

  • @yu_a_vi4427
    @yu_a_vi4427 8 місяців тому +6

    for new version of yaml-cpp just add a #define YAML_CPP_STATIC_DEFINE before including in any file,
    and turn on staticruntime in premakefile of yaml-cpp

    • @umairnasir4024
      @umairnasir4024 6 місяців тому

      @yu_a_vi4427 for some reason it is still giving me linking errors

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

    Thank you so much for keep doing these, you are making my dream of becoming an engine programmer actually posible.

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

    Im watching both and imo the incremental copy and paste is great because you explain the core of it, and the code isnt too complex to understand

  • @wakeupthesun3
    @wakeupthesun3 9 місяців тому +1

    Another thing to note (I'm not sure if this is covered later) is the scene is being deserialized in inverse order in which the original entities were added to the scene. You can see this by the original scene has the red square on top, covering the green square. When deserialized, the green square is on top. You can either serialize your entities backwards, or deserialize them backwards. I think deserializing backwards is better, because then the serialized file will match the order of your hierarchy panel. To deserialize backwards, you can make a vector of the entity nodes and then get a reverse iterator to that vector:
    auto entitiesNode = data["Entities"];
    // reverse it to add the entities in the order they were
    // originally added
    std::vector entitiesRev(entitiesNode.begin(),
    entitiesNode.end());
    for (auto it = entitiesRev.rbegin(); it != entitiesRev.rend(); ++it)
    {
    s_deserializeEntity(*it, mp_scene.get());
    }
    Have fun!

  • @mjthebest7294
    @mjthebest7294 Рік тому +10

    I had to define "YAML_CPP_STATIC_DEFINE" in the premake for the newer version of YAML, otherwise it will try to compile as a DLL

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

      It now build yaml project but cant link it to engine... there are errors like unresolved external dllimport...

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

      @@p3rk4n27 maybe the engine compiles as a .dll instead of a static .lib

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

      @@mjthebest7294 where did you put define? Engine or yaml project? I tried in yaml

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

      @@p3rk4n27 inside yaml premake

    • @user-ks3fu8ps5e
      @user-ks3fu8ps5e Рік тому

      @@p3rk4n27 Have you solved this problem, please

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

    27:21 Great thanks to you, CHERNO!

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

    I just implemented binary serialization/deserialization for my application with the cereal library. I read that was the fastest for CPP. Pretty cool stuff.

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

    I think copy paste is not an issue, you explain everything very good and understandable way.

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

    THE BEST!!!

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

    Serialization: In computing, serialization or serialisation is the process of translating a data structure or object state into a format that can be stored or transmitted and reconstructed later. From Wikipedia

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

    The code at 14:55 "m_Registry.each([&](........)" is deprecated in recent versions of entt. I used for iteration with registry.storage(): "for (const auto [ent, ref] : m_Scene->m_Registry.storage().each()) {...}. You can use the first element in the tuple (ent) as entity handle, which it is. I used because every entity has it. In the future i'm going to change it to or something like that, I presume.

  • @DexterLolInd
    @DexterLolInd 3 роки тому +25

    Is there any reason you've implemented this without reflection? Or is it just simplicity? For my engine I've added simple metaprogramming to allow for reflection, which means I don't have to write deserializers for every member variable, or write code to show it in the editor.

    • @qx-jd9mh
      @qx-jd9mh 3 роки тому +2

      @@mattmurphy7030 "gamedevs" are allergic to template metaprogramming

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

      how?

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

      He doesn't have a clue

    • @qx-jd9mh
      @qx-jd9mh 3 роки тому +2

      @@erniegutierrez410 lol every game dev bitches about templates

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

      Yes. Reflection information makes this a breeze.

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

    I'm wondering how animation and hierarchical entity updates are going to work in an ECS? Do you just do an animation pass outside the ECS?

  • @gautierlathuiliere6072
    @gautierlathuiliere6072 3 роки тому +16

    I start to really really miss the code tooling around the engine. It starts to look very "feature rushed" with UI and now Serialization hand written without a modular way of adding HUDs / Serializers. I think that we miss some architecture requirement (Registry & Metaprogramming) to allow the GPP to declare new components & register tools around them (HUD, Serializer). Then have the Entity Inspector use the Registry and rely on the user provided ImGui Widgets to do the job for us. Same with Serialization. I understand that at it's current state and for the sake of simplicity on YT it's probably not done (plus you can show more concrete features and not "tool" code). But I'm no beginer and making a Registry the right way is my current challenge, here I see all the applications where I should use it, but I still don't have a clue on how to achieve that. I'm sad :'(

    • @oskarpetersen5722
      @oskarpetersen5722 3 роки тому +5

      I've found that with these things, the most important thing to decide is the interface, and I like his view that serialisation is something external and to minimize its presence in the core code base. Once he's settled on an interface, the next task is to write something that works, and only after that it's time to start thinking about useful abstractions and modularizations. This last bit can easily take three or five times as long as the bit where you just got something to work, and you've gotta be ready for that. You're not gonna do it right first time around.
      I want to emphasize the _useful_ abstractions. I think you should almost always begin with a procedural implementation, and only when the code screams that it wants to be turned into objects is when you should consider doing it. If it's possible to implement and maintain the entire Python language or the Linux kernel in C, then clearly objects are not _needed_ for writing maintainable code, even in gigantic code bases. Starting in the other end, i.e. by defining the objects first and writing code around them later, usually gets you stuck in a code base with bad abstractions and unnatural interfaces.

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

      @@mattmurphy7030 Nah. Simple reflection code can be written in a weekend.

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

      @@johnjackson9767 I hate to bump this thread but how can C++ reflection code be written? As far as I'm aware there's no such think as true C++ reflection.

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

    thanks!

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

    hey cherno please tell how you can easily resolve merge conflicts in scene files

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

    Oh neato! Maybe you’ll actually see this. Thanks for making all of these videos. I’m not making an engine but learning how this stuff works is invaluable.

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

    Is there any reason why you didn't take same approach as with vec3 and apply it to Entity, Scene e.t.c.
    I mean by implementing operator for serialization.Maybe apply same to Entity components. Then instead of long method with IF statements to check component it will just call these operators. Or there is something to do with type inference from array of components? Thank you for your video series!
    P.S. Friendly reminder to drink water, stay hydrated dude :) I thought you coughing because of that

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

      @@mattmurphy7030 I'm not coding in cpp so I don't know if it's gonna work there and be best practices, maybe there are some pitfalls. I'm coding Swift, and language encourages you to implement it this way.

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

    Hey whats the diffrence between Hazelnut and Hazel ? I missed the last few streams ;)

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

      Hazel is the engine/runtime itself, Hazelnut is the editor UI

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

      (iirc) Hazel is the engine and Hazelnut is editor

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

      Thanks guys =)

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

    ProjectionType should be serialised to a string as well instead of your enum as int. Since you're doing this for readability. It makes your enums more robust when serialised as well.

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

    did you push to GitHub I didn't see the changes

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

    My god!

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

    I was afraid of serialization and deserialization, thought it was too complicated, until now. Thanks for the in-depth video!

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

    nice

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

    Hey Cherno why dont you analyse the new Assassins creed valhalla updated engine video. They released an updated final product and it looks pretty amazing.

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

    was wondering when you were going to add the c#(or whatever tbh) scripting layer because having to write directly in engine is kinda scaring me away from starting a project on hazel since working in engine is so easy to mess something up!

    • @akshayazariah
      @akshayazariah 3 роки тому +5

      Native scripting is essentially just adding code to the engine. It's good when you don't have to worry about internal engine-related stuff.

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

      @@akshayazariah It's been long since last time i heard about that term!

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

      @@akshayazariah having the buffer between me and the engine just eases the stress of worrying about the stupid stuff like naming conflicts ect and also having a scripting layer is easier than c++

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

      @@khaledhn1 Totally agree. That's why I have a Haxe scripting layer for my C engine. During the development, the game is run in a highly-optimized virtual machine, and all of the code is transpiled to highly-portable C code for release builds. This allows for the game to run "natively", without having to deal with naming conflicts and whatnot like you specified.

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

      Soon! Hazel-dev has had C# for a while now, you can see a demo of it in this video: ua-cam.com/video/g9HGp3icrIg/v-deo.html

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

    Not sure if you see these or not, but you should do a review of the Scorn gameplay on Xbox series X. I know you said you haven’t done a lot of Xbox stuff, so throwing it out there. Some very ‘interesting’ art.

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

    How do you save scripts tho?

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

    In C++ we have access to the raw memory, so would it be possible to make a "screenshot" of the memory and just dump that into a binary file? So the loading is just mapping the file into the memory? If we can't because of the dynamic allocations, would it be possible, for example, to make every allocation in the engine go through a custom allocator that knows where all blocks are so they can be saved and restored on demand? I have seen something like that in Handmade Hero

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

      If the classes only had trivial types and no need for bounds or validity checking then yes, but because these classes hold pointers and references to other objects, those objects will not be in the same place in memory the next time the app loads (the process will get a completely different randomized address space for its working set) so they would need to be manually processed anyway.
      The real question is why he would hand-code every class and every member when you could use reflection to just enumerate over the fields in every class? Adding a member to a class now requires writing UI code, serialization code, and deserialization code. Just home off the fact the the member is public and assume it should be (de)serialized.

  • @aloluk
    @aloluk Рік тому +1

    Why dont you just implement YAML

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

    Hahahahaha this is great... Im following this series but using d3d11

  • @0Brincess
    @0Brincess 3 роки тому

    👍👍👏👏

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

    can you do new series for diretX api

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

    Many of us don't know how to work with make files 😅
    A video about make, cmake, or premake will be great 💙

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

      @@blfunex I dont think it was an episode by its own, or I would notice it

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

      Woah! Never knew about it. Thanks a lot :)

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

    I'm fine with you copy pasting code as long as it's simple repetitive stuff.

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

    Third, and you are great man

  • @rio9415
    @rio9415 Рік тому +1

    With the new version of yaml-cpp, you need to change staticruntime to "on" in premake file of yaml-cpp project

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

    Hey, I heard you coughing 3 times during this stream... U sure u alright, mate?

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

    Babushka green square

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

    So who's gonna use hazel when It launches, I know I will

  • @Antonio-fo4fl
    @Antonio-fo4fl 3 роки тому

    First!! And love your vids!

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

    Third.
    But you probably don't care.

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

    Oh, so your a Game Engine creator? Name every game engine.

  • @AyushSingh-lo4qo
    @AyushSingh-lo4qo 3 роки тому

    If you feel that the code is complicated and/or requires some leaps of intuition for someone going through it first time, You might do well not to copy and paste but instead write it all. Otherwise yeah this is fine.

  • @wakeupthesun3
    @wakeupthesun3 9 місяців тому +1

    The stream syntax is so painfully verbose. If anyone is still following along - I recommend you do fingers a favor and do something like this:
    #define KEY(x)

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

    Please don't copy and paste, typing it out is way better.