summaryrefslogtreecommitdiff
path: root/Thronefall_1_57/Decompile/NGS.MeshFusionPro/BoundsHelper.cs
blob: 012a3503b31e0bbad4775b071858d3bbcfa33f81 (plain)
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
using UnityEngine;

namespace NGS.MeshFusionPro;

public static class BoundsHelper
{
	public static Bounds Transform(this Bounds bounds, Matrix4x4 transform)
	{
		Vector3 min = bounds.min;
		Vector3 max = bounds.max;
		Vector4 column = transform.GetColumn(3);
		Vector3 vector = column;
		Vector3 vector2 = column;
		for (int i = 0; i < 3; i++)
		{
			for (int j = 0; j < 3; j++)
			{
				float num = transform[i, j];
				float num2 = num * min[j];
				float num3 = num * max[j];
				vector[i] += ((num2 < num3) ? num2 : num3);
				vector2[i] += ((num2 < num3) ? num3 : num2);
			}
		}
		Bounds result = default(Bounds);
		result.center = transform.MultiplyPoint3x4(bounds.center);
		result.size = vector2 - vector;
		return result;
	}

	public static bool Contains(this Bounds bounds, Bounds target)
	{
		if (bounds.Contains(target.min))
		{
			return bounds.Contains(target.max);
		}
		return false;
	}
}