Skip to content

Commit

Permalink
More algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Jan 22, 2017
1 parent 4959149 commit cff4862
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions radiant/map/Map.cpp
Expand Up @@ -1040,8 +1040,6 @@ void Map::saveScaledModels()
{
saveScaledModel(node, childModel);
}

return false; // no further traversal
}

return true;
Expand Down Expand Up @@ -1084,18 +1082,18 @@ void Map::saveScaledModel(const scene::INodePtr& entityNode, const model::ModelN
targetPath.string() << std::endl;
}

targetPath /= "models";
targetPath /= "map_specific";
targetPath /= "scaled";
boost::filesystem::path modelPath = "models/map_specific/scaled";

targetPath /= modelPath;

boost::filesystem::create_directories(targetPath);

boost::filesystem::path modelPath = entity->getKeyValue("model");
boost::filesystem::path modelKeyValue = entity->getKeyValue("model");

// Open a temporary file to write the model
int i = 100;

boost::filesystem::path filenameWithoutExt = boost::filesystem::change_extension(modelPath, "");
boost::filesystem::path filenameWithoutExt = boost::filesystem::change_extension(modelKeyValue, "");

std::string generatedFilename = (filenameWithoutExt.string() + "_" + string::to_string(i) + "." + extension);
boost::filesystem::path targetFile = targetPath / generatedFilename;
Expand All @@ -1106,6 +1104,8 @@ void Map::saveScaledModel(const scene::INodePtr& entityNode, const model::ModelN
targetFile = targetPath / generatedFilename;
}

modelPath /= generatedFilename;

boost::filesystem::path tempFile = targetPath / ("_" + targetPath.filename().string());

std::ofstream tempStream(tempFile.string().c_str());
Expand Down Expand Up @@ -1148,6 +1148,8 @@ void Map::saveScaledModel(const scene::INodePtr& entityNode, const model::ModelN
throw std::runtime_error(
(boost::format(_("Could not rename the temporary file %s")) % tempFile.string()).str());
}

entity->setKeyValue("model", modelPath.string());
}

// Creates the static module instance
Expand Down

0 comments on commit cff4862

Please sign in to comment.