From 54a2510969c78566ce87a636e14aa1015b3d2c0d Mon Sep 17 00:00:00 2001 From: Mark Henderson Date: Tue, 10 Dec 2024 12:20:32 -0800 Subject: [PATCH] Fix for incorrectly ignoring meshes after show/hide is used in USD Composer Previously, a mesh that is overridden but has no child meshes will be ignored, regardless of the state of the references or the presence of the preserveOriginalDrawCall attribute. This changes that behavior so that override prims with no children that do not explicitly override the references will preserve the original draw call. --- src/dxvk/rtx_render/rtx_mod_usd.cpp | 32 ++++++++++++++++++----------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/src/dxvk/rtx_render/rtx_mod_usd.cpp b/src/dxvk/rtx_render/rtx_mod_usd.cpp index 265ad8ba..3bd35bfe 100644 --- a/src/dxvk/rtx_render/rtx_mod_usd.cpp +++ b/src/dxvk/rtx_render/rtx_mod_usd.cpp @@ -105,7 +105,7 @@ class UsdMod::Impl { void processPrim(Args& args, pxr::UsdPrim& prim); void processLight(Args& args, const pxr::UsdPrim& lightPrim, const bool isOverride); - void processReplacement(Args& args); + bool processReplacement(Args& args); Categorizer processCategoryFlags(const pxr::UsdPrim& prim); @@ -527,7 +527,7 @@ bool explicitlyNoReferences(const pxr::UsdPrim& prim) { return false; } -void UsdMod::Impl::processReplacement(Args& args) { +bool UsdMod::Impl::processReplacement(Args& args) { ScopedCpuProfileZone(); if (args.rootPrim.IsA()) { @@ -551,6 +551,14 @@ void UsdMod::Impl::processReplacement(Args& args) { if (args.meshes[0].includeOriginal) { args.meshes[0].categories = processCategoryFlags(args.rootPrim); } + return true; + } else { + bool result = preserveGameObject(args.rootPrim); + if (result) { + Logger::warn(str::format("Empty override prim found. ", args.rootPrim.GetPrimPath().GetString(), " has no children, but the original mesh reference is not explicitely deleted.")); + } + return !result; + } } @@ -663,11 +671,11 @@ void UsdMod::Impl::processUSD(const Rc& context) { Args args = {context, xformCache, child, replacementVec}; - processReplacement(args); - - variantCounts[hash]++; + if (processReplacement(args)) { + variantCounts[hash]++; - m_owner.m_replacements->set(hash, std::move(replacementVec)); + m_owner.m_replacements->set(hash, std::move(replacementVec)); + } } } } @@ -695,9 +703,9 @@ void UsdMod::Impl::processUSD(const Rc& context) { Args args = {context, xformCache, rootPrim, replacementVec}; - processReplacement(args); - - m_owner.m_replacements->set(variantHash, std::move(replacementVec)); + if (processReplacement(args)) { + m_owner.m_replacements->set(variantHash, std::move(replacementVec)); + } } } @@ -710,9 +718,9 @@ void UsdMod::Impl::processUSD(const Rc& context) { std::vector replacementVec; Args args = {context, xformCache, child, replacementVec}; - processReplacement(args); - - m_owner.m_replacements->set(hash, std::move(replacementVec)); + if (processReplacement(args)) { + m_owner.m_replacements->set(hash, std::move(replacementVec)); + } } } }