Changeset View
Changeset View
Standalone View
Standalone View
source/blender/io/wavefront_obj/importer/obj_import_mesh.cc
| Show First 20 Lines • Show All 298 Lines • ▼ Show 20 Lines | static Material *get_or_create_material(Main *bmain, | ||||
| /* We have not, will have to create it. Create a new default | /* We have not, will have to create it. Create a new default | ||||
| * MTLMaterial too, in case the OBJ file tries to use a material | * MTLMaterial too, in case the OBJ file tries to use a material | ||||
| * that was not in the MTL file. */ | * that was not in the MTL file. */ | ||||
| const MTLMaterial &mtl = *materials.lookup_or_add(name, std::make_unique<MTLMaterial>()); | const MTLMaterial &mtl = *materials.lookup_or_add(name, std::make_unique<MTLMaterial>()); | ||||
| Material *mat = BKE_material_add(bmain, name.c_str()); | Material *mat = BKE_material_add(bmain, name.c_str()); | ||||
| ShaderNodetreeWrap mat_wrap{bmain, mtl, mat, relative_paths}; | ShaderNodetreeWrap mat_wrap{bmain, mtl, mat, relative_paths}; | ||||
| mat->use_nodes = true; | mat->use_nodes = true; | ||||
| /* FIXME Only needed for the unique_pointer release part of #get_nodetree. Not safe or elegant at | |||||
| * all. */ | |||||
| mat->nodetree = mat_wrap.get_nodetree(); | mat->nodetree = mat_wrap.get_nodetree(); | ||||
| BKE_ntree_update_main_tree(bmain, mat->nodetree, nullptr); | BKE_ntree_update_main_tree(bmain, mat->nodetree, nullptr); | ||||
| created_materials.add_new(name, mat); | created_materials.add_new(name, mat); | ||||
| return mat; | return mat; | ||||
| } | } | ||||
| void MeshFromGeometry::create_materials(Main *bmain, | void MeshFromGeometry::create_materials(Main *bmain, | ||||
| ▲ Show 20 Lines • Show All 72 Lines • Show Last 20 Lines | |||||