THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 30/08/2004 at 04:13, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 8.206
Platform:
Language(s) : C++ ;
---------
Hello.
My ObjectData plugin has a linked list. I need to pass this linked list to the external renderer.
My problem is that because the external renderer clones the document thus creating a new instance of my Objectata plugin. The linked list is also created as new, so its empty by the time the renderer access it.
My code:
struct Node
{
LONG ID;
Node *NextNode;
};
class CCrashTest:public ObjectData
{
private:
LONG m_OldFrame;
LONG m_Counter;
Node *m_NodeHead;
void AddNode(Node n);
public:
//virtual Bool Init(GeListNode *node);
virtual BaseObject* GetVirtualObjects(PluginObject *op, HierarchyHelp *hh);
static NodeData *Alloc() { return gNew CCrashTest; }
};
BaseObject *CCrashTest::GetVirtualObjects(PluginObject *op, HierarchyHelp *hh)
{
GePrint(LongToString(m_Counter));
BaseTime bt = hh->GetDocument()->GetTime();
LONG CurrentFrame = bt.GetFrame(hh->GetDocument()->GetFps());
if(CurrentFrame != m_OldFrame)
{
Node n;
n.ID=m_Counter;
AddNode(n);
}
m_OldFrame = CurrentFrame;
return NULL;
}
void CCrashTest::AddNode(Node n)
{
Node *l_n = new Node;
(*l_n) = n;
l_n->NextNode=m_NodeHead;
m_NodeHead = l_n;
m_Counter++;
}
When the frame changes, a new item is added to the linked list. the m_Counter variable keeps track on how many items are in the linked list. If I scrub to frame 30, the number 30 is printed in the console. While i'm at frame 30 and I click render to picture viewer, the number 0 is printed to the console because the linked list was reset.
I can fix this my making the linked list global, but this is not good as multiple instances of the plugin would fight over the global variables.
As anyone got an suggestions on how I can solve this?