On 18/07/2018 at 00:42, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 18/19
Platform: Windows ;
Language(s) : C++ ;
---------
Howdy, I am a novice at C++. I have a python script that basically iterates through each point of a mesh and does SetWeight(sourceJoint.GetWeight).
In my test scene, the python script runs in about 9.2 seconds. It seemed like C++ would be able to speed this up. So I whipped up this little plugin which is basically a port of the python code, and it's like...1 second faster maybe(I haven't exactly figured out how to time it and print out the results, but by counting it's about 8 seconds).
Am I doing this in the best way, or is there a better way to do this? This si in my commandData plugin.
PointObject* obj = (PointObject* )(doc->GetActiveObject());
CAWeightTag* wt = (CAWeightTag* )(obj->GetTag(Tweights));
if (wt)
GePrint(wt->GetName());
BaseObject* targJoint = doc->SearchObject("Joint");
if (targJoint)
GePrint(targJoint->GetName());
BaseObject* sourceJoint = doc->SearchObject("mixamorig:Spine2");
if (sourceJoint)
GePrint(sourceJoint->GetName());
//Add targJoint to the weight tag
wt->AddJoint(targJoint);
Int32 pointCount = obj->GetPointCount();
Int32 sourceID = wt->FindJoint(sourceJoint, doc);
Int32 targID = wt->FindJoint(targJoint, doc);
for (int x = 0; x < pointCount; x = x + 1) {
wt->SetWeight(targID, x, wt->GetWeight(sourceID, x));
wt->WeightDirty();
wt->SetWeight(sourceID, x, 0.0);
wt->WeightDirty();
}
GePrint("Done Mofo");
//wt->TransferWeightMap(doc, wt, sindex, dindex, 0, NOTOK, nullptr);
EventAdd();
Forgive the dumb mistakes, I am very very new and pretty stoked I managed to get this far.