|
|
|
|
@ -111,17 +111,28 @@ parameters once for whole group instead of setting them again in each
|
|
|
|
|
|
|
|
|
|
@snippet MagnumSceneGraph-gl.cpp Drawable-multiple-groups |
|
|
|
|
|
|
|
|
|
@section SceneGraph-Drawable-draw-order Custom draw order |
|
|
|
|
@section SceneGraph-Drawable-draw-order Custom draw order and object culling |
|
|
|
|
|
|
|
|
|
By default the contents of a drawable group are drawn in the order they were |
|
|
|
|
By default all contents of a drawable group are drawn, in the order they were |
|
|
|
|
added. In some cases you may want to draw them in a different order (for |
|
|
|
|
example to have correctly sorted transparent objects) or draw just a subset |
|
|
|
|
(for example to cull invisible objects way). That can be achieved using @ref Camera::drawableTransformations() |
|
|
|
|
in combination with @ref Camera::draw(const std::vector<std::pair<std::reference_wrapper<Drawable<dimensions, T>>, MatrixTypeFor<dimensions, T>>>&) and applying @ref std::sort() with a custom |
|
|
|
|
predicate on the drawable transformation list: |
|
|
|
|
(for example to cull invisible objects away). That can be achieved using |
|
|
|
|
@ref Camera::drawableTransformations() in combination with |
|
|
|
|
@ref Camera::draw(const std::vector<std::pair<std::reference_wrapper<Drawable<dimensions, T>>, MatrixTypeFor<dimensions, T>>>&). |
|
|
|
|
For example, to have the objects sorted back-to-front, apply @ref std::sort() |
|
|
|
|
with a custom predicate on the drawable transformation list: |
|
|
|
|
|
|
|
|
|
@snippet MagnumSceneGraph.cpp Drawable-draw-order |
|
|
|
|
|
|
|
|
|
Another use case is object-level culling --- assuming each drawable instance |
|
|
|
|
provides an *absolute* AABB, one can calculate the transformations, cull them |
|
|
|
|
via e.g. @ref Math::Intersection::rangeFrustum() and then pass the filtered |
|
|
|
|
vector to @ref Camera::draw(). To be clear, this approach depends on AABBs |
|
|
|
|
provided as relative to world origin, the actual object transformations don't |
|
|
|
|
get used in any way except being passed to the draw function: |
|
|
|
|
|
|
|
|
|
@snippet MagnumSceneGraph.cpp Drawable-culling |
|
|
|
|
|
|
|
|
|
@section SceneGraph-Drawable-explicit-specializations Explicit template specializations |
|
|
|
|
|
|
|
|
|
The following specializations are explicitly compiled into @ref SceneGraph |
|
|
|
|
|