Skip to content

Commit 559b864

Browse files
Fix mmPointFromObjectSet DG evaluation.
The dirty propagation was not working as expected. By querying the input values *and* using 'setDependentsDirty' I am able to work around the DG evaluation update problem.
1 parent 5f09683 commit 559b864

File tree

2 files changed

+71
-4
lines changed

2 files changed

+71
-4
lines changed

src/mmSolver/node/MMPointFromObjectSetNode.cpp

Lines changed: 68 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,37 @@ MString MMPointFromObjectSetNode::nodeName() {
277277
return MString(MM_POINT_FROM_OBJECT_SET_TYPE_NAME);
278278
}
279279

280+
MStatus MMPointFromObjectSetNode::setDependentsDirty(const MPlug &plug,
281+
MPlugArray &plugArray) {
282+
MStatus status = MS::kSuccess;
283+
284+
// Check if any matrix array element changed.
285+
if (plug.isElement() && plug.array() == a_matrixArray) {
286+
MPlug outMatrixPlug(thisMObject(), a_outMatrix);
287+
plugArray.append(outMatrixPlug);
288+
MPlug outPointPlug(thisMObject(), a_outPoint);
289+
plugArray.append(outPointPlug);
290+
}
291+
292+
// Check if any mesh array element changed.
293+
if (plug.isElement() && plug.array() == a_meshArray) {
294+
MPlug outMatrixPlug(thisMObject(), a_outMatrix);
295+
plugArray.append(outMatrixPlug);
296+
MPlug outPointPlug(thisMObject(), a_outPoint);
297+
plugArray.append(outPointPlug);
298+
}
299+
300+
// Check if the set node connection changed.
301+
if (plug == a_setNode) {
302+
MPlug outMatrixPlug(thisMObject(), a_outMatrix);
303+
plugArray.append(outMatrixPlug);
304+
MPlug outPointPlug(thisMObject(), a_outPoint);
305+
plugArray.append(outPointPlug);
306+
}
307+
308+
return MS::kSuccess;
309+
}
310+
280311
MStatus MMPointFromObjectSetNode::compute(const MPlug &plug, MDataBlock &data) {
281312
// When 'true', verbose will print out additional details for
282313
// debugging.
@@ -288,6 +319,43 @@ MStatus MMPointFromObjectSetNode::compute(const MPlug &plug, MDataBlock &data) {
288319
(plug == a_outPoint) || (plug == a_outPointX) ||
289320
(plug == a_outPointY) || (plug == a_outPointZ) ||
290321
(plug == a_outMatrix)) {
322+
// Query the set node to ensure dirty propagation.
323+
MDataHandle setNodeHandle = data.inputValue(a_setNode, &status);
324+
325+
// Query the matrix array to ensure dirty propagation.
326+
MArrayDataHandle matrixArrayHandle =
327+
data.inputArrayValue(a_matrixArray, &status);
328+
if (status == MS::kSuccess) {
329+
unsigned int matrixCount = matrixArrayHandle.elementCount();
330+
for (unsigned int i = 0; i < matrixCount; ++i) {
331+
status = matrixArrayHandle.jumpToArrayElement(i);
332+
if (status == MS::kSuccess) {
333+
MDataHandle matrixHandle =
334+
matrixArrayHandle.inputValue(&status);
335+
if (status == MS::kSuccess) {
336+
MMatrix mat = matrixHandle.asMatrix();
337+
}
338+
}
339+
}
340+
}
341+
342+
// Query the mesh array to ensure dirty propagation.
343+
MArrayDataHandle meshArrayHandle =
344+
data.inputArrayValue(a_meshArray, &status);
345+
if (status == MS::kSuccess) {
346+
unsigned int meshCount = meshArrayHandle.elementCount();
347+
for (unsigned int i = 0; i < meshCount; ++i) {
348+
status = meshArrayHandle.jumpToArrayElement(i);
349+
if (status == MS::kSuccess) {
350+
MDataHandle meshHandle =
351+
meshArrayHandle.inputValue(&status);
352+
if (status == MS::kSuccess) {
353+
MObject meshObj = meshHandle.asMesh();
354+
}
355+
}
356+
}
357+
}
358+
291359
// Outputs
292360
double outPointX = 0.0;
293361
double outPointY = 0.0;
@@ -382,11 +450,9 @@ MStatus MMPointFromObjectSetNode::initialize() {
382450
a_matrixArray = matrixAttr.create("matrix", "mat",
383451
MFnMatrixAttribute::kDouble, &status);
384452
CHECK_MSTATUS(status);
385-
// CHECK_MSTATUS(matrixAttr.setStorable(true));
386453
CHECK_MSTATUS(matrixAttr.setReadable(true));
387454
CHECK_MSTATUS(matrixAttr.setConnectable(true));
388455
CHECK_MSTATUS(matrixAttr.setArray(true));
389-
// CHECK_MSTATUS(matrixAttr.setUsesArrayDataBuilder(true));
390456
CHECK_MSTATUS(addAttribute(a_matrixArray));
391457

392458
// Meshes.
@@ -396,11 +462,9 @@ MStatus MMPointFromObjectSetNode::initialize() {
396462
a_meshArray = typedAttr.create("mesh", "msh", MFnData::kMesh,
397463
MObject::kNullObj, &status);
398464
CHECK_MSTATUS(status);
399-
// CHECK_MSTATUS(typedAttr.setStorable(true));
400465
CHECK_MSTATUS(typedAttr.setReadable(true));
401466
CHECK_MSTATUS(typedAttr.setConnectable(true));
402467
CHECK_MSTATUS(typedAttr.setArray(true));
403-
// CHECK_MSTATUS(typedAttr.setUsesArrayDataBuilder(true));
404468
CHECK_MSTATUS(addAttribute(a_meshArray));
405469
}
406470

src/mmSolver/node/MMPointFromObjectSetNode.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ class MMPointFromObjectSetNode : public MPxNode {
3939

4040
virtual ~MMPointFromObjectSetNode();
4141

42+
virtual MStatus setDependentsDirty(const MPlug &plug,
43+
MPlugArray &plugArray);
44+
4245
virtual MStatus compute(const MPlug &plug, MDataBlock &data);
4346

4447
static void *creator();

0 commit comments

Comments
 (0)