Frustum culls meshes for an orthographic projection, and produces a buffer of visible mesh indices
| 97 | |
| 98 | // Frustum culls meshes for an orthographic projection, and produces a buffer of visible mesh indices |
| 99 | static uint64 CullMeshesOrthographic(const OrthographicCamera& camera, bool ignoreNearZ, const Array<DirectX::BoundingBox>& boundingBoxes, Array<uint32>& drawIndices) |
| 100 | { |
| 101 | Float3 mins = Float3(camera.MinX(), camera.MinY(), camera.NearClip()); |
| 102 | Float3 maxes = Float3(camera.MaxX(), camera.MaxY(), camera.FarClip()); |
| 103 | if(ignoreNearZ) |
| 104 | mins.z = -10000.0f; |
| 105 | |
| 106 | Float3 extents = (maxes - mins) / 2.0f; |
| 107 | Float3 center = mins + extents; |
| 108 | center = Float3::Transform(center, camera.Orientation()); |
| 109 | center += camera.Position(); |
| 110 | |
| 111 | DirectX::BoundingOrientedBox obb; |
| 112 | obb.Extents = extents.ToXMFLOAT3(); |
| 113 | obb.Center = center.ToXMFLOAT3(); |
| 114 | obb.Orientation = camera.Orientation().ToXMFLOAT4(); |
| 115 | |
| 116 | uint64 numVisible = 0; |
| 117 | const uint64 numMeshes = boundingBoxes.Size(); |
| 118 | for(uint64 i = 0; i < numMeshes; ++i) |
| 119 | { |
| 120 | if(obb.Intersects(boundingBoxes[i])) |
| 121 | drawIndices[numVisible++] = uint32(i); |
| 122 | } |
| 123 | |
| 124 | return numVisible; |
| 125 | } |
| 126 | |
| 127 | MeshRenderer::MeshRenderer() |
| 128 | { |
no test coverage detected