| 853 | } |
| 854 | |
| 855 | void FMultipatchTextureBuilder::ResolveAllPatches() |
| 856 | { |
| 857 | for (auto &bi : BuiltTextures) |
| 858 | { |
| 859 | ResolvePatches(bi); |
| 860 | } |
| 861 | // Now try to resolve the images. We only can do this at the end when all multipatch textures are set up. |
| 862 | |
| 863 | // reverse the list so that the Delete operation in the loop below deletes at the end. |
| 864 | // For normal sized lists this is of no real concern, but Total Chaos has over 250000 textures where this becomes a performance issue. |
| 865 | for (unsigned i = 0; i < BuiltTextures.Size() / 2; i++) |
| 866 | { |
| 867 | // std::swap is VERY inefficient here... |
| 868 | BuiltTextures[i].swap(BuiltTextures[BuiltTextures.Size() - 1 - i]); |
| 869 | } |
| 870 | |
| 871 | |
| 872 | while (BuiltTextures.Size() > 0) |
| 873 | { |
| 874 | bool donesomething = false; |
| 875 | |
| 876 | for (int i = BuiltTextures.Size()-1; i>= 0; i--) |
| 877 | { |
| 878 | auto &buildinfo = BuiltTextures[i]; |
| 879 | bool hasEmpty = false; |
| 880 | |
| 881 | for (unsigned j = 0; j < buildinfo.Inits.Size(); j++) |
| 882 | { |
| 883 | if (buildinfo.Parts[j].TexImage == nullptr) |
| 884 | { |
| 885 | auto image = buildinfo.Inits[j].GameTexture->GetTexture(); |
| 886 | if (image && image->GetImage() != nullptr) |
| 887 | { |
| 888 | buildinfo.Parts[j].TexImage = static_cast<FImageTexture*>(image); |
| 889 | donesomething = true; |
| 890 | } |
| 891 | else hasEmpty = true; |
| 892 | } |
| 893 | } |
| 894 | if (!hasEmpty) |
| 895 | { |
| 896 | // If this texture is just a wrapper around a single patch, we can simply |
| 897 | // use that patch's image directly here. |
| 898 | checkForHacks(buildinfo); |
| 899 | |
| 900 | bool done = false; |
| 901 | if (buildinfo.Parts.Size() == 1) |
| 902 | { |
| 903 | if (buildinfo.Parts[0].OriginX == 0 && buildinfo.Parts[0].OriginY == 0 && |
| 904 | buildinfo.Parts[0].TexImage->GetWidth() == buildinfo.Width && |
| 905 | buildinfo.Parts[0].TexImage->GetHeight() == buildinfo.Height && |
| 906 | buildinfo.Parts[0].Rotate == 0 && |
| 907 | !buildinfo.bComplex) |
| 908 | { |
| 909 | AddImageToTexture(buildinfo.Parts[0].TexImage, buildinfo); |
| 910 | done = true; |
| 911 | } |
| 912 | } |
no test coverage detected