[Closed] [SDK] Make modifier dependent of node's TM
I mean user can’t stack other osm mods on top of wsm. What would be the use of volumeselect if it was made on top of the stack?
This one fixes the collapse, but I still have no idea how to catch remove modifer event
void MaterialIDMod::NotifyPostCollapse(INode* node, Object* obj, IDerivedObject* derObj, int index)
{
if (container && node)
{
int j = -1;
j = container->FindRef(node->GetTMController());
if ( j != -1 && j < container->NumItems())
{
container->RemoveItem(j);
}
}
}
i don’t get anything in global tracks at all from my modifiers, do you get the same thing happening with vol select ?
Pretty sure that’s the reason you can’t see it.
I commented this line for debug purposes
from AddTVNode
container = CreateITrackViewNode(TRUE);
container->HideChildren(TRUE);
but I still have no idea how to catch remove modifer event
RegisterNotification(NotifyHandler,this, NOTIFY_PRE_MODIFIER_DELETED);
#define NOTIFY_PRE_MODIFIER_DELETED 0x00000073
Sent before a modifier is deleted from an object.
The NotifyInfo structure pointer callParam is passed a pointer to a struct{ INode* node; Modifier* mod; ModContext* mc;}.
something like this…
struct PreModDelete
{
INode* node;
Modifier* mod;
ModContext* mc;
};
void MaterialIDMod::NotifyHandler(void *param, NotifyInfo *info )
{
if(info->intcode != NOTIFY_PRE_MODIFIER_DELETED) return;
MaterialIDMod* mod = static_cast<MaterialIDMod*> (param);
DbgAssert(mod != NULL);
PreModDelete* data = static_cast<PreModDelete*> (info->callParam);
if(data->mod->ClassID() == POLY_BOOLEAN_MOD_CLASS_ID)
{
int id;
INode* node = GetNodeFromModContext(mod, data->mc->localData, id); // found in many examples in the sdk
if(!node) node = data->node;
if (mod->container && node)
{
int j = -1;
j = mod->container->FindRef(node->GetTMController());
if ( j != -1 && j < mod->container->NumItems())
mod->container->RemoveItem(j);
}
}
}
define as …
static void NotifyHandler(void *param, NotifyInfo *info);
within your class…
with…
RegisterNotification(NotifyHandler, this, NOTIFY_PRE_MODIFIER_DELETED);
in the constructor and…
UnRegisterNotification(NotifyHandler,this, NOTIFY_PRE_MODIFIER_DELETED);
in the destructor
Thanks, Klvnk!
I have it working, but not without minor changes.
Is it really necessary to call GetNodeFromModContext?
data->node contains the node we’re looking for.
It gets really complicated after the undo of remove modifier operation.
There’s nothing added back to global tracks, but TVNodeNotify::NotifyRefChanged keeps firing as if tvnode was still there… and it keeps firing even after I remove modifier again.
10% of features requires 90% of work… everytime
It didn’t work for me using data->node (unless theres just a single node), and I cache the “thisnode” in the localmoddata so i use that also GetNodeFromModContext doesn’t work with a single node so you have to add the line
if(!node) node = data->node;
not sure why this is as pointer addresses are identical but theres error somewhere it’s all very strange!
try adding
if(mod->notify)
{
mod->container->UnRegisterTVNodeNotify(mod->notify);
delete mod->notify;
}
after
mod->container->RemoveItem(j);
Unfortunately, this won’t work. It will affect all other nodes that are still have this modifier applied.
Moreover we’ll have to restore part_tm event listener after undo/redo to make it work.
I found an example of RestoreObj, but not yet sure if it can help me
you’ll need to move the nofity object to the local mod data and handle it there I guess.
Thanks, I’ll try.
Actually it is what I used before the trackview. One notifier per node.