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

Refactor of way serialization of layers is done within a maya scene file #53

Merged
merged 32 commits into from
Jan 16, 2018
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
bbed679
Transform: remove unset / unused outStageData attr
pmolodo Oct 5, 2017
166a593
Transform: simplify way inStageData is consumed
pmolodo Oct 6, 2017
bac1231
layer refactor: replace layer nodes with a single layer manager node
pmolodo Aug 29, 2017
c021970
fix for loading of plugin on scene open via requires
pmolodo Sep 11, 2017
59524c8
ProxyShape: make sure outStageData is marked dirty after stageReload()
pmolodo Oct 6, 2017
2931f9f
rename reloadStage to loadStage
pmolodo Nov 3, 2017
37351e4
make sure loadStage is only called once on node creation
pmolodo Nov 3, 2017
68d99c7
fix makeUsdTransformChain
pmolodo Nov 10, 2017
ed4bcc1
test_LayerManager: newFile at start of tests
pmolodo Dec 7, 2017
51484ee
remove commented out getSelectedNode
pmolodo Dec 22, 2017
80e1763
make LayerGetLayers -muted return display layers by default (like oth…
pmolodo Dec 22, 2017
f1033fb
LayerSave command - formally make layer a mandatory arg
pmolodo Dec 22, 2017
5dd57e6
[LayerManager] Add notes about multithreading / mutex locks
pmolodo Dec 22, 2017
2585ef4
[LayerManager] fix disconnectCompoundArrayPlug, add test
pmolodo Dec 23, 2017
c1239a7
[LayerManager] address miscellaneous code review notes from dbaz
pmolodo Dec 23, 2017
5a8abe3
Merge branch 'develop' into pr/layer_refactor
pmolodo Jan 4, 2018
a4b2d44
maya/Common.h: move where AL_MAYA_CHECK_ERROR_CONTINUE / AL_MAYA_CHEC…
pmolodo Jan 4, 2018
a1d35b8
LayerManager: use custom LayerDatabase class to store layers
pmolodo Jan 6, 2018
6e57f65
LayerManager: allow findOrCreateNode/Manager to take optional DGModifier
pmolodo Jan 6, 2018
ffb96a0
LayerManager: some tweaks to debug prints
pmolodo Jan 10, 2018
5c00bd6
test_ProxyShapeImport: add test for ProxyShapeImport with sessionLayer
pmolodo Jan 10, 2018
46f18e9
LayerManager: serialize session layers on layer manager, to prevent d…
pmolodo Jan 10, 2018
bde37e7
LayerManager: add some backward-compatibility code for ProxyShapes wi…
pmolodo Jan 10, 2018
7b6923a
LayerCommands: find proxyShape from selected ProxyShapeTransform
pmolodo Jan 11, 2018
64766d6
Merge branch 'pr/getProxyFromSelectedTransform' into pr/layer_refactor
pmolodo Jan 11, 2018
f11c856
CommandGuiHelper: setEditTarget gui should show ALL layers in stage
pmolodo Jan 12, 2018
db8afe1
ProxyShape: move trackEditTargetLayer back as a method on ProxyShape
pmolodo Jan 12, 2018
8f17acf
ProxyShape: on editTarget change, check if PREVIOUS target was dirty
pmolodo Jan 13, 2018
7209fae
LayerManager: add python wrapper
pmolodo Jan 15, 2018
15546c8
add AL_MAYA_CHECK_ERROR_RETURN_VAL
pmolodo Jan 15, 2018
85c1aa2
CommandGuiHelper::addExecuteText - print offending characters
pmolodo Jan 16, 2018
a9dfcaf
test_LayerManger: compatibility fixes for maya 2017
pmolodo Jan 16, 2018
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
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
## v0.??.? (????-??-??)

### Added


### Changed

* Using -muted/-m flag with AL_usdmaya_LayerGetLayers now returns layer display names by default, and identifiers if
the -identifiers/-id flag is set. This makes it more in line with all the other flags for the command (and more
flexible), but is a change in behavior - previously, the muted layers would ALWAYS be returned as identifier.


## v0.25.0 (2017-11-28)

### Added
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ include_directories(${PXR_INCLUDE_DIRS})
# is the rationale for listing them here.
find_package(Boost COMPONENTS
python
thread
REQUIRED
)

Expand Down
1 change: 0 additions & 1 deletion docs/layers.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Normally, the default Edit Target in USD will be the Root Layer of the scene, al
#### Commands
There are a number of layer-related commands available, all are available via MEL, and some from the USD->Layers dropdow in the UI.
+ AL_usdmaya_LayerSave
+ AL_usdmaya_LayerCreateSubLayer
+ AL_usdmaya_LayerCreateLayer
+ AL_usdmaya_LayerCurrentEditTarget
+ AL_usdmaya_LayerGetLayers
Expand Down
37 changes: 35 additions & 2 deletions lib/AL_USDMaya/AL/maya/CommandGuiHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,35 @@ CommandGuiHelper::~CommandGuiHelper()
MGlobal::executeCommand(MString(m_controls.str().data(), m_controls.str().size()));
}

