Skip to content

Commit f326c6e

Browse files
committed
Added dim for bool, and functions to create float4s from float3s and vice versa, and also for all dimensions
1 parent e576d1b commit f326c6e

File tree

1 file changed

+72
-8
lines changed

1 file changed

+72
-8
lines changed

Runtime/Math.Common.cs

Lines changed: 72 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -468,23 +468,37 @@ public static partial class mathx
468468
[MethodImpl(IL)] public static float4 dim(this float a, int4 b) => new(a * b.x, a * b.y, a * b.z, a * b.w);
469469

470470
/// <inheritdoc cref="dim(float, float)"/>
471-
[MethodImpl(IL)] public static float dim(this float a, bool b) => a * b.asfloat();
471+
[MethodImpl(IL)] public static float dim(this float a, bool b) => a * b.asint();
472472
/// <inheritdoc cref="dim(float, float)"/>
473-
[MethodImpl(IL)] public static float2 dim(this float2 a, bool2 b) => a * b.asfloat();
473+
[MethodImpl(IL)] public static float2 dim(this float2 a, bool2 b) => a * b.asint();
474474
/// <inheritdoc cref="dim(float, float)"/>
475-
[MethodImpl(IL)] public static float3 dim(this float3 a, bool3 b) => a * b.asfloat();
475+
[MethodImpl(IL)] public static float3 dim(this float3 a, bool3 b) => a * b.asint();
476476
/// <inheritdoc cref="dim(float, float)"/>
477-
[MethodImpl(IL)] public static float4 dim(this float4 a, bool4 b) => a * b.asfloat();
477+
[MethodImpl(IL)] public static float4 dim(this float4 a, bool4 b) => a * b.asint();
478478

479479
/// <inheritdoc cref="dim(float, float)"/>
480-
[MethodImpl(IL)] public static float dim(this bool a, float b) => a.asfloat() * b;
480+
[MethodImpl(IL)] public static float2 dim(this float2 a, bool b) => a * b.asint();
481+
/// <inheritdoc cref="dim(float, float)"/>
482+
[MethodImpl(IL)] public static float3 dim(this float3 a, bool b) => a * b.asint();
483+
/// <inheritdoc cref="dim(float, float)"/>
484+
[MethodImpl(IL)] public static float4 dim(this float4 a, bool b) => a * b.asint();
485+
486+
/// <inheritdoc cref="dim(float, float)"/>
487+
[MethodImpl(IL)] public static float dim(this bool a, float b) => b.asint() * b;
481488
/// <inheritdoc cref="dim(float, float)"/>
482489
[MethodImpl(IL)] public static float2 dim(this bool2 a, float2 b) => a.asfloat() * b;
483490
/// <inheritdoc cref="dim(float, float)"/>
484491
[MethodImpl(IL)] public static float3 dim(this bool3 a, float3 b) => a.asfloat() * b;
485492
/// <inheritdoc cref="dim(float, float)"/>
486493
[MethodImpl(IL)] public static float4 dim(this bool4 a, float4 b) => a.asfloat() * b;
487494

495+
/// <inheritdoc cref="dim(float, float)"/>
496+
[MethodImpl(IL)] public static float2 dim(this bool a, float2 b) => a.asint() * b;
497+
/// <inheritdoc cref="dim(float, float)"/>
498+
[MethodImpl(IL)] public static float3 dim(this bool a, float3 b) => a.asint() * b;
499+
/// <inheritdoc cref="dim(float, float)"/>
500+
[MethodImpl(IL)] public static float4 dim(this bool a, float4 b) => a.asint() * b;
501+
488502
/// <inheritdoc cref="dim(float, float)"/>
489503
[MethodImpl(IL)] public static int dim(this bool a, int b) => a.asint() * b;
490504
/// <inheritdoc cref="dim(float, float)"/>
@@ -494,6 +508,13 @@ public static partial class mathx
494508
/// <inheritdoc cref="dim(float, float)"/>
495509
[MethodImpl(IL)] public static int4 dim(this bool4 a, int4 b) => a.asint() * b;
496510

511+
/// <inheritdoc cref="dim(float, float)"/>
512+
[MethodImpl(IL)] public static int2 dim(this bool a, int2 b) => a.asint() * b;
513+
/// <inheritdoc cref="dim(float, float)"/>
514+
[MethodImpl(IL)] public static int3 dim(this bool a, int3 b) => a.asint() * b;
515+
/// <inheritdoc cref="dim(float, float)"/>
516+
[MethodImpl(IL)] public static int4 dim(this bool a, int4 b) => a.asint() * b;
517+
497518
/// <inheritdoc cref="dim(float, float)"/>
498519
[MethodImpl(IL)] public static int dim(this int a, bool b) => a * b.asint();
499520
/// <inheritdoc cref="dim(float, float)"/>
@@ -503,6 +524,13 @@ public static partial class mathx
503524
/// <inheritdoc cref="dim(float, float)"/>
504525
[MethodImpl(IL)] public static int4 dim(this int4 a, bool4 b) => a * b.asint();
505526

527+
/// <inheritdoc cref="dim(float, float)"/>
528+
[MethodImpl(IL)] public static int2 dim(this int2 a, bool b) => a * b.asint();
529+
/// <inheritdoc cref="dim(float, float)"/>
530+
[MethodImpl(IL)] public static int3 dim(this int3 a, bool b) => a * b.asint();
531+
/// <inheritdoc cref="dim(float, float)"/>
532+
[MethodImpl(IL)] public static int4 dim(this int4 a, bool b) => a * b.asint();
533+
506534
/// <inheritdoc cref="dim(float, float)"/>
507535
[MethodImpl(IL)] public static uint dim(this bool a, uint b) => a.asuint() * b;
508536
/// <inheritdoc cref="dim(float, float)"/>
@@ -512,6 +540,13 @@ public static partial class mathx
512540
/// <inheritdoc cref="dim(float, float)"/>
513541
[MethodImpl(IL)] public static uint4 dim(this bool4 a, uint4 b) => a.asuint() * b;
514542

