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
| 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 |
| 145 | void 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 |
no test coverage detected