Added asUpdate/Cull/EventVisitor and asCamera/asDrawable to osg::Object and usage of these within the code base to avoid dynamic_cast<> usage.
This commit is contained in:
@@ -18,6 +18,10 @@
|
||||
#include <osg/Matrix>
|
||||
#include <osg/FrameStamp>
|
||||
|
||||
|
||||
namespace osgUtil { class UpdateVisitor; class CullVisitor; class IntersectionVisitor; }
|
||||
namespace osgGA { class EventVisitor; }
|
||||
|
||||
namespace osg {
|
||||
|
||||
class Billboard;
|
||||
@@ -44,6 +48,10 @@ class CameraView;
|
||||
class Drawable;
|
||||
class Geometry;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const unsigned int UNINITIALIZED_FRAME_NUMBER=0xffffffff;
|
||||
|
||||
#define META_NodeVisitor(library, name) \
|
||||
@@ -104,6 +112,40 @@ class OSG_EXPORT NodeVisitor : public virtual Object
|
||||
* Equivalent to dynamic_cast<const NodeVisitor*>(this).*/
|
||||
virtual const NodeVisitor* asNodeVisitor() const { return this; }
|
||||
|
||||
/** Convert 'this' into a osgUtil::UpdateVisitor pointer if Object is a osgUtil::UpdateVisitor, otherwise return 0.
|
||||
* Equivalent to dynamic_cast<osgUtil::UpdateVisitor*>(this).*/
|
||||
virtual osgUtil::UpdateVisitor* asUpdateVisitor() { return 0; }
|
||||
|
||||
/** convert 'const this' into a const osgUtil::UpdateVisitor pointer if Object is a osgUtil::UpdateVisitor, otherwise return 0.
|
||||
* Equivalent to dynamic_cast<const osgUtil::UpdateVisitor*>(this).*/
|
||||
virtual const osgUtil::UpdateVisitor* asUpdateVisitor() const { return 0; }
|
||||
|
||||
/** Convert 'this' into a osgUtil::CullVisitor pointer if Object is a osgUtil::CullVisitor, otherwise return 0.
|
||||
* Equivalent to dynamic_cast<osgUtil::CullVisitor*>(this).*/
|
||||
virtual osgUtil::CullVisitor* asCullVisitor() { return 0; }
|
||||
|
||||
/** convert 'const this' into a const osgUtil::CullVisitor pointer if Object is a osgUtil::CullVisitor, otherwise return 0.
|
||||
* Equivalent to dynamic_cast<const osgUtil::CullVisitor*>(this).*/
|
||||
virtual const osgUtil::CullVisitor* asCullVisitor() const { return 0; }
|
||||
|
||||
/** Convert 'this' into a osgGA::EventVisitor pointer if Object is a osgGA::EventVisitor, otherwise return 0.
|
||||
* Equivalent to dynamic_cast<osgGA::EventVisitor*>(this).*/
|
||||
virtual osgGA::EventVisitor* asEventVisitor() { return 0; }
|
||||
|
||||
/** convert 'const this' into a const osgGA::EventVisitor pointer if Object is a osgGA::EventVisitor, otherwise return 0.
|
||||
* Equivalent to dynamic_cast<const osgGA::EventVisitor*>(this).*/
|
||||
virtual const osgGA::EventVisitor* asEventVisitor() const { return 0; }
|
||||
|
||||
/** Convert 'this' into a osgUtil::IntersectionVisitor pointer if Object is a IntersectionVisitor, otherwise return 0.
|
||||
* Equivalent to dynamic_cast<osgUtil::IntersectionVisitor*>(this).*/
|
||||
virtual osgUtil::IntersectionVisitor* asIntersectionVisitor() { return 0; }
|
||||
|
||||
/** convert 'const this' into a const osgUtil::IntersectionVisitor pointer if Object is a IntersectionVisitor, otherwise return 0.
|
||||
* Equivalent to dynamic_cast<const osgUtil::IntersectionVisitor*>(this).*/
|
||||
virtual const osgUtil::IntersectionVisitor* asIntersectionVisitor() const { return 0; }
|
||||
|
||||
|
||||
|
||||
|
||||
/** Method to call to reset visitor. Useful if your visitor accumulates
|
||||
state during a traversal, and you plan to reuse the visitor.
|
||||
|
||||
@@ -31,6 +31,8 @@ class Node;
|
||||
class NodeVisitor;
|
||||
class StateAttribute;
|
||||
class Uniform;
|
||||
class Drawable;
|
||||
class Camera;
|
||||
class Callback;
|
||||
class CallbackObject;
|
||||
|
||||
@@ -136,6 +138,14 @@ class OSG_EXPORT Object : public Referenced
|
||||
* Equivalent to dynamic_cast<const Uniform*>(this).*/
|
||||
virtual const Uniform* asUniform() const { return 0; }
|
||||
|
||||
/** Convert 'this' into a Camera pointer if Node is a Camera, otherwise return 0.
|
||||
* Equivalent to dynamic_cast<Camera*>(this).*/
|
||||
virtual Camera* asCamera() { return 0; }
|
||||
|
||||
/** convert 'const this' into a const Camera pointer if Node is a Camera, otherwise return 0.
|
||||
* Equivalent to dynamic_cast<const Camera*>(this).*/
|
||||
virtual const Camera* asCamera() const { return 0; }
|
||||
|
||||
/** Convert 'this' into a Drawable pointer if Object is a Drawable, otherwise return 0.
|
||||
* Equivalent to dynamic_cast<Drawable*>(this).*/
|
||||
virtual Drawable* asDrawable() { return 0; }
|
||||
|
||||
@@ -1744,7 +1744,7 @@ class OSG_EXPORT State : public Referenced
|
||||
{
|
||||
if (as.last_applied_attribute != attribute)
|
||||
{
|
||||
if (!as.global_default_attribute.valid()) as.global_default_attribute = dynamic_cast<StateAttribute*>(attribute->cloneType());
|
||||
if (!as.global_default_attribute.valid()) as.global_default_attribute = attribute->cloneType()->asStateAttribute();
|
||||
|
||||
as.last_applied_attribute = attribute;
|
||||
attribute->apply(*this);
|
||||
@@ -1770,7 +1770,7 @@ class OSG_EXPORT State : public Referenced
|
||||
{
|
||||
if (setActiveTextureUnit(unit))
|
||||
{
|
||||
if (!as.global_default_attribute.valid()) as.global_default_attribute = dynamic_cast<StateAttribute*>(attribute->cloneType());
|
||||
if (!as.global_default_attribute.valid()) as.global_default_attribute = attribute->cloneType()->asStateAttribute();
|
||||
|
||||
as.last_applied_attribute = attribute;
|
||||
attribute->apply(*this);
|
||||
|
||||
@@ -42,7 +42,7 @@ void Technique::traverse_implementation(osg::NodeVisitor& nv, Effect* fx)
|
||||
}
|
||||
|
||||
// special actions must be taken if the node visitor is actually a CullVisitor
|
||||
osgUtil::CullVisitor *cv = dynamic_cast<osgUtil::CullVisitor *>(&nv);
|
||||
osgUtil::CullVisitor *cv = nv.asCullVisitor();
|
||||
|
||||
// traverse all passes
|
||||
for (int i=0; i<getNumPasses(); ++i) {
|
||||
|
||||
@@ -18,7 +18,7 @@ using namespace osgGA;
|
||||
|
||||
void EventHandler::operator()(osg::Node* node, osg::NodeVisitor* nv)
|
||||
{
|
||||
osgGA::EventVisitor* ev = dynamic_cast<osgGA::EventVisitor*>(nv);
|
||||
osgGA::EventVisitor* ev = nv->asEventVisitor();
|
||||
if (ev && ev->getActionAdapter() && !ev->getEvents().empty())
|
||||
{
|
||||
for(osgGA::EventQueue::Events::iterator itr = ev->getEvents().begin();
|
||||
@@ -33,7 +33,7 @@ void EventHandler::operator()(osg::Node* node, osg::NodeVisitor* nv)
|
||||
|
||||
void EventHandler::event(osg::NodeVisitor* nv, osg::Drawable* drawable)
|
||||
{
|
||||
osgGA::EventVisitor* ev = dynamic_cast<osgGA::EventVisitor*>(nv);
|
||||
osgGA::EventVisitor* ev = nv->asEventVisitor();
|
||||
if (ev && ev->getActionAdapter() && !ev->getEvents().empty())
|
||||
{
|
||||
for(osgGA::EventQueue::Events::iterator itr = ev->getEvents().begin();
|
||||
|
||||
@@ -26,7 +26,7 @@ GUIEventHandler::~GUIEventHandler()
|
||||
// adapt EventHandler usage to old style GUIEventHandler usage
|
||||
bool GUIEventHandler::handle(osgGA::Event* event, osg::Object* object, osg::NodeVisitor* nv)
|
||||
{
|
||||
osgGA::EventVisitor* ev = dynamic_cast<osgGA::EventVisitor*>(nv);
|
||||
osgGA::EventVisitor* ev = nv->asEventVisitor();
|
||||
osgGA::GUIEventAdapter* ea = event->asGUIEventAdapter();
|
||||
if (ea && ev && ev->getActionAdapter())
|
||||
{
|
||||
|
||||
@@ -50,7 +50,7 @@ void Widget::setExtents(const osg::BoundingBoxf& bb)
|
||||
|
||||
void Widget::updateFocus(osg::NodeVisitor& nv)
|
||||
{
|
||||
osgGA::EventVisitor* ev = dynamic_cast<osgGA::EventVisitor*>(&nv);
|
||||
osgGA::EventVisitor* ev = nv.asEventVisitor();
|
||||
osgGA::GUIActionAdapter* aa = ev ? ev->getActionAdapter() : 0;
|
||||
if (ev && aa)
|
||||
{
|
||||
@@ -214,7 +214,7 @@ void Widget::traverseImplementation(osg::NodeVisitor& nv)
|
||||
if (!_graphicsInitialized && nv.getVisitorType()!=osg::NodeVisitor::CULL_VISITOR) createGraphics();
|
||||
|
||||
|
||||
osgGA::EventVisitor* ev = dynamic_cast<osgGA::EventVisitor*>(&nv);
|
||||
osgGA::EventVisitor* ev = nv.asEventVisitor();
|
||||
if (ev)
|
||||
{
|
||||
updateFocus(nv);
|
||||
|
||||
@@ -298,7 +298,7 @@ void Dragger::traverse(osg::NodeVisitor& nv)
|
||||
{
|
||||
if (_handleEvents && nv.getVisitorType()==osg::NodeVisitor::EVENT_VISITOR)
|
||||
{
|
||||
osgGA::EventVisitor* ev = dynamic_cast<osgGA::EventVisitor*>(&nv);
|
||||
osgGA::EventVisitor* ev = nv.asEventVisitor();
|
||||
if (ev)
|
||||
{
|
||||
for(osgGA::EventQueue::Events::iterator itr = ev->getEvents().begin();
|
||||
@@ -392,7 +392,7 @@ bool Dragger::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter&
|
||||
ritr != nodePath.rend();
|
||||
++ritr)
|
||||
{
|
||||
osg::Camera* camera = dynamic_cast<osg::Camera*>(*ritr);
|
||||
osg::Camera* camera = (*ritr)->asCamera();
|
||||
if (camera && (camera->getReferenceFrame()!=osg::Transform::RELATIVE_RF || camera->getParents().empty()))
|
||||
{
|
||||
rootCamera = camera;
|
||||
|
||||
@@ -55,7 +55,7 @@ osgParticle::ParticleProcessor::ParticleProcessor(const ParticleProcessor& copy,
|
||||
void osgParticle::ParticleProcessor::traverse(osg::NodeVisitor& nv)
|
||||
{
|
||||
// typecast the NodeVisitor to CullVisitor
|
||||
osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>(&nv);
|
||||
osgUtil::CullVisitor* cv = nv.asCullVisitor();
|
||||
|
||||
// continue only if the visitor actually is a cull visitor
|
||||
if (cv) {
|
||||
|
||||
@@ -135,7 +135,7 @@ void osgParticle::ParticleSystem::update(double dt, osg::NodeVisitor& nv)
|
||||
if (_sortMode != NO_SORT)
|
||||
{
|
||||
// sort particles
|
||||
osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>(&nv);
|
||||
osgUtil::CullVisitor* cv = nv.asCullVisitor();
|
||||
if (cv)
|
||||
{
|
||||
osg::Matrixd modelview = *(cv->getModelViewMatrix());
|
||||
|
||||
@@ -22,7 +22,7 @@ osgParticle::ParticleSystemUpdater::ParticleSystemUpdater(const ParticleSystemUp
|
||||
|
||||
void osgParticle::ParticleSystemUpdater::traverse(osg::NodeVisitor& nv)
|
||||
{
|
||||
osgUtil::CullVisitor *cv = dynamic_cast<osgUtil::CullVisitor *>(&nv);
|
||||
osgUtil::CullVisitor* cv = nv.asCullVisitor();
|
||||
if (cv)
|
||||
{
|
||||
if (nv.getFrameStamp())
|
||||
|
||||
@@ -182,7 +182,7 @@ void PrecipitationEffect::traverse(osg::NodeVisitor& nv)
|
||||
return;
|
||||
}
|
||||
|
||||
osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>(&nv);
|
||||
osgUtil::CullVisitor* cv = nv.asCullVisitor();
|
||||
if (!cv)
|
||||
{
|
||||
return;
|
||||
|
||||
@@ -30,7 +30,7 @@ writeNodeImplementation( const Node& node, ostream& fout,
|
||||
const osgDB::ReaderWriter::Options* options )
|
||||
{
|
||||
// get camera on the top of scene graph
|
||||
const Camera *camera = dynamic_cast< const Camera* >( &node );
|
||||
const Camera *camera = node.asCamera();
|
||||
|
||||
Vec3d eye, center, up, right;
|
||||
double fovy, aspectRatio, tmp;
|
||||
|
||||
@@ -179,7 +179,7 @@ void Cursor::traverse(osg::NodeVisitor& nv)
|
||||
}
|
||||
else if (nv.getVisitorType()==osg::NodeVisitor::EVENT_VISITOR)
|
||||
{
|
||||
osgGA::EventVisitor* ev = dynamic_cast<osgGA::EventVisitor*>(&nv);
|
||||
osgGA::EventVisitor* ev = nv.asEventVisitor();
|
||||
if (!ev) return;
|
||||
|
||||
osgGA::EventQueue::Events& events = ev->getEvents();
|
||||
@@ -200,7 +200,7 @@ void Cursor::traverse(osg::NodeVisitor& nv)
|
||||
if (event->getNumPointerData()>=1)
|
||||
{
|
||||
const osgGA::PointerData* pd = event->getPointerData(event->getNumPointerData()-1);
|
||||
osg::Camera* camera = dynamic_cast<osg::Camera*>(pd->object.get());
|
||||
osg::Camera* camera = pd->object.valid() ? pd->object->asCamera() : 0;
|
||||
|
||||
_cursorXY.set(pd->getXnormalized(), pd->getYnormalized());
|
||||
_camera = camera;
|
||||
@@ -239,7 +239,7 @@ void Cursor::traverse(osg::NodeVisitor& nv)
|
||||
#if 0
|
||||
if (!_camera)
|
||||
{
|
||||
osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>(&nv);
|
||||
osgUtil::CullVisitor* cv = nv.asCullVisitor();
|
||||
if (cv)
|
||||
{
|
||||
_camera = cv->getCurrentCamera();
|
||||
|
||||
@@ -196,7 +196,7 @@ void Timeout::traverse(osg::NodeVisitor& nv)
|
||||
{
|
||||
if (nv.getVisitorType()==osg::NodeVisitor::CULL_VISITOR)
|
||||
{
|
||||
osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>(&nv);
|
||||
osgUtil::CullVisitor* cv = nv.asCullVisitor();
|
||||
if (_displayTimeout && cv)
|
||||
{
|
||||
osgUtil::RenderStage* previous_stage = cv->getCurrentRenderBin()->getStage();
|
||||
@@ -248,7 +248,7 @@ void Timeout::traverse(osg::NodeVisitor& nv)
|
||||
bool previous_displayTimeout = _displayTimeout;
|
||||
bool needToDismiss = false;
|
||||
|
||||
osgGA::EventVisitor* ev = dynamic_cast<osgGA::EventVisitor*>(&nv);
|
||||
osgGA::EventVisitor* ev = nv.asEventVisitor();
|
||||
osgViewer::Viewer* viewer = ev ? dynamic_cast<osgViewer::Viewer*>(ev->getActionAdapter()) : 0;
|
||||
if (ev)
|
||||
{
|
||||
|
||||
@@ -84,7 +84,7 @@ void ShadowTechnique::traverse(osg::NodeVisitor& nv)
|
||||
}
|
||||
else if (nv.getVisitorType() == osg::NodeVisitor::CULL_VISITOR)
|
||||
{
|
||||
osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>(&nv);
|
||||
osgUtil::CullVisitor* cv = nv.asCullVisitor();
|
||||
if (cv) cull(*cv);
|
||||
else _shadowedScene->osg::Group::traverse(nv);
|
||||
}
|
||||
|
||||
@@ -168,8 +168,8 @@ VDSMCameraCullCallback::VDSMCameraCullCallback(ViewDependentShadowMap* vdsm, osg
|
||||
|
||||
void VDSMCameraCullCallback::operator()(osg::Node* node, osg::NodeVisitor* nv)
|
||||
{
|
||||
osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>(nv);
|
||||
osg::Camera* camera = dynamic_cast<osg::Camera*>(node);
|
||||
osgUtil::CullVisitor* cv = nv->asCullVisitor();
|
||||
osg::Camera* camera = node->asCamera();
|
||||
OSG_INFO<<"VDSMCameraCullCallback::operator()(osg::Node* "<<camera<<", osg::NodeVisitor* "<<cv<<")"<<std::endl;
|
||||
|
||||
#if 1
|
||||
|
||||
@@ -113,7 +113,7 @@ void Impostor::traverse(osg::NodeVisitor& nv)
|
||||
return;
|
||||
}
|
||||
|
||||
osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>(&nv);
|
||||
osgUtil::CullVisitor* cv = nv.asCullVisitor();
|
||||
if (!cv)
|
||||
{
|
||||
LOD::traverse(nv);
|
||||
|
||||
@@ -141,7 +141,7 @@ void LightPointNode::traverse(osg::NodeVisitor& nv)
|
||||
t1 = timer.tick();
|
||||
#endif
|
||||
|
||||
osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>(&nv);
|
||||
osgUtil::CullVisitor* cv = nv.asCullVisitor();
|
||||
|
||||
#ifdef USE_TIMER
|
||||
t2 = timer.tick();
|
||||
|
||||
@@ -1330,7 +1330,7 @@ void OverlayNode::traverse_OBJECT_DEPENDENT_WITH_ORTHOGRAPHIC_OVERLAY(osg::NodeV
|
||||
return;
|
||||
}
|
||||
|
||||
osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>(&nv);
|
||||
osgUtil::CullVisitor* cv = nv.asCullVisitor();
|
||||
if (!cv)
|
||||
{
|
||||
Group::traverse(nv);
|
||||
@@ -1384,7 +1384,7 @@ void OverlayNode::traverse_VIEW_DEPENDENT_WITH_ORTHOGRAPHIC_OVERLAY(osg::NodeVis
|
||||
return;
|
||||
}
|
||||
|
||||
osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>(&nv);
|
||||
osgUtil::CullVisitor* cv = nv.asCullVisitor();
|
||||
if (!cv)
|
||||
{
|
||||
Group::traverse(nv);
|
||||
|
||||
@@ -72,7 +72,7 @@ void DisplacementMappingTechnique::traverse(osg::NodeVisitor& nv)
|
||||
{
|
||||
// if (_terrainTile->getDirty()) _terrainTile->init(_terrainTile->getDirtyMask(), false);
|
||||
|
||||
osgUtil::UpdateVisitor* uv = dynamic_cast<osgUtil::UpdateVisitor*>(&nv);
|
||||
osgUtil::UpdateVisitor* uv = nv.asUpdateVisitor();
|
||||
if (uv)
|
||||
{
|
||||
update(uv);
|
||||
@@ -81,7 +81,7 @@ void DisplacementMappingTechnique::traverse(osg::NodeVisitor& nv)
|
||||
}
|
||||
else if (nv.getVisitorType()==osg::NodeVisitor::CULL_VISITOR)
|
||||
{
|
||||
osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>(&nv);
|
||||
osgUtil::CullVisitor* cv = nv.asCullVisitor();
|
||||
if (cv)
|
||||
{
|
||||
cull(cv);
|
||||
|
||||
@@ -1456,7 +1456,7 @@ void GeometryTechnique::traverse(osg::NodeVisitor& nv)
|
||||
{
|
||||
if (_terrainTile->getDirty()) _terrainTile->init(_terrainTile->getDirtyMask(), false);
|
||||
|
||||
osgUtil::UpdateVisitor* uv = dynamic_cast<osgUtil::UpdateVisitor*>(&nv);
|
||||
osgUtil::UpdateVisitor* uv = nv.asUpdateVisitor();
|
||||
if (uv)
|
||||
{
|
||||
update(uv);
|
||||
@@ -1465,7 +1465,7 @@ void GeometryTechnique::traverse(osg::NodeVisitor& nv)
|
||||
}
|
||||
else if (nv.getVisitorType()==osg::NodeVisitor::CULL_VISITOR)
|
||||
{
|
||||
osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>(&nv);
|
||||
osgUtil::CullVisitor* cv = nv.asCullVisitor();
|
||||
if (cv)
|
||||
{
|
||||
cull(cv);
|
||||
|
||||
@@ -92,7 +92,7 @@ void Terrain::traverse(osg::NodeVisitor& nv)
|
||||
if (nv.getVisitorType()==osg::NodeVisitor::UPDATE_VISITOR)
|
||||
{
|
||||
// need to check if any TerrainTechniques need to have their update called on them.
|
||||
osgUtil::UpdateVisitor* uv = dynamic_cast<osgUtil::UpdateVisitor*>(&nv);
|
||||
osgUtil::UpdateVisitor* uv = nv.asUpdateVisitor();
|
||||
if (uv)
|
||||
{
|
||||
typedef std::list< osg::ref_ptr<TerrainTile> > TerrainTileList;
|
||||
@@ -125,7 +125,7 @@ void Terrain::traverse(osg::NodeVisitor& nv)
|
||||
|
||||
if (nv.getVisitorType()==osg::NodeVisitor::CULL_VISITOR)
|
||||
{
|
||||
osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>(&nv);
|
||||
osgUtil::CullVisitor* cv = nv.asCullVisitor();
|
||||
osg::StateSet* ss = _geometryPool.valid() ? _geometryPool->getRootStateSetForTerrain(this) : 0;
|
||||
if (cv && ss)
|
||||
{
|
||||
|
||||
@@ -114,7 +114,7 @@ void TerrainTechnique::traverse(osg::NodeVisitor& nv)
|
||||
{
|
||||
if (_terrainTile->getDirty()) _terrainTile->init(_terrainTile->getDirtyMask(), false);
|
||||
|
||||
osgUtil::UpdateVisitor* uv = dynamic_cast<osgUtil::UpdateVisitor*>(&nv);
|
||||
osgUtil::UpdateVisitor* uv = nv.asUpdateVisitor();
|
||||
if (uv)
|
||||
{
|
||||
update(uv);
|
||||
@@ -124,7 +124,7 @@ void TerrainTechnique::traverse(osg::NodeVisitor& nv)
|
||||
}
|
||||
else if (nv.getVisitorType()==osg::NodeVisitor::CULL_VISITOR)
|
||||
{
|
||||
osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>(&nv);
|
||||
osgUtil::CullVisitor* cv = nv.asCullVisitor();
|
||||
if (cv)
|
||||
{
|
||||
cull(cv);
|
||||
|
||||
@@ -38,7 +38,7 @@ bool CloseCallback::run(osg::Object* object, osg::Parameters&, osg::Parameters&)
|
||||
_closeWidget->setVisible(false);
|
||||
}
|
||||
|
||||
osg::Node* node = dynamic_cast<osg::Node*>(object);
|
||||
osg::Node* node = object->asNode();
|
||||
if (node)
|
||||
{
|
||||
osg::NodePathList nodePathList = node->getParentalNodePaths();
|
||||
|
||||
@@ -61,7 +61,7 @@ void Widget::setExtents(const osg::BoundingBoxf& bb)
|
||||
|
||||
void Widget::updateFocus(osg::NodeVisitor& nv)
|
||||
{
|
||||
osgGA::EventVisitor* ev = dynamic_cast<osgGA::EventVisitor*>(&nv);
|
||||
osgGA::EventVisitor* ev = nv.asEventVisitor();
|
||||
osgGA::GUIActionAdapter* aa = ev ? ev->getActionAdapter() : 0;
|
||||
if (ev && aa)
|
||||
{
|
||||
@@ -209,7 +209,7 @@ void Widget::traverseImplementation(osg::NodeVisitor& nv)
|
||||
{
|
||||
if (!_graphicsInitialized && nv.getVisitorType()!=osg::NodeVisitor::CULL_VISITOR) createGraphics();
|
||||
|
||||
osgGA::EventVisitor* ev = dynamic_cast<osgGA::EventVisitor*>(&nv);
|
||||
osgGA::EventVisitor* ev = nv.asEventVisitor();
|
||||
if (ev)
|
||||
{
|
||||
if (_visible && _enabled)
|
||||
@@ -255,7 +255,7 @@ void Widget::traverseImplementation(osg::NodeVisitor& nv)
|
||||
else if (_visible ||
|
||||
(nv.getVisitorType()!=osg::NodeVisitor::UPDATE_VISITOR && nv.getVisitorType()!=osg::NodeVisitor::CULL_VISITOR && nv.getVisitorType()!=osg::NodeVisitor::INTERSECTION_VISITOR) )
|
||||
{
|
||||
osgUtil::CullVisitor* cv = (nv.getVisitorType()==osg::NodeVisitor::CULL_VISITOR) ? dynamic_cast<osgUtil::CullVisitor*>(&nv) : 0;
|
||||
osgUtil::CullVisitor* cv = (nv.getVisitorType()==osg::NodeVisitor::CULL_VISITOR) ? nv.asCullVisitor() : 0;
|
||||
if (cv && _widgetStateSet.valid()) cv->pushStateSet(_widgetStateSet.get());
|
||||
|
||||
GraphicsSubgraphMap::iterator itr = _graphicsSubgraphMap.begin();
|
||||
@@ -476,7 +476,7 @@ bool Widget::computeExtentsPositionInLocalCoordinates(osgGA::EventVisitor* ev, o
|
||||
if (event->getNumPointerData()>=1)
|
||||
{
|
||||
const osgGA::PointerData* pd = event->getPointerData(event->getNumPointerData()-1);
|
||||
camera = dynamic_cast<const osg::Camera*>(pd->object.get());
|
||||
camera = pd->object->asCamera();
|
||||
if (camera)
|
||||
{
|
||||
x = pd->getXnormalized();
|
||||
|
||||
@@ -719,11 +719,11 @@ void SceneView::cull()
|
||||
else
|
||||
{
|
||||
|
||||
if (!_cullVisitorLeft.valid()) _cullVisitorLeft = dynamic_cast<CullVisitor*>(_cullVisitor->clone());
|
||||
if (!_cullVisitorLeft.valid()) _cullVisitorLeft = _cullVisitor->clone();
|
||||
if (!_stateGraphLeft.valid()) _stateGraphLeft = dynamic_cast<StateGraph*>(_stateGraph->cloneType());
|
||||
if (!_renderStageLeft.valid()) _renderStageLeft = dynamic_cast<RenderStage*>(_renderStage->clone(osg::CopyOp::DEEP_COPY_ALL));
|
||||
|
||||
if (!_cullVisitorRight.valid()) _cullVisitorRight = dynamic_cast<CullVisitor*>(_cullVisitor->clone());
|
||||
if (!_cullVisitorRight.valid()) _cullVisitorRight = _cullVisitor->clone();
|
||||
if (!_stateGraphRight.valid()) _stateGraphRight = dynamic_cast<StateGraph*>(_stateGraph->cloneType());
|
||||
if (!_renderStageRight.valid()) _renderStageRight = dynamic_cast<RenderStage*>(_renderStage->clone(osg::CopyOp::DEEP_COPY_ALL));
|
||||
|
||||
|
||||
@@ -916,7 +916,8 @@ void CompositeViewer::reprojectPointerData(osgGA::GUIEventAdapter& source_event,
|
||||
|
||||
dest_event.setMouseYOrientationAndUpdateCoords(osgGA::GUIEventAdapter::Y_INCREASING_UPWARDS);
|
||||
|
||||
osg::Camera* camera = (source_event.getNumPointerData()>=2) ? dynamic_cast<osg::Camera*>(source_event.getPointerData(1)->object.get()) : 0;
|
||||
osg::Object* object = (source_event.getNumPointerData()>=2) ? source_event.getPointerData(1)->object.get() : 0;
|
||||
osg::Camera* camera = object ? object->asCamera() : 0;
|
||||
osg::Viewport* viewport = camera ? camera->getViewport() : 0;
|
||||
|
||||
if (!viewport) return;
|
||||
@@ -1030,7 +1031,8 @@ void CompositeViewer::eventTraversal()
|
||||
}
|
||||
|
||||
osgGA::PointerData* pd = event->getNumPointerData()>0 ? event->getPointerData(event->getNumPointerData()-1) : 0;
|
||||
osg::Camera* camera = pd ? dynamic_cast<osg::Camera*>(pd->object.get()) : 0;
|
||||
osg::Object* object = pd ? pd->object.get() : 0;
|
||||
osg::Camera* camera = object ? object->asCamera() : 0;
|
||||
osgViewer::View* view = camera ? dynamic_cast<osgViewer::View*>(camera->getView()) : 0;
|
||||
|
||||
if (!view)
|
||||
|
||||
@@ -118,7 +118,7 @@ struct KeystoneUpdateCallback : public osg::DrawableUpdateCallback
|
||||
/** do customized update code.*/
|
||||
virtual void update(osg::NodeVisitor*, osg::Drawable* drawable)
|
||||
{
|
||||
update(dynamic_cast<osg::Geometry*>(drawable));
|
||||
update(drawable->asGeometry());
|
||||
}
|
||||
|
||||
void update(osg::Geometry* geometry)
|
||||
@@ -418,8 +418,8 @@ osg::Vec2d KeystoneHandler::incrementScale(const osgGA::GUIEventAdapter& ea) con
|
||||
|
||||
bool KeystoneHandler::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& /*aa*/, osg::Object* obj, osg::NodeVisitor* /*nv*/)
|
||||
{
|
||||
osg::Camera* camera = dynamic_cast<osg::Camera*>(obj);
|
||||
osg::Viewport* viewport = camera ? camera->getViewport() : 0;
|
||||
osg::Camera* camera = obj ? obj->asCamera() : 0;
|
||||
osg::Viewport* viewport = camera ? camera->getViewport() : 0;
|
||||
|
||||
if (!viewport) return false;
|
||||
|
||||
|
||||
@@ -908,7 +908,7 @@ void Renderer::operator () (osg::Object* object)
|
||||
osg::GraphicsContext* context = dynamic_cast<osg::GraphicsContext*>(object);
|
||||
if (context) operator()(context);
|
||||
|
||||
osg::Camera* camera = dynamic_cast<osg::Camera*>(object);
|
||||
osg::Camera* camera =object->asCamera();
|
||||
if (camera) cull();
|
||||
}
|
||||
|
||||
|
||||
@@ -1014,7 +1014,7 @@ bool View::computeIntersections(const osgGA::GUIEventAdapter& ea, osgUtil::LineS
|
||||
if (ea.getNumPointerData()>=1)
|
||||
{
|
||||
const osgGA::PointerData* pd = ea.getPointerData(ea.getNumPointerData()-1);
|
||||
const osg::Camera* camera = dynamic_cast<const osg::Camera*>(pd->object.get());
|
||||
const osg::Camera* camera = pd->object.valid() ? pd->object->asCamera() : 0;
|
||||
if (camera)
|
||||
{
|
||||
return computeIntersections(camera, osgUtil::Intersector::PROJECTION, pd->getXnormalized(), pd->getYnormalized(), intersections, traversalMask);
|
||||
@@ -1030,7 +1030,7 @@ bool View::computeIntersections(const osgGA::GUIEventAdapter& ea, const osg::Nod
|
||||
if (ea.getNumPointerData()>=1)
|
||||
{
|
||||
const osgGA::PointerData* pd = ea.getPointerData(ea.getNumPointerData()-1);
|
||||
const osg::Camera* camera = dynamic_cast<const osg::Camera*>(pd->object.get());
|
||||
const osg::Camera* camera = pd->object.valid() ? pd->object->asCamera() : 0;
|
||||
if (camera)
|
||||
{
|
||||
return computeIntersections(camera, osgUtil::Intersector::PROJECTION, pd->getXnormalized(), pd->getYnormalized(), nodePath, intersections, traversalMask);
|
||||
|
||||
@@ -849,7 +849,8 @@ void Viewer::reprojectPointerData(osgGA::GUIEventAdapter& source_event, osgGA::G
|
||||
|
||||
dest_event.setMouseYOrientationAndUpdateCoords(osgGA::GUIEventAdapter::Y_INCREASING_UPWARDS);
|
||||
|
||||
osg::Camera* camera = (source_event.getNumPointerData()>=2) ? dynamic_cast<osg::Camera*>(source_event.getPointerData(1)->object.get()) : 0;
|
||||
osg::Object* object = (source_event.getNumPointerData()>=2) ? source_event.getPointerData(1)->object.get() : 0;
|
||||
osg::Camera* camera = object ? object->asCamera() : 0;
|
||||
osg::Viewport* viewport = camera ? camera->getViewport() : 0;
|
||||
|
||||
if (!viewport) return;
|
||||
|
||||
@@ -276,7 +276,7 @@ void FixedFunctionTechnique::traverse(osg::NodeVisitor& nv)
|
||||
{
|
||||
if (_volumeTile->getDirty()) _volumeTile->init();
|
||||
|
||||
osgUtil::UpdateVisitor* uv = dynamic_cast<osgUtil::UpdateVisitor*>(&nv);
|
||||
osgUtil::UpdateVisitor* uv = nv.asUpdateVisitor();
|
||||
if (uv)
|
||||
{
|
||||
update(uv);
|
||||
@@ -286,7 +286,7 @@ void FixedFunctionTechnique::traverse(osg::NodeVisitor& nv)
|
||||
}
|
||||
else if (nv.getVisitorType()==osg::NodeVisitor::CULL_VISITOR)
|
||||
{
|
||||
osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>(&nv);
|
||||
osgUtil::CullVisitor* cv = nv.asCullVisitor();
|
||||
if (cv)
|
||||
{
|
||||
cull(cv);
|
||||
|
||||
@@ -163,7 +163,7 @@ class RTTCameraCullCallback : public osg::NodeCallback
|
||||
|
||||
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
|
||||
{
|
||||
osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>(nv);
|
||||
osgUtil::CullVisitor* cv = nv->asCullVisitor();
|
||||
|
||||
cv->pushProjectionMatrix(_tileData->projectionMatrix.get());
|
||||
|
||||
@@ -937,7 +937,7 @@ class RTTBackfaceCameraCullCallback : public osg::NodeCallback
|
||||
|
||||
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
|
||||
{
|
||||
osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>(nv);
|
||||
osgUtil::CullVisitor* cv = nv->asCullVisitor();
|
||||
|
||||
cv->pushProjectionMatrix(_tileData->projectionMatrix.get());
|
||||
|
||||
@@ -1157,7 +1157,7 @@ void MultipassTechnique::traverse(osg::NodeVisitor& nv)
|
||||
{
|
||||
if (_volumeTile->getDirty()) _volumeTile->init();
|
||||
|
||||
osgUtil::UpdateVisitor* uv = dynamic_cast<osgUtil::UpdateVisitor*>(&nv);
|
||||
osgUtil::UpdateVisitor* uv = nv.asUpdateVisitor();
|
||||
if (uv)
|
||||
{
|
||||
update(uv);
|
||||
@@ -1167,7 +1167,7 @@ void MultipassTechnique::traverse(osg::NodeVisitor& nv)
|
||||
}
|
||||
else if (nv.getVisitorType()==osg::NodeVisitor::CULL_VISITOR)
|
||||
{
|
||||
osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>(&nv);
|
||||
osgUtil::CullVisitor* cv = nv.asCullVisitor();
|
||||
if (cv)
|
||||
{
|
||||
cull(cv);
|
||||
|
||||
@@ -525,7 +525,7 @@ void RayTracedTechnique::traverse(osg::NodeVisitor& nv)
|
||||
{
|
||||
if (_volumeTile->getDirty()) _volumeTile->init();
|
||||
|
||||
osgUtil::UpdateVisitor* uv = dynamic_cast<osgUtil::UpdateVisitor*>(&nv);
|
||||
osgUtil::UpdateVisitor* uv = nv.asUpdateVisitor();
|
||||
if (uv)
|
||||
{
|
||||
update(uv);
|
||||
@@ -535,7 +535,7 @@ void RayTracedTechnique::traverse(osg::NodeVisitor& nv)
|
||||
}
|
||||
else if (nv.getVisitorType()==osg::NodeVisitor::CULL_VISITOR)
|
||||
{
|
||||
osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>(&nv);
|
||||
osgUtil::CullVisitor* cv = nv.asCullVisitor();
|
||||
if (cv)
|
||||
{
|
||||
cull(cv);
|
||||
|
||||
@@ -33,7 +33,7 @@ class RTTCameraCullCallback : public osg::NodeCallback
|
||||
|
||||
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
|
||||
{
|
||||
osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>(nv);
|
||||
osgUtil::CullVisitor* cv = nv->asCullVisitor();
|
||||
|
||||
_volumeScene->osg::Group::traverse(*nv);
|
||||
|
||||
@@ -135,7 +135,7 @@ TileData* VolumeScene::getTileData(osgUtil::CullVisitor* cv, osgVolume::VolumeTi
|
||||
|
||||
void VolumeScene::traverse(osg::NodeVisitor& nv)
|
||||
{
|
||||
osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>(&nv);
|
||||
osgUtil::CullVisitor* cv = nv.asCullVisitor();
|
||||
if (!cv)
|
||||
{
|
||||
Group::traverse(nv);
|
||||
|
||||
@@ -63,7 +63,7 @@ void VolumeTechnique::traverse(osg::NodeVisitor& nv)
|
||||
{
|
||||
if (_volumeTile->getDirty()) _volumeTile->init();
|
||||
|
||||
osgUtil::UpdateVisitor* uv = dynamic_cast<osgUtil::UpdateVisitor*>(&nv);
|
||||
osgUtil::UpdateVisitor* uv = nv.asUpdateVisitor();
|
||||
if (uv)
|
||||
{
|
||||
update(uv);
|
||||
@@ -73,7 +73,7 @@ void VolumeTechnique::traverse(osg::NodeVisitor& nv)
|
||||
}
|
||||
else if (nv.getVisitorType()==osg::NodeVisitor::CULL_VISITOR)
|
||||
{
|
||||
osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>(&nv);
|
||||
osgUtil::CullVisitor* cv = nv.asCullVisitor();
|
||||
if (cv)
|
||||
{
|
||||
cull(cv);
|
||||
|
||||
Reference in New Issue
Block a user