12 #ifndef RENDERQUEUE_H_6014714286
13 #define RENDERQUEUE_H_6014714286
15 #include <Carna/Carna.h>
62 template<
typename RenderableCompare >
68 std::vector< Renderable > renderables;
69 std::size_t nextRenderableIndex;
94 RenderQueue(
unsigned int geometryType,
unsigned int geometryTypeMask = EXACT_MATCH_GEOMETRY_TYPE_MASK );
150 template<
typename RenderableCompare >
154 template<
typename RenderableCompare >
156 : geometryType( geometryType )
157 , geometryTypeMask( geometryTypeMask )
162 template<
typename RenderableCompare >
163 struct RenderableSort
165 static void sort( std::vector< Renderable >& renderables,
bool skipIfViewDependent )
167 if( renderables.size() >= 2 && ( RenderableCompare::isViewDependent || !skipIfViewDependent ) )
169 std::sort( renderables.begin(), renderables.end(), RenderableCompare() );
176 struct RenderableSort< void >
178 static void sort( std::vector< Renderable >& renderables,
bool skipIfViewDependent )
184 template<
typename RenderableCompare >
188 nextRenderableIndex = 0;
195 if( geom !=
nullptr && ( geom->
geometryType & geometryTypeMask ) == geometryType )
198 renderables.push_back(
Renderable( *geom, modelViewTransform ) );
205 RenderableSort< RenderableCompare >::sort( renderables,
false );
209 template<
typename RenderableCompare >
212 nextRenderableIndex = 0;
216 template<
typename RenderableCompare >
221 std::for_each( renderables.begin(), renderables.end(),
224 r.setModelViewTransform( viewTransform * r.geometry().worldTransform() );
230 RenderableSort< RenderableCompare >::sort( renderables,
true );
234 template<
typename RenderableCompare >
237 return nextRenderableIndex >= renderables.size();
241 template<
typename RenderableCompare >
245 return renderables[ nextRenderableIndex++ ];
249 template<
typename RenderableCompare >
253 return renderables.front();
257 template<
typename RenderableCompare >
261 return renderables.back();
270 #endif // RENDERQUEUE_H_6014714286
Defines Carna::base::Renderable.
Defines Carna::base::math namespace and CARNA_FOR_VECTOR3UI.
void updateModelViewTransforms(const math::Matrix4f &viewTransform)
Recomputes the model-view transforms of all enqueued renderables. This only is neccessary in certain ...
Defines scene graph leafs. Instances of this class represent visible geometry that can be rendered...
Defines Carna::base::Node.
const Renderable & first() const
References the next element of the queue, but does not move ahead. The referenced object stays alive ...
Gathers renderable geometry nodes from scene graph and provides those in a particular order...
bool isEmpty() const
Tells whether this queue has reached it's end.
const Renderable & last() const
References the last element of the queue. The referenced object stays alive until the queue is delete...
Defines the inner node of a scene graph. Implements a spatial scene element that is allowed to have c...
const unsigned int geometryType
Holds the geometry type of this geometry node.
Represents a spatial scene element. It's location is determined relatively to another spatial that is...
static const unsigned int EXACT_MATCH_GEOMETRY_TYPE_MASK
Holds the mask that makes this queue only accept such geometry nodes whose geometry type matches the ...
Eigen::Matrix< float, 4, 4, Eigen::ColMajor > Matrix4f
Defines matrix.
RenderQueue(unsigned int geometryType, unsigned int geometryTypeMask=EXACT_MATCH_GEOMETRY_TYPE_MASK)
Creates new instance that enqueues Geometry scene graph nodes if their geometry type AND-linked with ...
const Renderable & poll()
References the next element of the queue and moves ahead. The referenced object stays alive until the...
const unsigned int geometryTypeMask
Holds the mask that this queue uses for matching geometry nodes.
void visitChildren(bool recursively, const MutableVisitor &visit)
Invokes visit once on each child of this node recursively.
Represents a Geometry object that has been queued into a RenderQueue. The object's model-view transfo...
Defines Carna::base::CarnaException, Carna::base::AssertionFailure.
void build(const Node &root, const math::Matrix4f &viewTransform)
Rebuilds this queue by gathering matching geometry nodes from children of root recursively. The argument viewTransform is required for the computation of the model-view matrix.
void rewind()
Rewinds this queue. This is an operation in contrast to build, so prefer it whenever possible...
const math::Matrix4f & worldTransform() const
Tells the transformation to world space for this spatial that was last computed.
#define CARNA_ASSERT(expression)
If the given expression is false, a break point is raised in debug mode and an AssertionFailure throw...
#define NON_COPYABLE
Features class it is placed in as non-copyable.
const unsigned int geometryType
Holds the geometry type that this queue uses for matching geometry nodes.
Defines Carna::base::Geometry.