public static void CalculateFrustumPlanes(Camera InCamera, ref Plane[] OutPlanes) { Matrix4x4 projectionMatrix = InCamera.projectionMatrix; Matrix4x4 worldToCameraMatrix = InCamera.worldToCameraMatrix; Matrix4x4 matrix4x = projectionMatrix * worldToCameraMatrix; GeometryUtilityUser.RootVector[0] = matrix4x[3, 0]; GeometryUtilityUser.RootVector[1] = matrix4x[3, 1]; GeometryUtilityUser.RootVector[2] = matrix4x[3, 2]; GeometryUtilityUser.RootVector[3] = matrix4x[3, 3]; GeometryUtilityUser.ComVector[0] = matrix4x[0, 0]; GeometryUtilityUser.ComVector[1] = matrix4x[0, 1]; GeometryUtilityUser.ComVector[2] = matrix4x[0, 2]; GeometryUtilityUser.ComVector[3] = matrix4x[0, 3]; GeometryUtilityUser.CalcPlane(ref OutPlanes[0], GeometryUtilityUser.ComVector[0] + GeometryUtilityUser.RootVector[0], GeometryUtilityUser.ComVector[1] + GeometryUtilityUser.RootVector[1], GeometryUtilityUser.ComVector[2] + GeometryUtilityUser.RootVector[2], GeometryUtilityUser.ComVector[3] + GeometryUtilityUser.RootVector[3]); GeometryUtilityUser.CalcPlane(ref OutPlanes[1], -GeometryUtilityUser.ComVector[0] + GeometryUtilityUser.RootVector[0], -GeometryUtilityUser.ComVector[1] + GeometryUtilityUser.RootVector[1], -GeometryUtilityUser.ComVector[2] + GeometryUtilityUser.RootVector[2], -GeometryUtilityUser.ComVector[3] + GeometryUtilityUser.RootVector[3]); GeometryUtilityUser.ComVector[0] = matrix4x[1, 0]; GeometryUtilityUser.ComVector[1] = matrix4x[1, 1]; GeometryUtilityUser.ComVector[2] = matrix4x[1, 2]; GeometryUtilityUser.ComVector[3] = matrix4x[1, 3]; GeometryUtilityUser.CalcPlane(ref OutPlanes[2], GeometryUtilityUser.ComVector[0] + GeometryUtilityUser.RootVector[0], GeometryUtilityUser.ComVector[1] + GeometryUtilityUser.RootVector[1], GeometryUtilityUser.ComVector[2] + GeometryUtilityUser.RootVector[2], GeometryUtilityUser.ComVector[3] + GeometryUtilityUser.RootVector[3]); GeometryUtilityUser.CalcPlane(ref OutPlanes[3], -GeometryUtilityUser.ComVector[0] + GeometryUtilityUser.RootVector[0], -GeometryUtilityUser.ComVector[1] + GeometryUtilityUser.RootVector[1], -GeometryUtilityUser.ComVector[2] + GeometryUtilityUser.RootVector[2], -GeometryUtilityUser.ComVector[3] + GeometryUtilityUser.RootVector[3]); GeometryUtilityUser.ComVector[0] = matrix4x[2, 0]; GeometryUtilityUser.ComVector[1] = matrix4x[2, 1]; GeometryUtilityUser.ComVector[2] = matrix4x[2, 2]; GeometryUtilityUser.ComVector[3] = matrix4x[2, 3]; GeometryUtilityUser.CalcPlane(ref OutPlanes[4], GeometryUtilityUser.ComVector[0] + GeometryUtilityUser.RootVector[0], GeometryUtilityUser.ComVector[1] + GeometryUtilityUser.RootVector[1], GeometryUtilityUser.ComVector[2] + GeometryUtilityUser.RootVector[2], GeometryUtilityUser.ComVector[3] + GeometryUtilityUser.RootVector[3]); GeometryUtilityUser.CalcPlane(ref OutPlanes[5], -GeometryUtilityUser.ComVector[0] + GeometryUtilityUser.RootVector[0], -GeometryUtilityUser.ComVector[1] + GeometryUtilityUser.RootVector[1], -GeometryUtilityUser.ComVector[2] + GeometryUtilityUser.RootVector[2], -GeometryUtilityUser.ComVector[3] + GeometryUtilityUser.RootVector[3]); }
void UpdateGroupVisibility() { GeometryUtilityUser.CalculateFrustumPlanes(mainCam, ref camPlane); for (int i = 0; i < renderGroup.Count; i++) { Bounds b = renderGroup[i].bound; SetGroupVisible(i, GeometryUtility.TestPlanesAABB(camPlane, b), b.SqrDistance(mainCamTrans.position)); } }
private Plane[] CalcFrustum(Camera InCamera) { GeometryUtilityUser.CalculateFrustumPlanes(InCamera, ref CachedPlanes); #if UNITY_EDITOR && true Plane[] SysPlanes = GeometryUtility.CalculateFrustumPlanes(InCamera); for (int i = 0; i < SysPlanes.Length; ++i) { if (!IsEqual(SysPlanes[i], CachedPlanes[i])) { DebugHelper.Assert(false, "Internal error in CalcFrustum"); } } #endif return(CachedPlanes); }
private Plane[] CalcFrustum(Camera InCamera) { GeometryUtilityUser.CalculateFrustumPlanes(InCamera, ref this.CachedPlanes); return(this.CachedPlanes); }
void CustomTests() { GeometryUtilityUser.CalculateFrustumPlanes(Camera.main, ref CustomPlanes); }