302 unsigned int count = this->SubMeshCount();
303 _material = (_unique && count > 0) ? _material->Clone() : _material;
305 for (
unsigned int i = 0; i < count; ++i)
308 subMesh->SetMaterial(_material,
false);
315 if (!_unique && _material == this->material)
318 if (this->material && this->ownsMaterial)
321 this->ownsMaterial = _unique;
322 this->material = _material;
346 gzerr <<
"Cloning a mesh failed because the mesh to be "
347 <<
"cloned does not belong to a scene.\n";
350 else if (this->meshDescriptor.meshName.empty())
352 gzerr <<
"Cloning a geometry failed because the name of the mesh is "
363 result->SetMaterial(this->
Material());
369 for (
unsigned int i = 0; i < this->SubMeshCount(); ++i)
371 auto existingSubMeshMaterial = this->SubMeshByIndex(i)->Material();
372 if (existingSubMeshMaterial)
373 result->SubMeshByIndex(i)->SetMaterial(existingSubMeshMaterial);