Vertex Color Tag disappearing when made editable
-
Hello, I was using a Vertex Color Tag and I noticed that is was disappearing when I made the object it was on editable. I did a bit of testing and it seems like it disappears when it's on a plugin object and not a Cinema object.
For example, on the "C++ SDK - Plane By Polygons Generator Example" the Vertex Color Tag will vanish, but when on a Cube it stays as it should.
Before making editable:
After making editable:
"C++ SDK - Plane By Polygons Generator Example"'s Vertex Color Tag is gone in the second case.
The same behavior is happening with my plugin, but the SDK example seems like the clearer case. Any ideas on why this behavior would be happening?
Dan
-
Hi Dan,
The Make Editable command retrieves the cache of your object via GetVirtualObjects() function, which returns just an ordinary BaseObject*. Hence, it is up to plugin to decide what tags should be added to the returned cache object.
In case of Plane By Polygons Generator example there's no such a line of code that creates any tags on the returned cache object, hence none of your tags on this object will survive after Make Editable command.
If you want to keep them, you need to manually copy them over to your returned BaseObject*. This is usually done using CopyTagsTo() function, something that looks like the following:
BaseObject* MyGenerator::GetVirtualObjects(BaseObject* op, const HierarchyHelp* hh) { // ... some code BaseObject* ret = BaseObject::Alloc(Onull); // or likely Opolygon if (!op->CopyTagsTo(ret, true, NOTOK, false, nullptr)) return BaseObject::Alloc(Onull); // ... some code return ret; }
Note, that here nullptr is used for alias translator for simplicity. Normally, you need to use AliasTrans that would handle tag's dependencies for you.
You can check the GetVirtualObjects() implementation in the Rounded Tube example. Please note, that in this example the CopyTagsTo() function uses false for the 3rd 'variable' argument, which means that variable tags will not be copied over. If you want to make it work with the Vertex Color tag, you need to use either true or NOTOK, depending if you want to copy over all tags or only variable ones.
Cheers,
Ilia -
Thanks Ilia! That was exactly what I needed!
Dan