Skip to content

Improve new API #312

@Nicolas-Ferre

Description

@Nicolas-Ferre

Feature
Improve the new API:

  • Use App everywhere instead of Context for more flexibility
  • Avoid splitting data between local node and glob, and instead put everything on glob side
  • Ensure valid state at any time by applying full glob update each time a glob field is modified

Tasks

  • Replace Context by App #315
  • Add FromApp #316
  • Require FromApp to be implemented for all glob types #317
  • Refactor globs #318
  • Allow mutable borrowing of multiple root nodes #320
  • Replace nodes by states #321
  • Support Instant creation in FromApp derive macro #322
  • Allow glob mutation with Globals #323
  • Add updater traits and derive macros #324
  • Change physics API #325
  • Change resource API #326
  •  Change material api #328
  • Simplify updaters
    • Don't generate for_* methods (so updater fields can be Option instead of Update)
    • Generation *_option methods to simplify updaters calling other updaters
    • Generate updater fields with updater(inner_type) only to support custom methods
    • Rename attributes
      • Generate field only -> updater(field)
      • Generate methods + fields -> updater(methods)
  • Add Init trait to initalize automatically after FromApp::from_app() call
  • Make ... a glob a glob and implements GlobUpdater
  • Optimize state index access in App (see Snippet 1)
    • Actually, current version is convenient to have a way to control state update ordering.
  • Avoid storing the GPU objects in an Arc, and use App::take instead
  • Perform last global cleanup/refactoring if necessary, including:
    • Remove unnecessary app.update() in tests
    • Put most objects outside Root in tests to simplify borrowing
    • Remove FontManager and instead update all Text2D when the font is updated.
    • Make sure all structfield doc references are still valid.
  • Allow deletion of states (and provide State::delete() callback, for example to delete recursively)
    • Possible issue: delete state of type T, and then run StateHandle::<T>::get
    • Possible issue: what happens to Globs when Globals state is deleted?
  • Either replace GlobRef by Glob, or disallow mutation from GlobRef.
  • Implement From/Into<[f32; N]> for Vec2, Vec3, ...
  • Add ModelMapper to derivate a set of models dynamically (for picking, shadow maps, ...)
  • Get access to shader + textures + raw material data + material type ID from MaterialGlob
  • Add is_main_rendering field in Target
  • Ensure that when TextureAnimation.part field is updated, the current frame is reset

Snippet 1:

fn root_index_or_create<T>(&mut self) -> usize
where
    T: RootNode,
{
    let type_id = TypeId::of::<T>();
    let index = *self
        .root_indexes
        .entry(type_id)
        .or_insert_with(|| self.roots.len());
    if index == self.roots.len() {
        debug!("Create root node `{}`...", any::type_name::<T>());
        // reserve slot in case other root node is creating during T::from_app_with
        let root = T::from_app_with(self, T::init);
        self.roots.push(RootNodeData::new::<T>(root));
        debug!("Root node `{}` created", any::type_name::<T>());
    }
    index
}

Metadata

Metadata

Assignees

Labels

state: readyThis issue is ready to be implementedtype: enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions