So I think about smart resource manager implementation. I'll explain how I make it and please fix my mistakes...
I have a separate thread, which processes the queue of requests (we see new object, so we need to load mesh, texture and animation). If there are no such mesh/texture/animation on client, then ask server to send it.
All the requests are processed one by one, because object needs model->texture->animation to do not get animation until mesh is loaded (we cannot assign texture to null mesh). Also what to do if we need to change a mesh, but current mesh is still loading. Sometimes objects load very slow if we wait for server data, and there is about hundred objects must be loaded from local filesystem, but they don't because we cannot assign texture to null mesh, or animation to null mesh.
Maybe I need to make one-by-one queue per object? Or make this functionality inside mesh or texture? But what to do if I have a man with a gun in his hand? Until I get the man skinned mesh, I cannot assign a gun there.
Or I need to remove my one-by-one queue and check like this:
Creature::Creature(int mesh, int texture){ loadModel(mesh); loadTexture(texture); m_meshID = mesh; m_textureID = texture;}void Creature::onLoad(int type, int id, Object* obj){ if (type == MESH) { // We got mesh, but soneone assigned new one in setMesh-like function if(id != m_meshID) { return; } m_mesh = (Mesh*) obj; if(m_texture) { m_mesh->setTexture(m_texture); } } else if (type == TEXTURE) { // We got texture, but soneone assigned new one in setTexture-like function if(id != m_textureID) { return; } m_texture = (Texture*) obj; if(m_mesh) { m_mesh->setTexture(m_texture); } }}