| 75 | } |
| 76 | |
| 77 | void ImportTexture::InitOptions(CreateAssetContext& context, Options& options) |
| 78 | { |
| 79 | // Gather import options |
| 80 | if (context.CustomArg != nullptr) |
| 81 | { |
| 82 | // Copy options |
| 83 | options = *static_cast<Options*>(context.CustomArg); |
| 84 | ASSERT_LOW_LAYER(options.Sprites.Count() >= 0); |
| 85 | } |
| 86 | else |
| 87 | { |
| 88 | // Restore the previous settings or use default ones |
| 89 | if (!TryGetImportOptions(context.TargetAssetPath, options)) |
| 90 | { |
| 91 | LOG(Warning, "Missing texture import options. Using default values."); |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | // Tweak options |
| 96 | if (options.IsAtlas) |
| 97 | { |
| 98 | // Disable streaming for atlases |
| 99 | // TODO: maybe we could use streaming for atlases? |
| 100 | options.NeverStream = true; |
| 101 | |
| 102 | // Add default tile if has no sprites |
| 103 | if (options.Sprites.IsEmpty()) |
| 104 | options.Sprites.Add({ Rectangle(Float2::Zero, Float2::One), TEXT("Default") }); |
| 105 | } |
| 106 | options.MaxSize = Math::Min(options.MaxSize, GPU_MAX_TEXTURE_SIZE); |
| 107 | } |
| 108 | |
| 109 | CreateAssetResult ImportTexture::Create(CreateAssetContext& context, const TextureData& textureData, Options& options) |
| 110 | { |