MaterialX: fix review comments #19

Merged
Bogdan Nagirniak merged 10 commits from matx-fix-review-comments into matx-export-material 2023-09-14 02:01:04 +02:00
2 changed files with 8 additions and 0 deletions
Showing only changes of commit 3038b952d4 - Show all commits

View File

@ -210,6 +210,7 @@ if(WITH_OPENVDB)
endif() endif()
if(WITH_MATERIALX) if(WITH_MATERIALX)
add_definitions(-DWITH_MATERIALX)
list(APPEND LIB MaterialXCore) list(APPEND LIB MaterialXCore)
endif() endif()

View File

@ -12,8 +12,10 @@
#include <pxr/imaging/hd/tokens.h> #include <pxr/imaging/hd/tokens.h>
#include <pxr/usdImaging/usdImaging/materialParamUtils.h> #include <pxr/usdImaging/usdImaging/materialParamUtils.h>
#ifdef WITH_MATERIALX
#include <pxr/usd/usdMtlx/reader.h> #include <pxr/usd/usdMtlx/reader.h>
#include <pxr/usd/usdMtlx/utils.h> #include <pxr/usd/usdMtlx/utils.h>
#endif
#include "MEM_guardedalloc.h" #include "MEM_guardedalloc.h"
@ -73,6 +75,7 @@ void MaterialData::init()
image_cache_file_path()}; image_cache_file_path()};
/* Create USD material. */ /* Create USD material. */
pxr::UsdShadeMaterial usd_material; pxr::UsdShadeMaterial usd_material;
#ifdef WITH_MATERIALX
if (scene_delegate_->use_materialx) { if (scene_delegate_->use_materialx) {
MaterialX::DocumentPtr doc = blender::nodes::materialx::export_to_materialx( MaterialX::DocumentPtr doc = blender::nodes::materialx::export_to_materialx(
scene_delegate_->depsgraph, (Material *)id); scene_delegate_->depsgraph, (Material *)id);
@ -85,8 +88,12 @@ void MaterialData::init()
} }
} }
else { else {
#endif
usd_material = usd::create_usd_material(export_context, material_path, (Material *)id, "st"); usd_material = usd::create_usd_material(export_context, material_path, (Material *)id, "st");
#ifdef WITH_MATERIALX
} }
#endif
BogdanNagirniak marked this conversation as resolved
Review

simplify to:

....
  else
#endif
{
usd_material = usd::create_usd_material(export_context, material_path, (Material *)id, "st");
}
simplify to: ``` .... else #endif { usd_material = usd::create_usd_material(export_context, material_path, (Material *)id, "st"); } ```
/* Convert USD material to Hydra material network map, adapted for render delegate. */ /* Convert USD material to Hydra material network map, adapted for render delegate. */
const pxr::HdRenderDelegate *render_delegate = const pxr::HdRenderDelegate *render_delegate =