| 264 | } |
| 265 | |
| 266 | void MaterialInstance::SetBaseMaterial(MaterialBase* baseMaterial) |
| 267 | { |
| 268 | if (baseMaterial != nullptr && baseMaterial->WaitForLoaded()) |
| 269 | { |
| 270 | LOG(Warning, "Cannot set base material of {0} to {1} because it failed to load.", ToString(), baseMaterial->ToString()); |
| 271 | return; |
| 272 | } |
| 273 | |
| 274 | ScopeLock lock(Locker); |
| 275 | |
| 276 | if (baseMaterial == _baseMaterial) |
| 277 | return; |
| 278 | |
| 279 | #if !BUILD_RELEASE |
| 280 | // Prevent recursion |
| 281 | auto mi = Cast<MaterialInstance>(baseMaterial); |
| 282 | while (mi) |
| 283 | { |
| 284 | if (mi == this) |
| 285 | { |
| 286 | LOG(Error, "Cannot set base material of {0} to {1} because it's recursive.", ToString(), baseMaterial->ToString()); |
| 287 | return; |
| 288 | } |
| 289 | mi = Cast<MaterialInstance>(mi->GetBaseMaterial()); |
| 290 | } |
| 291 | #endif |
| 292 | |
| 293 | // Release previous parameters |
| 294 | Params.Dispose(); |
| 295 | |
| 296 | // Set new value |
| 297 | if (_baseMaterial) |
| 298 | { |
| 299 | OnBaseUnset(); |
| 300 | } |
| 301 | _baseMaterial = baseMaterial; |
| 302 | if (baseMaterial) |
| 303 | { |
| 304 | _baseMaterial = baseMaterial; |
| 305 | OnBaseSet(); |
| 306 | } |
| 307 | } |
| 308 | |
| 309 | void MaterialInstance::ResetParameters() |
| 310 | { |
no test coverage detected