On 30/01/2016 at 14:39, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R17
Platform:
Language(s) : C++ ;
---------
Hello Cinema community,
How to get unique ID of BaseMaterial? I need it in some complex system that tracks updates of individual materials based on dirty bits of BaseMaterial and mapping between BaseMaterials and objects to which material is assigned. I construct this mapping structure traversing the scene graph when geometry or tags are updated.
I used pointer to BaseMaterial as identifier in this mapping structure.
Everything was fine except that sometimes the address of BaseMaterial is changed:
// this code works for each EVMSG_CHANGE
BaseDocument * doc = GetActiveDocument();
for (BaseMaterial * mat = doc->GetFirstMaterial(); mat; mat = mat->GetNext())
{
printf("\n material ID %10d", int(mat));
}
As you see I print the addresses of BaseMaterials. When I edit them they remain constant and it is what I need. When I click Ctrl+Z the system changes the address of material which should be changed and I can't track my changes based on adresses of BaseMaterials used as unique keys.
How to get unique ID for each material? This ID should live as long as material lives.
Thanks,
Anton