Skip to content

Potential issue with asset removal Problem #159

@GitNiko

Description

@GitNiko

https://github.com/andriyDev/landmass/blob/0e3680e29ea0020966177955ede8a5e931918367/crates/landmass_rerecast/src/lib.rs#L219C73-L220C1

  for rerecast_id in changed_rerecast_ids {
    let Some(landmass_id) = mapping.get(rerecast_id) else {
      // The mapping has been cleaned up since we got the event OR this mesh
      // never had a mapping.
      continue;
    };

    let Some(rerecast_mesh) = rerecast_meshes.remove(rerecast_id) else { // <------here
      // We always send an event the first time the conversion is created in
      // case this asset exists. But it is also perfectly valid for this asset
      // to not exist and still be loading.
      continue;
    };
    let landmass_mesh =
      convert_rerecast_navmesh_to_landmass_navmesh(&rerecast_mesh);
    let landmass_mesh = match landmass_mesh.validate() {
      Ok(landmass_mesh) => landmass_me

I noticed a potential issue in the convert_changed_rerecast_meshes_to_landmass system where rerecast_meshes.remove(rerecast_id) is used to get the rerecast mesh for conversion. This seems problematic as it permanently removes the asset from the Assets storage.

Questions:

  • Is this remove() call intentional, or should it be get()?
  • Are there any specific reasons why the original rerecast mesh needs to be removed after conversion?
  • Could this cause issues when multiple entities reference the same rerecast mesh?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions