Skip to content

Commit

Permalink
rviz: Fixed bugs #5025 and #5073 relating to selection flicker and mi…
Browse files Browse the repository at this point in the history
…scoloration by narrowing what is updated after the main update. Still a hack because I don't understand the underlying reason for the behavior.

git-svn-id: https://code.ros.org/svn/ros-pkg/stacks/visualization/trunk@37650 eb33c2ac-9c88-4c90-87e0-44a10359b0c3
  • Loading branch information
hershwg committed Jul 21, 2011
1 parent 38c1257 commit 7feb02d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
26 changes: 25 additions & 1 deletion src/rviz/selection/selection_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

#include <OGRE/OgreCamera.h>
#include <OGRE/OgreViewport.h>
#include <OGRE/OgreRenderSystem.h>
#include <OGRE/OgreRenderTexture.h>
#include <OGRE/OgreTextureManager.h>
#include <OGRE/OgreSceneNode.h>
Expand Down Expand Up @@ -683,7 +684,19 @@ bool SelectionManager::render(Ogre::Viewport* viewport, Ogre::TexturePtr tex,
Ogre::MaterialManager::getSingleton().addListener(this);

render_texture->update();
Ogre::Root::getSingleton().renderOneFrame();

// For some reason we need to pretend to render the main window in
// order to get the picking render to show up in the pixelbox below.
// If we don't do this, it will show up there the *next* time we
// pick something, but not this time. This object as a
// render queue listener tells the scene manager to skip every
// render step, so nothing actually gets drawn.
//
// TODO: find out what part of _renderScene() actually makes this work.
Ogre::Viewport* main_view = vis_manager_->getRenderPanel()->getViewport();
vis_manager_->getSceneManager()->addRenderQueueListener(this);
vis_manager_->getSceneManager()->_renderScene(main_view->getCamera(), main_view, false);
vis_manager_->getSceneManager()->removeRenderQueueListener(this);

ros::WallTime end = ros::WallTime::now();
ros::WallDuration d = end - start;
Expand All @@ -708,6 +721,17 @@ bool SelectionManager::render(Ogre::Viewport* viewport, Ogre::TexturePtr tex,
return true;
}

void SelectionManager::renderQueueStarted( uint8_t queueGroupId,
const std::string& invocation,
bool& skipThisInvocation )
{
// This render queue listener function tells the scene manager to
// skip every render step, so nothing actually gets drawn.

// ROS_DEBUG("SelectionManager renderQueueStarted(%d, '%s') returning skip = true.", (int)queueGroupId, invocation.c_str());
skipThisInvocation = true;
}

void SelectionManager::pick(Ogre::Viewport* viewport, int x1, int y1, int x2, int y2, M_Picked& results, bool single_render_pass)
{
boost::recursive_mutex::scoped_lock lock(global_mutex_);
Expand Down
8 changes: 7 additions & 1 deletion src/rviz/selection/selection_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include <OGRE/OgreMaterial.h>
#include <OGRE/OgreMaterialManager.h>
#include <OGRE/OgreMovableObject.h>
#include <OGRE/OgreRenderQueueListener.h>

#include <vector>
#include <set>
Expand Down Expand Up @@ -71,7 +72,7 @@ class VisualizationManager;
class PropertyManager;


class SelectionManager : public Ogre::MaterialManager::Listener
class SelectionManager : public Ogre::MaterialManager::Listener, public Ogre::RenderQueueListener
{
public:
enum SelectType
Expand Down Expand Up @@ -143,6 +144,11 @@ class SelectionManager : public Ogre::MaterialManager::Listener
// be changed to contain the 3D point corresponding to it.
bool get3DPoint( Ogre::Viewport* viewport, int x, int y, Ogre::Vector3& result_point );

// Implementation for Ogre::RenderQueueListener.
void renderQueueStarted( uint8_t queueGroupId,
const std::string& invocation,
bool& skipThisInvocation );

protected:
std::pair<Picked, bool> addSelection(const Picked& obj);
void removeSelection(const Picked& obj);
Expand Down

0 comments on commit 7feb02d

Please sign in to comment.