Load terrain
| 604 | |
| 605 | // Load terrain |
| 606 | void Terrain::Load(const char *name, const std::string &model_override) { |
| 607 | minimal = false; |
| 608 | heightmap_.LoadData(name, HeightmapImage::DOWNSAMPLED); |
| 609 | |
| 610 | LOGI << "Loading terrain \"" << name << "\"" << std::endl; |
| 611 | AddLoadingText("Checking for terrain cache file..."); |
| 612 | |
| 613 | if (!LoadCachedSimplifiedTerrain()) { |
| 614 | LOGI << "Failed to load cached terrain, calculating a simplified terrain" << std::endl; |
| 615 | CalculateSimplifiedTerrain(); |
| 616 | } |
| 617 | |
| 618 | if (!model_override.empty()) { |
| 619 | Model &terrain_simplified_model = Models::Instance()->GetModel(model_id); |
| 620 | terrain_simplified_model.LoadObj(model_override, 0); |
| 621 | for (float &i : terrain_simplified_model.tex_coords2) { |
| 622 | i *= 2048.0f; |
| 623 | } |
| 624 | } |
| 625 | |
| 626 | LOGI << "*****************" << std::endl; |
| 627 | |
| 628 | CalculatePatches(); |
| 629 | |
| 630 | heightmap_.LoadData(heightmap_.path(), HeightmapImage::ORIGINAL_RES); |
| 631 | |
| 632 | terrain_texture_size = heightmap_.width() / Graphics::Instance()->config_.texture_reduction_factor(); |
| 633 | } |
| 634 | |
| 635 | void Terrain::LoadMinimal(const char *name, const std::string &model_override) { |
| 636 | minimal = true; |
no test coverage detected