Commit 45da5e0b authored by Hans-Christian Ebke's avatar Hans-Christian Ebke
Browse files

Add getCollectedSubtreeObjects() function.

parent 6a90e90e
......@@ -400,7 +400,7 @@ void IRenderer::collectRenderObjects( ACG::GLState* _glState, ACG::SceneGraph::D
// {
// renderObjects_[i].uniformPool_.clear();
// }
renderObjects_.resize(0);
renderObjects_.clear();
// default material needed
......@@ -439,6 +439,7 @@ void IRenderer::traverseRenderableNodes( ACG::GLState* _glState, ACG::SceneGraph
if ( _node->status() != ACG::SceneGraph::BaseNode::HideNode )
_node->enter(this, *_glState, nodeDM);
const size_t subtree_index_start = renderObjects_.size();
// fetch material (Node itself can be a material node, so we have to
// set that in front of the nodes own rendering
......@@ -467,6 +468,10 @@ void IRenderer::traverseRenderableNodes( ACG::GLState* _glState, ACG::SceneGraph
}
// Prepare current subtree info before calling leave().
current_subtree_objects_ = RenderObjectRange(
renderObjects_.begin() + subtree_index_start,
renderObjects_.end());
if (_node->status() != ACG::SceneGraph::BaseNode::HideNode )
_node->leave(this, *_glState, nodeDM);
......
......@@ -123,6 +123,25 @@ public:
ACG::Vec2f spotCutoffExponent; // (cutoff angle, exponent) for spotlights
};
class RenderObjectRange {
public:
RenderObjectRange() {}
RenderObjectRange(std::vector<ACG::RenderObject>::iterator begin,
std::vector<ACG::RenderObject>::iterator end) :
begin_(begin), end_(end) {}
std::vector<ACG::RenderObject>::iterator begin() const {
return begin_;
}
std::vector<ACG::RenderObject>::iterator end() const {
return end_;
}
private:
std::vector<ACG::RenderObject>::iterator begin_, end_;
};
/** \brief Callback for the scenegraph nodes, which send new lights to the renderer via this function
*
* Scenegraph nodes are able to add new light sources to the renderer with this function.
......@@ -430,6 +449,18 @@ public:
*/
void setViewerID(int _viewerID);
/**
* During traversal of the scene graph this method returns the range of
* render objects that has been collected in the current subtree.
*
* This method is exclusively intended to be called in the leave() function
* of scene graph nodes. Calling it from anywhere else will yield an
* undefined result with potentially invalid iterators.
*/
const RenderObjectRange &getCollectedSubtreeObjects() const {
return current_subtree_objects_;
}
protected:
/// Number of Lights
int numLights_;
......@@ -491,6 +522,8 @@ protected:
/// error-detection level for checking render objects
int errorDetectionLevel_;
RenderObjectRange current_subtree_objects_;
private:
//=========================================================================
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment