MCPcopy Create free account
hub / github.com/WolfireGames/overgrowth / Load

Method Load

Source/Objects/envobject.cpp:1434–1589  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1432}
1433
1434bool EnvObject::Load(const std::string& type_file) {
1435 bool ret = true;
1436 Textures* textures = Textures::Instance();
1437 textures->setWrap(GL_REPEAT);
1438
1439 ofr = Engine::Instance()->GetAssetManager()->LoadSync<ObjectFile>(type_file);
1440
1441 if (ofr.valid()) {
1442 modsource_ = ofr->modsource_;
1443
1444 ofr_material = Engine::Instance()->GetAssetManager()->LoadSync<Material>(ofr->material_path);
1445
1446 if (ofr_material.valid()) {
1447 PROFILER_ENTER(g_profiler_ctx, "Loading detail/weight texture refs");
1448 if (!ofr->weight_map.empty()) {
1449 weight_map_ref_ = Engine::Instance()->GetAssetManager()->LoadSync<TextureAsset>(ofr->weight_map);
1450 if (weight_map_ref_.valid() == false) {
1451 LOGE << "Failed at loading weight_map " << ofr->weight_map << " for envobject " << type_file << std::endl;
1452 ret = false;
1453 }
1454 }
1455
1456 TextureRef detail_color_map_ref_ = textures->getDetailColorArray();
1457 detail_texture_color_indices_.resize(ofr->m_detail_color_maps.size());
1458 for (unsigned i = 0; i < ofr->m_detail_color_maps.size(); ++i) {
1459 detail_texture_color_indices_[i] = textures->loadArraySlice(detail_color_map_ref_, ofr->m_detail_color_maps[i]);
1460 }
1461
1462 detail_texture_normal_indices_.resize(ofr->m_detail_normal_maps.size());
1463 TextureRef detail_normal_map_ref_ = textures->getDetailNormalArray();
1464 for (unsigned i = 0; i < ofr->m_detail_normal_maps.size(); ++i) {
1465 detail_texture_normal_indices_[i] = textures->loadArraySlice(detail_normal_map_ref_, ofr->m_detail_normal_maps[i]);
1466 }
1467 PROFILER_LEAVE(g_profiler_ctx);
1468
1469 PROFILER_ENTER(g_profiler_ctx, "Getting average colors");
1470 detail_texture_color_.resize(ofr->m_detail_color_maps.size());
1471 detail_texture_color_srgb_.resize(ofr->m_detail_color_maps.size());
1472 for (unsigned i = 0; i < ofr->m_detail_color_maps.size(); i++) {
1473 vec4& dtc = detail_texture_color_[i];
1474 vec4& dtc_srgb = detail_texture_color_srgb_[i];
1475 // dtc = AverageColors::Instance()->ReturnRef(ofr->m_detail_color_maps[i])->color();
1476
1477 AverageColorRef color_ref = Engine::Instance()->GetAssetManager()->LoadSync<AverageColor>(ofr->m_detail_color_maps[i]);
1478 if (color_ref.valid()) {
1479 average_color_refs.insert(color_ref);
1480 dtc = color_ref->color();
1481
1482 dtc_srgb[0] = pow(dtc[0], 2.2f);
1483 dtc_srgb[1] = pow(dtc[1], 2.2f);
1484 dtc_srgb[2] = pow(dtc[2], 2.2f);
1485 dtc_srgb[3] = dtc[3];
1486 } else {
1487 LOGE << "Failed at loading AverageColor " << ofr->m_detail_color_maps[i] << " for EnvObject " << type_file << std::endl;
1488 ret = false;
1489 }
1490 }
1491 PROFILER_LEAVE(g_profiler_ctx);

Callers 4

TerrainObjectMethod · 0.45
CreateRiggedObjectMethod · 0.45
AddMethod · 0.45
CheckMethod · 0.45

Calls 15

setWrapMethod · 0.80
GetAssetManagerMethod · 0.80
getDetailColorArrayMethod · 0.80
loadArraySliceMethod · 0.80
getDetailNormalArrayMethod · 0.80
LoadAuxFromImageMethod · 0.80
powFunction · 0.50
validMethod · 0.45
emptyMethod · 0.45
resizeMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected