Skip to content

Commit

Permalink
chore: sharping (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
elringus authored Apr 21, 2024
1 parent e30bf9a commit 72d63b1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion plugins/unity/Assets/Samples/Runtime/SceneSwitcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ private void OnGUI ()

private static Rect GetRectForSceneAt (int index)
{
var yPos = Screen.height - (buttonHeight + buttonHeight * index);
var yPos = Screen.height - (buttonHeight + (buttonHeight * index));
return new Rect(0, yPos, buttonWidth, buttonHeight);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private SourceSprite[] CollectSourceSprites ()
AtlasPOT = ForcePot,
PPU = PPU,
Pivot = new Native.Pivot { X = DefaultPivot.x, Y = DefaultPivot.y },
OnProgress = p => DisplayProgressBar(p.Activity, .25f + p.Ratio / 4)
OnProgress = p => DisplayProgressBar(p.Activity, .25f + (p.Ratio / 4))
};

private Texture2D[] ImportAtlases (IReadOnlyList<Native.Texture> atlases)
Expand All @@ -85,7 +85,7 @@ private Texture2D[] ImportAtlases (IReadOnlyList<Native.Texture> atlases)
var imported = new Texture2D[paths.Length];
for (int i = 0; i < paths.Length; i++)
{
var progress = .5f + .25f * ((i + 1f) / paths.Length);
var progress = .5f + (.25f * ((i + 1f) / paths.Length));
DisplayProgressBar($"Importing atlases... ({i + 1} of {paths.Length})", progress);
imported[i] = importer.Import(paths[i]);
}
Expand Down Expand Up @@ -128,7 +128,7 @@ private void BuildDicedSprites (IReadOnlyList<Native.DicedSprite> diced, IReadOn
var builder = new SpriteBuilder(PPU, atlases);
for (int i = 0; i < diced.Count; i++)
{
var progress = .75f + .25f * ((i + 1f) / diced.Count);
var progress = .75f + (.25f * ((i + 1f) / diced.Count));
DisplayProgressBar($"Building diced sprites... ({i + 1} of {diced.Count})", progress);
sprites.Add(builder.Build(diced[i]));
}
Expand Down
8 changes: 5 additions & 3 deletions plugins/unity/Assets/SpriteDicing/Editor/Native/Native.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Runtime.InteropServices;
using UnityEngine.TestTools;
Expand All @@ -9,6 +10,7 @@ namespace SpriteDicing
/// <summary>
/// Managed wrapper over native dicing library.
/// </summary>
[SuppressMessage("ReSharper", "MemberHidesStaticFromOuterClass")]
public static unsafe class Native
{
public readonly struct SourceSprite
Expand Down Expand Up @@ -187,7 +189,7 @@ private struct CDicedSprite
public CSlice uvs;
public CSlice indices;
public CRect rect;
public CPivot Pivot;
public CPivot pivot;
}

[StructLayout(LayoutKind.Sequential)]
Expand Down Expand Up @@ -280,7 +282,7 @@ private static T[] MarshalSlice<T> (CSlice c, List<IntPtr> pts)

for (long i = 0; i < (int)c.len; i++)
{
var ins = new IntPtr(c.ptr.ToInt64() + i * size);
var ins = new IntPtr(c.ptr.ToInt64() + (i * size));
structs[i] = Marshal.PtrToStructure<T>(ins);
}

Expand Down Expand Up @@ -326,7 +328,7 @@ private static CSlice MarshalSourceSprites (IEnumerable<SourceSprite> sources, L
UVs = MarshalSlice<CUv>(c.uvs, pts).Select(MarshalUV).ToArray(),
Indices = MarshalIndices(c.indices),
Rect = MarshalRect(c.rect),
Pivot = MarshalPivot(c.Pivot)
Pivot = MarshalPivot(c.pivot)
};

private static DicedSprite[] MarshalDicedSprites (CSlice c, List<IntPtr> pts)
Expand Down

0 comments on commit 72d63b1

Please sign in to comment.