void DrawFrustrumAABB() { var material = this.boundingAABBMaterial; var thickness = this.viewerCamera.IsUsed ? 0.05f : Mathf.Max(this.orbitalCamera.Zoom * 0.005f, 0.05f); Graphics.DrawMesh(this.cubeMesh, Matrix4x4.TRS(FrustrumAABB.Center, Quaternion.identity, FrustrumAABB.Extents * 2f), material, 0); Draw.AABBEdges(this.cubeMesh, material.color.Opaque(), FrustrumAABB.Extents, FrustrumAABB.Center, thickness); }
void DrawEntityAABBs() { var aabbs = EntityQuery.ToComponentDataArray <WorldRenderBounds>(Allocator.Temp); var count = aabbs.Length; var viewer = this.viewerCamera.IsUsed ? this.viewerCamera.transform.position : this.orbitalCamera.transform.position; var maxDistSq = this.maxAABBDrawDistance * this.maxAABBDrawDistance; var matrices = new List <Matrix4x4>(1024); for (int i = 0; i < count; ++i) { var aabb = aabbs[i].Value; if (math.distancesq(viewer, aabb.Center) > maxDistSq) { continue; } var center = aabb.Center; var size = aabb.Extents * 2.05f; // Draw it a liitle bit bigger to avoid artefacts var matrix = Matrix4x4.TRS(center, Quaternion.identity, size); matrices.Add(matrix); Draw.AABBEdges(this.cubeMesh, this.boundingAABBMaterial.color.Opaque(), aabb.Extents, aabb.Center, 1f); if (matrices.Count == 1023) { Graphics.DrawMeshInstanced(this.cubeMesh, 0, this.boundingAABBMaterial, matrices); matrices.Clear(); } } Graphics.DrawMeshInstanced(this.cubeMesh, 0, this.boundingAABBMaterial, matrices); }