//----------------------------------------------------------------------------------------------------------------------
void CommandGuiHelper::addExecuteText(const char* toAdd)
{
// TODO: write a proper string encoder for MEL (tricky, because can't represent
// all 256 character-bytes using mel string literals - would have to resort to
// calling out to python for a truly string rerpr encoder.
// (note that even mel's builtin "encodeString" command doesn't actually always
// return a mel string that will evaluate to the input - ie, it will return
// "\004", but that isn't a valid mel escape sequence, and will just result in "004"

// for now, just check to make sure we have printable characters... only need to
// implement a full MEL-string-encoder if we really have a need...
m_execute << " $str += \"";

for(size_t i = 0; toAdd[i] != '\0'; ++i)
{
if(toAdd[i] < 32 || toAdd[i] > 126)
{
// Just throwing, if we ever need to use a string with weird chars, need to
// update this function...
throw std::logic_error("CommandGuiHelper::addExecuteText may only be called with normal printable characters");
Copy link
Contributor

Choose a reason for hiding this comment

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

Having a bit more information about which character is the 'bad' one would be nice, Could we print out the index of the character in the string?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, could make this a std::cerr and a return. Seems a bit harsh to throw an exception for this case.

}
else if (toAdd[i] == '"') m_execute << "\\\"";
else if (toAdd[i] == '\\') m_execute << "\\\\";
else m_execute << toAdd[i];
}
m_execute << "\";\n";
}

//----------------------------------------------------------------------------------------------------------------------
void CommandGuiHelper::addFlagOption(const char* commandFlag, const char* label, const bool defaultVal, bool persist)
{
Expand Down Expand Up @@ -314,7 +343,7 @@ void CommandGuiHelper::addBoolOption(const char* commandFlag, const char* label,
}

//----------------------------------------------------------------------------------------------------------------------
void CommandGuiHelper::addListOption(const char* commandFlag, const char* label, GenerateListFn generateList)
void CommandGuiHelper::addListOption(const char* commandFlag, const char* label, GenerateListFn generateList, bool isMandatory)
{
const std::string optionVar = m_commandName + "_" + commandFlag;
const std::string getOptionVar = std::string("`optionVar -q -sl \"") + optionVar + "\"`";
Expand All @@ -336,7 +365,11 @@ void CommandGuiHelper::addListOption(const char* commandFlag, const char* label,

//
m_execute << " global string $" << optionVar << "_sl;"
<< " $str += \" -" << commandFlag << " $" << optionVar << "_sl \";\n";
<< " $str += \" ";
if (!isMandatory) {
m_execute << "-" << commandFlag << " ";
}
m_execute << "$" << optionVar << "_sl \";\n";
}

//----------------------------------------------------------------------------------------------------------------------
Expand Down
8 changes: 7 additions & 1 deletion lib/AL_USDMaya/AL/maya/CommandGuiHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ class CommandGuiHelper
/// \brief dtor - auto generates, and executes the GUI code.
~CommandGuiHelper();

/// \brief add some text to the execute command, unconditionally
/// Useful if, ie, you always want to set a non-default command flag
/// \param toAdd extra flags / text to add to the execution command
void addExecuteText(const char* toAdd);

/// \brief add a boolean option value to the GUI
/// \param commandFlag the flag for the command
/// \param label human readable GUI label for the option
Expand Down Expand Up @@ -230,7 +235,8 @@ class CommandGuiHelper
/// \param commandFlag the flag for the command
/// \param label human readable GUI label for the option
/// \param generateList The C++ command to build up a list of text strings for the GUI to display
void addListOption(const char* commandFlag, const char* label, GenerateListFn generateList);
/// \param isMandatory If true, our commandFlag is actually a mandatory argument, not a option / flag
void addListOption(const char* commandFlag, const char* label, GenerateListFn generateList, bool isMandatory=false);

/// \brief add an enum option value to the GUI
/// \param commandFlag the flag for the command
Expand Down
34 changes: 34 additions & 0 deletions lib/AL_USDMaya/AL/maya/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,40 @@ class ProfilerSectionTag;
MGlobal::displayError(maya_error_string); \
} }

/// \brief Given the status, validates that the status is ok. If not, an error is logged using the specified error
/// message. If an error occurs, then a "continue" statement is issued (and so should be used in loops).
/// \ingroup mayautils
#define AL_MAYA_CHECK_ERROR_CONTINUE(status, ErrorString) { \
MStatus _status_##__LINE__ = status; \
if (!_status_##__LINE__) \
{ \
MString maya_error_string = __FILE__ ":"; \
maya_error_string += __LINE__; \
maya_error_string += " "; \
maya_error_string += _status_##__LINE__.errorString(); \
maya_error_string += " : "; \
maya_error_string += ErrorString; \
MGlobal::displayError(maya_error_string); \
continue; \
} }

