Skip to content

Commit

Permalink
Merge pull request #49 from AnimalLogic/usd_19_1_backport
Browse files Browse the repository at this point in the history
Backport to USD 19.1, get tests running
  • Loading branch information
HamedSabri-adsk authored Oct 22, 2019
2 parents b2e836d + 98362d4 commit 00aac98
Show file tree
Hide file tree
Showing 17 changed files with 95 additions and 7 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ if(NOT WIN32)
endif()
string(REPLACE ";" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")


#==============================================================================
# PLUGINS
#==============================================================================
Expand Down
6 changes: 6 additions & 0 deletions plugin/al/lib/AL_USDMaya/AL/usdmaya/PluginRegister.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,11 @@

#include "pxr/base/plug/plugin.h"
#include "pxr/base/plug/registry.h"

#if (PXR_MAJOR_VERSION > 0) || (PXR_MINOR_VERSION >= 19 && PXR_PATCH_VERSION >= 5)
#include "pxr/imaging/glf/contextCaps.h"
#include "pxr/imaging/glf/glContext.h"
#endif

#include "maya/MDrawRegistry.h"
#include "maya/MGlobal.h"
Expand Down Expand Up @@ -167,11 +170,14 @@ template<typename AFnPlugin>
MStatus registerPlugin(AFnPlugin& plugin)
{
GlfGlewInit();

#if (PXR_MAJOR_VERSION > 0) || (PXR_MINOR_VERSION >= 19 && PXR_PATCH_VERSION >= 5)
// We may be in a non-gui maya... if so,
// GlfContextCaps::InitInstance() will error
if (GlfGLContext::GetCurrentGLContext()->IsValid()) {
GlfContextCaps::InitInstance();
}
#endif

if(!MGlobal::optionVarExists("AL_usdmaya_selectMode"))
{
Expand Down
3 changes: 1 addition & 2 deletions plugin/al/lib/AL_USDMaya/AL/usdmaya/Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

#pragma once

Expand All @@ -23,7 +22,7 @@

#define AL_USDMAYA_VERSION_MAJOR 0
#define AL_USDMAYA_VERSION_MINOR 34
#define AL_USDMAYA_VERSION_PATCH 2
#define AL_USDMAYA_VERSION_PATCH 6

#define AL_USDMAYA_VERSION_STR xstr(AL_USDMAYA_VERSION_MAJOR) "." \
xstr(AL_USDMAYA_VERSION_MINOR) "." \
Expand Down
48 changes: 48 additions & 0 deletions plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
#include <vector>
#include "AL/usdmaya/nodes/Engine.h"

#if (PXR_MAJOR_VERSION > 0) || (PXR_MINOR_VERSION >= 19 && PXR_PATCH_VERSION >= 7)
#include "pxr/imaging/hdx/pickTask.h"
#endif
#include "pxr/imaging/hdx/taskController.h"

namespace AL {
Expand All @@ -53,6 +55,8 @@ bool Engine::TestIntersectionBatch(
if (ARCH_UNLIKELY(_legacyImpl)) {
return false;
}

#if (PXR_MAJOR_VERSION > 0) || (PXR_MINOR_VERSION >= 19 && PXR_PATCH_VERSION >= 7)
_UpdateHydraCollection(&_intersectCollection, paths, params);

TfTokenVector renderTags;
Expand All @@ -64,6 +68,7 @@ bool Engine::TestIntersectionBatch(
HdxRenderTaskParams hdParams = _MakeHydraUsdImagingGLRenderParams(params);
_taskController->SetRenderParams(hdParams);


HdxPickTaskContextParams pickParams;
pickParams.resolution = GfVec2i(pickResolution, pickResolution);
pickParams.hitMode = HdxPickTokens->hitAll;
Expand All @@ -82,6 +87,49 @@ bool Engine::TestIntersectionBatch(
if (allHits.size() == 0) {
return false;
}
#else

_UpdateHydraCollection(&_intersectCollection, paths, params, &_renderTags);

HdxIntersector::HitVector allHits;
HdxIntersector::Params qparams;
qparams.viewMatrix = worldToLocalSpace * viewMatrix;
qparams.projectionMatrix = projectionMatrix;
qparams.alphaThreshold = params.alphaThreshold;
switch (params.cullStyle) {
case UsdImagingGLCullStyle::CULL_STYLE_NO_OPINION:
qparams.cullStyle = HdCullStyleDontCare;
break;
case UsdImagingGLCullStyle::CULL_STYLE_NOTHING:
qparams.cullStyle = HdCullStyleNothing;
break;
case UsdImagingGLCullStyle::CULL_STYLE_BACK:
qparams.cullStyle = HdCullStyleBack;
break;
case UsdImagingGLCullStyle::CULL_STYLE_FRONT:
qparams.cullStyle = HdCullStyleFront;
break;
case UsdImagingGLCullStyle::CULL_STYLE_BACK_UNLESS_DOUBLE_SIDED:
qparams.cullStyle = HdCullStyleBackUnlessDoubleSided;
break;
default:
qparams.cullStyle = HdCullStyleDontCare;
}
qparams.renderTags = _renderTags;
qparams.enableSceneMaterials = params.enableSceneMaterials;

_taskController->SetPickResolution(pickResolution);
if (!_taskController->TestIntersection(
&_engine,
_intersectCollection,
qparams,
HdxIntersectionModeTokens->unique,
&allHits)) {
return false;
}


#endif

if (!outHit) {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,10 +385,17 @@ void ProxyDrawOverride::draw(const MHWRender::MDrawContext& context, const MUser
int originX, originY, width, height;
context.getViewportDimensions(originX, originY, width, height);

#if (PXR_MAJOR_VERSION > 0) || (PXR_MINOR_VERSION >= 19 && PXR_PATCH_VERSION >= 7)
engine->SetCameraState(
GfMatrix4d(context.getMatrix(MHWRender::MFrameContext::kViewMtx).matrix),
GfMatrix4d(context.getMatrix(MHWRender::MFrameContext::kProjectionMtx).matrix));
engine->SetRenderViewport(GfVec4d(originX, originY, width, height));
#else
engine->SetCameraState(
GfMatrix4d(context.getMatrix(MHWRender::MFrameContext::kViewMtx).matrix),
GfMatrix4d(context.getMatrix(MHWRender::MFrameContext::kProjectionMtx).matrix),
GfVec4d(originX, originY, width, height));
#endif

engine->SetRootTransform(GfMatrix4d(ptr->m_objPath.inclusiveMatrix().matrix));

Expand Down
7 changes: 7 additions & 0 deletions plugin/al/lib/AL_USDMaya/AL/usdmaya/nodes/ProxyShapeUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,17 @@ void ProxyShapeUI::draw(const MDrawRequest& request, M3dView& view) const

unsigned int x, y, w, h;
view.viewport(x, y, w, h);

#if (PXR_MAJOR_VERSION > 0) || (PXR_MINOR_VERSION >= 19 && PXR_PATCH_VERSION >= 7)
engine->SetCameraState(
GfMatrix4d((model.inverse() * viewMatrix).matrix),
GfMatrix4d(projection.matrix));
engine->SetRenderViewport(GfVec4d(x, y, w, h));
#else
engine->SetCameraState(
GfMatrix4d((model.inverse() * viewMatrix).matrix),
GfMatrix4d(projection.matrix), GfVec4d(x, y, w, h));
#endif

switch(request.displayStyle())
{
Expand Down
1 change: 1 addition & 0 deletions plugin/al/mayatest/AL/maya/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ target_include_directories(${MAYA_TEST_LIBRARY_NAME}
${MAYATEST_INCLUDE_LOCATION}
${MAYA_INCLUDE_DIRS}
${GTEST_INCLUDE_DIRS}
${USD_INCLUDE_DIR}
)

# install the public headers
Expand Down
3 changes: 2 additions & 1 deletion plugin/al/plugin/AL_USDMayaTestPlugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ add_test(
NAME TestAL_USDMaya
COMMAND
${CMAKE_CURRENT_SOURCE_DIR}/run_mayaplugin_tests.sh
${CMAKE_INSTALL_PREFIX}
${CMAKE_INSTALL_PREFIX}/${INSTALL_DIR_SUFFIX}
${USD_LIBRARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
)

Expand Down
2 changes: 1 addition & 1 deletion plugin/al/plugin/AL_USDMayaTestPlugin/py/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
add_test(
NAME TestUSDMayaPython
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND testUSDMayaPython.sh ${CMAKE_INSTALL_PREFIX} USD_LIBRARY_DIR ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND testUSDMayaPython.sh ${CMAKE_INSTALL_PREFIX}/${INSTALL_DIR_SUFFIX} ${USD_LIBRARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}
)
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export PATH=$MAYA_LOCATION/bin:$PATH
export MAYA_PLUG_IN_PATH=$AL_USDMAYA_LOCATION/plugin:$MAYA_PLUG_IN_PATH
export PYTHONPATH=$1/lib/python:$PYTHONPATH

maya -batch -script "$2/run_mayaplugin_tests.mel"
maya -batch -script "$3/run_mayaplugin_tests.mel"
5 changes: 5 additions & 0 deletions plugin/al/schemas/AL/usd/schemas/maya/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ target_compile_definitions(AL_USDMayaSchemas
AL_USDMAYASCHEMAS_EXPORTS
)

target_include_directories(AL_USDMayaSchemas
PUBLIC
${USD_INCLUDE_DIR}
)

# Hamed 2019
# https://stackoverflow.com/questions/25617839/undefined-reference-to-symbol-pthread-key-deleteglibc-2-2-5
set(PTHREAD_LINK "")
Expand Down
4 changes: 3 additions & 1 deletion plugin/al/schemas/AL/usd/schemas/maya/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ target_include_directories(testMayaSchemas
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../schemas
${GTEST_INCLUDE_DIRS}
${USD_INCLUDE_DIR}
)

target_link_libraries(testMayaSchemas
Expand All @@ -27,7 +28,8 @@ target_link_libraries(testMayaSchemas
${Boost_PYTHON_LIBRARY}
)

# install(TARGETS testMayaSchemas DESTINATION bin)
install(TARGETS testMayaSchemas DESTINATION ${INSTALL_DIR_SUFFIX}/bin)


add_test(
NAME TestAdditionalSchemas
Expand Down
5 changes: 5 additions & 0 deletions plugin/al/schemas/AL/usd/schemas/mayatest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ target_compile_definitions(AL_USDMayaSchemasTest
AL_USDMAYASCHEMASTEST_EXPORTS
)

target_include_directories(AL_USDMayaSchemasTest
PUBLIC
${USD_INCLUDE_DIR}
)

target_link_libraries(AL_USDMayaSchemasTest ${DEPENDANT_LIBRARIES})

install(
Expand Down
1 change: 1 addition & 0 deletions plugin/al/usdmayautils/AL/usdmaya/utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ target_link_libraries(${USDMAYA_UTILS_LIBRARY_NAME}
target_include_directories(${USDMAYA_UTILS_LIBRARY_NAME}
PUBLIC
${USDMAYAUTILS_INCLUDE_LOCATION}
${USD_INCLUDE_DIR}
)

# install the public headers
Expand Down
2 changes: 2 additions & 0 deletions plugin/al/usdtransaction/AL/usd/transaction/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ target_compile_definitions(${USDTRANSACTION_LIBRARY_NAME}
target_include_directories(${USDTRANSACTION_LIBRARY_NAME}
PUBLIC
${USDTRANSACTION_INCLUDE_LOCATION}
${USD_INCLUDE_DIR}
)

target_link_libraries(${USDTRANSACTION_LIBRARY_NAME}
Expand Down Expand Up @@ -70,6 +71,7 @@ target_compile_definitions(${USDTRANSACTION_PYTHON_LIBRARY_NAME}
target_include_directories(${USDTRANSACTION_PYTHON_LIBRARY_NAME}
PUBLIC
${USDTRANSACTION_INCLUDE_LOCATION}
${USD_INCLUDE_DIR}
)

target_link_libraries(${USDTRANSACTION_PYTHON_LIBRARY_NAME}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ target_include_directories(${USDTRANSACTION_TEST_EXECUTABLE_NAME}
${GTEST_INCLUDE_DIRS}
PUBLIC
${USDTRANSACTION_INCLUDE_LOCATION}
${USD_INCLUDE_DIR}
)

add_test(
Expand All @@ -48,9 +49,10 @@ add_test(

set_tests_properties(${USDTRANSACTION_PYTHON_TEST_NAME}
PROPERTIES
ENVIRONMENT PYTHONPATH=${CMAKE_BINARY_DIR}/src:$ENV{PYTHONPATH}
ENVIRONMENT PYTHONPATH=${CMAKE_BINARY_DIR}/${INSTALL_DIR_SUFFIX}/usdtransaction:${CMAKE_BINARY_DIR}/src:$ENV{PYTHONPATH}
)


if (TARGET all_tests)
add_dependencies(all_tests ${USDTRANSACTION_TEST_EXECUTABLE_NAME} ${USDTRANSACTION_PYTHON_LIBRARY_NAME})
endif()
1 change: 1 addition & 0 deletions plugin/al/usdutils/AL/usd/utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ target_include_directories(${USDUTILS_LIBRARY_NAME}
PUBLIC
${UTILS_INCLUDE_LOCATION}
${USDUTILS_INCLUDE_LOCATION}
${USD_INCLUDE_DIR}
)

target_link_libraries(${USDUTILS_LIBRARY_NAME}
Expand Down

0 comments on commit 00aac98

Please sign in to comment.