Issues with MPxNode::comput not firing

Issues with MPxNode::comput not firing

Anonymous
Not applicable
491 Views
1 Reply
Message 1 of 2

Issues with MPxNode::comput not firing

Anonymous
Not applicable

Hey, i've been stuck with an issue where the compute fuction of my node doesn't fire. I create 2 input strings and 2 typedattributes as outputs but when I change the string attribute the compute node is not being fired and I don't know why. below is the code from my header and source file. when i put a breakpoint inside the compute method it doedn't get hit.

 

header:

 

#pragma once
#include <maya\MPxNode.h>
#include <maya\MPlug.h>

class TrackPieceNode : public MPxNode
{
public:
	TrackPieceNode() {}
	virtual ~TrackPieceNode() override {};

	virtual MStatus         compute(const MPlug& plug, MDataBlock& data) override;
	// virtual MStatus         setDependentsDirty(const MPlug& plugBeingDirtied,MPlugArray &affectedPlugs) override;

	static  void*           creator();
	static  MStatus         initialize();

	static  MTypeId         id;                             // The IFF type id

public:
	static  MObject         next;
	static  MObject         previous;

	static  MObject         nextName;
	static  MObject         previousName;

	static  MObject         start;
};

source

#include "TrackPieceNode.h"

#include <maya\MFnMatrixAttribute.h>
#include <maya\MFnTypedAttribute.h>
#include <maya\MFnNumericAttribute.h>
#include <maya\MDGModifier.h>
#include <maya\MPlug.h>

MTypeId TrackPieceNode::id(0x81019);

  MObject         TrackPieceNode::next;
  MObject         TrackPieceNode::previous;
  MObject         TrackPieceNode::nextName;
  MObject         TrackPieceNode::previousName;
  MObject         TrackPieceNode::start;

MStatus TrackPieceNode::compute(const MPlug & plug, MDataBlock & data)
{
	int i = 0;
	return MStatus::kSuccess;
}


void * TrackPieceNode::creator()
{
	return new TrackPieceNode;
}

MStatus TrackPieceNode::initialize()
{
	MDGModifier mod;

	MFnMatrixAttribute transFn;
	MObject trans = transFn.create("input", "in");
	addAttribute(trans);

	MFnNumericAttribute startFn;
	start = startFn.create("istart", "startToggle", MFnNumericData::Type::kBoolean);
	addAttribute(start);



	MFnTypedAttribute nextFn;
	next = nextFn.create("nextTrackPiece", "next", MFnData::Type::kNObject);
	nextFn.setReadable(true);
	nextFn.setWritable(true);
	addAttribute(next);

	MFnTypedAttribute previousFn;
	previous = previousFn.create("PreviousNextPiece", "prev", MFnData::Type::kNObject);
	previousFn.setReadable(true);
	previousFn.setWritable(true);
	addAttribute(previous);



	MFnTypedAttribute stringFn;
	nextName = stringFn.create("inputGeomName", "geom1", MFnData::Type::kString);
	stringFn.setReadable(true);
	stringFn.setReadable(true);
	addAttribute(nextName);

	previousName = stringFn.create("outputGeom", "geom2", MFnData::Type::kString);
	stringFn.setReadable(true);
	stringFn.setReadable(true);
	addAttribute(previousName);
	MStatus stat;
	stat = attributeAffects(nextName, next);
	if (stat != MStatus::kSuccess)
	{
		return stat;
	}


	stat = attributeAffects(previousName, previous);

	if (stat != MStatus::kSuccess)
	{
		return stat;
	}

	return MStatus::kSuccess;
}
0 Likes
492 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable

Do you have anything connected to one of the outputs affected by the input string? Compute is only fired when needed. You can test it by hovering the plug in the node editor. After a few seconds (when the tooltip is generated), your compute method should be called.

0 Likes