-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* photo improvements * modified mode switch sfx
- Loading branch information
1 parent
bf70735
commit d11ceed
Showing
45 changed files
with
890 additions
and
194 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using UnityEngine; | ||
using UnityEngine.UI; | ||
|
||
namespace Pennycook.Tablet { | ||
public sealed class TabletPhotoAnimation : MonoBehaviour { | ||
public LayoutOffset Offset; | ||
public CanvasGroup Group; | ||
public RawImage PhotoRenderer; | ||
|
||
public Material DefaultMaterial; | ||
public Material FailureMaterial; | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,119 @@ | ||
using BeauUtil; | ||
using BeauUtil.Debugger; | ||
|
||
namespace FieldDay.Mathematics { | ||
static public class DependencySolver { | ||
public struct SourceNode<TIdentifier> where TIdentifier : unmanaged { | ||
public TIdentifier Id; | ||
public UnsafeSpan<TIdentifier> Dependencies; | ||
public enum Result { | ||
Success = 0, | ||
CycleDetected = 1, | ||
MissingNode = 2 | ||
} | ||
|
||
public struct OutputNode { | ||
public UnsafeSpan<uint> DependencyIndices; | ||
public struct Node<T> where T : unmanaged { | ||
public T Id; | ||
public OffsetLengthU16 Edges; | ||
} | ||
|
||
public struct Edge<T> where T : unmanaged { | ||
public T Endpoint; | ||
} | ||
|
||
public struct OutputNode<T> where T : unmanaged { | ||
public T Id; | ||
public int OriginalIndex; | ||
} | ||
|
||
private struct MultiEdgeSolverData<T> where T : unmanaged { | ||
public UnsafeSpan<Node<T>> Nodes; | ||
public UnsafeSpan<Edge<T>> Edges; | ||
public UnsafeSpan<OutputNode<T>> Output; | ||
public UnsafeBitSet VisitBits; | ||
public UnsafeBitSet CycleDetectionBits; | ||
public int OutputCount; | ||
} | ||
|
||
static public unsafe Result Solve<T>(UnsafeSpan<Node<T>> nodes, UnsafeSpan<Edge<T>> edges, UnsafeSpan<OutputNode<T>> output) where T : unmanaged { | ||
Assert.True(output.Length >= nodes.Length); | ||
|
||
int nodeCount = nodes.Length; | ||
int requiredBackingMemSize = Unsafe.AlignUp32(nodeCount) / 32; | ||
uint* visitMem = stackalloc uint[requiredBackingMemSize]; | ||
uint* cycleMem = stackalloc uint[requiredBackingMemSize]; | ||
|
||
UnsafeBitSet visited = new UnsafeBitSet(visitMem, requiredBackingMemSize); | ||
UnsafeBitSet cycle = new UnsafeBitSet(cycleMem, requiredBackingMemSize); | ||
|
||
MultiEdgeSolverData<T> solverData = new MultiEdgeSolverData<T>() { | ||
Nodes = nodes, | ||
Edges = edges, | ||
Output = output, | ||
VisitBits = visited, | ||
CycleDetectionBits = cycle | ||
}; | ||
|
||
Result result = Result.Success; | ||
|
||
for(int i = 0; i < nodeCount; i++) { | ||
if (!visited.IsSet(i)) { | ||
result = Traverse(ref solverData, i); | ||
if (result != Result.Success) { | ||
break; | ||
} | ||
} | ||
} | ||
|
||
Assert.True(result != Result.Success || solverData.OutputCount == nodes.Length); | ||
return result; | ||
} | ||
|
||
static private Result Traverse<T>(ref MultiEdgeSolverData<T> solverData, int nodeIndex) where T : unmanaged { | ||
if (solverData.VisitBits.IsSet(nodeIndex)) { | ||
return Result.Success; | ||
} | ||
if (solverData.CycleDetectionBits.IsSet(nodeIndex)) { | ||
return Result.CycleDetected; | ||
} | ||
|
||
solverData.CycleDetectionBits.Set(nodeIndex); | ||
Node<T> node = solverData.Nodes[nodeIndex]; | ||
|
||
for(int edgeIdx = node.Edges.Offset; edgeIdx < node.Edges.End; edgeIdx++) { | ||
int nextIdx = IndexOfNode(solverData.Nodes, solverData.Edges[edgeIdx].Endpoint); | ||
if (nextIdx < 0) { | ||
return Result.MissingNode; | ||
} | ||
Result edgeResult = Traverse(ref solverData, nextIdx); | ||
if (edgeResult != Result.Success) { | ||
return edgeResult; | ||
} | ||
} | ||
|
||
solverData.CycleDetectionBits.Unset(nodeIndex); | ||
solverData.VisitBits.Set(nodeIndex); | ||
|
||
solverData.Output[solverData.OutputCount++] = new OutputNode<T>() { | ||
Id = node.Id, | ||
OriginalIndex = nodeIndex | ||
}; | ||
return Result.Success; | ||
} | ||
|
||
static private int IndexOfNode<T>(UnsafeSpan<Node<T>> nodes, in T id) where T : unmanaged { | ||
for(int i = 0; i < nodes.Length; i++) { | ||
if (CompareUtils.Equals(id, nodes[i].Id)) { | ||
return i; | ||
} | ||
} | ||
return -1; | ||
} | ||
|
||
static private int IndexOfNode<T>(UnsafeSpan<T> nodes, in T id) where T : unmanaged { | ||
for (int i = 0; i < nodes.Length; i++) { | ||
if (CompareUtils.Equals(id, nodes[i])) { | ||
return i; | ||
} | ||
} | ||
return -1; | ||
} | ||
} | ||
} |
Oops, something went wrong.