On 16/09/2015 at 08:59, xxxxxxxx wrote:
I had to walk the road that lies ahead of you and I didn't like it...
Especially identifying the materials on paste can be really tricky. Can you perhaps give me some more detail on the materials and how they are linked? I mean, is it your own MaterialData material, that needs special handling? Or is it about special shaders linked into the standard material?
Here I had the situation, that I had my own shader, which then linked to some special resource. On Copy/Paste I needed to make sure, that on every copied material (actually every copied object, that may contain a shader), not only the material got copied, but also the special resource that was linked by the shader.
The copy part was actually quite easy (similar to your code above). But then on paste I needed to identify the pasted shaders, in order to repair the links. In the end I stored a pointer to my special resource inside of the shader (special care needs to be taken in CopyTo of the shader). Side note: Never ever dereference such a pointer! On copy I stored this pointer in the BaseContainer and on paste I could then walk all shaders looking for that pointer (using the pointer just as a compare key) and thus repair the link.
Not sure, if the above makes sense. It's a bit hard to explain in a few words.