I'm working on a small game engine and for my assets I use the filepath as an id
void loadAssets() {
loadMesh("path/to/test.fbx");
}
And using strings it's very easy to reuse it or to access it
void loadScene() {
GameObject player;
player.modelId = "path/to/test.fbx";
}
// During rendering in a for loop:
getMesh(object.modelId);
But using an int/unsigned int seems to be more common and better practice then strings and although I don't care about optimization or performance I am curious how do you work if something is a number? If my loadMesh() function generates some random id (uuid?) like 347856 or even just simple increments 1,2,3,… I wouldn't be able to do what I did in the above code since how would I know what id is for test.fbx? The only ideas popping into my head is using the string id to access the handle so the loadMesh() function would take the filepath and if it already exists return a handle so my loadScene() function would look like this
void loadScene() {
GameObject player;
player.modelId = loadMesh("path/to/test.fbx"); // Since this was already loaded it would return a handle
}
But the entire point of using ints seems to be to avoid strings so I think this defeats the purpose? Unless there's something I'm missing or not getting?