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
<PackageReference Include="BorrowedTorch.Culling" Version="1.1.1" />
<PackageVersion Include="BorrowedTorch.Culling" Version="1.1.1" />
<PackageReference Include="BorrowedTorch.Culling" />
paket add BorrowedTorch.Culling --version 1.1.1
#r "nuget: BorrowedTorch.Culling, 1.1.1"
#:package BorrowedTorch.Culling@1.1.1
#addin nuget:?package=BorrowedTorch.Culling&version=1.1.1
#tool nuget:?package=BorrowedTorch.Culling&version=1.1.1
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 | Versions 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. |
-
net10.0
- BorrowedTorch.Collisions (>= 1.2.0)
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.