BorrowedTorch.Culling 1.1.1

Prefix Reserved
dotnet add package BorrowedTorch.Culling --version 1.1.1
                    
NuGet\Install-Package BorrowedTorch.Culling -Version 1.1.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BorrowedTorch.Culling" Version="1.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BorrowedTorch.Culling" Version="1.1.1" />
                    
Directory.Packages.props
<PackageReference Include="BorrowedTorch.Culling" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add BorrowedTorch.Culling --version 1.1.1
                    
#r "nuget: BorrowedTorch.Culling, 1.1.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package BorrowedTorch.Culling@1.1.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=BorrowedTorch.Culling&version=1.1.1
                    
Install as a Cake Addin
#tool nuget:?package=BorrowedTorch.Culling&version=1.1.1
                    
Install as a Cake Tool

BorrowedTorch.Culling

Frustum culling on MonoGame's types: what a view can see, from its view-projection matrix - perspective or orthographic - against the volumes of BorrowedTorch.Collisions, and a query of its dynamic AABB tree that takes whole subtrees at once.

var tree = new DynamicAabbTree();                                   // BorrowedTorch.Collisions
var proxy = tree.CreateProxy(meshBounds, entityId);                 // ... one per thing drawn, moved as it moves

var frustum = Frustum.FromViewProjection(camera.View * camera.Projection);
var visible = new List<int>();

FrustumQuery.Visible(tree, frustum, visible);                       // the proxies in view - draw only those

Install

dotnet add package BorrowedTorch.Culling

Targets net10.0, on BorrowedTorch.Collisions. It is compiled against MonoGame 3.8.1.303 (DesktopGL) and does not pass MonoGame on: the game brings its own - DesktopGL, WindowsDX or BorrowedTorch's compute fork, any release from 3.8.1.303 on.

Frustum

Frustum.FromViewProjection(viewProjection) takes the planes a view shows between - left, right, bottom, top, near, far - from the matrix alone (MonoGame's row vectors, clip depth 0..1), each facing in and unit. So it is the same for a perspective view and an orthographic one, follows a jittered projection's sub-pixel shift, and drops a plane the matrix leaves without a direction - an infinite far plane. A camera that rebases its view on a floating origin gives it the view that takes absolute positions.

Method Gives
Classify(sphere / aabb / boundingBox / orientedBox / capsule / cylinder / shape) ContainmentType.Contains (wholly inside), Disjoint (wholly outside) or Intersects (across a plane).
Intersects(...) Whether any of it can be seen: not outside.
Contains(point) Whether the point is in view.

The tests go plane by plane, so a volume outside the frustum but across two planes near a corner is called crossing: kept, never wrongly thrown away.

Query

FrustumQuery.Visible(tree, frustum, ...) goes down a DynamicAabbTree by each node's box: a subtree whose box is outside is passed over, one wholly inside is taken whole without testing a box under it, one across is gone down into. It finds the proxies whose fat boxes are not outside - into a list, through a delegate, or through a struct IFrustumCallback that allocates nothing and is told whether each was taken inside (otherwise its fat box crosses the frustum, and a tighter volume of the caller's own may still be tested).

Building and testing

dotnet test BorrowedTorch.Culling.sln

To build against a BorrowedTorch.Collisions not yet published, from a local pack: -p:CollisionsVersion=<its version> -p:RestoreAdditionalProjectSources=<its folder>.

The tests check known frusta (perspective, orthographic, an infinite far plane), boxes and spheres against MonoGame's BoundingFrustum, turned boxes, capsules and cylinders against points of their surfaces, and the tree query against brute force.

Changelog

  • 1.1.1 - Built on BorrowedTorch.Collisions 1.2.0 instead of 1.0.0. No API changes.
  • 1.1.0 - Compiled against MonoGame 3.8.1.303 instead of 3.8.0.1641, as every BorrowedTorch library that does not need the compute fork now is. A game needs MonoGame 3.8.1.303 or newer; 3.8.0 no longer loads it. No API changes.
  • 1.0.0 - The frustum from a view-projection matrix, its tests of the collision volumes, and the tree query.

License

MIT

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on BorrowedTorch.Culling:

Package Downloads
BorrowedTorch.Engine.AdditionalFeatures

Kindling, Borrowed Torch's game engine: its additional features - sound, post effects, vegetation, fabric, sprites, collisions and culling - for a game's own code to build against beside the engine

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.1 48 11/18/2026
1.1.0 55 11/18/2026
1.0.0 107 11/16/2026