forked from Dreaming381/Latios-Framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExtraFunctions.cs
68 lines (60 loc) · 2.48 KB
/
ExtraFunctions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace Unity.Mathematics
{
public static partial class math
{
/// <summary>Returns b if c is true, a otherwise.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool select(bool a, bool b, bool c)
{
return a ^ ((a ^ b) & c);
}
/// <summary>Returns b if c is true, a otherwise.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool2 select(bool2 a, bool2 b, bool c)
{
return a ^ ((a ^ b) & c);
}
/// <summary>Returns b if c is true, a otherwise.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool3 select(bool3 a, bool3 b, bool c)
{
return a ^ ((a ^ b) & c);
}
/// <summary>Returns b if c is true, a otherwise.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool4 select(bool4 a, bool4 b, bool c)
{
return a ^ ((a ^ b) & c);
}
/// <summary>
/// Returns a componentwise selection between two bool2 vectors a and b based on a bool2 selection mask c.
/// Per component, the component from b is selected when c is true, otherwise the component from a is selected.
/// </summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool2 select(bool2 a, bool2 b, bool2 c)
{
return a ^ ((a ^ b) & c);
}
/// <summary>
/// Returns a componentwise selection between two bool3 vectors a and b based on a bool3 selection mask c.
/// Per component, the component from b is selected when c is true, otherwise the component from a is selected.
/// </summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool3 select(bool3 a, bool3 b, bool3 c)
{
return a ^ ((a ^ b) & c);
}
/// <summary>
/// Returns a componentwise selection between two bool4 vectors a and b based on a bool4 selection mask c.
/// Per component, the component from b is selected when c is true, otherwise the component from a is selected.
/// </summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool4 select(bool4 a, bool4 b, bool4 c)
{
return a ^ ((a ^ b) & c);
}
}
}