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

Function CullMeshesOrthographic

BindlessDeferred/MeshRenderer.cpp:99–125  ·  view source on GitHub ↗

Frustum culls meshes for an orthographic projection, and produces a buffer of visible mesh indices

Source from the content-addressed store, hash-verified

97
98// Frustum culls meshes for an orthographic projection, and produces a buffer of visible mesh indices
99static 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
127MeshRenderer::MeshRenderer()
128{

Callers 1

RenderSunShadowDepthMethod · 0.85

Calls 9

Float3Class · 0.85
MinXMethod · 0.80
MinYMethod · 0.80
MaxXMethod · 0.80
MaxYMethod · 0.80
OrientationMethod · 0.80
ToXMFLOAT3Method · 0.80
ToXMFLOAT4Method · 0.80
SizeMethod · 0.45

Tested by

no test coverage detected