Skip to content

Commit

Permalink
fix duplicate load of first mesh
Browse files Browse the repository at this point in the history
  • Loading branch information
goopey7 committed Dec 30, 2023
1 parent 1645c37 commit d50349c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion goop/sys/ResourceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,16 @@ int ResourceManager::initialize()

bool ResourceManager::loadMesh(MeshComponent& mesh)
{
if (loadedMeshes[mesh.path] != 0)
if (numLoadedMeshes[mesh.path] > 0)
{
std::cout << "Mesh " << mesh.path << " already loaded" << std::endl;
mesh.id = loadedMeshes[mesh.path];
numLoadedMeshes[mesh.path]++;
return true;
}
mesh.id = meshLoader->load(mesh.path);
loadedMeshes[mesh.path] = mesh.id;
numLoadedMeshes[mesh.path]++;
std::cout << "Loaded mesh " << mesh.path << " with id " << mesh.id << std::endl;
return true;
}
Expand Down
1 change: 1 addition & 0 deletions goop/sys/ResourceManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ class ResourceManager : public Subsystem
std::unique_ptr<MeshLoader> meshLoader;
std::unique_ptr<Sfx> sfx;
std::map<std::string, uint32_t> loadedMeshes;
std::map<std::string, uint32_t> numLoadedMeshes;
};
} // namespace goop::sys

0 comments on commit d50349c

Please sign in to comment.