| 269 | } |
| 270 | |
| 271 | bool SDFGrid::loadValuesFromFile(const std::filesystem::path& path) |
| 272 | { |
| 273 | std::ifstream file(path, std::ios::in | std::ios::binary); |
| 274 | |
| 275 | if (file.is_open()) |
| 276 | { |
| 277 | uint32_t gridWidth; |
| 278 | file.read(reinterpret_cast<char*>(&gridWidth), sizeof(uint32_t)); |
| 279 | |
| 280 | uint32_t totalValueCount = (gridWidth + 1) * (gridWidth + 1) * (gridWidth + 1); |
| 281 | std::vector<float> cornerValues(totalValueCount, 0.0f); |
| 282 | file.read(reinterpret_cast<char*>(cornerValues.data()), totalValueCount * sizeof(float)); |
| 283 | |
| 284 | file.close(); |
| 285 | setValues(cornerValues, gridWidth); |
| 286 | |
| 287 | mInitializedWithPrimitives = false; |
| 288 | return true; |
| 289 | } |
| 290 | |
| 291 | logWarning("SDFGrid::loadValuesFromFile() file '{}' could not be opened!", path); |
| 292 | return false; |
| 293 | } |
| 294 | |
| 295 | void SDFGrid::generateCheeseValues(uint32_t gridWidth, uint32_t seed) |
| 296 | { |
no test coverage detected