4
4
// ** Repository : https://github.com/LTMX/Unity.mathx
5
5
#endregion
6
6
7
- using System ;
7
+
8
8
using System . Runtime . CompilerServices ;
9
+
10
+ #if MATHX_FUNCTION_POINTERS
11
+
12
+ using System ;
9
13
using AOT ;
10
14
using Unity . Burst ;
11
15
using Unity . Collections . LowLevel . Unsafe ;
12
- using static Unity . Mathematics . FunctionPointers ;
13
- using static Unity . Mathematics . FunctionPointers . Signature ;
16
+ using static Unity . Mathematics . FunctionPointers
17
+
18
+ #endif
19
+
14
20
15
21
namespace Unity . Mathematics
16
22
{
@@ -19,45 +25,47 @@ public static partial class mathx
19
25
// Component-wise comparison --------------------------------------------------------------
20
26
21
27
/// <inheritdoc cref="math.cmax(float4)"/>
22
- [ MethodImpl ( IL ) ] public static float cmax ( this float4 f ) => f . xy . fmax ( f . zw ) . cmax ( ) ;
28
+ [ MethodImpl ( IL ) ] public static float cmax ( this float4 f ) => math . cmax ( f ) ;
23
29
24
30
/// <inheritdoc cref="math.cmax(float4)"/>
25
- [ MethodImpl ( IL ) ] public static float cmax ( this float3 f ) => f . x . max ( f . y ) . max ( f . z ) ;
31
+ [ MethodImpl ( IL ) ] public static float cmax ( this float3 f ) => math . cmax ( f ) ;
26
32
27
33
/// <inheritdoc cref="math.cmax(float4)"/>
28
- [ MethodImpl ( IL ) ] public static float cmax ( this float2 f ) => f . x . max ( f . y ) ;
34
+ [ MethodImpl ( IL ) ] public static float cmax ( this float2 f ) => math . cmax ( f ) ;
29
35
30
36
/// <inheritdoc cref="math.cmin(float4)"/>
31
- [ MethodImpl ( IL ) ] public static float cmin ( this float4 f ) => fcmin ( f ) ;
37
+ [ MethodImpl ( IL ) ] public static float cmin ( this float4 f ) => math . cmin ( f ) ;
32
38
/// <inheritdoc cref="math.cmin(float4)"/>
33
- [ MethodImpl ( IL ) ] public static float cmin ( this float3 f ) => f . x . min ( f . y ) . min ( f . z ) ;
39
+ [ MethodImpl ( IL ) ] public static float cmin ( this float3 f ) => math . cmin ( f ) ;
34
40
/// <inheritdoc cref="math.cmin(float4)"/>
35
- [ MethodImpl ( IL ) ] public static float cmin ( this float2 f ) => fcmin ( f ) ;
41
+ [ MethodImpl ( IL ) ] public static float cmin ( this float2 f ) => math . cmin ( f ) ;
36
42
37
43
/// returns the greatest absolute value of the components
38
- [ MethodImpl ( IL ) ] public static float acmax ( this float4 f ) => f . abs ( ) . fcmin ( ) ;
44
+ [ MethodImpl ( IL ) ] public static float acmax ( this float4 f ) => f . abs ( ) . cmin ( ) ;
39
45
/// <inheritdoc cref="acmax(float4)"/>
40
- [ MethodImpl ( IL ) ] public static float acmax ( this float3 f ) => f . abs ( ) . fcmin ( ) ;
46
+ [ MethodImpl ( IL ) ] public static float acmax ( this float3 f ) => f . abs ( ) . cmin ( ) ;
41
47
/// <inheritdoc cref="acmax(float4)"/>
42
- [ MethodImpl ( IL ) ] public static float acmax ( this float2 f ) => f . abs ( ) . fcmin ( ) ;
48
+ [ MethodImpl ( IL ) ] public static float acmax ( this float2 f ) => f . abs ( ) . cmin ( ) ;
43
49
44
50
/// returns the smallest absolute value of the components
45
- [ MethodImpl ( IL ) ] public static float acmin ( this float4 f ) => f . abs ( ) . fcmin ( ) ;
51
+ [ MethodImpl ( IL ) ] public static float acmin ( this float4 f ) => f . abs ( ) . cmin ( ) ;
46
52
/// <inheritdoc cref="acmin(float4)"/>
47
- [ MethodImpl ( IL ) ] public static float acmin ( this float3 f ) => f . abs ( ) . fcmin ( ) ;
53
+ [ MethodImpl ( IL ) ] public static float acmin ( this float3 f ) => f . abs ( ) . cmin ( ) ;
48
54
/// <inheritdoc cref="acmin(float4)"/>
49
- [ MethodImpl ( IL ) ] public static float acmin ( this float2 f ) => f . abs ( ) . fcmin ( ) ;
55
+ [ MethodImpl ( IL ) ] public static float acmin ( this float2 f ) => f . abs ( ) . cmin ( ) ;
50
56
51
57
52
58
// [BurstCompile]
53
59
54
-
60
+ #if MATHX_FUNCTION_POINTERS
55
61
public static readonly f1x2_f1 p_fmax = compile < f1x2_f1 > ( fmax ) ; // We want to generate this line
56
62
57
63
[ MethodImpl ( IL ) ]
58
64
public static int fmax ( int x , int y ) => x ^ ( ( x ^ y ) & - ( x < y ? 1 : 0 ) ) ;
59
65
66
+
60
67
[ BurstCompile , MonoPInvokeCallback ( typeof ( f1x2_f1 ) ) ] // and also generate this attribute for the method we added the attribute to
68
+
61
69
[ MethodImpl ( IL ) ] public static float fmax ( this float x , float y ) => x <= y ? x : y ;
62
70
63
71
[ MethodImpl ( IL ) ] public static float2 fmax ( this float2 x , float y ) => p_fmax . RunPerAxis ( x , y ) ;
@@ -69,6 +77,7 @@ public static partial class mathx
69
77
[ MethodImpl ( IL ) ] public static float4 fmax ( this float4 x , float4 y ) => p_fmax . RunPerAxis ( x , y ) ;
70
78
71
79
[ MethodImpl ( IL ) ] public static float fcmax ( this float2 x ) => fmax ( x . x , x . y ) ;
80
+
72
81
[ MethodImpl ( IL ) ] public static float fcmax ( this float3 x ) => p_fmax . RunNested ( x ) ;
73
82
[ MethodImpl ( IL ) ] public static float fcmax ( this float4 x ) => p_fmax . RunNested ( x ) ;
74
83
@@ -79,6 +88,8 @@ public static partial class mathx
79
88
[ MethodImpl ( IL ) ] public static float fcmin ( this float3 x ) => x . x . fmin ( x . y ) . fmin ( x . z ) ;
80
89
[ MethodImpl ( IL ) ] public static float fcmin ( this float4 x ) => fmin ( x . x . fmin ( x . y ) , x . z . fmin ( x . w ) ) ;
81
90
91
+ #endif
92
+
82
93
83
94
// /// <summary>
84
95
// /// Returns the sign of x
0 commit comments