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 all 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
2 changes: 1 addition & 1 deletion plugin/al/lib/AL_USDMaya/AL/usdmaya/Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#define stringify(a) #a

#define AL_USDMAYA_VERSION_MAJOR 0
#define AL_USDMAYA_VERSION_MINOR 36
#define AL_USDMAYA_VERSION_MINOR 39
#define AL_USDMAYA_VERSION_PATCH 0

#define AL_USDMAYA_VERSION_STR xstr(AL_USDMAYA_VERSION_MAJOR) "." \
Expand Down
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 @@ -41,7 +41,7 @@ MObject DagNodeTranslator::m_initialShadingGroup = MObject::kNullObj;
//----------------------------------------------------------------------------------------------------------------------
MStatus DagNodeTranslator::registerType()
{
const char* const errorString = "Unable to extract attribute for DagNodeTranslator";
const char* const errorString = "DagNodeTranslator::Unable to extract attribute for DagNodeTranslator";
MNodeClass fn("transform");
MStatus status;

Expand All @@ -67,11 +67,20 @@ void DagNodeTranslator::initialiseDefaultShadingGroup(MObject& target)
//----------------------------------------------------------------------------------------------------------------------
MObject DagNodeTranslator::createNode(const UsdPrim& from, MObject parent, const char* nodeType, const ImporterParams& params)
{
std::string xformError = std::string("DagNodeTranslator::createNode error creating node of type ") + nodeType
+ ". Create transform instead";
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);
AL_MAYA_CHECK_ERROR2(status, xformError.c_str());
if (status!= MS::kSuccess) {
to = fn.create("transform", parent, &status);
}
AL_MAYA_CHECK_ERROR2(status, "DagNodeTranslator::createNode error creating node of type transform");

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

return to;
}
Expand All @@ -90,7 +99,7 @@ MStatus DagNodeTranslator::applyDefaultMaterialOnShape(MObject shape)
{
MStatus status;
MFnSet fn(m_initialShadingGroup, &status);
AL_MAYA_CHECK_ERROR(status, "Unable to attach MfnSet to initialShadingGroup");
AL_MAYA_CHECK_ERROR(status, "DagNodeTranslator::Unable to attach MfnSet to initialShadingGroup");
return fn.addMember(shape);
}

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