Changing texture path in .egg file


I’m trying to load in a .egg file, modify the path to a texture file, and save out a new .egg file. When I load, the file, perform the replacement, then call write_egg, I end up seeing the original texture paths. I’ve tried loading the texture collection a second time and confirmed that the EggData has the correct paths, and it appears to. Here’s my replacement method:

void EggHandler::ReplaceTexturePaths(std::map<std::string, std::string>& map, std::string sModelPath, std::string sOutputPath)
EggTextureCollection tc;
EggTextureCollection::TextureReplacement replacementMap;
for (auto it = tc.begin(); it != tc.end(); it++)
	Filename fn = (*it)->get_fullpath();
	auto outPathIt = map.find(fn);
	if (outPathIt == map.end())
		outPathIt = map.find(sModelPath + "/" + fn.c_str());
		if (outPathIt == map.end()) continue;
	PT(EggTexture) tex = new EggTexture(**it);
	replacementMap.insert(std::pair<PT_EggTexture, PT_EggTexture>(*it, tex));		
tc.replace_textures(m_pData, replacementMap);

m_pData is my only member variable, and it’s defined as PT(EggData). I’m nor sure why I’m getting stale data when I call write_egg, but I consistently see the old paths and not the replacement paths. Any help would be appreciated.


I just did a little experiment:

EggTextureCollection tc, tc2;

I would have expected to find a .egg file with no textures in it. Instead, what I saw was that tc had the three textures extracted from the .egg file, tc2 had no textures since tc had extracted them all and removed them, and the output .egg file still had the original textures in them.

So, is there something that I need to do to refresh the hierarchy after using an function like extract_textures before writing to a .egg file? I also threw in a call to change the coordinate system to make sure that the .egg files themselves weren’t stale, and saw that the coordinate system did in fact change.