Fixed compilation error in src/osgDB/FileUtils.cpp.
Added support for nested NodeCallbacks, allowing them to be chained together so that multiple operations can be applied.
This commit is contained in:
@@ -209,6 +209,10 @@ SOURCE=..\..\src\osg\Node.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\osg\NodeCallback.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\src\osg\NodeVisitor.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -77,7 +77,7 @@ class SG_EXPORT Matrix : public Object
|
||||
// can I still do something to optimize the same case now?
|
||||
|
||||
void makeRot( const Vec3& from, const Vec3& to );
|
||||
void makeRot( float angle, const Vec3& orientation );
|
||||
void makeRot( float angle, const Vec3& axis );
|
||||
void makeRot( float angle, float x, float y, float z );
|
||||
void makeRot( const Quat& );
|
||||
void makeRot( float, float, float ); //Euler angles
|
||||
@@ -92,6 +92,7 @@ class SG_EXPORT Matrix : public Object
|
||||
inline static Matrix trans( float, float, float );
|
||||
inline static Matrix rotate( const Vec3&, const Vec3& );
|
||||
inline static Matrix rotate( float, float, float, float );
|
||||
inline static Matrix rotate( float angle, const Vec3& axis);
|
||||
inline static Matrix rotate( const Quat& );
|
||||
|
||||
inline Vec3 preMult( const Vec3& v ) const;
|
||||
@@ -215,7 +216,12 @@ inline Matrix Matrix::rotate(float angle, float x, float y, float z )
|
||||
m.makeRot(angle,x,y,z);
|
||||
return m;
|
||||
}
|
||||
|
||||
inline Matrix Matrix::rotate(float angle, const Vec3& axis )
|
||||
{
|
||||
Matrix m;
|
||||
m.makeRot(angle,axis);
|
||||
return m;
|
||||
}
|
||||
inline Matrix Matrix::rotate(const Vec3& from, const Vec3& to )
|
||||
{
|
||||
Matrix m;
|
||||
|
||||
@@ -39,9 +39,50 @@ class SG_EXPORT NodeCallback : public Referenced {
|
||||
/** Callback method call by the NodeVisitor when visiting a node.*/
|
||||
virtual void operator()(Node*, NodeVisitor*) {}
|
||||
|
||||
/** Call any nested callbacks and then traverse the scene graph. */
|
||||
void traverse(Node* node,NodeVisitor* nv);
|
||||
|
||||
void setNestedCallback(NodeCallback* nc) { _nestedCallback = nc; }
|
||||
NodeCallback* getNestedCallback() { return _nestedCallback.get(); }
|
||||
|
||||
inline void addNestedCallback(NodeCallback* nc)
|
||||
{
|
||||
if (nc)
|
||||
{
|
||||
if (_nestedCallback.valid())
|
||||
{
|
||||
nc->addNestedCallback(_nestedCallback.get());
|
||||
_nestedCallback = nc;
|
||||
}
|
||||
else
|
||||
{
|
||||
_nestedCallback = nc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline void removeNestedCallback(NodeCallback* nc)
|
||||
{
|
||||
if (nc)
|
||||
{
|
||||
if (_nestedCallback==nc)
|
||||
{
|
||||
NodeCallback* nested_nc = _nestedCallback->getNestedCallback();
|
||||
if (nested_nc) _nestedCallback = nc;
|
||||
else _nestedCallback = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_nestedCallback->removeNestedCallback(nc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
Requirements _requirements;
|
||||
|
||||
ref_ptr<NodeCallback> _nestedCallback;
|
||||
};
|
||||
|
||||
}; // namespace
|
||||
|
||||
@@ -21,18 +21,26 @@ class ref_ptr
|
||||
inline ref_ptr& operator = (const ref_ptr& rp)
|
||||
{
|
||||
if (_ptr==rp._ptr) return *this;
|
||||
if (_ptr) _ptr->unref();
|
||||
T* tmp_ptr = _ptr;
|
||||
_ptr = rp._ptr;
|
||||
if (_ptr) _ptr->ref();
|
||||
// unref second to prevent any deletion of any object which might
|
||||
// be referenced by the other object. i.e rp is child of the
|
||||
// original _ptr.
|
||||
if (tmp_ptr) tmp_ptr->unref();
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline ref_ptr& operator = (T* ptr)
|
||||
{
|
||||
if (_ptr==ptr) return *this;
|
||||
if (_ptr) _ptr->unref();
|
||||
T* tmp_ptr = _ptr;
|
||||
_ptr = ptr;
|
||||
if (_ptr) _ptr->ref();
|
||||
// unref second to prevent any deletion of any object which might
|
||||
// be referenced by the other object. i.e rp is child of the
|
||||
// original _ptr.
|
||||
if (tmp_ptr) tmp_ptr->unref();
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ class TransformCallback : public osg::NodeCallback{
|
||||
}
|
||||
|
||||
// must continue subgraph traversal.
|
||||
nv->traverse(*node);
|
||||
traverse(node,nv);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -84,8 +84,7 @@ class TransformCallback : public osg::NodeCallback{
|
||||
}
|
||||
|
||||
// must continue subgraph traversal.
|
||||
nv->traverse(*node);
|
||||
|
||||
traverse(node,nv);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ C++FILES = \
|
||||
Material.cpp\
|
||||
Matrix.cpp\
|
||||
Node.cpp\
|
||||
NodeCallback.cpp\
|
||||
NodeVisitor.cpp\
|
||||
Notify.cpp\
|
||||
Object.cpp\
|
||||
|
||||
@@ -99,9 +99,6 @@ void Matrix::set( float a00, float a01, float a02, float a03,
|
||||
|
||||
void Matrix::setTrans( float tx, float ty, float tz )
|
||||
{
|
||||
#ifdef WARN_DEPRECATED
|
||||
notify(NOTICE) << "Matrix::setTrans is deprecated."<<endl;
|
||||
#endif
|
||||
ensureRealized();
|
||||
|
||||
_mat[3][0] = tx;
|
||||
|
||||
@@ -206,7 +206,7 @@ char *osgDB::findDSO( const char *name )
|
||||
}
|
||||
else
|
||||
{
|
||||
return (char *)strdup(_name);
|
||||
return (char *)strdup(name);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user