4 public struct CellFace : IEquatable<CellFace> {
15 public static readonly
Point3[]
m_faceToPoint3 = [
new(0, 0, 1),
new(1, 0, 0),
new(0, 0, -1),
new(-1, 0, 0),
new(0, 1, 0),
new(0, -1, 0)];
18 new(0f, 0f, 1f),
new(1f, 0f, 0f),
new(0f, 0f, -1f),
new(-1f, 0f, 0f),
new(0f, 1f, 0f),
new(0f, -1f, 0f)
21 public static readonly
int[][]
m_faceToTangents = [[1, 4, 3, 5], [4, 0, 5, 2], [4, 1, 5, 3], [0, 4, 2, 5], [0, 1, 2, 3], [1, 0, 3, 2]];
32 public CellFace(
int x,
int y,
int z,
int face) {
55 for (
int i = 0; i < maxFace; i++) {
60 throw new InvalidOperationException(
"Invalid Point3.");
66 for (
int i = 0; i <= maxFace; i++) {
82 case 0: result.Face = direction > 0f ? 1 : 3;
break;
83 case 1: result.Face = direction > 0f ? 4 : 5;
break;
84 case 2: result.Face = !(direction > 0f) ? 2 : 0;
break;
105 float halfSize = size * 0.5f;
111 result[0] = center - tangent1 - tangent2;
112 result[1] = center + tangent1 - tangent2;
113 result[2] = center + tangent1 + tangent2;
114 result[3] = center - tangent1 + tangent2;
119 float halfSize = size * 0.5f;
124 Vector3 v0 = center - tangent1 - tangent2;
125 Vector3 v1 = center + tangent1 - tangent2;
126 Vector3 v2 = center + tangent1 + tangent2;
127 Vector3 v3 = center - tangent1 + tangent2;
142 public override bool Equals(
object obj) {
153 return other.Face ==
Face;
158 public override string ToString() => $
"{X}, {Y}, {Z}, face {Face}";
static float Dot(Vector3 v1, Vector3 v2)
static readonly Vector3[] m_faceToVector3
override bool Equals(object obj)
bool Equals(CellFace other)
Vector3[] GetSixVertices(float size=1f, float offset=0f)
CellFace(int x, int y, int z, int face)
override int GetHashCode()
static int[] FaceToTangents(int face)
override string ToString()
static readonly Point3[] m_faceToPoint3
static readonly int[][] m_faceToTangents
static int Vector3ToFace(Vector3 v, int maxFace=5)
static int OppositeFace(int face)
static bool operator!=(CellFace c1, CellFace c2)
Vector3 GetFaceCenter(float offset=0f)
static Vector3 FaceToVector3(int face)
static readonly int[] m_oppositeFaces
Vector3[] GetFourVertices(float size=1f, float offset=0f)
static bool operator==(CellFace c1, CellFace c2)
static Point3 FaceToPoint3(int face)
static int Point3ToFace(Point3 p, int maxFace=5)
CellFace(Point3 point, int face)
static CellFace FromAxisAndDirection(int x, int y, int z, int axis, float direction)