| 124 | } |
| 125 | |
| 126 | EngineRoot::EngineRoot(const EngineRootConfig& config) : |
| 127 | scheduler(new px_sched::Scheduler), |
| 128 | fileLocator(locateFile), |
| 129 | scenario(std::make_unique<Scenario>()), |
| 130 | typeRegistry(std::make_unique<refl::TypeRegistry>()), |
| 131 | factoryRegistries(std::make_unique<FactoryRegistries>()), |
| 132 | engineSettings(config.engineSettings) |
| 133 | { |
| 134 | int threadCount = determineThreadCountFromHardwareAndUserLimits(); |
| 135 | |
| 136 | px_sched::SchedulerParams schedulerParams; |
| 137 | schedulerParams.max_running_threads = threadCount; |
| 138 | schedulerParams.num_threads = threadCount; |
| 139 | scheduler->init(schedulerParams); |
| 140 | |
| 141 | std::vector<std::string> assetSearchPaths = { |
| 142 | "Assets/", |
| 143 | "../Assets/" |
| 144 | }; |
| 145 | |
| 146 | if (const char* path = std::getenv("SKYBOLT_ASSETS_PATH"); path) |
| 147 | { |
| 148 | auto paths = file::splitByPathListSeparator(std::string(path)); |
| 149 | assetSearchPaths.insert(assetSearchPaths.begin(), paths.begin(), paths.end()); |
| 150 | } |
| 151 | |
| 152 | std::set<std::string> requiredPackages = {"Core", "Globe"}; |
| 153 | for (const auto& assetSearchPath : assetSearchPaths) |
| 154 | { |
| 155 | file::Paths folders = file::findFoldersInDirectory(assetSearchPath); |
| 156 | for (const auto& folder : folders) |
| 157 | { |
| 158 | std::string folderName = folder.stem().string(); |
| 159 | mAssetPackagePaths.push_back(folder.string()); |
| 160 | registerAssetPackage(folder.string()); |
| 161 | BOOST_LOG_TRIVIAL(info) << "Registered asset package: " << folderName; |
| 162 | |
| 163 | requiredPackages.erase(folderName); |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | if (!requiredPackages.empty()) |
| 168 | { |
| 169 | std::string packagesString = boost::algorithm::join(requiredPackages, ", "); |
| 170 | throw std::runtime_error("Could not find asset packages: {" + packagesString + "}. Ensure working directory and/or SKYBOLT_ASSETS_PATH is set correctly. " |
| 171 | "Please refer to Skybolt documentation for information about finding assets."); |
| 172 | } |
| 173 | |
| 174 | if (config.enableVis) |
| 175 | { |
| 176 | programs = vis::createShaderPrograms(); |
| 177 | } |
| 178 | scene.reset(new vis::Scene(new osg::StateSet())); |
| 179 | |
| 180 | auto julianDateProvider = [scenario = scenario.get()]() { |
| 181 | return getCurrentJulianDate(*scenario); |
| 182 | }; |
| 183 |
nothing calls this directly
no test coverage detected