forked from Unity-Technologies/Unity.Mathematics
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfloat2.cs
More file actions
63 lines (52 loc) · 1.78 KB
/
float2.cs
File metadata and controls
63 lines (52 loc) · 1.78 KB
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
using System;
using System.Runtime.CompilerServices;
using System.Diagnostics;
#pragma warning disable 0660, 0661
namespace Unity.Mathematics
{
[DebuggerTypeProxy(typeof(float2.DebuggerProxy))]
[System.Serializable]
public partial struct float2 : IFormattable
{
internal sealed class DebuggerProxy
{
public float x;
public float y;
public DebuggerProxy(float2 vec)
{
x = vec.x;
y = vec.y;
}
}
public float x;
public float y;
[MethodImpl((MethodImplOptions)0x100)] // agressive inline
public float2(float x, float y)
{
this.x = x;
this.y = y;
}
[MethodImpl((MethodImplOptions)0x100)] // agressive inline
public float2(float val) { x = y = val; }
[MethodImpl((MethodImplOptions)0x100)] // agressive inline
public float2(int val) { x = y = val; }
[MethodImpl((MethodImplOptions)0x100)] // agressive inline
public float2(int2 val)
{
x = val.x;
y = val.y;
}
[MethodImpl((MethodImplOptions)0x100)] // agressive inline
public static implicit operator float2(float d) { return new float2(d); }
[MethodImpl((MethodImplOptions)0x100)] // agressive inline
public static implicit operator float2(int2 d) { return new float2(d.x, d.y); }
public override string ToString()
{
return string.Format("float2({0:R}f, {1:R}f)", x, y);
}
public string ToString(string format, IFormatProvider formatProvider)
{
return string.Format("float2({0}f, {1}f)", x.ToString(format, formatProvider), y.ToString(format, formatProvider));
}
}
}