MCPcopy Create free account
hub / github.com/codereader/DarkRadiant / refreshModelsByPath

Function refreshModelsByPath

radiantcore/map/algorithm/Models.cpp:145–165  ·  view source on GitHub ↗

Reloads all entities with their model spawnarg referencing the given model path. The given model path denotes a VFS path, i.e. it is mod/game-relative

Source from the content-addressed store, hash-verified

143// Reloads all entities with their model spawnarg referencing the given model path.
144// The given model path denotes a VFS path, i.e. it is mod/game-relative
145void refreshModelsByPath(const std::string& relativeModelPath)
146{
147 std::size_t refreshedEntityCount = 0;
148
149 GlobalModelCache().removeModel(relativeModelPath);
150
151 GlobalMapModule().getRoot()->foreachNode([&](const scene::INodePtr& node)
152 {
153 auto entity = std::dynamic_pointer_cast<IEntityNode>(node);
154
155 if (entity && entity->getEntity().getKeyValue("model") == relativeModelPath)
156 {
157 entity->refreshModel();
158 ++refreshedEntityCount;
159 }
160
161 return true;
162 });
163
164 rMessage() << "Refreshed " << refreshedEntityCount << " entities using the model " << relativeModelPath << std::endl;
165}
166
167}
168

Callers 1

exportSelectedAsModelFunction · 0.85

Calls 7

rMessageFunction · 0.85
removeModelMethod · 0.45
foreachNodeMethod · 0.45
getRootMethod · 0.45
getKeyValueMethod · 0.45
getEntityMethod · 0.45
refreshModelMethod · 0.45

Tested by

no test coverage detected