Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Save & load): new crate bevy_gltf_save_load + lots of upgrades & improvements #95

Merged
merged 46 commits into from
Jan 10, 2024

Conversation

kaosat-dev
Copy link
Owner

@kaosat-dev kaosat-dev commented Jan 4, 2024

  • feat(bevy_gltf_save_load): saving & loading implemented

    • created new crate for save & load features, uses & filters out blueprints for efficient loading
    • saving & loading, even with dynamically spawned nested hierarchies works
    • component filter , resource filter & save path root are configurable
    • for saving: added removal & cleanup logic for children component with children
      that have been filtered out: ie no more invalid children getting stored in the save files !
    • added sending of event once saving is done
  • feat(examples/save-load): example for the new crate

    • loading level static & dynamic data as blueprints
    • added a bit of ui when entering saving & loading states & cleanup when exiting
  • feat(bevy_gltf_blueprints): significant rewrite of how the crate works

    • simplified spawning process, no more spawning children containing blueprints etc
    • simplified post process : instead of copying original entity into blueprint root
      we now copy blueprint root data (components & children) into the original entity ! fixes Fix need to register every component for bevy_gltf_blueprints, even if they are not needed for the gltf -> components logic #96
    • much simpler code wise
    • solves issue with needing to register components that we only use on the bevy side (not gltf)
      since we are not copying the bevy data into the blueprints data
    • added copyComponents helper to copy components from one entity to another, excluding existing
      components on the target entity, & some bells & whistles
    • Name is now optional when spawning a blueprint: closes Remove need for Name component to spawn blueprints #97
    • Transform is now optional when spawning a blueprint: closes Remove need for Transform component to spawn blueprints  #98
    • removed transform from bundle (BREAKING change)
    • added (optional) NoInBlueprint component to have finer control over whether to inject the InBlueprint component inside spawned blueprint entities
    • added (optional) Library component, so we can override library path when we want
    • added (optional) AddToGameWorld component for convenience to automatically add entities to the game world, if there is one
  • chore(bevy_gltf_components): removed verbose output, cleaned it up a bit

  • feat(tools/auto_export): added option to split out "dynamic" objects in main scenes

    • ie if a collection instance (or its original collection) has a "dynamic" (aka mutable, saveable etc)
      flag it can get exported to a seperate gltf file (essentially acting like an "initial save")
    • the rest of the levels (the "static" data) is exported without the dynamic objects and
      can be reused with save files !

 * added example
 * experimenting with generating gltf
 * changes to standard bevy scene serialization to get a better grasp
…in main scenes

 * ie if a collection instance (or its original collection) has a "dynamic" (aka mutable, saveable etc)
   flag it can get exported to a seperate gltf file (essentially acting like an "initial save")
 * the rest of the levels (the "static" data) is exported WITHOUT the dynamic objects and
   CAN BE REUSED with save files !!!
 * very inneficient for now, but works fine
…mple !

 * both initial load & load-after-save work similarly
 * ie load static level data first, then load "saved" data , inject into game world, done !
 * it REALLY works !! and so simple !!
 * to make sure entities get respawned with their blueprints, "SpawnHere" components get injected
  back into saveable entities before the actual saving
 * very minor nitpick : loaded data for dynamic scene  is still agressively cached by Bevy
  so you need to restart to get the latest save to work
 * saving & loading repeateadly now works correctly
 * cleaned up save & load, now works with events where you can specify save file
 * found a crucial bug with children added to a blueprint instance.. wip
 * experimenting with save filtering
 * experimenting with adding flags to all sub entities of a blueprint instance
 * attempts at fixing these hierarchy problems at the crate level (where it should be)
 * experimenting with entity id remapping etc
 * etc
 * simplified spawning process, no more spawning children containg blueprints etc
 * simplified post process : instead of copying original entity  into blueprint root
  we now copy blueprint root data (components & children) into the original entity !
 * much simplier code wise
 * solves issue with needing to register components that we only use on the bevy side (not gltf)
since we are not copying the bevy data into the blueprints data
 * removes need for remapping entity ids when nesting blueprints at runtime
 * modified aabb calculation to match other changes
 * a ton of related cleanups, more to come
…nts internal logic

 * added copyComponents helper to copy components from one entity to another, excluding existing
 components on the target entity, & some bells & whistles
 * components are now correctly copied from the blueprint to the original entity
 * removed second post process step as it is not needed anymore
 * cleaned up code
 * further cleanups
 * bumped version for future release
 * found a way to seperate extraction of root (no parent other than dynamicroot) from other
   entities to avoid serializing their parents, which leads to issues
 * basically saving & loading, even with dynamically spawned hierarchies WORKS
 * experimented with loading level as blueprint
 * added clearing of loaded dynamicscene handle after it has been loaded:
 you can now save & load any number of times withouth issues
 * renamed previously failing spawn system (because of unregistered components)
  that now works correctly in all relevant examples
 * tweaks & more experiments
 * scene filter + save path root are now configurable
 * related changes + various other cleanups
 * cleanups, related tweaks
 * moved code around to have it working
 * updated boilerplate (cargo files etc)
 * added LoadingFinished event & its handling in example to change state in the user code , not the crate
 * removed any references to state in the crate
 * experimented with injecting the static world name into the dynamic data, so that the save file
 contains information about the static world & loading of the static data is now done after the dynamic data is loaded
 * various minor tweaks & changes
 * for saving: added removal & cleanup logic for children component with children
that have been filtered out: ie no more invalid children getting stored in the save files !
 * added sending of event once saving is done
 * cleanups & tweaks
…handling

 * saving & loading state are now GameStates, not appStates
 * added a bit of ui when entering saving & loading states & cleanup when exiting
 * improved handling of save & load events
…ew issues

 * now injecting a resource after the initial event to make sure it lives long enough for all systems
 * added a second marker resource to make sure the "post process" part has time to run & is seperate from the first part
 * removed sub sets
 * various tweaks & experiments
 * added NoInBlueprint component to have finer control over whether to inject the 'InBlueprint' component or not
 * minor cleanups
 * transforms are now optional when spawning a blueprint
 * added NoInBlueprint (optional) component to prevent injecting of "InBlueprint" components when we do not want it
 * added Library (optional) component, so we can override library path when we want
 * sorted parameters to main functions, optional ones at the end
 * moved out bevy_gltf_blueprints/basic_save to a new bevy_gltf_save_load examples folder
 * lots of cleanups
 * removed transform from bundle
 * cleaned up the code a bit
 * updated the README
 * renamed entity_filter to component_filter
 * moved a few components to the presets (ie always present) components
 * added & fleshed out docs
 * tweaks & cleanups
 * added optional convenience AddToGameWorld component to automatically add entities to the game world, if there
is one
@kaosat-dev kaosat-dev marked this pull request as ready for review January 10, 2024 13:26
@kaosat-dev kaosat-dev changed the title Save load feat(Save & load): new crate bevy_gltf_save_load + lots of upgrades & improvements Jan 10, 2024
@kaosat-dev kaosat-dev merged commit 5429bf4 into main Jan 10, 2024
@kaosat-dev kaosat-dev deleted the save_load branch January 22, 2024 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant