Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autodesk/ppt/refactoring sandbox to dev 00 #154

Merged
merged 8 commits into from
Jan 14, 2020

Conversation

ppt-adsk
Copy link
Collaborator

@ppt-adsk ppt-adsk commented Dec 4, 2019

This is the second large pull request to move code from the Pixar plugin to the mayaUsd core library and translator plugins. Impact on the AL plugin is minimal. All Pixar and mayaUsd core tests pass on my CentOS 7 Linux box (albeit with some difficult to reproduce random failures). All AL tests using the AL test plugin pass when run inside an interactive Maya. When running the test stage of the build script, the following tests fail, but these are apparently known to fail in the dev branch at this time:
74 - AL_MayaUtilsTests (Failed)
77 - TestAL_USDMaya (Failed)
78 - TestUSDMayaPython (Failed)
80 - TestAdditionalTranslators (Failed)
81 - TestPxrUsdTranslators (Failed)

@ppt-adsk
Copy link
Collaborator Author

ppt-adsk commented Dec 4, 2019

Tests also pass on OS X and Windows.

Copy link
Contributor

@robthebloke robthebloke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Behind our firewall, trying to review a PR this size is a painfully slow experience :(

I think I'd prefer changes such as the copyright notices, changes to the export macro, changes to the file paths, and then the actual code changes split out into their own commits in the future.

I'm really not a fan of the change to use relative include paths (especially since half the PR uses absolute paths, the other half uses relative paths). It's a change that only serves to introduce more git noise than is really needed (and also worth mentioning that both the pixar and animal coding conventions already use absolute include paths everywhere)

{
try {
const MFnDagNode& dagNodeFn =
dynamic_cast<const MFnDagNode&>(depNodeFn);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If i pass an MFnSet to this method, dagNodeFn will be initialised to NULL right? You then next call:

const MDagPath dagPath = dagNodeFn.dagPath(&status);

Which would crash horribly. Dynamic casting a reference is not the safest way of programming if you ask me :/

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dynamic_cast of a reference throws bad_cast when it fails, which is caught at line 48. Therefore, in that case, line 33 won't be reached.

#include "usdMaya/registryHelper.h"
#include "usdMaya/shadingModeRegistry.h"
#include "../registryHelper.h"
#include "../shading/shadingModeRegistry.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason you've decided to go for relative include paths everywhere? (I must confess, I'm not a big fan of this style)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I obviously agree with @robthebloke, given the stink I raised in #91.

We let it slide there, but in my opinion this all really needs to be cleaned up before this change gets merged in. Otherwise, we're significantly backsliding with this change.

UsdMayaPrimUpdaterContext::GetUsdStage() const
{
return _stage;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DSO exporting these getters is madness. make them inline.

@@ -60,28 +60,32 @@ class UsdMayaShadingModeRegistry : public TfWeakBase
{
public:

MAYAUSD_CORE_PUBLIC
static UsdMayaShadingModeExporterCreator GetExporter(const TfToken& name) {
return GetInstance()._GetExporter(name);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this an inline function, or an exported one? Please remove the export macros. This change is a change for the worse imho.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. The export macros should not have been added for the functions defined here in the header.

@@ -14,7 +14,7 @@
// limitations under the License.
//
#include "pxr/pxr.h"
#include "usdMaya/userTaggedAttribute.h"
#include <mayaUsd/fileio/utils/userTaggedAttribute.h>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rest of this PR turns all absolute paths into relative ones (bad choice if you ask me), so why does it differ here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No reason, both are valid, since these changes were done manually I will assume it was an on the spot decision.

const MString& optionsString,
MPxFileTranslator::FileAccessMode /*mode*/)
{
std::string fileName(file.fullName().asChar());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::string fileName(file.fullName().asChar(), file.fullName().length());

continue;
}

std::string argName(theOption[0].asChar());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::string argName(theOption[0].asChar(), theOption[0].length());

MStringArray optionList;
MStringArray theOption;
optionsString.split(';', optionList);
for(int i=0; i<(int)optionList.length(); ++i) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for(unsigned i=0, n = optionList.length(); i<n; ++i)

#include <maya/MFnPlugin.h>

namespace {
#define CMD_NAME "usdUndoHelperCmd"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const char* const CMD_NAME = "usdUndoHelperCmd";

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't be doing this one, prevents C literal string concatenation, which is used in 5 places in this file. I agree that in general macros are to be avoided, but this one is a nice convenience.

UsdMayaUndoHelperCommand::initialize(MFnPlugin& plugin)
{
// If we're already registered, do nothing.
if (_registrationCount++ > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pattern is still a bug ;)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Armor plated this.

Copy link
Contributor

@mattyjams mattyjams left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I've read through all of the changes at this point. I'm still working on adapting our internal build to deal with all of the moves, so I've not yet been able to run our tests on it. I'll be continuing to work on that next week.

There are some important problems in lib/CMakeLists.txt that need fixing.

I let the header include paths issue go in #91 but I really can't let it go here. Those need to be fixed.

I'd love to hear what others think about the mayaUsd.lib.<...> Python package path. Do we expect a lot of other stuff to end up under the mayaUsd namespace? Why the extra lib step? We have to touch up a lot of internal code to account for these moves as other might have to also, so I want to try to make sure we only need to do it once.

There are a handful of other minor cosmetic issues, and then a few cases where isolated, unrelated changes crept in. It would really be helpful if future PRs could be smaller and more focused, or at the very least be organized somewhat into a series of commits that clarify what's changing. This and #91 were painful to review on GitHub even if you're not on the other side of the Earth. 😛

Comment on lines 47 to 65
fileio/registryHelper.cpp
fileio/primReaderContext.cpp
fileio/primReaderArgs.cpp
fileio/primReader.cpp
fileio/primReaderRegistry.cpp
fileio/functorPrimReader.cpp
fileio/fallbackPrimReader.cpp
fileio/primWriterContext.cpp
fileio/primWriterArgs.cpp
fileio/primWriter.cpp
fileio/primWriterRegistry.cpp
fileio/functorPrimWriter.cpp
fileio/writeJobContext.cpp
fileio/instancedNodeWriter.cpp
fileio/transformWriter.cpp
fileio/shaderWriter.cpp
fileio/primUpdater.cpp
fileio/primUpdaterContext.cpp
fileio/primUpdaterRegistry.cpp
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to keep each of these subgroups ordered lexicographically, and have the groups themselves ordered that way as well

utils/stageCache.cpp
utils/query.cpp
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utils/query.cpp is included twice in this block.

utils/query.h
utils/util.h
utils/utilFileSystem.h
utils/blockSceneModificationContext.h
utils/stageCache.h
utils/query.h
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utils/query.h listed twice here too, though not as a result of this change.

@ppt-adsk
Copy link
Collaborator Author

Thanks all for the detailed comments. Back on January 6th, will pick things up at that point.

@ppt-adsk
Copy link
Collaborator Author

ppt-adsk commented Jan 6, 2020

Hey all, thanks for the careful reviews. Correct me if I'm wrong, but I believe that two issues would be considered blocking:

  1. Relative include path changes: we would like to make a targeted branch to remove relative include paths later on.
  2. mayaUsd package structure: in refactoring_sandbox, we have two sub-packages, mayaUsd.lib for core code, and mayaUsd.ufe for Python bindings to UFE interface implementations.

All other suggested changes appear reasonable to me, and I think should be implemented. However, our goal is to minimize difficulties in merging back dev to refactoring_sandbox. This merge is needed to bring refactoring_sandbox and all branches created from it that are still in flight up to date, so that they can in turn be merged back to dev and ultimately clean out and close down refactoring_sandbox development.
Our hope is therefore to implement the suggestions made here in a later dev branch.

@mattyjams did you run your internal tests with this branch? Let us know the results.

Comment on lines 66 to 72
mArgs(iArgs),
mFileName(iFileName),
mPrimPath(iPrimPath),
mVariants(iVariants),
mPrimPath(iPrimPath),
mDagModifierUndo(),
mDagModifierSeeded(false),
mMayaRootDagPath()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the ordering or properties in the header, these initializers need to be re-ordered to avoid tripping over -Werror=reorder:

    mArgs(iArgs),
    mFileName(iFileName),
    mVariants(iVariants),
    mMayaRootDagPath(),
    mPrimPath(iPrimPath),
    mDagModifierUndo(),
    mDagModifierSeeded(false)

UsdMayaPrimUpdater() = default;
virtual ~UsdMayaPrimUpdater() = default;

MAYAUSD_CORE_PUBLIC
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This export macro should be removed. Our build fails because of -Werror=attributes:

maya_open_source/maya-usd/lib/fileio/primUpdater.h:45:16: error: attribute ignored in declaration of 'enum class UsdMayaPrimUpdater::Supports' [-Werror=attributes]

@@ -0,0 +1,42 @@
//
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file was newly added when it should have been moved from plugin/pxr/maya/lib/usdMaya.

The file is still present in the old location and should be removed:
https://github.com/Autodesk/maya-usd/blob/Autodesk/ppt/refactoring_sandbox_to_dev_00/plugin/pxr/maya/lib/usdMaya/chaser.cpp

@ppt-adsk
Copy link
Collaborator Author

ppt-adsk commented Jan 8, 2020

Hello again all,

After the discussion that this PR has triggered, and because of the fact that some of the problems raised cause build breaks with Pixar's internal builds, I've decided that it would be too much work to manage those changes that need to be done in this PR because they're blocking, versus those that could be postponed to a later branch as non-blocking. Since implementing all suggested changes was the intent all along, I will therefore do them immediately, except for include path changes. This should reduce e-mail discussions and tracking of which suggested changes were done in which branch, while keeping the merge back to refactoring_sandbox efficient (I hope). I will proceed with this approach immediately. Let me know if you still have questions.

@@ -41,7 +41,6 @@ class UsdMayaPrimUpdater
UsdMayaPrimUpdater() = default;
virtual ~UsdMayaPrimUpdater() = default;

MAYAUSD_CORE_PUBLIC
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Symbol visibility attribute warning fix.

@@ -304,7 +304,7 @@ namespace {
const VtIntArray &faceVertexCounts = topology.GetFaceVertexCounts();

unsigned int numIndex = 0;
for (int i = 0; i < faceVertexCounts.size(); i++)
for (std::size_t i = 0; i < faceVertexCounts.size(); i++)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Signed / unsigned comparison warning fix.

@@ -96,11 +96,6 @@ target_include_directories(${TRANSLATORS_PLUGIN}
${CMAKE_BINARY_DIR}
)

target_include_directories(${TRANSLATORS_PLUGIN}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

api.h is not an include directory warning fix.

@ppt-adsk
Copy link
Collaborator Author

ppt-adsk commented Jan 9, 2020

Unless otherwise noted, changes in commit
b10bf8e
are to fix unsigned vs. signed comparison warnings.

@@ -160,6 +160,8 @@ void Profiler::popTime()
timespec endtime;
#ifdef _WIN32
while(clock_gettime(CLOCK_REALTIME_COARSE, &endtime) != 0) /* deliberately empty */;
#else
timespec_get(&endtime, TIME_UTC);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes endtime uninitialized warning.

usdSkel
usdUtils
vt
${Boost_PYTHON_LIBRARY}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think Boost is required for this library?

mattyjams added a commit to mattyjams/maya-usd that referenced this pull request Jan 14, 2020
…a namespace

Pull request Autodesk#154 relocates a bunch of Python bindings from pxr.UsdMaya to
mayaUsd.lib. To ease the transition for Python code that uses the bindings from
the old package namespace, this change reintroduces the migrated names back
into the pxr.UsdMaya namespace by importing them from mayaUsd.lib. It is
wrapped in a try/except so that it will work both before and after PR Autodesk#154 is
merged.
Copy link
Contributor

@mattyjams mattyjams left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for addressing all of the notes @ppt-adsk!

With those changes, I've now been able to get this PR to build internally and pass all of our tests, so we're ready to take this change.

There were a few minor things I needed to touch up, one of which submitted as #199. The changes here end up being a breaking change for any Python code that used any of the UsdMaya functionality that moved to mayaUsd.lib, so #199 keeps old code working and allows some additional time to revisit it. The goal is definitely for that to be temporary though. I'm not sure how much others outside of Pixar are affected by this, but we have a fair bit of clean-up to do there.

The other two things had to do with how the Python bindings for mayaUsd.lib.mayaUsd and mayaUsd.ufe get built (making them consistent with other Python binding libs), and how the plugInfo.json files are arranged. I'll wait until the smoke clears from this PR going in (along with the backlog behind it) before I try to clean up our internal changes for those and put them up as PRs.

Thanks again!

Copy link
Contributor

@murphyeoin murphyeoin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ppt-adsk ppt-adsk merged commit 0e21c26 into dev Jan 14, 2020
@ppt-adsk ppt-adsk deleted the Autodesk/ppt/refactoring_sandbox_to_dev_00 branch January 14, 2020 14:45
asluk pushed a commit to asluk/maya-usd that referenced this pull request Jan 18, 2020
Methods to query information about renderer plugins are now static
pmolodo pushed a commit to LumaPictures/maya-usd that referenced this pull request Jan 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants