44// ** Repository : https://github.com/LTMX/Unity.mathx
55#endregion
66
7- using System ;
7+
88using System . Runtime . CompilerServices ;
9+
10+ #if MATHX_FUNCTION_POINTERS
11+
12+ using System ;
913using AOT ;
1014using Unity . Burst ;
1115using 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+
1420
1521namespace Unity . Mathematics
1622{
@@ -19,45 +25,47 @@ public static partial class mathx
1925 // Component-wise comparison --------------------------------------------------------------
2026
2127 /// <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 ) ;
2329
2430 /// <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 ) ;
2632
2733 /// <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 ) ;
2935
3036 /// <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 ) ;
3238 /// <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 ) ;
3440 /// <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 ) ;
3642
3743 /// 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 ( ) ;
3945 /// <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 ( ) ;
4147 /// <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 ( ) ;
4349
4450 /// 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 ( ) ;
4652 /// <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 ( ) ;
4854 /// <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 ( ) ;
5056
5157
5258 // [BurstCompile]
5359
54-
60+ #if MATHX_FUNCTION_POINTERS
5561 public static readonly f1x2_f1 p_fmax = compile < f1x2_f1 > ( fmax ) ; // We want to generate this line
5662
5763 [ MethodImpl ( IL ) ]
5864 public static int fmax ( int x , int y ) => x ^ ( ( x ^ y ) & - ( x < y ? 1 : 0 ) ) ;
5965
66+
6067 [ BurstCompile , MonoPInvokeCallback ( typeof ( f1x2_f1 ) ) ] // and also generate this attribute for the method we added the attribute to
68+
6169 [ MethodImpl ( IL ) ] public static float fmax ( this float x , float y ) => x <= y ? x : y ;
6270
6371 [ 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
6977 [ MethodImpl ( IL ) ] public static float4 fmax ( this float4 x , float4 y ) => p_fmax . RunPerAxis ( x , y ) ;
7078
7179 [ MethodImpl ( IL ) ] public static float fcmax ( this float2 x ) => fmax ( x . x , x . y ) ;
80+
7281 [ MethodImpl ( IL ) ] public static float fcmax ( this float3 x ) => p_fmax . RunNested ( x ) ;
7382 [ MethodImpl ( IL ) ] public static float fcmax ( this float4 x ) => p_fmax . RunNested ( x ) ;
7483
@@ -79,6 +88,8 @@ public static partial class mathx
7988 [ MethodImpl ( IL ) ] public static float fcmin ( this float3 x ) => x . x . fmin ( x . y ) . fmin ( x . z ) ;
8089 [ MethodImpl ( IL ) ] public static float fcmin ( this float4 x ) => fmin ( x . x . fmin ( x . y ) , x . z . fmin ( x . w ) ) ;
8190
91+ #endif
92+
8293
8394 // /// <summary>
8495 // /// Returns the sign of x
0 commit comments