using System;
namespace UnityEngine.XR.ARSubsystems
{
///
/// Describes the geometry and transform of the camera background for a given platform.
///
public readonly struct XRCameraBackgroundRenderingParams : IEquatable
{
///
/// The geometry that should be used to render the camera background.
///
public Mesh backgroundGeometry { get; }
///
/// The transform that should be used to render the camera background.
///
public Matrix4x4 backgroundTransform { get; }
///
/// Constructs a from a mesh and transform.
///
/// The geometry that should be used to render the camera background. Cannot be null.
/// The transform that should be used to render the camera background.
public XRCameraBackgroundRenderingParams(Mesh mesh, Matrix4x4 transform)
{
if (mesh == null)
throw new ArgumentNullException(nameof(mesh), "Cannot construct XRCameraBackgroundRenderingParams from null mesh");
backgroundGeometry = mesh;
backgroundTransform = transform;
}
///
/// Constructs a from a mesh and transform.
///
/// The geometry that should be used to render the camera background. Cannot be null.
/// The model matrix that should be used to render the camera background.
/// The view matrix that should be used to render the camera background.
/// The projection matrix that should be used to render the camera background.
///
/// The model, view, and projection matrices are combined to form the transform.
///
public XRCameraBackgroundRenderingParams(Mesh mesh, Matrix4x4 model, Matrix4x4 view, Matrix4x4 projection)
: this(mesh, model * view * projection)
{
}
///
/// Tests for equality.
///
/// The other to compare against.
/// if every field in is equal to this . Otherwise, .
public bool Equals(XRCameraBackgroundRenderingParams other)
=> backgroundGeometry.Equals(other.backgroundGeometry) && backgroundTransform.Equals(other.backgroundTransform);
///
/// Tests for equality.
///
/// The `object` to compare against.
/// if is of type
/// and
/// also returns . Otherwise, .
public override bool Equals(object obj)
=> obj is XRCameraBackgroundRenderingParams other && Equals(other);
///
/// Generates a hash suitable for use with containers like `HashSet` and `Dictionary`.
///
/// A hash code generated from this object's fields.
public override int GetHashCode() => HashCode.Combine(backgroundGeometry, backgroundTransform);
///
/// Tests for equality. Same as .
///
/// The left-hand side of the comparison.
/// The right-hand side of the comparison.
/// if is equal to .
/// Otherwise, .
public static bool operator ==(XRCameraBackgroundRenderingParams lhs, XRCameraBackgroundRenderingParams rhs)
=> lhs.Equals(rhs);
///
/// Tests for inequality. Same as `!`.
///
/// The left-hand side of the comparison.
/// The right-hand side of the comparison.
/// if is not equal to .
/// Otherwise, .
public static bool operator !=(XRCameraBackgroundRenderingParams lhs, XRCameraBackgroundRenderingParams rhs)
=> !lhs.Equals(rhs);
}
}