| 695 | } |
| 696 | |
| 697 | void SceneCache::writeMaterial(OutputStream& stream, const ref<Material>& pMaterial) |
| 698 | { |
| 699 | // Write common fields. |
| 700 | stream.write((uint32_t)pMaterial->getType()); |
| 701 | stream.write(pMaterial->mName); |
| 702 | stream.write(pMaterial->mHeader); |
| 703 | stream.write(pMaterial->mUpdates); |
| 704 | writeTransform(stream, pMaterial->mTextureTransform); |
| 705 | |
| 706 | auto writeTextureSlot = [&stream, &pMaterial](Material::TextureSlot slot) |
| 707 | { |
| 708 | auto pTexture = pMaterial->getTexture(slot); |
| 709 | bool hasTexture = pTexture != nullptr; |
| 710 | stream.write(hasTexture); |
| 711 | if (hasTexture) |
| 712 | { |
| 713 | stream.write(pTexture->getSourcePath()); |
| 714 | } |
| 715 | }; |
| 716 | |
| 717 | for (uint32_t slot = 0; slot < (uint32_t)Material::TextureSlot::Count; ++slot) |
| 718 | { |
| 719 | writeTextureSlot(Material::TextureSlot(slot)); |
| 720 | } |
| 721 | |
| 722 | // Write data in derived class. |
| 723 | if (auto pBasicMaterial = pMaterial->toBasicMaterial()) writeBasicMaterial(stream, pBasicMaterial); |
| 724 | else FALCOR_THROW("Unsupported material type"); |
| 725 | } |
| 726 | |
| 727 | void SceneCache::writeBasicMaterial(OutputStream& stream, const ref<BasicMaterial>& pMaterial) |
| 728 | { |
nothing calls this directly
no test coverage detected