Skip to content

Commit 0882062

Browse files
committed
UTexture2DArray support
1 parent c07dc02 commit 0882062

File tree

6 files changed

+21
-12
lines changed

6 files changed

+21
-12
lines changed

FModel/ViewModels/CUE4ParseViewModel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,7 @@ public void Extract(CancellationToken cancellationToken, string fullPath, bool a
647647
case "bat":
648648
case "dat":
649649
case "cfg":
650+
case "ddr":
650651
case "ide":
651652
case "ipl":
652653
case "zon":

FModel/ViewModels/SearchViewModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ private bool ItemFilter(object item, IEnumerable<string> filters)
5858
return filters.All(x => assetItem.FullPath.Contains(x, HasMatchCaseEnabled ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase));
5959

6060
var o = RegexOptions.None;
61-
if (HasMatchCaseEnabled) o |= RegexOptions.IgnoreCase;
61+
if (!HasMatchCaseEnabled) o |= RegexOptions.IgnoreCase;
6262
return new Regex(FilterText, o).Match(assetItem.FullPath).Success;
6363
}
64-
}
64+
}

FModel/Views/Snooper/Options.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using FModel.Views.Snooper.Lights;
1010
using FModel.Views.Snooper.Models;
1111
using FModel.Views.Snooper.Shading;
12+
using SkiaSharp;
1213

1314
namespace FModel.Views.Snooper;
1415

@@ -185,17 +186,26 @@ public void SelectMorph(int index, SkeletalModel model)
185186
model.UpdateMorph(SelectedMorph);
186187
}
187188

188-
public bool TryGetTexture(UTexture2D o, bool fix, out Texture texture)
189+
public bool TryGetTexture(UTexture o, bool fix, out Texture texture)
189190
{
190191
var guid = o.LightingGuid;
191-
if (!Textures.TryGetValue(guid, out texture) &&
192-
o.Decode(UserSettings.Default.PreviewMaxTextureSize, UserSettings.Default.CurrentDir.TexturePlatform) is { } bitmap)
192+
if (Textures.TryGetValue(guid, out texture)) return texture != null;
193+
194+
SKBitmap bitmap = o switch
195+
{
196+
UTexture2D texture2D => texture2D.Decode(UserSettings.Default.PreviewMaxTextureSize, UserSettings.Default.CurrentDir.TexturePlatform),
197+
UTexture2DArray texture2DArray => texture2DArray.DecodeTextureArray(UserSettings.Default.CurrentDir.TexturePlatform)?.FirstOrDefault(),
198+
_ => o.Decode(UserSettings.Default.CurrentDir.TexturePlatform)
199+
};
200+
201+
if (bitmap is not null)
193202
{
194203
texture = new Texture(bitmap, o);
195204
if (fix) TextureHelper.FixChannels(_game, texture);
196205
Textures[guid] = texture;
197206
bitmap.Dispose();
198207
}
208+
199209
return texture != null;
200210
}
201211

FModel/Views/Snooper/Shading/Material.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,9 @@ public void Setup(Options options, int uvCount)
158158
/// <param name="triggers">list of texture parameter names by uv channel</param>
159159
/// <param name="fallback">fallback texture name to use if no top texture found</param>
160160
/// <param name="first">if no top texture, no fallback texture, then use the first texture found</param>
161-
private Texture[] FillTextures(Options options, int uvCount, bool top, IReadOnlyList<string[]> triggers, string fallback, bool first = false)
161+
private Texture[] FillTextures(Options options, int uvCount, bool top, string[][] triggers, string fallback, bool first = false)
162162
{
163-
UTexture2D original;
163+
UTexture original;
164164
Texture transformed;
165165
var fix = fallback == CMaterialParams2.FallbackSpecularMasks;
166166
var textures = new Texture[uvCount];
@@ -192,7 +192,7 @@ private Texture[] FillTextures(Options options, int uvCount, bool top, IReadOnly
192192
/// <param name="textures">reference array</param>
193193
/// <param name="triggers">list of color parameter names by uv channel</param>
194194
/// <param name="fallback">fallback color to use if no trigger was found</param>
195-
private Vector4[] FillColors(int uvCount, IReadOnlyList<Texture> textures, IReadOnlyList<string[]> triggers, Vector4 fallback)
195+
private Vector4[] FillColors(int uvCount, Texture[] textures, string[][] triggers, Vector4 fallback)
196196
{
197197
var colors = new Vector4[uvCount];
198198
for (int i = 0; i < colors.Length; i++)

FModel/Views/Snooper/Shading/Texture.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,13 @@ public Texture(int width, int height) : this(TextureType.Framebuffer)
7979
GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.ColorAttachment0, _target, _handle, 0);
8080
}
8181

82-
public Texture(SKBitmap bitmap, UTexture2D texture2D) : this(TextureType.Normal)
82+
public Texture(SKBitmap bitmap, UTexture texture2D) : this(TextureType.Normal)
8383
{
8484
Type = texture2D.ExportType;
8585
Guid = texture2D.LightingGuid;
8686
Name = texture2D.Name;
8787
Path = texture2D.GetPathName();
8888
Format = texture2D.Format;
89-
ImportedWidth = texture2D.ImportedSize.X;
90-
ImportedHeight = texture2D.ImportedSize.Y;
9189
Width = bitmap.Width;
9290
Height = bitmap.Height;
9391
Bind(TextureUnit.Texture0);

0 commit comments

Comments
 (0)