116 lines
3.8 KiB
C#
116 lines
3.8 KiB
C#
using System;
|
|
using System.Runtime.CompilerServices;
|
|
using UnityEngine.Scripting;
|
|
|
|
namespace UnityEngine
|
|
{
|
|
// Token: 0x0200005E RID: 94
|
|
public sealed class GeometryUtility
|
|
{
|
|
// Token: 0x06000752 RID: 1874 RVA: 0x00009D74 File Offset: 0x00007F74
|
|
private static void Internal_ExtractPlanes(Plane[] planes, Matrix4x4 worldToProjectionMatrix)
|
|
{
|
|
GeometryUtility.INTERNAL_CALL_Internal_ExtractPlanes(planes, ref worldToProjectionMatrix);
|
|
}
|
|
|
|
// Token: 0x06000753 RID: 1875
|
|
[GeneratedByOldBindingsGenerator]
|
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
|
private static extern void INTERNAL_CALL_Internal_ExtractPlanes(Plane[] planes, ref Matrix4x4 worldToProjectionMatrix);
|
|
|
|
// Token: 0x06000754 RID: 1876 RVA: 0x00009D80 File Offset: 0x00007F80
|
|
public static bool TestPlanesAABB(Plane[] planes, Bounds bounds)
|
|
{
|
|
return GeometryUtility.INTERNAL_CALL_TestPlanesAABB(planes, ref bounds);
|
|
}
|
|
|
|
// Token: 0x06000755 RID: 1877
|
|
[GeneratedByOldBindingsGenerator]
|
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
|
private static extern bool INTERNAL_CALL_TestPlanesAABB(Plane[] planes, ref Bounds bounds);
|
|
|
|
// Token: 0x06000756 RID: 1878 RVA: 0x00009DA0 File Offset: 0x00007FA0
|
|
private static Bounds Internal_CalculateBounds(Vector3[] positions, Matrix4x4 transform)
|
|
{
|
|
Bounds bounds;
|
|
GeometryUtility.INTERNAL_CALL_Internal_CalculateBounds(positions, ref transform, out bounds);
|
|
return bounds;
|
|
}
|
|
|
|
// Token: 0x06000757 RID: 1879
|
|
[GeneratedByOldBindingsGenerator]
|
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
|
private static extern void INTERNAL_CALL_Internal_CalculateBounds(Vector3[] positions, ref Matrix4x4 transform, out Bounds value);
|
|
|
|
// Token: 0x06000758 RID: 1880 RVA: 0x00009DC0 File Offset: 0x00007FC0
|
|
public static bool TryCreatePlaneFromPolygon(Vector3[] vertices, out Plane plane)
|
|
{
|
|
bool flag;
|
|
if (vertices == null || vertices.Length < 3)
|
|
{
|
|
plane = new Plane(Vector3.up, 0f);
|
|
flag = false;
|
|
}
|
|
else if (vertices.Length == 3)
|
|
{
|
|
Vector3 vector = vertices[0];
|
|
Vector3 vector2 = vertices[1];
|
|
Vector3 vector3 = vertices[2];
|
|
plane = new Plane(vector, vector2, vector3);
|
|
flag = plane.normal.sqrMagnitude > 0f;
|
|
}
|
|
else
|
|
{
|
|
Vector3 zero = Vector3.zero;
|
|
int num = vertices.Length - 1;
|
|
Vector3 vector4 = vertices[num];
|
|
foreach (Vector3 vector5 in vertices)
|
|
{
|
|
zero.x += (vector4.y - vector5.y) * (vector4.z + vector5.z);
|
|
zero.y += (vector4.z - vector5.z) * (vector4.x + vector5.x);
|
|
zero.z += (vector4.x - vector5.x) * (vector4.y + vector5.y);
|
|
vector4 = vector5;
|
|
}
|
|
zero.Normalize();
|
|
float num2 = 0f;
|
|
foreach (Vector3 vector6 in vertices)
|
|
{
|
|
num2 -= Vector3.Dot(zero, vector6);
|
|
}
|
|
num2 /= (float)vertices.Length;
|
|
plane = new Plane(zero, num2);
|
|
flag = plane.normal.sqrMagnitude > 0f;
|
|
}
|
|
return flag;
|
|
}
|
|
|
|
// Token: 0x06000759 RID: 1881 RVA: 0x00009F94 File Offset: 0x00008194
|
|
public static Plane[] CalculateFrustumPlanes(Camera camera)
|
|
{
|
|
return GeometryUtility.CalculateFrustumPlanes(camera.projectionMatrix * camera.worldToCameraMatrix);
|
|
}
|
|
|
|
// Token: 0x0600075A RID: 1882 RVA: 0x00009FC0 File Offset: 0x000081C0
|
|
public static Plane[] CalculateFrustumPlanes(Matrix4x4 worldToProjectionMatrix)
|
|
{
|
|
Plane[] array = new Plane[6];
|
|
GeometryUtility.Internal_ExtractPlanes(array, worldToProjectionMatrix);
|
|
return array;
|
|
}
|
|
|
|
// Token: 0x0600075B RID: 1883 RVA: 0x00009FE4 File Offset: 0x000081E4
|
|
public static Bounds CalculateBounds(Vector3[] positions, Matrix4x4 transform)
|
|
{
|
|
if (positions == null)
|
|
{
|
|
throw new ArgumentNullException("positions");
|
|
}
|
|
if (positions.Length == 0)
|
|
{
|
|
throw new ArgumentException("Zero-sized array is not allowed.", "positions");
|
|
}
|
|
return GeometryUtility.Internal_CalculateBounds(positions, transform);
|
|
}
|
|
}
|
|
}
|