Which way is Correct snax?

I’ve been calling flatten strong, but don’t know if I did it right. I’ve done it like this:

self.MainObj.flattenStrong();
self.MainObj.reparentTo(render);
self.PieceOfMain1.flattenStrong();
self.PieceOfMain1.reparentTo(self.MainObj);
self.PieceOfMain2.flattenStrong();
self.PieceOfMain2.reparentTo(self.MainObj);

You can see that I’ve flattened everything separately, then did the reparenting. I was wonder if I should reparent first, then call one flatten, like this:

self.MainObj.reparentTo(render);
self.PieceOfMain1.reparentTo(self.MainObj);
self.PieceOfMain2.reparentTo(self.MainObj);
self.MainObj.flattenStrong();

Which way is Correct? or does it Matter?

And yes, I’m placing every in a different NodePath other than the Model Root, because the Panda Manual stated that flattenStrong() will not work for a file/model under the root…just in case someone was wondering.

It’s pointless to call it multiple times like that. You could first do all the reparenting, and then flatten the model.

Note that it’s quite unconventional to use semi-colons after every line in Python (it is not a requirement in Python).

The paragraph in the manual was referring to the fact that flattenStrong won’t traverse below model nodes, but you can simply fix this by calling .clearModelNodes() before flattening (this way, you’re sure that the model will be flattened into a single node).

Keep in mind, though, that self.PieceOfMain1, self.PieceOfMain2 and self.MainObj will (in the ideal situation) refer to the same object after flattening. The point of flattenStrong is to strongly reduce the number of nodes, and (in the ideal situation) convert it to a single node.

I believe I’m on the right track then; because when I hide or show the object that will act like the Parent object which all others reparent to, all the other objects show and hide as well.

But then again… That’s because of the parenting and does not mean that they are all acting as one node and does not signify that flattenStrong() succeeded.

Oh man… This is killing me.