forked from MattRix/UnityDecompiled
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBounds.cs
More file actions
183 lines (183 loc) · 4.53 KB
/
Bounds.cs
File metadata and controls
183 lines (183 loc) · 4.53 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
using System;
using System.Runtime.CompilerServices;
namespace UnityEngine
{
public struct Bounds
{
private Vector3 m_Center;
private Vector3 m_Extents;
public Vector3 center
{
get
{
return this.m_Center;
}
set
{
this.m_Center = value;
}
}
public Vector3 size
{
get
{
return this.m_Extents * 2f;
}
set
{
this.m_Extents = value * 0.5f;
}
}
public Vector3 extents
{
get
{
return this.m_Extents;
}
set
{
this.m_Extents = value;
}
}
public Vector3 min
{
get
{
return this.center - this.extents;
}
set
{
this.SetMinMax(value, this.max);
}
}
public Vector3 max
{
get
{
return this.center + this.extents;
}
set
{
this.SetMinMax(this.min, value);
}
}
public Bounds(Vector3 center, Vector3 size)
{
this.m_Center = center;
this.m_Extents = size * 0.5f;
}
public override int GetHashCode()
{
return this.center.GetHashCode() ^ this.extents.GetHashCode() << 2;
}
public override bool Equals(object other)
{
if (!(other is Bounds))
{
return false;
}
Bounds bounds = (Bounds)other;
return this.center.Equals(bounds.center) && this.extents.Equals(bounds.extents);
}
public void SetMinMax(Vector3 min, Vector3 max)
{
this.extents = (max - min) * 0.5f;
this.center = min + this.extents;
}
public void Encapsulate(Vector3 point)
{
this.SetMinMax(Vector3.Min(this.min, point), Vector3.Max(this.max, point));
}
public void Encapsulate(Bounds bounds)
{
this.Encapsulate(bounds.center - bounds.extents);
this.Encapsulate(bounds.center + bounds.extents);
}
public void Expand(float amount)
{
amount *= 0.5f;
this.extents += new Vector3(amount, amount, amount);
}
public void Expand(Vector3 amount)
{
this.extents += amount * 0.5f;
}
public bool Intersects(Bounds bounds)
{
return this.min.x <= bounds.max.x && this.max.x >= bounds.min.x && this.min.y <= bounds.max.y && this.max.y >= bounds.min.y && this.min.z <= bounds.max.z && this.max.z >= bounds.min.z;
}
private static bool Internal_Contains(Bounds m, Vector3 point)
{
return Bounds.INTERNAL_CALL_Internal_Contains(ref m, ref point);
}
[WrapperlessIcall]
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern bool INTERNAL_CALL_Internal_Contains(ref Bounds m, ref Vector3 point);
public bool Contains(Vector3 point)
{
return Bounds.Internal_Contains(this, point);
}
private static float Internal_SqrDistance(Bounds m, Vector3 point)
{
return Bounds.INTERNAL_CALL_Internal_SqrDistance(ref m, ref point);
}
[WrapperlessIcall]
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern float INTERNAL_CALL_Internal_SqrDistance(ref Bounds m, ref Vector3 point);
public float SqrDistance(Vector3 point)
{
return Bounds.Internal_SqrDistance(this, point);
}
private static bool Internal_IntersectRay(ref Ray ray, ref Bounds bounds, out float distance)
{
return Bounds.INTERNAL_CALL_Internal_IntersectRay(ref ray, ref bounds, out distance);
}
[WrapperlessIcall]
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern bool INTERNAL_CALL_Internal_IntersectRay(ref Ray ray, ref Bounds bounds, out float distance);
public bool IntersectRay(Ray ray)
{
float num;
return Bounds.Internal_IntersectRay(ref ray, ref this, out num);
}
public bool IntersectRay(Ray ray, out float distance)
{
return Bounds.Internal_IntersectRay(ref ray, ref this, out distance);
}
private static Vector3 Internal_GetClosestPoint(ref Bounds bounds, ref Vector3 point)
{
return Bounds.INTERNAL_CALL_Internal_GetClosestPoint(ref bounds, ref point);
}
[WrapperlessIcall]
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern Vector3 INTERNAL_CALL_Internal_GetClosestPoint(ref Bounds bounds, ref Vector3 point);
public Vector3 ClosestPoint(Vector3 point)
{
return Bounds.Internal_GetClosestPoint(ref this, ref point);
}
public override string ToString()
{
return UnityString.Format("Center: {0}, Extents: {1}", new object[]
{
this.m_Center,
this.m_Extents
});
}
public string ToString(string format)
{
return UnityString.Format("Center: {0}, Extents: {1}", new object[]
{
this.m_Center.ToString(format),
this.m_Extents.ToString(format)
});
}
public static bool operator ==(Bounds lhs, Bounds rhs)
{
return lhs.center == rhs.center && lhs.extents == rhs.extents;
}
public static bool operator !=(Bounds lhs, Bounds rhs)
{
return !(lhs == rhs);
}
}
}