heres the handler so far…
static void cloned_notify_proc(void* param, NotifyInfo* info)
INode* cloned_node = static_cast<INode*>(info->callParam);
Object* cloned_node_obj = cloned_node->GetObjectRef();
cloned_node_obj = cloned_node_obj->FindBaseObject(); // skip over any modifers (not that any work on this)
if(cloned_node_obj->SuperClassID() == GEN_DERIVOB_CLASS_ID) // is it a reference ?
IDerivedObject* dobj = static_cast<IDerivedObject*>(cloned_node_obj);
cloned_node_obj = dobj->GetObjRef(); // it is so get what it's derived from
if(cloned_node_obj->ClassID() != XFORM_MONITOR_CLASS_ID) return; // this clone is not our's to interfere with so bum out
// get the object the the new node is references
XFormMonitor* cloned_xfm_obj = static_cast<XFormMonitor*>(cloned_node_obj);
if(!cloned_xfm_obj || cloned_xfm_obj->GetThisNode() == cloned_node) return; // already a copy clone op
// get the object we are cloning from
XFormMonitor* src_xfm_obj = static_cast<XFormMonitor*>(param);
if(!src_xfm_obj || src_xfm_obj->GetThisNode() == cloned_node) return; // catch whether the src node and new node the same ?
// so we now have 2 different nodes and one xfm object so make the cloned_node a nice "unique" xfm object of it's own
// it's "this node" (cloned_node) will be caught and assigned to the object when the node references it in SetObjectRef.
XFormMonitor* unique_xfm_obj = static_cast<XFormMonitor*>(src_xfm_obj->Clone());
if(src_xfm_obj != cloned_xfm_obj)
cloned_xfm_obj->DeleteThis(); // delete the derived object the reference was referencing
a couple of notes…
GetThisNode() if a function that returns the node from a INodeTransformMonitor reference that our object maintains.
It’s weird/unusal notify event because it’s not as general as most so every node that is cloned will fire off this event but with our this pointer attached (regardless of class) and if we have 20 of our nodes in the scene that’s 20 different events ready to be fired off when cloning something completely unrelated which is pretty bonkers. It’s was quite amusing and a tad bizarre turning boxes into helpers when instance or reference cloning
perhaps the more “global” NOTIFY_POST_NODES_CLONED would be a better bet than trying to handle at an individual level though it would still need to be registered with the class and not in each constructor. hmmmm.