/// \brief Given the status, validates that the status is ok. If not, an error is logged using the specified error
/// message. If an error occurs, then exit immediately, with no return.
/// \ingroup mayautils
#define AL_MAYA_CHECK_ERROR_RETURN(status, ErrorString) { \
MStatus _status_##__LINE__ = status; \
if (!_status_##__LINE__) \
{ \
MString maya_error_string = __FILE__ ":"; \
maya_error_string += __LINE__; \
maya_error_string += " "; \
maya_error_string += _status_##__LINE__.errorString(); \
maya_error_string += " : "; \
maya_error_string += ErrorString; \
MGlobal::displayError(maya_error_string); \
return; \
} }

/// \brief Given the status, validates that the status is ok. If not, an error is logged using the specified error
/// message. If an error occurs, a null MObject is returned.
/// \ingroup mayautils
Expand Down
14 changes: 14 additions & 0 deletions lib/AL_USDMaya/AL/maya/NodeHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1597,6 +1597,20 @@ MStatus NodeHelper::outputDataValue(MDataBlock& dataBlock, const MObject& attrib
return status;
}

//----------------------------------------------------------------------------------------------------------------------
MPxData* NodeHelper::outputDataValue(MDataBlock& dataBlock, const MObject& attribute)
{
MStatus status;
MDataHandle outDataHandle = dataBlock.outputValue(attribute, &status);
if(status)
{
return outDataHandle.asPluginData();
}
report_get_error(attribute, MPxData, status);
return 0;
}


//----------------------------------------------------------------------------------------------------------------------
MPxData* NodeHelper::createData(const MTypeId& dataTypeId, MObject& data)
{
Expand Down
39 changes: 37 additions & 2 deletions lib/AL_USDMaya/AL/maya/NodeHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,21 @@ namespace maya {
/// \endcode
/// \ingroup mayagui
//----------------------------------------------------------------------------------------------------------------------
#define AL_DECL_ATTRIBUTE(XX) \

// For children of multi-attribute, a generic XXPlug() method
// isn't very helpful, as we need to attach to a specific indexed
// element plug of the parent array... and defining it just
// creates a confusing name
#define AL_DECL_MULTI_CHILD_ATTRIBUTE(XX) \
private: \
static MObject m_##XX; \
public: \
MPlug XX##Plug() const { return MPlug( thisMObject(), m_##XX ); } \
static const MObject& XX () { return m_##XX; }

#define AL_DECL_ATTRIBUTE(XX) \
AL_DECL_MULTI_CHILD_ATTRIBUTE(XX) \
MPlug XX##Plug() const { return MPlug( thisMObject(), m_##XX ); } \

//----------------------------------------------------------------------------------------------------------------------
/// \brief This is a little helper object designed to reduce the amount of boilerplate GUI code you need to jump through
/// to add your own nodes that match a USD schema type. It has been designed to attempt to match the attribute
Expand Down Expand Up @@ -481,6 +489,33 @@ class NodeHelper
/// \return MS::kSuccess if all went well
static MStatus outputDataValue(MDataBlock& dataBlock, const MObject& attribute, MPxData* value);

/// \brief get an output data value from the dataBlock from the specified attribute
/// \param dataBlock the data block to get the value from
/// \param attribute the handle to the attribute to get an MPxData for
/// \return the value
/// \note If the value could not be queried, and error will be logged to std::cerr
/// Useful when you want to modify something on the underlying MPxData, without
/// creating / setting an entirely new instance of the MPxData
static MPxData* outputDataValue(MDataBlock& dataBlock, const MObject& attribute);

/// \brief get an output data value from the dataBlock from the specified attribute
/// \param dataBlock the data block to get the value from
/// \param attribute the handle to the attribute to get an MPxData subclass for
/// \return the value
/// \note If the value could not be queried, and error will be logged to std::cerr
/// Useful when you want to modify something on the underlying MPxData subclass, without
/// creating / setting an entirely new instance of the MPxData subclass
template<typename MPxDataType>
static MPxDataType* outputDataValue(MDataBlock& dataBlock, const MObject& attribute)
{
MPxData* data = NodeHelper::outputDataValue(dataBlock, attribute);
if(data)
{
return dynamic_cast<MPxDataType*>(data);
}
return 0;
}

/// \brief helper method to create new data objects of the specified data type
/// \param dataTypeId the MTypeId of the plugin data object to create
/// \param data the returned handle to the created data object, usually passed to MDataHandle::set, or MPlug::setValue.
Expand Down
1 change: 0 additions & 1 deletion lib/AL_USDMaya/AL/usdmaya/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ namespace cmds {
struct CompareLayerHandle;
class LayerCommandBase;
class LayerConstructTree;
class LayerCreateSubLayer;
class LayerCurrentEditTarget;
class LayerExport;
class LayerGetLayers;
Expand Down
Loading