Refactored Callback system in osg::Node, osg::Drawable, osg::StateSet and osg::StateAttribute to use a new osg::Callback base class.
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14244 16af8721-9629-0410-8352-f15c8da7e697
This commit is contained in:
@@ -37,6 +37,7 @@ SET(TARGET_H
|
||||
${HEADER_PATH}/buffered_value
|
||||
${HEADER_PATH}/BufferIndexBinding
|
||||
${HEADER_PATH}/BufferObject
|
||||
${HEADER_PATH}/Callback
|
||||
${HEADER_PATH}/Camera
|
||||
${HEADER_PATH}/CameraView
|
||||
${HEADER_PATH}/ClampColor
|
||||
@@ -230,6 +231,7 @@ SET(TARGET_SRC
|
||||
BlendFunc.cpp
|
||||
BufferIndexBinding.cpp
|
||||
BufferObject.cpp
|
||||
Callback.cpp
|
||||
Camera.cpp
|
||||
CameraView.cpp
|
||||
ClampColor.cpp
|
||||
@@ -296,7 +298,6 @@ SET(TARGET_SRC
|
||||
# Matrix_implementation.cpp
|
||||
MatrixTransform.cpp
|
||||
Multisample.cpp
|
||||
NodeCallback.cpp
|
||||
Node.cpp
|
||||
NodeTrackerCallback.cpp
|
||||
NodeVisitor.cpp
|
||||
|
||||
109
src/osg/Callback.cpp
Normal file
109
src/osg/Callback.cpp
Normal file
@@ -0,0 +1,109 @@
|
||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
|
||||
*
|
||||
* This library is open source and may be redistributed and/or modified under
|
||||
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
||||
* (at your option) any later version. The full license is in LICENSE file
|
||||
* included with this distribution, and on the openscenegraph.org website.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* OpenSceneGraph Public License for more details.
|
||||
*/
|
||||
#include <osg/Node>
|
||||
#include <osg/NodeVisitor>
|
||||
#include <osg/ScriptEngine>
|
||||
|
||||
using namespace osg;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Callback
|
||||
//
|
||||
bool Callback::traverse(Object* object, Object* data)
|
||||
{
|
||||
if (_nestedCallback.valid()) return run(object, data);
|
||||
else
|
||||
{
|
||||
#if 1
|
||||
osg::Node* node = dynamic_cast<osg::Node*>(object);
|
||||
osg::NodeVisitor* nv = dynamic_cast<osg::NodeVisitor*>(data);
|
||||
#else
|
||||
osg::Node* node = object ? data->asNode() : 0;
|
||||
osg::NodeVisitor* nv = data ? data->asNodeVisitor() : 0;
|
||||
#endif
|
||||
if (node && nv)
|
||||
{
|
||||
nv->traverse(*node);
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CallbackObject
|
||||
//
|
||||
bool CallbackObject::run(osg::Object* object, osg::Object* data)
|
||||
{
|
||||
osg::Parameters inputParameters, outputParameters;
|
||||
|
||||
if (data && data->referenceCount()>=1)
|
||||
{
|
||||
inputParameters.push_back(data);
|
||||
}
|
||||
|
||||
return run(object,inputParameters, outputParameters);
|
||||
}
|
||||
|
||||
bool CallbackObject::run(osg::Object* object, osg::Parameters& inputParameters, osg::Parameters& outputParameters) const
|
||||
{
|
||||
OSG_NOTICE<<"CallbackObject::run(object="<<object<<")"<<std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// NodeCallback
|
||||
//
|
||||
bool NodeCallback::run(osg::Object* object, osg::Object* data)
|
||||
{
|
||||
osg::Node* node = dynamic_cast<osg::Node*>(object);
|
||||
osg::NodeVisitor* nv = dynamic_cast<osg::NodeVisitor*>(data);
|
||||
if (node && nv)
|
||||
{
|
||||
operator()(node, nv);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return traverse(object, data);
|
||||
}
|
||||
}
|
||||
void NodeCallback::operator()(Node* node, NodeVisitor* nv)
|
||||
{
|
||||
// note, callback is responsible for scenegraph traversal so
|
||||
// they must call traverse(node,nv) to ensure that the
|
||||
// scene graph subtree (and associated callbacks) are traversed.
|
||||
traverse(node,nv);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// StateAttributeCallback
|
||||
//
|
||||
bool StateAttributeCallback::run(osg::Object* object, osg::Object* data)
|
||||
{
|
||||
osg::StateAttribute* sa = dynamic_cast<osg::StateAttribute*>(object);
|
||||
osg::NodeVisitor* nv = dynamic_cast<osg::NodeVisitor*>(data);
|
||||
if (sa && nv)
|
||||
{
|
||||
operator()(sa, nv);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return traverse(object, data);
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <osg/PrimitiveSet>
|
||||
#include <osg/Shape>
|
||||
#include <osg/StateAttribute>
|
||||
#include <osg/Callback>
|
||||
|
||||
using namespace osg;
|
||||
|
||||
@@ -66,19 +67,19 @@ StateAttribute* CopyOp::operator() (const StateAttribute* attr) const
|
||||
return const_cast<StateAttribute*>(attr);
|
||||
}
|
||||
|
||||
NodeCallback* CopyOp::operator() (const NodeCallback* nc) const
|
||||
Callback* CopyOp::operator() (const Callback* nc) const
|
||||
{
|
||||
if (nc && _flags&DEEP_COPY_CALLBACKS)
|
||||
{
|
||||
// deep copy the full chain of callback
|
||||
osg::NodeCallback* first = osg::clone(nc, *this);
|
||||
Callback* first = osg::clone(nc, *this);
|
||||
if (!first) return 0;
|
||||
|
||||
first->setNestedCallback(0);
|
||||
nc = nc->getNestedCallback();
|
||||
while (nc)
|
||||
{
|
||||
osg::NodeCallback* ucb = osg::clone(nc, *this);
|
||||
Callback* ucb = osg::clone(nc, *this);
|
||||
if (ucb)
|
||||
{
|
||||
ucb->setNestedCallback(0);
|
||||
@@ -89,5 +90,5 @@ NodeCallback* CopyOp::operator() (const NodeCallback* nc) const
|
||||
return first;
|
||||
}
|
||||
else
|
||||
return const_cast<NodeCallback*>(nc);
|
||||
return const_cast<Callback*>(nc);
|
||||
}
|
||||
|
||||
@@ -216,6 +216,36 @@ void Drawable::flushDeletedDisplayLists(unsigned int contextID, double& availabl
|
||||
#endif
|
||||
}
|
||||
|
||||
bool Drawable::UpdateCallback::run(osg::Object* object, osg::Object* data)
|
||||
{
|
||||
osg::Drawable* drawable = dynamic_cast<osg::Drawable*>(object);
|
||||
osg::NodeVisitor* nv = dynamic_cast<osg::NodeVisitor*>(data);
|
||||
if (drawable && nv)
|
||||
{
|
||||
update(nv, drawable);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return traverse(object, data);
|
||||
}
|
||||
}
|
||||
|
||||
bool Drawable::EventCallback::run(osg::Object* object, osg::Object* data)
|
||||
{
|
||||
osg::Drawable* drawable = dynamic_cast<osg::Drawable*>(object);
|
||||
osg::NodeVisitor* nv = dynamic_cast<osg::NodeVisitor*>(data);
|
||||
if (drawable && nv)
|
||||
{
|
||||
event(nv, drawable);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return traverse(object, data);
|
||||
}
|
||||
}
|
||||
|
||||
Drawable::Drawable()
|
||||
{
|
||||
_boundingBoxComputed = false;
|
||||
@@ -468,48 +498,6 @@ void Drawable::dirtyDisplayList()
|
||||
}
|
||||
|
||||
|
||||
void Drawable::setUpdateCallback(UpdateCallback* ac)
|
||||
{
|
||||
if (_drawableUpdateCallback==ac) return;
|
||||
|
||||
int delta = 0;
|
||||
if (_drawableUpdateCallback.valid()) --delta;
|
||||
if (ac) ++delta;
|
||||
|
||||
_drawableUpdateCallback = ac;
|
||||
|
||||
if (delta!=0 && !(_stateset.valid() && _stateset->requiresUpdateTraversal()))
|
||||
{
|
||||
for(ParentList::iterator itr=_parents.begin();
|
||||
itr!=_parents.end();
|
||||
++itr)
|
||||
{
|
||||
(*itr)->setNumChildrenRequiringUpdateTraversal((*itr)->getNumChildrenRequiringUpdateTraversal()+delta);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Drawable::setEventCallback(EventCallback* ac)
|
||||
{
|
||||
if (_drawableEventCallback==ac) return;
|
||||
|
||||
int delta = 0;
|
||||
if (_drawableEventCallback.valid()) --delta;
|
||||
if (ac) ++delta;
|
||||
|
||||
_drawableEventCallback = ac;
|
||||
|
||||
if (delta!=0 && !(_stateset.valid() && _stateset->requiresEventTraversal()))
|
||||
{
|
||||
for(ParentList::iterator itr=_parents.begin();
|
||||
itr!=_parents.end();
|
||||
++itr)
|
||||
{
|
||||
(*itr)->setNumChildrenRequiringEventTraversal( (*itr)->getNumChildrenRequiringEventTraversal()+delta );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct ComputeBound : public PrimitiveFunctor
|
||||
{
|
||||
ComputeBound()
|
||||
|
||||
@@ -203,7 +203,7 @@ MatrixList Node::getWorldMatrices(const osg::Node* haltTraversalAtNode) const
|
||||
return matrices;
|
||||
}
|
||||
|
||||
void Node::setUpdateCallback(NodeCallback* nc)
|
||||
void Node::setUpdateCallback(Callback* nc)
|
||||
{
|
||||
// if no changes just return.
|
||||
if (_updateCallback==nc) return;
|
||||
@@ -281,7 +281,7 @@ void Node::setNumChildrenRequiringUpdateTraversal(unsigned int num)
|
||||
}
|
||||
|
||||
|
||||
void Node::setEventCallback(NodeCallback* nc)
|
||||
void Node::setEventCallback(Callback* nc)
|
||||
{
|
||||
// if no changes just return.
|
||||
if (_eventCallback==nc) return;
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
|
||||
*
|
||||
* This library is open source and may be redistributed and/or modified under
|
||||
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
||||
* (at your option) any later version. The full license is in LICENSE file
|
||||
* included with this distribution, and on the openscenegraph.org website.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* OpenSceneGraph Public License for more details.
|
||||
*/
|
||||
#include <osg/Node>
|
||||
#include <osg/NodeCallback>
|
||||
#include <osg/NodeVisitor>
|
||||
|
||||
using namespace osg;
|
||||
|
||||
void NodeCallback::traverse(Node* node,NodeVisitor* nv)
|
||||
{
|
||||
if (_nestedCallback.valid()) (*_nestedCallback)(node,nv);
|
||||
else nv->traverse(*node);
|
||||
}
|
||||
@@ -16,13 +16,6 @@
|
||||
|
||||
using namespace osg;
|
||||
|
||||
|
||||
bool CallbackObject::run(osg::Object* object, osg::Parameters& inputParameters, osg::Parameters& outputParameters) const
|
||||
{
|
||||
OSG_NOTICE<<"CallbackObject::run(object="<<object<<")"<<std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
ScriptEngine* ScriptNodeCallback::getScriptEngine(osg::NodePath& nodePath)
|
||||
{
|
||||
if (!_script) return 0;
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <osg/StateAttribute>
|
||||
#include <osg/StateSet>
|
||||
#include <osg/State>
|
||||
#include <osg/NodeVisitor>
|
||||
#include <osg/Notify>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@@ -84,6 +84,26 @@ bool osg::isTextureMode(StateAttribute::GLMode mode)
|
||||
return getTextureGLModeSet().isTextureMode(mode);
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// StateAttributeCallback
|
||||
//
|
||||
bool StateSet::Callback::run(osg::Object* object, osg::Object* data)
|
||||
{
|
||||
osg::StateSet* ss = dynamic_cast<osg::StateSet*>(object);
|
||||
osg::NodeVisitor* nv = dynamic_cast<osg::NodeVisitor*>(data);
|
||||
if (ss && nv)
|
||||
{
|
||||
operator()(ss, nv);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return traverse(object, data);
|
||||
}
|
||||
}
|
||||
|
||||
StateSet::StateSet():
|
||||
Object(true),
|
||||
_nestRenderBins(true)
|
||||
|
||||
@@ -62,7 +62,7 @@ void AnimationManagerBase::operator()(osg::Node* node, osg::NodeVisitor* nv)
|
||||
}
|
||||
|
||||
|
||||
AnimationManagerBase::AnimationManagerBase(const AnimationManagerBase& b, const osg::CopyOp& copyop) : osg::Object(b, copyop), osg::NodeCallback(b,copyop) // TODO check this
|
||||
AnimationManagerBase::AnimationManagerBase(const AnimationManagerBase& b, const osg::CopyOp& copyop) : osg::Callback(b, copyop), osg::NodeCallback(b,copyop) // TODO check this
|
||||
{
|
||||
const AnimationList& animationList = b.getAnimationList();
|
||||
for (AnimationList::const_iterator it = animationList.begin();
|
||||
|
||||
@@ -64,7 +64,7 @@ void LinkVisitor::apply(osg::Node& node)
|
||||
if (st)
|
||||
handle_stateset(st);
|
||||
|
||||
osg::NodeCallback* cb = node.getUpdateCallback();
|
||||
osg::Callback* cb = node.getUpdateCallback();
|
||||
while (cb)
|
||||
{
|
||||
osgAnimation::AnimationUpdateCallbackBase* cba = dynamic_cast<osgAnimation::AnimationUpdateCallbackBase*>(cb);
|
||||
|
||||
@@ -466,7 +466,7 @@ struct FindTimelineStats : public osg::NodeVisitor
|
||||
FindTimelineStats() : osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) {}
|
||||
|
||||
void apply(osg::Node& node) {
|
||||
osg::NodeCallback* cb = node.getUpdateCallback();
|
||||
osg::Callback* cb = node.getUpdateCallback();
|
||||
while (cb) {
|
||||
osgAnimation::TimelineAnimationManager* tam = dynamic_cast<osgAnimation::TimelineAnimationManager*>(cb);
|
||||
if (tam)
|
||||
|
||||
@@ -21,7 +21,7 @@ CameraManipulator::CameraManipulator()
|
||||
|
||||
|
||||
CameraManipulator::CameraManipulator(const CameraManipulator& mm, const CopyOp& copyOp)
|
||||
: osg::Object(mm, copyOp),
|
||||
: osg::Callback(mm, copyOp),
|
||||
inherited(mm, copyOp),
|
||||
_intersectTraversalMask(mm._intersectTraversalMask),
|
||||
_autoComputeHomePosition(mm._autoComputeHomePosition),
|
||||
|
||||
@@ -44,7 +44,7 @@ FirstPersonManipulator::FirstPersonManipulator( int flags )
|
||||
|
||||
/// Constructor.
|
||||
FirstPersonManipulator::FirstPersonManipulator( const FirstPersonManipulator& fpm, const CopyOp& copyOp )
|
||||
: osg::Object(fpm, copyOp),
|
||||
: osg::Callback(fpm, copyOp),
|
||||
inherited( fpm, copyOp ),
|
||||
_eye( fpm._eye ),
|
||||
_rotation( fpm._rotation ),
|
||||
|
||||
@@ -28,7 +28,7 @@ FlightManipulator::FlightManipulator( int flags )
|
||||
|
||||
/// Constructor.
|
||||
FlightManipulator::FlightManipulator( const FlightManipulator& fm, const CopyOp& copyOp )
|
||||
: osg::Object(fm, copyOp),
|
||||
: osg::Callback(fm, copyOp),
|
||||
inherited( fm, copyOp ),
|
||||
_yawMode( fm._yawMode )
|
||||
{
|
||||
|
||||
@@ -30,7 +30,7 @@ MultiTouchTrackballManipulator::MultiTouchTrackballManipulator( int flags )
|
||||
|
||||
/// Constructor.
|
||||
MultiTouchTrackballManipulator::MultiTouchTrackballManipulator( const MultiTouchTrackballManipulator& tm, const CopyOp& copyOp )
|
||||
: osg::Object(tm, copyOp), inherited( tm, copyOp )
|
||||
: osg::Callback(tm, copyOp), inherited( tm, copyOp )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ NodeTrackerManipulator::NodeTrackerManipulator( int flags )
|
||||
|
||||
|
||||
NodeTrackerManipulator::NodeTrackerManipulator( const NodeTrackerManipulator& m, const CopyOp& copyOp )
|
||||
: osg::Object(m, copyOp),
|
||||
: osg::Callback(m, copyOp),
|
||||
inherited( m, copyOp ),
|
||||
_trackNodePath( m._trackNodePath ),
|
||||
_trackerMode( m._trackerMode )
|
||||
|
||||
@@ -43,7 +43,7 @@ OrbitManipulator::OrbitManipulator( int flags )
|
||||
|
||||
/// Constructor.
|
||||
OrbitManipulator::OrbitManipulator( const OrbitManipulator& om, const CopyOp& copyOp )
|
||||
: osg::Object(om, copyOp),
|
||||
: osg::Callback(om, copyOp),
|
||||
inherited( om, copyOp ),
|
||||
_center( om._center ),
|
||||
_rotation( om._rotation ),
|
||||
|
||||
@@ -48,7 +48,7 @@ StandardManipulator::StandardManipulator( int flags )
|
||||
|
||||
/// Constructor.
|
||||
StandardManipulator::StandardManipulator( const StandardManipulator& uim, const CopyOp& copyOp )
|
||||
: osg::Object(uim, copyOp),
|
||||
: osg::Callback(uim, copyOp),
|
||||
inherited( uim, copyOp ),
|
||||
_thrown( uim._thrown ),
|
||||
_allowThrow( uim._allowThrow ),
|
||||
|
||||
@@ -29,7 +29,7 @@ TerrainManipulator::TerrainManipulator( int flags )
|
||||
|
||||
/// Constructor.
|
||||
TerrainManipulator::TerrainManipulator( const TerrainManipulator& tm, const CopyOp& copyOp )
|
||||
: osg::Object(tm, copyOp),
|
||||
: osg::Callback(tm, copyOp),
|
||||
inherited( tm, copyOp ),
|
||||
_previousUp( tm._previousUp )
|
||||
{
|
||||
|
||||
@@ -28,7 +28,7 @@ TrackballManipulator::TrackballManipulator( int flags )
|
||||
|
||||
/// Constructor.
|
||||
TrackballManipulator::TrackballManipulator( const TrackballManipulator& tm, const CopyOp& copyOp )
|
||||
: osg::Object(tm, copyOp),
|
||||
: osg::Callback(tm, copyOp),
|
||||
inherited( tm, copyOp )
|
||||
{
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ public:
|
||||
parent->setMatrixInSkeletonSpace( osg::Matrix::translate(offset) *
|
||||
parent->getMatrixInSkeletonSpace() );
|
||||
osgAnimation::UpdateBone* updateBone =
|
||||
static_cast<osgAnimation::UpdateBone*>( parent->getUpdateCallback() );
|
||||
dynamic_cast<osgAnimation::UpdateBone*>( parent->getUpdateCallback() );
|
||||
if ( updateBone )
|
||||
{
|
||||
osgAnimation::StackedTransform& stack = updateBone->getStackedTransforms();
|
||||
|
||||
@@ -758,7 +758,7 @@ daeReader::ChannelPart* daeReader::processSampler(domChannel* pDomChannel, Sourc
|
||||
return NULL;
|
||||
}
|
||||
|
||||
osgAnimation::Target* findChannelTarget(osg::NodeCallback* nc, const std::string& targetName, bool& rotation)
|
||||
osgAnimation::Target* findChannelTarget(osg::Callback* nc, const std::string& targetName, bool& rotation)
|
||||
{
|
||||
if (osgAnimation::UpdateMatrixTransform* umt = dynamic_cast<osgAnimation::UpdateMatrixTransform*>(nc))
|
||||
{
|
||||
@@ -827,7 +827,7 @@ void daeReader::processChannel(domChannel* pDomChannel, SourceMap& sources, Targ
|
||||
domChannelOsgAnimationUpdateCallbackMap::iterator iter = _domChannelOsgAnimationUpdateCallbackMap.find(pDomChannel);
|
||||
if (iter != _domChannelOsgAnimationUpdateCallbackMap.end())
|
||||
{
|
||||
osg::NodeCallback* nc = iter->second.get();
|
||||
osg::Callback* nc = iter->second.get();
|
||||
|
||||
std::string channelName, targetName, componentName;
|
||||
extractTargetName(pDomChannel->getTarget(), channelName, targetName, componentName);
|
||||
|
||||
@@ -44,7 +44,7 @@ osg::Transform* daeReader::processOsgMatrixTransform(domNode *node, bool isBone)
|
||||
resultNode = new osg::MatrixTransform;
|
||||
}
|
||||
|
||||
osg::NodeCallback* pNodeCallback = resultNode->getUpdateCallback();
|
||||
osg::Callback* pNodeCallback = resultNode->getUpdateCallback();
|
||||
std::vector<osg::ref_ptr<osgAnimation::StackedTransformElement> > transformElements;
|
||||
osg::ref_ptr<osgAnimation::StackedTransformElement> pLastStaticTransformElement;
|
||||
|
||||
|
||||
@@ -241,7 +241,7 @@ public:
|
||||
typedef std::map<domMaterial*, osg::ref_ptr<osg::StateSet> > domMaterialStateSetMap;
|
||||
typedef std::map<std::string, osg::ref_ptr<osg::StateSet> > MaterialStateSetMap;
|
||||
typedef std::multimap< daeElement*, domChannel*> daeElementDomChannelMap;
|
||||
typedef std::map<domChannel*, osg::ref_ptr<osg::NodeCallback> > domChannelOsgAnimationUpdateCallbackMap;
|
||||
typedef std::map<domChannel*, osg::ref_ptr<osg::Callback> > domChannelOsgAnimationUpdateCallbackMap;
|
||||
typedef std::map<domNode*, osg::ref_ptr<osgAnimation::Bone> > domNodeOsgBoneMap;
|
||||
typedef std::map<domNode*, osg::ref_ptr<osgAnimation::Skeleton> > domNodeOsgSkeletonMap;
|
||||
typedef std::map<TextureParameters, osg::ref_ptr<osg::Texture2D> > TextureParametersMap;
|
||||
|
||||
@@ -37,7 +37,7 @@ using namespace osgDAE;
|
||||
void daeWriter::writeAnimations( osg::Node &node )
|
||||
{
|
||||
const std::string nodeNameUTF( _pluginOptions.namesUseCodepage ? osgDB::convertStringFromCurrentCodePageToUTF8(node.getName()) : node.getName() );
|
||||
osg::NodeCallback* ncb = node.getUpdateCallback();
|
||||
osg::Callback* ncb = node.getUpdateCallback();
|
||||
if (ncb)
|
||||
{
|
||||
osgAnimation::AnimationManagerBase* am = dynamic_cast<osgAnimation::AnimationManagerBase*>(ncb);
|
||||
|
||||
@@ -67,7 +67,7 @@ void daeWriter::apply( osg::MatrixTransform &node )
|
||||
std::string nodeName = getNodeName(node,"matrixTransform");
|
||||
currentNode->setId(nodeName.c_str());
|
||||
|
||||
osg::NodeCallback* ncb = node.getUpdateCallback();
|
||||
osg::Callback* ncb = node.getUpdateCallback();
|
||||
bool handled = false;
|
||||
if (ncb)
|
||||
{
|
||||
@@ -124,7 +124,7 @@ void daeWriter::apply( osg::PositionAttitudeTransform &node )
|
||||
const osg::Quat &q = node.getAttitude();
|
||||
const osg::Vec3 &s = node.getScale();
|
||||
|
||||
osg::NodeCallback* ncb = node.getUpdateCallback();
|
||||
osg::Callback* ncb = node.getUpdateCallback();
|
||||
bool handled = false;
|
||||
if (ncb)
|
||||
{
|
||||
@@ -287,7 +287,7 @@ void daeWriter::apply( osg::Transform &node )
|
||||
osg::Matrix matrix;
|
||||
node.computeLocalToWorldMatrix(matrix, NULL);
|
||||
|
||||
osg::NodeCallback* ncb = node.getUpdateCallback();
|
||||
osg::Callback* ncb = node.getUpdateCallback();
|
||||
bool handled = false;
|
||||
if (ncb)
|
||||
{
|
||||
@@ -309,7 +309,7 @@ void daeWriter::apply( osg::Transform &node )
|
||||
domMatrix *mat = daeSafeCast< domMatrix >(currentNode->add( COLLADA_ELEMENT_MATRIX ) );
|
||||
nodeName += "_matrix";
|
||||
mat->setSid(nodeName.c_str());
|
||||
|
||||
|
||||
const osg::Matrix::value_type *mat_vals = matrix.ptr();
|
||||
for ( int i = 0; i < 4; i++ )
|
||||
{
|
||||
|
||||
@@ -93,7 +93,7 @@ public:
|
||||
|
||||
virtual void apply(osg::Node& node)
|
||||
{
|
||||
osg::NodeCallback* ncb = node.getUpdateCallback();
|
||||
osg::Callback* ncb = node.getUpdateCallback();
|
||||
if (ncb)
|
||||
{
|
||||
osgAnimation::AnimationUpdateCallback<osg::NodeCallback>* ut = dynamic_cast<osgAnimation::AnimationUpdateCallback<osg::NodeCallback>*>(ncb);
|
||||
|
||||
@@ -37,7 +37,6 @@
|
||||
|
||||
#include <osg/Group>
|
||||
#include <osg/NodeVisitor>
|
||||
#include <osg/NodeCallback>
|
||||
#include <osg/ref_ptr>
|
||||
|
||||
#include "TXPArchive.h"
|
||||
|
||||
@@ -985,8 +985,11 @@ void CullVisitor::apply(osg::Drawable& drawable)
|
||||
|
||||
if( drawable.getCullCallback() )
|
||||
{
|
||||
if( drawable.getCullCallback()->cull( this, &drawable, &_renderInfo ) == true )
|
||||
return;
|
||||
osg::Drawable::CullCallback* dcb = dynamic_cast<osg::Drawable::CullCallback*>(drawable.getCullCallback());
|
||||
if (dcb)
|
||||
{
|
||||
if( dcb->cull( this, &drawable, &_renderInfo ) == true ) return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!getNodePath().empty() && getNodePath().back()->isCullingActive() && isCulled(bb)) return;
|
||||
@@ -1073,7 +1076,8 @@ void CullVisitor::apply(Billboard& node)
|
||||
|
||||
if( drawable->getCullCallback() )
|
||||
{
|
||||
if( drawable->getCullCallback()->cull( this, drawable, &_renderInfo ) == true )
|
||||
osg::Drawable::CullCallback* dcb = dynamic_cast<osg::Drawable::CullCallback*>(drawable->getCullCallback());
|
||||
if (dcb && dcb->cull( this, drawable, &_renderInfo ) == true )
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -903,8 +903,8 @@ bool SceneView::cullStage(const osg::Matrixd& projection,const osg::Matrixd& mod
|
||||
// If the camera has a cullCallback execute the callback which has the
|
||||
// requirement that it must traverse the camera's children.
|
||||
{
|
||||
osg::NodeCallback* callback = _camera->getCullCallback();
|
||||
if (callback) (*callback)(_camera.get(), cullVisitor);
|
||||
osg::Callback* callback = _camera->getCullCallback();
|
||||
if (callback) callback->run(_camera.get(), cullVisitor);
|
||||
else cullVisitor->traverse(*_camera);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <osg/Notify>
|
||||
|
||||
#include <osg/NodeCallback>
|
||||
#include <osg/Callback>
|
||||
|
||||
#include <osgDB/Registry>
|
||||
#include <osgDB/Input>
|
||||
|
||||
18
src/osgWrappers/serializers/osg/Callback.cpp
Normal file
18
src/osgWrappers/serializers/osg/Callback.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#undef OBJECT_CAST
|
||||
#define OBJECT_CAST dynamic_cast
|
||||
|
||||
#include <osg/Node>
|
||||
#include <osgDB/ObjectWrapper>
|
||||
#include <osgDB/InputStream>
|
||||
#include <osgDB/OutputStream>
|
||||
|
||||
REGISTER_OBJECT_WRAPPER( Callback,
|
||||
new osg::Callback,
|
||||
osg::Callback,
|
||||
"osg::Object osg::Callback" )
|
||||
{
|
||||
ADD_OBJECT_SERIALIZER( NestedCallback, osg::Callback, NULL ); // _nestedCallback
|
||||
}
|
||||
|
||||
#undef OBJECT_CAST
|
||||
#define OBJECT_CAST static_cast
|
||||
@@ -43,8 +43,8 @@ REGISTER_OBJECT_WRAPPER( Drawable,
|
||||
ADD_BOOL_SERIALIZER( SupportsDisplayList, true ); // _supportsDisplayList
|
||||
ADD_BOOL_SERIALIZER( UseDisplayList, true ); // _useDisplayList
|
||||
ADD_BOOL_SERIALIZER( UseVertexBufferObjects, false ); // _useVertexBufferObjects
|
||||
ADD_OBJECT_SERIALIZER( UpdateCallback, osg::Drawable::UpdateCallback, NULL ); // _updateCallback
|
||||
ADD_OBJECT_SERIALIZER( EventCallback, osg::Drawable::EventCallback, NULL ); // _eventCallback
|
||||
ADD_OBJECT_SERIALIZER( CullCallback, osg::Drawable::CullCallback, NULL ); // _cullCallback
|
||||
ADD_OBJECT_SERIALIZER( UpdateCallback, osg::Callback, NULL ); // _updateCallback
|
||||
ADD_OBJECT_SERIALIZER( EventCallback, osg::Callback, NULL ); // _eventCallback
|
||||
ADD_OBJECT_SERIALIZER( CullCallback, osg::Callback, NULL ); // _cullCallback
|
||||
ADD_OBJECT_SERIALIZER( DrawCallback, osg::Drawable::DrawCallback, NULL ); // _drawCallback
|
||||
}
|
||||
|
||||
@@ -72,9 +72,9 @@ REGISTER_OBJECT_WRAPPER( Node,
|
||||
ADD_USER_SERIALIZER( InitialBound ); // _initialBound
|
||||
ADD_OBJECT_SERIALIZER( ComputeBoundingSphereCallback,
|
||||
osg::Node::ComputeBoundingSphereCallback, NULL ); // _computeBoundCallback
|
||||
ADD_OBJECT_SERIALIZER( UpdateCallback, osg::NodeCallback, NULL ); // _updateCallback
|
||||
ADD_OBJECT_SERIALIZER( EventCallback, osg::NodeCallback, NULL ); // _eventCallback
|
||||
ADD_OBJECT_SERIALIZER( CullCallback, osg::NodeCallback, NULL ); // _cullCallback
|
||||
ADD_OBJECT_SERIALIZER( UpdateCallback, osg::Callback, NULL ); // _updateCallback
|
||||
ADD_OBJECT_SERIALIZER( EventCallback, osg::Callback, NULL ); // _eventCallback
|
||||
ADD_OBJECT_SERIALIZER( CullCallback, osg::Callback, NULL ); // _cullCallback
|
||||
ADD_BOOL_SERIALIZER( CullingActive, true ); // _cullingActive
|
||||
ADD_HEXINT_SERIALIZER( NodeMask, 0xffffffff ); // _nodeMask
|
||||
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
#undef OBJECT_CAST
|
||||
#define OBJECT_CAST dynamic_cast
|
||||
|
||||
#include <osg/Node>
|
||||
#include <osgDB/ObjectWrapper>
|
||||
#include <osgDB/InputStream>
|
||||
@@ -9,10 +6,6 @@
|
||||
REGISTER_OBJECT_WRAPPER( NodeCallback,
|
||||
new osg::NodeCallback,
|
||||
osg::NodeCallback,
|
||||
"osg::Object osg::NodeCallback" )
|
||||
"osg::Object osg::Callback osg::NodeCallback" )
|
||||
{
|
||||
ADD_OBJECT_SERIALIZER( NestedCallback, osg::NodeCallback, NULL ); // _nestedCallback
|
||||
}
|
||||
|
||||
#undef OBJECT_CAST
|
||||
#define OBJECT_CAST static_cast
|
||||
|
||||
Reference in New Issue
Block a user