//Renderer.bounds are AABB in world space private void DisplayMeshRendererAABB(MeshRenderer mr) { Bounds bounds = mr.bounds; //Vector3 halfSize = bounds.extents; //Vector3 top = bounds.center + Vector3.up * halfSize.y; //Vector3 bottom = bounds.center - Vector3.up * halfSize.y; //Vector3 topFR = top + Vector3.forward * halfSize.z + Vector3.right * halfSize.x; //Vector3 topFL = top + Vector3.forward * halfSize.z + Vector3.left * halfSize.x; //Vector3 topBR = top - Vector3.forward * halfSize.z + Vector3.right * halfSize.x; //Vector3 topBL = top - Vector3.forward * halfSize.z + Vector3.left * halfSize.x; //Vector3 bottomFR = bottom + Vector3.forward * halfSize.z + Vector3.right * halfSize.x; //Vector3 bottomFL = bottom + Vector3.forward * halfSize.z + Vector3.left * halfSize.x; //Vector3 bottomBR = bottom - Vector3.forward * halfSize.z + Vector3.right * halfSize.x; //Vector3 bottomBL = bottom - Vector3.forward * halfSize.z + Vector3.left * halfSize.x; AABB3 aabb = new AABB3(bounds); Gizmos.color = Color.black; List <Edge3> edges = aabb.GetEdges(); foreach (Edge3 e in edges) { Gizmos.DrawLine(e.p1.ToVector3(), e.p2.ToVector3()); } }
public BinnedSAHBVHController() { this.boundsPool = AABB3.CreateAABBPool(); this.indices = new List <int>(); this.sah = new BinnedSAH(boundsPool); this.objectBounds = new List <AABB3>(); }
public void BinnedSAHTestSimplePasses() { var bounds = new List <AABB3>(); var indices = new List <int>(); for (var i = 0; i < 4; i++) { var bb = (AABB3) new Bounds(new Vector3(((i % 2) == 0 ? 1f : -1f) * (i + 1f), 0f, 0f), Vector3.one); bounds.Add(bb); } for (var i = 0; i < bounds.Count; i++) { indices.Add(i); } var pool = AABB3.CreateAABBPool(); var sah = new BinnedSAH(pool); int countFromLeft; sah.Build(bounds, indices, 0, bounds.Count, out countFromLeft); Assert.AreEqual(2, countFromLeft); AreEqual(new int[] { 3, 1, 0, 2 }, indices); Assert.AreEqual(indices.Count, bounds.Count); }
public override bool Equals(object obj) { if (obj == null) { return(false); } AABB3 aABB = (AABB3)obj; return(min == aABB.min && max == aABB.max); }
public static void DebugAABB(Vector3 position, AABB3 bounds, Color color, float duration = 0f, bool depthTest = true) { Vector3 vector = bounds.Range * 0.5f; DebugExtense(vector.x, vector.y, vector.z, position, color, duration, depthTest); }
public static void DebugAABB(AABB3 bounds, Color color, float duration = 0f, bool depthTest = true) { Vector3 range = bounds.Range; DebugExtense(range.x, range.y, range.z, bounds.Center, color, duration, depthTest); }
public bool Intersects(AABB3 aabb) { return(min.LessEqual(aabb.max) && aabb.min.Less(max)); }
public bool Contains(AABB3 aabb) { return(Contains(aabb.min) && Contains(aabb.max)); }
public void ExpandToFit(AABB3 aabb) { min = min.Min(aabb.min); max = max.Max(aabb.max); }