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

Allow ProtoData to store handles without paths #16

Closed
B-Reif opened this issue Mar 13, 2022 · 1 comment · Fixed by #17
Closed

Allow ProtoData to store handles without paths #16

B-Reif opened this issue Mar 13, 2022 · 1 comment · Fixed by #17

Comments

@B-Reif
Copy link
Contributor

B-Reif commented Mar 13, 2022

Currently the ProtoData struct requires a path when insert a handle:

    pub fn insert_handle<T: Asset>(
        &mut self,
        protoytpe: &dyn Prototypical,
        component: &dyn ProtoComponent,
        path: &HandlePath,
        handle: Handle<T>,
    ) {}

This poses a problem when inserting handles that don't correspond 1:1 with an asset path.

For instance, when loading an Aseprite file with bevy_ase, one .aseprite file path corresponds to many different handles (each frame has its own Image handle, other metadata handles are inserted, etc.)

As far as I can tell, ProtoData only uses this path as a key in its map. Fortunately for us, Handle already exposes HandleId, which implements Hash and uniquely identifies the Handle. We can fix this problem and simplify our API by keying on HandleId instead of a HandlePath.

@B-Reif B-Reif changed the title Allow ProtoData to store paths without handles Allow ProtoData to store handles without paths Mar 13, 2022
@B-Reif B-Reif mentioned this issue Mar 13, 2022
@MrGVSV
Copy link
Owner

MrGVSV commented Mar 14, 2022

This poses a problem when inserting handles that don't correspond 1:1 with an asset path.

For instance, when loading an Aseprite file with bevy_ase, one .aseprite file path corresponds to many different handles (each frame has its own Image handle, other metadata handles are inserted, etc.)

Good point. Not something I had considered when making this.

As far as I can tell, ProtoData only uses this path as a key in its map. Fortunately for us, Handle already exposes HandleId, which implements Hash and uniquely identifies the Handle. We can fix this problem and simplify our API by keying on HandleId instead of a HandlePath.

Yep, this is definitely a better way of doing this.

@MrGVSV MrGVSV linked a pull request Mar 14, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants