Changeset View
Changeset View
Standalone View
Standalone View
source/blender/io/usd/intern/usd_reader_mesh.cc
| Show First 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | static void build_mat_map(const Main *bmain, std::map<std::string, Material *> *r_mat_map) | ||||
| for (; material; material = static_cast<Material *>(material->id.next)) { | for (; material; material = static_cast<Material *>(material->id.next)) { | ||||
| /* We have to do this because the stored material name is coming directly from USD. */ | /* We have to do this because the stored material name is coming directly from USD. */ | ||||
| (*r_mat_map)[pxr::TfMakeValidIdentifier(material->id.name + 2)] = material; | (*r_mat_map)[pxr::TfMakeValidIdentifier(material->id.name + 2)] = material; | ||||
| } | } | ||||
| } | } | ||||
| static pxr::UsdShadeMaterial compute_bound_material(const pxr::UsdPrim &prim) | static pxr::UsdShadeMaterial compute_bound_material(const pxr::UsdPrim &prim) | ||||
| { | { | ||||
| return pxr::UsdShadeMaterialBindingAPI(prim).ComputeBoundMaterial(); | pxr::UsdShadeMaterialBindingAPI api = pxr::UsdShadeMaterialBindingAPI(prim); | ||||
| /* Compute generically bound ('allPurpose') materials. */ | |||||
| pxr::UsdShadeMaterial mtl = api.ComputeBoundMaterial(); | |||||
| /* If no generic material could be resolved, also check for 'full' and | |||||
| * 'preview' purpose materials as fallbacks. */ | |||||
| if (!mtl) { | |||||
| mtl = api.ComputeBoundMaterial(pxr::UsdShadeTokens->full); | |||||
| } | |||||
| if (!mtl) { | |||||
| mtl = api.ComputeBoundMaterial(pxr::UsdShadeTokens->preview); | |||||
| } | |||||
| return mtl; | |||||
| } | } | ||||
| /* Returns an existing Blender material that corresponds to the USD | /* Returns an existing Blender material that corresponds to the USD | ||||
| * material with with the given path. Returns null if no such material | * material with with the given path. Returns null if no such material | ||||
| * exists. */ | * exists. */ | ||||
| static Material *find_existing_material( | static Material *find_existing_material( | ||||
| const pxr::SdfPath &usd_mat_path, | const pxr::SdfPath &usd_mat_path, | ||||
| const USDImportParams ¶ms, | const USDImportParams ¶ms, | ||||
| ▲ Show 20 Lines • Show All 840 Lines • Show Last 20 Lines | |||||