Hi.
I am currently working on an object plugin that would utilize Takes for a user to be able to quickly iterate through different potential versions of their scene. I've looked through the sdk and the different manuals that are available and I believe I understand the processes required.
My issue comes in with the amount of time it take Cinema to run my plugin in regards to the creation of the Takes and if this is just the time that it takes to create them.
I created a simple scene with a hundred objects underneath my plugin. With the code below I create a Take and assign a layer to each of the child objects. For time testing I create an additional 500 Takes using the first Take as the cloneFrom inside AddTake. This isn't a final version of my code just a test example.
The code is executed on a button press.
case idRunTakes:
{
TakeData* takeData = doc->GetTakeData();
if (!takeData)
return TRUE;
LayerObject *hideLayer = LayerObject::Alloc();
const Vector hsv = Vector(1.0, 0, 0);
const Vector rgb = HSVToRGB(hsv);
newTakeTime = 0;
settingTakeTime = 0;
LayerData newdata;
newdata.color = rgb;
newdata.solo = FALSE;
newdata.view = FALSE;
newdata.render = FALSE;
newdata.manager = TRUE;
newdata.locked = FALSE;
newdata.generators = FALSE;
newdata.deformers = FALSE;
newdata.expressions = FALSE;
newdata.animation = FALSE;
newdata.xref = TRUE;
hideLayer->SetLayerData(doc, newdata);
hideLayer->SetName("Hide Layer"_s);
GeListHead* layerList = NULL;
layerList = doc->GetLayerObjectRoot();
layerList->InsertLast(hideLayer);
maxon::BaseArray<BaseObject*> childObjArray;
GatherAllChildObjects(splineObj->GetDown(), childObjArray);
DescID aliasLinkDId = DescLevel(ID_LAYER_LINK, DA_ALIASLINK, 0);
GeData setData;
setData.SetBaseList2D((BaseList2D*)hideLayer);
Float createNewTakesTime = 0;
Float timeStart = 0;
Float loopTimeStart = GeGetMilliSeconds();
timeStart = GeGetMilliSeconds();
BaseTake* newTake = takeData->AddTake(String("Take " + String::IntToString(0)), nullptr, nullptr);
if (newTake == nullptr)
return TRUE;
createNewTakesTime = createNewTakesTime + GeGetMilliSeconds() - timeStart;
for (Int32 childObjIndex = 0; childObjIndex < childObjArray.GetCount(); childObjIndex++)
{
BaseOverride* overrideNode = newTake->FindOrAddOverrideParam(takeData, childObjArray[childObjIndex], aliasLinkDId, setData);
if (overrideNode == nullptr)
return TRUE;
childObjArray[childObjIndex]->SetLayerObject(hideLayer);
overrideNode->UpdateSceneNode(takeData, aliasLinkDId);
}
for (Int32 takeIndex = 1; takeIndex < 501; takeIndex++)
{
timeStart = GeGetMilliSeconds();
// This is the line taking up a lot of time
BaseTake* loopTake = takeData->AddTake(String("Take " + String::IntToString(takeIndex)), nullptr, newTake);
if (loopTake == nullptr)
return TRUE;
createNewTakesTime = createNewTakesTime + GeGetMilliSeconds() - timeStart;
}
ApplicationOutput("Take time " + String::FloatToString(createNewTakesTime) + " " + String::FloatToString(GeGetMilliSeconds() - loopTimeStart - createNewTakesTime));
break;
}
// Code for getting all of the child objects
void TakeCreatorPlugin::GatherAllChildObjects(BaseObject *childObject, maxon::BaseArray<BaseObject*> &objChildOfNullsArray)
{
if (childObject == nullptr)
return;
while (childObject)
{
objChildOfNullsArray.Append(childObject);
GatherAllChildObjects(childObject->GetDown(), objChildOfNullsArray);
childObject = childObject->GetNext();
}
}
Running the code in my test scene gives the following print out "Take time 1920.243 20.232". So most of the time my plugin is running is taken up by adding the takes into the document. Is this just the time that Cinema takes in this kind of circumstance to create the Takes or am I just missing a crucial step,
I've looked through the manuals in the sdk and tried to follow them.
I've also tried to create all of the Takes empty and add the Overrides to each one individually which increases the time that step takes which isn't desirable either.
Any help would be greatly appreciated.
JohnTerenece