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

Improvements to USDGeomScope Functionality #232

Merged
merged 4 commits into from
Feb 4, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion plugin/al/lib/AL_USDMaya/AL/usdmaya/fileio/NodeFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,13 @@ NodeFactory::~NodeFactory()
//----------------------------------------------------------------------------------------------------------------------
MObject NodeFactory::createNode(const UsdPrim& from, const char* const nodeType, MObject parent, bool parentUnmerged)
{
TF_DEBUG(ALUSDMAYA_TRANSLATORS).Msg(" NodeFactory::createNode: %s of type %s\n", from.GetPrimPath().GetText(), nodeType);
std::unordered_map<std::string, translators::DgNodeTranslator*>::iterator it = m_builders.find(nodeType);
if(it == m_builders.end()) return MObject::kNullObj;
if(it == m_builders.end())
{
//If we can't find a specific translator, use the DagNodeTranslator
it = m_builders.find("dagNode");
Copy link
Contributor

Choose a reason for hiding this comment

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

I was going to ask if we need to check if it actually found this one but it looks like it’s added in the constructor and should always be there.

}
MObject obj = it->second->createNode(from, parent, nodeType, *m_params);
setupNode(from, obj, parent, parentUnmerged);
return obj;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,19 @@ void DagNodeTranslator::initialiseDefaultShadingGroup(MObject& target)
//----------------------------------------------------------------------------------------------------------------------
MObject DagNodeTranslator::createNode(const UsdPrim& from, MObject parent, const char* nodeType, const ImporterParams& params)
{
const char* const xformError = "DagNodeTranslator::createNode error creating node";
MStatus status;
MFnDagNode fn;
MObject to = fn.create(nodeType);

MStatus status = copyAttributes(from, to, params);
AL_MAYA_CHECK_ERROR_RETURN_NULL_MOBJECT(status, "Dag node translator: unable t/o get attributes");
MObject to = fn.create(nodeType, parent, &status);
if (status!= MS::kSuccess) {
std::cerr << "DagNodeTranslator::createNode unable to create node of type " << nodeType << ". Create transform instead" << std::endl;
Copy link
Contributor

Choose a reason for hiding this comment

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

The only thing I’d probably change is use of std::cerr. The macros here are all using MGlobal::displayError/Warning/Info functions so maybe stick with one of those?

to = fn.create("transform", parent, &status);
}
AL_MAYA_CHECK_ERROR2(status, xformError);

status = copyAttributes(from, to, params);
AL_MAYA_CHECK_ERROR_RETURN_NULL_MOBJECT(status, "DagNodeTranslator::createNode unable to get attributes");

return to;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,10 @@ class BasicTransformationMatrix
AL_USDMAYA_PUBLIC
static MPxTransformationMatrix* creator();

private:

protected:
UsdPrim m_prim;

private:
UsdGeomScope m_scope;
MObjectHandle m_transformNode;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ MPxTransformationMatrix* TransformationMatrix::creator()
//----------------------------------------------------------------------------------------------------------------------
TransformationMatrix::TransformationMatrix()
: BasicTransformationMatrix(),
m_prim(),
m_xform(),
m_time(UsdTimeCode::Default()),
m_scaleTweak(0, 0, 0),
Expand Down Expand Up @@ -75,8 +74,7 @@ TransformationMatrix::TransformationMatrix()

//----------------------------------------------------------------------------------------------------------------------
TransformationMatrix::TransformationMatrix(const UsdPrim& prim)
: BasicTransformationMatrix(),
m_prim(prim),
: BasicTransformationMatrix(prim),
m_xform(prim),
m_time(UsdTimeCode::Default()),
m_scaleTweak(0, 0, 0),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ class TransformationMatrix

friend class Transform;

UsdPrim m_prim;
UsdGeomXformable m_xform;
UsdTimeCode m_time;
std::vector<UsdGeomXformOp> m_xformops;
Expand Down