Skip to content

Commit

Permalink
Merge pull request #232 from AnimalLogic/AL_1013
Browse files Browse the repository at this point in the history
Improvements to USDGeomScope Functionality
  • Loading branch information
Krystian Ligenza authored Feb 4, 2020
2 parents 699a354 + 5b9f537 commit 31e6f34
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 13 deletions.
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");
}
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

0 comments on commit 31e6f34

Please sign in to comment.