From 72fbaffd8e6fdc07ba7b5e3164478334cd683137 Mon Sep 17 00:00:00 2001 From: lilike-adsk <134404162+lilike-adsk@users.noreply.github.com> Date: Thu, 26 Sep 2024 09:11:50 -0400 Subject: [PATCH] HYDRA-973 - set HDST_RENDER_SELECTED_EDGE_FROM_FACE as 0 by default (#171) * set HDST_RENDER_SELECTED_EDGE_FROM_FACE as 0 by default * fix build warning on Mac/Linux --- lib/mayaHydra/mayaPlugin/plugin.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/lib/mayaHydra/mayaPlugin/plugin.cpp b/lib/mayaHydra/mayaPlugin/plugin.cpp index 8624510a4..af7e160aa 100644 --- a/lib/mayaHydra/mayaPlugin/plugin.cpp +++ b/lib/mayaHydra/mayaPlugin/plugin.cpp @@ -69,6 +69,16 @@ namespace { std::vector _renderOverrides; std::vector _pluginLoadingCallbackIds; + + void setEnvVar(const char* envVarSet) + { + // putenv requires char* and I'm not willing to use const cast! + const auto envVarSize = strlen(envVarSet) + 1; + std::vector envVarData; + envVarData.resize(envVarSize); + snprintf(envVarData.data(), envVarSize, "%s", envVarSet); + putenv(envVarData.data()); + } } void initialize() @@ -133,14 +143,11 @@ PLUGIN_EXPORT MStatus initializePlugin(MObject obj) return ret; } - // For now this is required for the HdSt backed to use lights. - // putenv requires char* and I'm not willing to use const cast! - constexpr const char* envVarSet = "USDIMAGING_ENABLE_SCENE_LIGHTS=1"; - const auto envVarSize = strlen(envVarSet) + 1; - std::vector envVarData; - envVarData.resize(envVarSize); - snprintf(envVarData.data(), envVarSize, "%s", envVarSet); - putenv(envVarData.data()); + // For now this is required for the HdSt backend to use lights. + setEnvVar("USDIMAGING_ENABLE_SCENE_LIGHTS=1"); + + // Performance optimization: disable RENDER_SELECTED_EDGE_FROM_FACE feature that could trigger unnecessary running of gometry shader. + setEnvVar("HDST_RENDER_SELECTED_EDGE_FROM_FACE=0"); MFnPlugin plugin(obj, "Autodesk", PLUGIN_VERSION, "Any");