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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user