299 unsigned int count = this->SubMeshCount();
300 _material = (_unique && count > 0) ? _material->Clone() : _material;
302 for (
unsigned int i = 0; i < count; ++i)
305 subMesh->SetMaterial(_material,
false);
308 if (this->material && this->ownsMaterial)
311 this->ownsMaterial = _unique;
312 this->material = _material;
336 gzerr <<
"Cloning a mesh failed because the mesh to be "
337 <<
"cloned does not belong to a scene.\n";
340 else if (this->meshDescriptor.meshName.empty())
342 gzerr <<
"Cloning a geometry failed because the name of the mesh is "
353 result->SetMaterial(this->
Material());
359 for (
unsigned int i = 0; i < this->SubMeshCount(); ++i)
361 auto existingSubMeshMaterial = this->SubMeshByIndex(i)->Material();
362 if (existingSubMeshMaterial)
363 result->SubMeshByIndex(i)->SetMaterial(existingSubMeshMaterial);