543+
/// <inheritdoc cref="dim(float, float)"/>
544+
[MethodImpl(IL)] public static uint2 dim(this bool a, uint2 b) => a.asuint() * b;
545+
/// <inheritdoc cref="dim(float, float)"/>
546+
[MethodImpl(IL)] public static uint3 dim(this bool a, uint3 b) => a.asuint() * b;
547+
/// <inheritdoc cref="dim(float, float)"/>
548+
[MethodImpl(IL)] public static uint4 dim(this bool a, uint4 b) => a.asuint() * b;
549+
515550
/// <inheritdoc cref="dim(float, float)"/>
516551
[MethodImpl(IL)] public static uint dim(this uint a, bool b) => a * b.asuint();
517552
/// <inheritdoc cref="dim(float, float)"/>
@@ -520,6 +555,13 @@ public static partial class mathx
520555
[MethodImpl(IL)] public static uint3 dim(this uint3 a, bool3 b) => a * b.asuint();
521556
/// <inheritdoc cref="dim(float, float)"/>
522557
[MethodImpl(IL)] public static uint4 dim(this uint4 a, bool4 b) => a * b.asuint();
558+
559+
/// <inheritdoc cref="dim(float, float)"/>
560+
[MethodImpl(IL)] public static uint2 dim(this uint2 a, bool b) => a * b.asuint();
561+
/// <inheritdoc cref="dim(float, float)"/>
562+
[MethodImpl(IL)] public static uint3 dim(this uint3 a, bool b) => a * b.asuint();
563+
/// <inheritdoc cref="dim(float, float)"/>
564+
[MethodImpl(IL)] public static uint4 dim(this uint4 a, bool b) => a * b.asuint();
523565

524566
#endregion
525567

@@ -588,7 +630,7 @@ public static partial class mathx
588630
[MethodImpl(IL)] public static float3 add(this float x, float3 y) => x + y;
589631
/// <inheritdoc cref="add(float, float)"/>
590632
[MethodImpl(IL)] public static float4 add(this float x, float4 y) => x + y;
591-
633+
592634
/// Subtraction Operation
593635
[MethodImpl(IL)] public static float sub(this float x, float y) => x - y;
594636
/// <inheritdoc cref="sub(float, float)"/>
@@ -641,6 +683,8 @@ public static partial class mathx
641683
/// sets the value of x to f and returns f
642684
[MethodImpl(IL)] public static T set<T>(this T f, out T x) { x = f; return f; }
643685

686+
#region Type Building
687+
644688
///<inheritdoc cref="math.float4(float)"/>
645689
public static float4 float4(float f) => math.float4(f);
646690
/// Returns a float4 with the first two components set to f, and the last two set to 0
@@ -651,25 +695,45 @@ public static partial class mathx
651695
public static float4 float4(float a, float b, float c, float d) => math.float4(a, b, c, d);
652696
/// <inheritdoc cref="math.float4(Mathematics.float2, Mathematics.float2)"/>
653697
public static float4 float4(float2 a, float2 b) => math.float4(a, b);
698+
/// <inheritdoc cref="math.float4(Mathematics.float3, float)"/>
654699
public static float4 float4(float3 a, float b) => math.float4(a, b);
700+
/// <inheritdoc cref="math.float4(float, Mathematics.float3)"/>
655701
public static float4 float4(float a, float3 b) => math.float4(a, b);
702+
/// <inheritdoc cref="math.float4(float, float, Mathematics.float2)"/>
656703
public static float4 float4(float a, float2 b, float c) => math.float4(a, b, c);
704+
/// <inheritdoc cref="math.float4(float, float, float, float)"/>
657705
public static float4 float4(float a, float b, float2 c) => math.float4(a, b, c);
706+
/// <inheritdoc cref="math.float4(float, float, float, float)"/>
658707
public static float4 float4(float2 a, float b, float c) => math.float4(a, b, c);
659708

709+
/// <inheritdoc cref="math.float3(float, float, float)"/>
660710
public static float3 float3(float a, float b, float c) => math.float3(a, b, c);
711+
/// <inheritdoc cref="math.float3(Mathematics.float2, float)"/>
661712
public static float3 float3(float2 a, float b) => math.float3(a, b);
713+
/// <inheritdoc cref="math.float3(float, Mathematics.float2)"/>
662714
public static float3 float3(float a, float2 b) => math.float3(a, b);
715+
/// <inheritdoc cref="math.float3(float)"/>
663716
public static float3 float3(float f) => math.float3(f);
717+
/// <inheritdoc cref="math.float3(Mathematics.float2)"/>
664718
public static float3 float3(float2 f) => math.float3(f, 0);
719+
/// Returns a float3 with containing the first three components of a float4
665720
public static float3 float3(float4 f) => math.float3(f.xyz); // crop w
666721

722+
/// <inheritdoc cref="math.float2(float, float)"/>
667723
public static float2 float2(float a, float b) => math.float2(a, b);
724+
/// <inheritdoc cref="math.float2(float)"/>
668725
public static float2 float2(float f) => math.float2(f);
726+
/// Returns a float2 with containing the first two components of a float3
669727
public static float2 float2(float3 f) => math.float2(f.xy); // crop z
728+
/// Returns a float2 with containing the first two components of a float4
670729
public static float2 float2(float4 f) => math.float2(f.xy); // crop zw
671-
672-
730+
731+
732+
#endregion
733+
734+
735+
736+
673737

674738
}
675739
}

0 commit comments

Comments
 (0)