void MaterialEntityItem::setParentID(const QUuid& parentID) { if (getParentID() != parentID) { removeMaterial(); EntityItem::setParentID(parentID); applyMaterial(); } }
void MaterialEntityItem::setClientOnly(bool clientOnly) { if (getClientOnly() != clientOnly) { removeMaterial(); EntityItem::setClientOnly(clientOnly); applyMaterial(); } }
void MaterialEntityItem::setPriority(quint16 priority) { if (_priority != priority) { removeMaterial(); _priority = priority; applyMaterial(); } }
void MaterialEntityItem::setParentMaterialName(const QString& parentMaterialName) { if (_parentMaterialName != parentMaterialName) { removeMaterial(); _parentMaterialName = parentMaterialName; applyMaterial(); } }
void MaterialEntityItem::setMaterialMappingRot(const float& materialMappingRot) { if (_materialMappingRot != materialMappingRot) { removeMaterial(); _materialMappingRot = materialMappingRot; applyMaterial(); } }
void MaterialEntityItem::setMaterialMappingScale(const glm::vec2& materialMappingScale) { if (_materialMappingScale != materialMappingScale) { removeMaterial(); _materialMappingScale = materialMappingScale; applyMaterial(); } }
void MaterialEntityItem::setMaterialMappingPos(const glm::vec2& materialMappingPos) { if (_materialMappingPos != materialMappingPos) { removeMaterial(); _materialMappingPos = materialMappingPos; applyMaterial(); } }
void MaterialEntityItem::setOwningAvatarID(const QUuid& owningAvatarID) { if (getOwningAvatarID() != owningAvatarID) { removeMaterial(); EntityItem::setOwningAvatarID(owningAvatarID); applyMaterial(); } }
bool TrussMaterialLibrary::removeMaterial ( const QString& uuid ) { TrussMaterialListConstIter iter = materials.begin(); for ( ; iter != materials.end(); ++iter ) { TrussMaterial* material = *iter; if ( material->getUUID() == uuid ) return removeMaterial( *material ); } return false; }
bool TrussMaterialLibrary::removeMaterial ( int indx ) { if ( indx > materials.size() ) return false; try { return removeMaterial( *materials.at(indx) ); } catch ( ... ) { return false; } }
void FEMesh::refreshMaterials(PyObject *skeletoncontext) { for(ElementIterator ei=element_iterator(); !ei.end(); ++ei) { Element *element = ei.element(); const Material *oldmat = element->material(); element->refreshMaterial(skeletoncontext); const Material *newmat = element->material(); if(newmat != oldmat) { if(oldmat) removeMaterial(oldmat); if(newmat) addMaterial(newmat); } } // TODO INTERFACE: Should this just be in-line here? refreshInterfaceMaterials(skeletoncontext); }
// TODO INTERFACE: Called from FEMesh::refreshMaterials, but possibly // from elsewhere also. Should this function just be in-line in // refreshMaterials, or is there a good reason for it to stand alone? void FEMesh::refreshInterfaceMaterials(PyObject *skelctxt) { for(ElementIterator ei=edgement_iterator(); !ei.end(); ++ei) { Element *el = ei.element(); const Material *om = el->material(); InterfaceElement *ed = dynamic_cast<InterfaceElement*>(el); ed->refreshInterfaceMaterial(skelctxt); const Material *nm = el->material(); if (nm != om) { if (om) removeMaterial(om); if (nm) addMaterial(nm); } } }
// Replace the material specified by id with another one void GLC_Mesh::replaceMaterial(const GLC_uint oldId, GLC_Material* pMat) { Q_ASSERT(containsMaterial(oldId)); Q_ASSERT(!containsMaterial(pMat->id()) || (pMat->id() == oldId)); if (pMat->id() != oldId) { // Iterate over Level of detail PrimitiveGroupsHash::const_iterator iGroups= m_PrimitiveGroups.constBegin(); while (m_PrimitiveGroups.constEnd() != iGroups) { LodPrimitiveGroups* pPrimitiveGroups= iGroups.value(); // Iterate over material group LodPrimitiveGroups::iterator iGroup= pPrimitiveGroups->begin(); while (pPrimitiveGroups->constEnd() != iGroup) { if (iGroup.key() == oldId) { GLC_PrimitiveGroup* pGroup= iGroup.value(); // Erase old group pointer pPrimitiveGroups->erase(iGroup); // Change the group ID pGroup->setId(pMat->id()); // Add the group with new ID pPrimitiveGroups->insert(pMat->id(), pGroup); iGroup= pPrimitiveGroups->end(); } else { ++iGroup; } } ++iGroups; } } if (pMat != m_MaterialHash.value(oldId)) { // Remove old material removeMaterial(oldId); addMaterial(pMat); } }
// Replace the Master material void GLC_Geometry::replaceMasterMaterial(GLC_Material* pMaterial) { Q_ASSERT(!m_IsWire); if (!m_MaterialHash.isEmpty()) { if (pMaterial != firstMaterial()) { // Remove the first material MaterialHash::iterator iMaterial= m_MaterialHash.begin(); removeMaterial(iMaterial.value()->id()); // Add the new material addMaterial(pMaterial); } } else { addMaterial(pMaterial); } }
void MaterialEntityItem::setMaterialURL(const QString& materialURLString, bool userDataChanged) { bool usingUserData = materialURLString.startsWith("userData"); if (_materialURL != materialURLString || (usingUserData && userDataChanged)) { removeMaterial(); _materialURL = materialURLString; if (materialURLString.contains("?")) { auto split = materialURLString.split("?"); _currentMaterialName = split.last().toStdString(); } if (usingUserData) { _parsedMaterials = NetworkMaterialResource::parseJSONMaterials(QJsonDocument::fromJson(getUserData().toUtf8())); // Since our material changed, the current name might not be valid anymore, so we need to update setCurrentMaterialName(_currentMaterialName); applyMaterial(); } else { _networkMaterial = MaterialCache::instance().getMaterial(materialURLString); auto onMaterialRequestFinished = [&](bool success) { if (success) { _parsedMaterials = _networkMaterial->parsedMaterials; setCurrentMaterialName(_currentMaterialName); applyMaterial(); } }; if (_networkMaterial) { if (_networkMaterial->isLoaded()) { onMaterialRequestFinished(!_networkMaterial->isFailed()); } else { connect(_networkMaterial.data(), &Resource::finished, this, onMaterialRequestFinished); } } } } }
MaterialEntityItem::~MaterialEntityItem() { removeMaterial(); }
void kore::ResourceManager::removeMaterial(const Material* mat) { removeMaterial(mat->getID()); }
void MaterialEntityItem::postParentFixup() { removeMaterial(); applyMaterial(); }
void MaterialEntityItem::preDelete() { EntityItem::preDelete(); removeMaterial(); }