Commit b48419b1 authored by Jan Möbius's avatar Jan Möbius
Browse files

Use-enter-leavePick-for-picking

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@5398 383ad7c9-94d9-4d36-a494-682f7c89f535
parent cca4536b
......@@ -824,8 +824,8 @@ void QtBaseViewer::drawScene_mono()
glPushName((GLuint) 0);
// do the picking
SceneGraph::PickAction action(pickRendererMode_);
SceneGraph::traverse(sceneGraphRoot_, action, *glstate_);
SceneGraph::PickAction action(*glstate_, pickRendererMode_, curDrawMode_);
SceneGraph::traverse(sceneGraphRoot_, action);
glEnable(GL_LIGHTING);
}
......
......@@ -102,8 +102,8 @@ bool QtBaseViewer::pick( SceneGraph::PickTarget _pickTarget,
glstate_->pick_init (false);
// do the picking
SceneGraph::PickAction action(_pickTarget);
SceneGraph::traverse(sceneGraphRoot_, action, *glstate_);
SceneGraph::PickAction action(*glstate_, _pickTarget, curDrawMode_);
SceneGraph::traverse(sceneGraphRoot_, action);
int hits = glRenderMode(GL_RENDER);
// restore GL state
......
......@@ -65,7 +65,7 @@ BaseNode* find_node(BaseNode* _root, unsigned int _node_idx)
//----------------------------------------------------------------------------
bool PickAction::operator()(BaseNode* _node, GLState& _state)
bool PickAction::operator()(BaseNode* _node)
{
// If picking is disabled for the given Node, return here
// As this is not a failure return true;
......@@ -76,11 +76,11 @@ bool PickAction::operator()(BaseNode* _node, GLState& _state)
glDisable(GL_DITHER);
glShadeModel(GL_FLAT);
_state.pick_push_name ((GLuint) _node->id());
state_.pick_push_name ((GLuint) _node->id());
_node->pick(_state, pickTarget_);
_node->pick(state_, pickTarget_);
_state.pick_pop_name ();
state_.pick_pop_name ();
return true;
}
......
......@@ -462,13 +462,34 @@ class ACGDLLEXPORT PickAction
public:
/// constructor: what picking target to use
PickAction(PickTarget _target) : pickTarget_(_target) {}
PickAction(GLState &_state, PickTarget _target, unsigned int _drawmode) :
state_(_state),
pickTarget_(_target),
drawmode_(_drawmode) {}
bool operator()(BaseNode* _node, GLState& _state);
bool operator()(BaseNode* _node);
void enter(BaseNode* _node)
{
if (_node->drawMode() == DrawModes::DEFAULT)
_node->enterPick(state_, pickTarget_, drawmode_);
else
_node->enterPick(state_, pickTarget_, _node->drawMode());
}
void leave(BaseNode* _node)
{
if (_node->drawMode() == DrawModes::DEFAULT)
_node->leavePick(state_, pickTarget_, drawmode_);
else
_node->leavePick(state_, pickTarget_, _node->drawMode());
}
private:
PickTarget pickTarget_;
GLState &state_;
PickTarget pickTarget_;
unsigned int drawmode_;
};
......
......@@ -507,8 +507,8 @@ void glViewer::drawScene_mono()
// do the picking
glstate_->pick_init (true);
ACG::SceneGraph::PickAction action(properties_.renderPickingMode());
ACG::SceneGraph::traverse(sceneGraphRoot_, action, *glstate_);
ACG::SceneGraph::PickAction action(*glstate_, properties_.renderPickingMode(), properties_.drawMode());
ACG::SceneGraph::traverse(sceneGraphRoot_, action);
glEnable(GL_LIGHTING);
}
......
......@@ -126,8 +126,8 @@ int glViewer::pickColor( ACG::SceneGraph::PickTarget _pickTarget,
properties_.glState().pick_init (true);
// do the picking
ACG::SceneGraph::PickAction action(_pickTarget);
ACG::SceneGraph::traverse(sceneGraphRoot_, action, properties_.glState());
ACG::SceneGraph::PickAction action(properties_.glState(), _pickTarget, properties_.drawMode());
ACG::SceneGraph::traverse(sceneGraphRoot_, action);
// restore GL state
glMatrixMode( GL_PROJECTION );
......@@ -219,8 +219,8 @@ bool glViewer::pickGL( ACG::SceneGraph::PickTarget _pickTarget,
properties_.glState().pick_init (false);
// do the picking
ACG::SceneGraph::PickAction action(_pickTarget);
ACG::SceneGraph::traverse(sceneGraphRoot_, action, properties_.glState());
ACG::SceneGraph::PickAction action(properties_.glState(), _pickTarget, properties_.drawMode());
ACG::SceneGraph::traverse(sceneGraphRoot_, action);
int hits = glRenderMode(GL_RENDER);
// restore GL state
......@@ -314,8 +314,8 @@ bool glViewer::pick_region( ACG::SceneGraph::PickTarget _pickTarg
properties_.glState().pick_init (true);
// do the picking
ACG::SceneGraph::PickAction action(_pickTarget);
ACG::SceneGraph::traverse(sceneGraphRoot_, action, properties_.glState());
ACG::SceneGraph::PickAction action(properties_.glState(), _pickTarget, properties_.drawMode());
ACG::SceneGraph::traverse(sceneGraphRoot_, action);
// restore GL state
glMatrixMode( GL_PROJECTION );
......
Markdown is supported
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