Notifications
Clear all

[Closed] [SDK] Make modifier dependent of node's TM

well, this would be a good time to start.

I use the NodeTransformMonitor method for objects and ITrackViewNode method for modifiers.

poly_bool

it’s an object space poly boolean modifier on the 2 boxes and the cylinder is set to the operand

Cool. I’ve seen ITrackViewNode in volumeselect, but it is above my skills at the moment. Don’t understand how it works at all.

class WeakRef : public MaxSDK::SingleWeakRefMaker
{
public:
	MyModifier* mod;
	virtual RefResult NotifyRefChanged(Interval changeInt, RefTargetHandle hTarget, PartID& partID, RefMessage message);

};

RefResult WeakRef::NotifyRefChanged(Interval changeInt, RefTargetHandle hTarget, PartID& partID, RefMessage message)
{
	if (partID == PART_TM)
	{
		mod->Invalidate( (INode*)hTarget );
	}
	return REF_SUCCEED;
}

Works for single node now, but I have some ideas how to improve that.
92N9sSQBji

that’s why INodeTransfornMoniter is suitable for objects as theres usually only one node.

Klvnk, how do you handle modifier delete / post collapse event?
My globaltracks tvnode that is connected to node tm still exist even after I put a lot of undo entries (more than max undo level) . I thought it should force the destructor to kill these tvnodes, but they’re still there. They disappear only after the maxscript GC() call.

doesn’t this work for you?

SelMod::~SelMod()
{
	// mjm - begin - 5.10.99
	if (container && notify)
	{
		ITrackViewNode *tvr = GetCOREInterface()->GetTrackViewRootNode();
		ITrackViewNode *global = tvr->GetNode(GLOBAL_VAR_TVNODE_CLASS_ID);
		ITrackViewNode *tvroot = global->GetNode(MCONTAINER_TVNODE_CLASS_ID);
		if (!tvroot)
			tvroot = tvr;
		if (tvroot) 
		{
			int ct = tvroot->NumItems();
			for (int i = 0; i < ct; i++)
			{
				ITrackViewNode *n = tvroot->GetNode(i);
				if (container == n) {
					container->UnRegisterTVNodeNotify(notify);
					tvroot->RemoveItem(i);
					// [YF] break the loop on found
					break;
				}
			}
		}
	}

	if (notify)
		delete notify;
	// mjm - end
}

Yes, that’s exactly what I use
Just checked and it manages to survive single GC call just fine and removes it after the second GC call… sometimes one gc call is enough…

Imagine a situation.
Add modifier instance to a thousand of nodes.
Then remove this modifier from 999 nodes
Thousand tvnodes are still exist as a result.

as you can see all of them survive just fine unless all the initial modifier instances are destructed

do it as a world space modifier if that’s how you intend to use it.

That’s bad as it will require me to sacrifice 90% of the mod functionality and usability.
I’ll try to find the corresponding tvnode in postcollapse method and remove it from the container.

eh ? I have World Space mods that have as much functionality as an Object space modifier for example a variation on meshblend
blend

Page 2 / 3