#include <maya/MIOStream.h>
#include <maya/MFnPlugin.h>
#include <maya/MString.h>
#include <maya/MPxCustomEvaluator.h>
#include <maya/MEulerRotation.h>
#include <maya/MCustomEvaluatorClusterNode.h>
#include <maya/MGlobal.h>
#include <maya/MTime.h>
#include <maya/MFnDependencyNode.h>
#include <maya/MPlugArray.h>
#include <maya/MPlug.h>
#include <maya/MAnimControl.h>
#include <maya/MSelectionList.h>
#include <maya/MFnSet.h>
#include <maya/MProfiler.h>
#include <maya/MItDependencyNodes.h>
#include <vector>
#include <string>
template <class T>
inline void hash_combine(std::size_t & seed, const T & v)
{
std::hash<T> hasher;
seed ^= hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
}
{
public:
virtual ~simpleEvaluator();
virtual const char* evaluatorName ();
static void* creator();
protected:
void buildPlugListWithControllerTag();
void buildHashValue();
private:
std::size_t fOldHashValue;
std::size_t fCurrentHashValue;
};
{
return true;
}
void simpleEvaluator::buildPlugListWithControllerTag()
{
{
const char* values[] = {"translateX", "translateY", "translateZ", "rotateX", "rotateY", "rotateZ"};
for (; !dgIter.isDone(); dgIter.next())
{
MPlug currControllerTagPlug = controllerTagNode.findPlug(
"controllerObject", &stat);
if (currControllerTagPlug.
connectedTo(source,
true ,
false , &stat))
{
MObject controllerNode = source[0].node(&stat);
for (unsigned int j = 0; j < 6; j++)
{
MPlug currPlug = currControllerNode.findPlug(values[j], &stat);
{
fControllerPlugs.append(currPlug);
}
else
{
std::cerr <<
"NO PLUG: " << currControllerNode.
name().
asChar() <<
"." << values[j] << std::endl;
}
}
}
}
}
}
void simpleEvaluator::buildHashValue()
{
unsigned int length = fControllerPlugs.length();
for (unsigned int i = 0; i < length; i++)
{
float value = 0;
stat = fControllerPlugs[i].getValue(value);
{
hash_combine(fCurrentHashValue, value);
}
else
{
std::cerr << "NO VALUE: " << fControllerPlugs[i].name().asChar() << std::endl;
}
}
}
{
}
{
MProfilingScope profilingScopeForEval(_profilerCategory, MProfiler::kColorD_L1,
"buildPoseHash",
"building pose hash");
buildHashValue();
}
{
fOldHashValue = fCurrentHashValue;
fCurrentHashValue = 0;
}
{
if (fControllerPlugs.length() == 0)
{
buildPlugListWithControllerTag();
}
return true;
}
{
if (fOldHashValue != fCurrentHashValue)
{
}
}
{
if (fControllerPlugs.length() > 0)
{
fControllerPlugs.clear();
}
}
void* simpleEvaluator::creator()
{
return new simpleEvaluator();
}
const char* simpleEvaluator::evaluatorName()
{
return "SimpleEvaluator";
}
simpleEvaluator::~simpleEvaluator()
{
}
{
MFnPlugin plugin( obj, PLUGIN_COMPANY,
"3.0",
"Any");
status = plugin.registerEvaluator("SimpleEvaluator", 40 , simpleEvaluator::creator);
if (!status)
{
status.
perror(
"registerEvaluator");
return status;
}
return status;
}
{
status = plugin.deregisterEvaluator( "SimpleEvaluator" );
if (!status)
{
status.
perror(
"deRegisterEvaluator");
return status;
}
return status;
}