On 31/01/2013 at 01:14, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R14
Platform: Windows ;
Language(s) :
---------
Hey guys,
I trying to do the following:
I got an objectdata generator plugin which takes a spline and generate maybe an extrude nurbs with that spline.
But here special is, that the spline should not be under the generator, it should be the previous or parent.
If I use spline = op->GetPred() it works but the editor does not update correct not until I click in the editor view.
If I use spline = op->GetUp() it does not work, c4d crash.
If I use spline = op->GetDown() all is fine.
Check dirty of spline does not work, but you will see the effect if you toggle xray or change any other data of the generator (color, name...).
#include "c4d.h"
#define ID_PLUGIN_TESTOBJECT 12345678
class TestObject : public ObjectData
{
INSTANCEOF(TestObject, ObjectData)
public:
virtual BaseObject* GetVirtualObjects(BaseObject* op, HierarchyHelp* hh);
static NodeData* Alloc(void) { return gNew TestObject; }
};
BaseObject* TestObject::GetVirtualObjects(BaseObject* op, HierarchyHelp* hh)
{
BaseObject *spline = op->GetPred();
//BaseObject *spline = op->GetUp();
//BaseObject *spline = op->GetDown();
if (!spline || (spline->GetInfo() & OBJECT_ISSPLINE) != OBJECT_ISSPLINE) return NULL;
// check cache for validity and check master object for changes
Bool dirty = op->CheckCache(hh) || op->IsDirty(DIRTYFLAGS_DATA);
// check spline for changes - does not work
dirty |= spline->IsDirty(DIRTYFLAGS_DATA) || spline->IsDirty(DIRTYFLAGS_MATRIX) || spline->IsDirty(DIRTYFLAGS_CACHE);
// if no change has been detected, return original cache
if (!dirty) return op->GetCache(hh);
BaseObject *obj = BaseObject::Alloc(Oextrude);
BaseObject *splineClone = (BaseObject* ) spline->GetClone(COPYFLAGS_0, NULL);
splineClone->InsertUnder(obj);
return obj;
}
Bool RegisterTestObject(void)
{
return RegisterObjectPlugin(ID_PLUGIN_TESTOBJECT, "TestObject", OBJECT_GENERATOR, TestObject::Alloc, "", NULL, 0);
}