MCPcopy Create free account
hub / github.com/TheRealMJP/DeferredTexturing / CullMeshes

Function CullMeshes

BindlessDeferred/MeshRenderer.cpp:53–67  ·  view source on GitHub ↗

Frustum culls meshes, and produces a buffer of visible mesh indices

Source from the content-addressed store, hash-verified

51
52// Frustum culls meshes, and produces a buffer of visible mesh indices
53static uint64 CullMeshes(const Camera& camera, const Array<DirectX::BoundingBox>& boundingBoxes, Array<uint32>& drawIndices)
54{
55 DirectX::BoundingFrustum frustum(camera.ProjectionMatrix().ToSIMD());
56 frustum.Transform(frustum, 1.0f, camera.Orientation().ToSIMD(), camera.Position().ToSIMD());
57
58 uint64 numVisible = 0;
59 const uint64 numMeshes = boundingBoxes.Size();
60 for(uint64 i = 0; i < numMeshes; ++i)
61 {
62 if(frustum.Intersects(boundingBoxes[i]))
63 drawIndices[numVisible++] = uint32(i);
64 }
65
66 return numVisible;
67}
68
69// Frustum culls meshes, and produces a buffer of visible mesh indices. Also sorts the indices by depth.
70static uint64 CullMeshesAndSort(const Camera& camera, const Array<DirectX::BoundingBox>& boundingBoxes,

Callers 4

RenderMainPassMethod · 0.85
RenderGBufferMethod · 0.85
RenderDepthPrepassMethod · 0.85

Calls 4

OrientationMethod · 0.80
ToSIMDMethod · 0.45
TransformMethod · 0.45
SizeMethod · 0.45

Tested by

no test coverage detected