Introduced CMake option OSG_PROVIDE_READFILE option that defaults to ON, but when switched to OFF disables the building of the osgDB::read*File() methods,
forcing users to use osgDB::readRef*File() methods. The later is preferable as it closes a potential threading bug when using paging databases in conjunction
with the osgDB::Registry Object Cache. This threading bug occurs when one thread gets an object from the Cache via an osgDB::read*File() call where only
a pointer to the object is passed back, so taking a reference to the object is delayed till it gets reassigned to a ref_ptr<>, but at the same time another
thread calls a flush of the Object Cache deleting this object as it's referenceCount is now zero. Using osgDB::readREf*File() makes sure the a ref_ptr<> is
passed back and the referenceCount never goes to zero.
To ensure the OSG builds when OSG_PROVIDE_READFILE is to OFF the many cases of osgDB::read*File() usage had to be replaced with a ref_ptr<> osgDB::readRef*File()
usage. The avoid this change causing lots of other client code to be rewritten to handle the use of ref_ptr<> in place of C pointer I introduced a serious of
templte methods in various class to adapt ref_ptr<> to the underly C pointer to be passed to old OSG API's, example of this is found in include/osg/Group:
bool addChild(Node* child); // old method which can only be used with a Node*
tempalte<class T> bool addChild(const osg::ref_ptr<T>& child) { return addChild(child.get()); } // adapter template method
These changes together cover 149 modified files, so it's a large submission. This extent of changes are warrent to make use of the Object Cache
and multi-threaded loaded more robust.
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/branches/OpenSceneGraph-3.4@15165 16af8721-9629-0410-8352-f15c8da7e697
This commit is contained in:
@@ -191,6 +191,8 @@ class OSG_EXPORT Drawable : public Node
|
||||
*/
|
||||
inline void setShape(Shape* shape) { _shape = shape; }
|
||||
|
||||
template<class T> void setShape(const ref_ptr<T>& shape) { setShape(shape.get()); }
|
||||
|
||||
/** Get the Shape of the Drawable.*/
|
||||
inline Shape* getShape() { return _shape.get(); }
|
||||
|
||||
|
||||
@@ -49,6 +49,8 @@ class OSG_EXPORT Geode : public Group
|
||||
*/
|
||||
virtual bool addDrawable( Drawable *drawable );
|
||||
|
||||
template<class T> bool addDrawable( const ref_ptr<T>& drawable ) { return addDrawable(drawable.get()); }
|
||||
|
||||
/** Remove a \c Drawable from the \c Geode.
|
||||
* Equivalent to <tt>removeDrawable(getDrawableIndex(drawable)</tt>.
|
||||
* @param drawable The drawable to be removed.
|
||||
@@ -57,6 +59,8 @@ class OSG_EXPORT Geode : public Group
|
||||
*/
|
||||
virtual bool removeDrawable( Drawable *drawable );
|
||||
|
||||
template<class T> bool removeDrawable( const ref_ptr<T>& drawable ) { return removeDrawable( drawable.get() ); }
|
||||
|
||||
/** Remove <tt>Drawable</tt>(s) from the specified position in
|
||||
* <tt>Geode</tt>'s drawable list.
|
||||
* @param i The index of the first \c Drawable to remove.
|
||||
@@ -73,6 +77,8 @@ class OSG_EXPORT Geode : public Group
|
||||
*/
|
||||
virtual bool replaceDrawable( Drawable *origDraw, Drawable *newDraw );
|
||||
|
||||
template<class T, class R> bool replaceDrawable( const ref_ptr<T>& origDraw, const ref_ptr<R>& newDraw ) { return replaceDrawable(origDraw.get(), newDraw.get()); }
|
||||
|
||||
/** Set \c Drawable at position \c i.
|
||||
* Decrement the reference count origGSet and increments the
|
||||
* reference count of newGset, and dirty the bounding sphere
|
||||
@@ -85,6 +91,8 @@ class OSG_EXPORT Geode : public Group
|
||||
*/
|
||||
virtual bool setDrawable( unsigned int i, Drawable* drawable );
|
||||
|
||||
template<class T> bool setDrawable( unsigned int i, const ref_ptr<T>& drawable ) { return setDrawable(i, drawable.get()); }
|
||||
|
||||
/** Return the number of <tt>Drawable</tt>s currently attached to the
|
||||
* \c Geode.
|
||||
*/
|
||||
@@ -108,6 +116,8 @@ class OSG_EXPORT Geode : public Group
|
||||
return false;
|
||||
}
|
||||
|
||||
template<class T> bool containsDrawable(const ref_ptr<T>& drawable) const { return containsDrawable(drawable.get()); }
|
||||
|
||||
/** Get the index number of \c drawable.
|
||||
* @return A value between 0 and <tt>getNumDrawables()-1</tt> if
|
||||
* \c drawable is found; if not found, then
|
||||
@@ -118,6 +128,8 @@ class OSG_EXPORT Geode : public Group
|
||||
return getChildIndex(drawable);
|
||||
}
|
||||
|
||||
template<class T> unsigned int getDrawableIndex( const ref_ptr<T>& drawable ) const { return getDrawableIndex(drawable.get()); }
|
||||
|
||||
/** Compile OpenGL Display List for each drawable.*/
|
||||
void compileDrawables(RenderInfo& renderInfo);
|
||||
|
||||
|
||||
@@ -50,6 +50,8 @@ class OSG_EXPORT Group : public Node
|
||||
*/
|
||||
virtual bool addChild( Node *child );
|
||||
|
||||
template<class T> bool addChild( const ref_ptr<T>& child ) { return addChild(child.get()); }
|
||||
|
||||
/** Insert Node to Group at specific location.
|
||||
* The new child node is inserted into the child list
|
||||
* before the node at the specified index. No nodes
|
||||
@@ -57,6 +59,8 @@ class OSG_EXPORT Group : public Node
|
||||
*/
|
||||
virtual bool insertChild( unsigned int index, Node *child );
|
||||
|
||||
template<class T> bool insertChild( unsigned int index, const ref_ptr<T>& child ) { return insertChild(index, child.get()); }
|
||||
|
||||
/** Remove Node from Group.
|
||||
* If Node is contained in Group then remove it from the child
|
||||
* list, decrement its reference count, and dirty the
|
||||
@@ -67,6 +71,8 @@ class OSG_EXPORT Group : public Node
|
||||
*/
|
||||
virtual bool removeChild( Node *child );
|
||||
|
||||
template<class T> bool removeChild( const ref_ptr<T>& child ) { return removeChild(child.get()); }
|
||||
|
||||
/** Remove Node from Group.
|
||||
* If Node is contained in Group then remove it from the child
|
||||
* list, decrement its reference count, and dirty the
|
||||
@@ -91,6 +97,8 @@ class OSG_EXPORT Group : public Node
|
||||
*/
|
||||
virtual bool replaceChild( Node *origChild, Node* newChild );
|
||||
|
||||
template<class T, class R> bool replaceChild( const ref_ptr<T>& origChild, const ref_ptr<R>& newChild ) { return replaceChild( origChild.get(), newChild.get()); }
|
||||
|
||||
/** Return the number of children nodes. */
|
||||
virtual unsigned int getNumChildren() const;
|
||||
|
||||
@@ -124,6 +132,8 @@ class OSG_EXPORT Group : public Node
|
||||
return false;
|
||||
}
|
||||
|
||||
template<class T> bool conatainsNode(const ref_ptr<T>& node) const { return containsNode(node.get()); }
|
||||
|
||||
/** Get the index number of child, return a value between
|
||||
* 0 and _children.size()-1 if found, if not found then
|
||||
* return _children.size().
|
||||
|
||||
@@ -542,11 +542,17 @@ class Geode;
|
||||
* Use the image's s and t values to scale the dimensions of the image.
|
||||
*/
|
||||
extern OSG_EXPORT Geode* createGeodeForImage(Image* image);
|
||||
|
||||
template<class T> Geode* createGeodeForImage(const ref_ptr<T>& image) { return createGeodeForImage(image.get()); }
|
||||
|
||||
|
||||
/** Convenience function to be used by image loaders to generate a valid geode
|
||||
* to return for readNode().
|
||||
* Use the specified s and t values to scale the dimensions of the image.
|
||||
*/
|
||||
extern OSG_EXPORT Geode* createGeodeForImage(Image* image,float s,float t);
|
||||
extern OSG_EXPORT Geode* createGeodeForImage(Image* image, float s, float t);
|
||||
|
||||
template<class T> Geode* createGeodeForImage(const ref_ptr<T>& image, float s, float t) { return createGeodeForImage(image.get(), s, t); }
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -92,6 +92,8 @@ class OSG_EXPORT ImageSequence : public ImageStream
|
||||
|
||||
void addImage(osg::Image* image);
|
||||
|
||||
template<class T> void addImage(const osg::ref_ptr<T>& image) { addImage(image.get()); }
|
||||
|
||||
void setImage(int s,int t,int r,
|
||||
GLint internalTextureformat,
|
||||
GLenum pixelFormat,GLenum type,
|
||||
@@ -100,6 +102,9 @@ class OSG_EXPORT ImageSequence : public ImageStream
|
||||
int packing=1) { Image::setImage(s,t,r,internalTextureformat, pixelFormat, type, data, mode, packing); }
|
||||
|
||||
void setImage(unsigned int pos, osg::Image* image);
|
||||
|
||||
template<class T> void setImage(unsigned int pos, const osg::ref_ptr<T>& image) { setImage(pos, image.get()); }
|
||||
|
||||
Image* getImage(unsigned int pos);
|
||||
const Image* getImage(unsigned int pos) const;
|
||||
|
||||
@@ -108,7 +113,7 @@ class OSG_EXPORT ImageSequence : public ImageStream
|
||||
ImageDataList& getImageDataList() { return _imageDataList; }
|
||||
const ImageDataList& getImageDataList() const { return _imageDataList; }
|
||||
|
||||
|
||||
|
||||
/** ImageSequence requires a call to update(NodeVisitor*) during the update traversal so return true.*/
|
||||
virtual bool requiresUpdateCall() const { return true; }
|
||||
|
||||
|
||||
@@ -48,9 +48,13 @@ class OSG_EXPORT LOD : public Group
|
||||
|
||||
virtual void traverse(NodeVisitor& nv);
|
||||
|
||||
using osg::Group::addChild;
|
||||
|
||||
virtual bool addChild(Node *child);
|
||||
|
||||
virtual bool addChild(Node *child, float min, float max);
|
||||
virtual bool addChild(Node *child, float rmin, float rmax);
|
||||
|
||||
template<class T> bool addChild( const ref_ptr<T>& child, float rmin, float rmax) { return addChild(child.get(), rmin, rmax); }
|
||||
|
||||
virtual bool removeChildren(unsigned int pos,unsigned int numChildrenToRemove=1);
|
||||
|
||||
|
||||
@@ -212,6 +212,8 @@ class OSG_EXPORT Node : public Object
|
||||
/** Set update node callback, called during update traversal. */
|
||||
void setUpdateCallback(Callback* nc);
|
||||
|
||||
template<class T> void setUpdateCallback(const ref_ptr<T>& nc) { setUpdateCallback(nc.get()); }
|
||||
|
||||
/** Get update node callback, called during update traversal. */
|
||||
inline Callback* getUpdateCallback() { return _updateCallback.get(); }
|
||||
|
||||
@@ -226,6 +228,8 @@ class OSG_EXPORT Node : public Object
|
||||
}
|
||||
}
|
||||
|
||||
template<class T> void addUpdateCallback(const ref_ptr<T>& nc) { addUpdateCallback(nc.get()); }
|
||||
|
||||
/** Convenience method that removes a given callback from a node, even if that callback is nested. There is no error return in case the given callback is not found. */
|
||||
inline void removeUpdateCallback(Callback* nc) {
|
||||
if (nc != NULL && _updateCallback.valid()) {
|
||||
@@ -239,6 +243,8 @@ class OSG_EXPORT Node : public Object
|
||||
}
|
||||
}
|
||||
|
||||
template<class T> void removeUpdateCallback(const ref_ptr<T>& nc) { removeUpdateCallback(nc.get()); }
|
||||
|
||||
/** Get the number of Children of this node which require Update traversal,
|
||||
* since they have an Update Callback attached to them or their children.*/
|
||||
inline unsigned int getNumChildrenRequiringUpdateTraversal() const { return _numChildrenRequiringUpdateTraversal; }
|
||||
@@ -247,6 +253,8 @@ class OSG_EXPORT Node : public Object
|
||||
/** Set event node callback, called during event traversal. */
|
||||
void setEventCallback(Callback* nc);
|
||||
|
||||
template<class T> void setEventCallback(const ref_ptr<T>& nc) { setEventCallback(nc.get()); }
|
||||
|
||||
/** Get event node callback, called during event traversal. */
|
||||
inline Callback* getEventCallback() { return _eventCallback.get(); }
|
||||
|
||||
@@ -261,6 +269,8 @@ class OSG_EXPORT Node : public Object
|
||||
}
|
||||
}
|
||||
|
||||
template<class T> void addEventCallback(const ref_ptr<T>& nc) { addEventCallback(nc.get()); }
|
||||
|
||||
/** Convenience method that removes a given callback from a node, even if that callback is nested. There is no error return in case the given callback is not found. */
|
||||
inline void removeEventCallback(Callback* nc) {
|
||||
if (nc != NULL && _eventCallback.valid()) {
|
||||
@@ -274,7 +284,9 @@ class OSG_EXPORT Node : public Object
|
||||
}
|
||||
}
|
||||
|
||||
/** Get the number of Children of this node which require Event traversal,
|
||||
template<class T> void removeEventCallback(const ref_ptr<T>& nc) { removeEventCallback(nc.get()); }
|
||||
|
||||
/** Get the number of Children of this node which require Event traversal,
|
||||
* since they have an Event Callback attached to them or their children.*/
|
||||
inline unsigned int getNumChildrenRequiringEventTraversal() const { return _numChildrenRequiringEventTraversal; }
|
||||
|
||||
@@ -282,6 +294,8 @@ class OSG_EXPORT Node : public Object
|
||||
/** Set cull node callback, called during cull traversal. */
|
||||
void setCullCallback(Callback* nc) { _cullCallback = nc; }
|
||||
|
||||
template<class T> void setCullCallback(const ref_ptr<T>& nc) { setCullCallback(nc.get()); }
|
||||
|
||||
/** Get cull node callback, called during cull traversal. */
|
||||
inline Callback* getCullCallback() { return _cullCallback.get(); }
|
||||
|
||||
@@ -296,6 +310,8 @@ class OSG_EXPORT Node : public Object
|
||||
}
|
||||
}
|
||||
|
||||
template<class T> void addCullCallback(const ref_ptr<T>& nc) { addCullCallback(nc.get()); }
|
||||
|
||||
/** Convenience method that removes a given callback from a node, even if that callback is nested. There is no error return in case the given callback is not found. */
|
||||
inline void removeCullCallback(Callback* nc) {
|
||||
if (nc != NULL && _cullCallback.valid()) {
|
||||
@@ -309,6 +325,8 @@ class OSG_EXPORT Node : public Object
|
||||
}
|
||||
}
|
||||
|
||||
template<class T> void removeCullCallback(const ref_ptr<T>& nc) { removeCullCallback(nc.get()); }
|
||||
|
||||
/** Set the view frustum/small feature culling of this node to be active or inactive.
|
||||
* The default value is true for _cullingActive. Used as a guide
|
||||
* to the cull traversal.*/
|
||||
@@ -360,6 +378,8 @@ class OSG_EXPORT Node : public Object
|
||||
/** Set the node's StateSet.*/
|
||||
void setStateSet(osg::StateSet* stateset);
|
||||
|
||||
template<class T> void setStateSet(const osg::ref_ptr<T>& stateset) { setStateSet(stateset.get()); }
|
||||
|
||||
/** return the node's StateSet, if one does not already exist create it
|
||||
* set the node and return the newly created StateSet. This ensures
|
||||
* that a valid StateSet is always returned and can be used directly.*/
|
||||
@@ -444,6 +464,8 @@ class OSG_EXPORT Node : public Object
|
||||
/** Set the compute bound callback to override the default computeBound.*/
|
||||
void setComputeBoundingSphereCallback(ComputeBoundingSphereCallback* callback) { _computeBoundCallback = callback; }
|
||||
|
||||
template<class T> void setComputeBoundingSphereCallback(const ref_ptr<T>& callback) { setComputeBoundingSphereCallback(callback.get()); }
|
||||
|
||||
/** Get the compute bound callback.*/
|
||||
ComputeBoundingSphereCallback* getComputeBoundingSphereCallback() { return _computeBoundCallback.get(); }
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ class OSG_EXPORT NodeVisitor : public virtual Object
|
||||
* Equivalent to dynamic_cast<const NodeVisitor*>(this).*/
|
||||
virtual const NodeVisitor* asNodeVisitor() const { return this; }
|
||||
|
||||
|
||||
|
||||
/** Method to call to reset visitor. Useful if your visitor accumulates
|
||||
state during a traversal, and you plan to reuse the visitor.
|
||||
To flush that state for the next traversal: call reset() prior
|
||||
|
||||
@@ -92,8 +92,8 @@ class OSG_EXPORT Object : public Referenced
|
||||
|
||||
/** return the compound class name that combines the library name and class name.*/
|
||||
std::string getCompoundClassName() const { return std::string(libraryName()) + std::string("::") + std::string(className()); }
|
||||
|
||||
|
||||
|
||||
|
||||
/** Convert 'this' into a Node pointer if Object is a Node, otherwise return 0.
|
||||
* Equivalent to dynamic_cast<Node*>(this).*/
|
||||
virtual Node* asNode() { return 0; }
|
||||
@@ -168,6 +168,8 @@ class OSG_EXPORT Object : public Referenced
|
||||
/** set the UserDataContainer object.*/
|
||||
void setUserDataContainer(osg::UserDataContainer* udc);
|
||||
|
||||
template<class T> void setUserDataContainer(const ref_ptr<T>& udc) { setUserDataContainer(udc.get()); }
|
||||
|
||||
/** get the UserDataContainer attached to this object.*/
|
||||
osg::UserDataContainer* getUserDataContainer() { return _userDataContainer; }
|
||||
|
||||
@@ -187,6 +189,8 @@ class OSG_EXPORT Object : public Referenced
|
||||
*/
|
||||
virtual void setUserData(Referenced* obj);
|
||||
|
||||
template<class T> void setUserData(const ref_ptr<T>& ud) { setUserData(ud.get()); }
|
||||
|
||||
/** Get user data.*/
|
||||
virtual Referenced* getUserData();
|
||||
|
||||
|
||||
@@ -31,15 +31,19 @@ class OSG_EXPORT PagedLOD : public LOD
|
||||
|
||||
META_Node(osg, PagedLOD);
|
||||
|
||||
|
||||
|
||||
virtual void traverse(NodeVisitor& nv);
|
||||
|
||||
using osg::Group::addChild;
|
||||
|
||||
virtual bool addChild(Node *child);
|
||||
|
||||
virtual bool addChild(Node *child, float min, float max);
|
||||
virtual bool addChild(Node *child, float rmin, float rmax);
|
||||
|
||||
virtual bool addChild(Node *child, float min, float max,const std::string& filename, float priorityOffset=0.0f, float priorityScale=1.0f);
|
||||
template<class T> bool addChild( const ref_ptr<T>& child, float rmin, float rmax) { return addChild(child.get(), rmin, rmax); }
|
||||
|
||||
virtual bool addChild(Node *child, float rmin, float rmax, const std::string& filename, float priorityOffset=0.0f, float priorityScale=1.0f);
|
||||
|
||||
template<class T> bool addChild( const ref_ptr<T>& child, float rmin, float rmax, const std::string& filename, float priorityOffset=0.0f, float priorityScale=1.0f) { return addChild(child.get(), rmin, rmax, filename, priorityOffset, priorityScale); }
|
||||
|
||||
virtual bool removeChildren(unsigned int pos,unsigned int numChildrenToRemove=1);
|
||||
|
||||
|
||||
@@ -86,6 +86,8 @@ class OSG_EXPORT Program : public osg::StateAttribute
|
||||
* Mark Program as needing relink. Return true for success */
|
||||
bool addShader( Shader* shader );
|
||||
|
||||
template<class T> bool addShader( const ref_ptr<T>& shader ) { return addShader(shader.get()); }
|
||||
|
||||
unsigned int getNumShaders() const { return static_cast<unsigned int>(_shaderList.size()); }
|
||||
|
||||
Shader* getShader( unsigned int i ) { return _shaderList[i].get(); }
|
||||
@@ -95,6 +97,8 @@ class OSG_EXPORT Program : public osg::StateAttribute
|
||||
* Mark Program as needing relink. Return true for success */
|
||||
bool removeShader( Shader* shader );
|
||||
|
||||
template<class T> bool removeShader( const ref_ptr<T>& shader ) { return removeShader(shader.get()); }
|
||||
|
||||
/** Set/get GL program parameters */
|
||||
void setParameter( GLenum pname, GLint value );
|
||||
GLint getParameter( GLenum pname ) const;
|
||||
|
||||
@@ -36,9 +36,14 @@ class OSG_EXPORT ProxyNode : public Group
|
||||
|
||||
virtual void traverse(NodeVisitor& nv);
|
||||
|
||||
using osg::Group::addChild;
|
||||
|
||||
virtual bool addChild(Node *child);
|
||||
|
||||
virtual bool addChild(Node *child, const std::string& filename);
|
||||
|
||||
template<class T> bool addChild( const ref_ptr<T>& child, const std::string& filename) { return addChild(child.get(), filename); }
|
||||
|
||||
virtual bool removeChildren(unsigned int pos,unsigned int numChildrenToRemove);
|
||||
|
||||
|
||||
|
||||
@@ -41,14 +41,22 @@ class OSG_EXPORT Sequence : public Group
|
||||
// maintained. New code should set defaultTime and use addChild, and
|
||||
// not mess with the setTime method
|
||||
|
||||
using osg::Group::addChild;
|
||||
using osg::Group::insertChild;
|
||||
using osg::Group::removeChild;
|
||||
|
||||
virtual bool addChild( Node *child);
|
||||
|
||||
virtual bool addChild( Node *child, double t);
|
||||
|
||||
template<class T> bool addChild( const ref_ptr<T>& child, double t) { return addChild(child.get(), t); }
|
||||
|
||||
virtual bool insertChild( unsigned int index, Node *child);
|
||||
|
||||
virtual bool insertChild( unsigned int index, Node *child, double t);
|
||||
|
||||
template<class T> bool insertChild( unsigned int index, const ref_ptr<T>& child, double t) { return insertChild(index, child.get(), t); }
|
||||
|
||||
virtual bool removeChild( Node *child );
|
||||
|
||||
virtual bool removeChildren(unsigned int pos,unsigned int numChildrenToRemove);
|
||||
|
||||
@@ -622,6 +622,8 @@ class OSG_EXPORT CompositeShape : public Shape
|
||||
/** Add a child to the list.*/
|
||||
void addChild(Shape* shape) { _children.push_back(shape); }
|
||||
|
||||
template<class T> void addChild( const ref_ptr<T>& child ) { addChild(child.get()); }
|
||||
|
||||
/** remove a child from the list.*/
|
||||
void removeChild(unsigned int i) { _children.erase(_children.begin()+i); }
|
||||
|
||||
|
||||
@@ -132,6 +132,12 @@ class OSG_EXPORT ShapeDrawable : public Drawable
|
||||
|
||||
ShapeDrawable(Shape* shape, TessellationHints* hints=0);
|
||||
|
||||
template<class T> ShapeDrawable(const ref_ptr<T>& shape, TessellationHints* hints=0):
|
||||
_color(1.0f,1.0f,1.0f,1.0f),
|
||||
_tessellationHints(hints) { setShape(shape.get()); }
|
||||
|
||||
|
||||
|
||||
/** Copy constructor using CopyOp to manage deep vs shallow copy.*/
|
||||
ShapeDrawable(const ShapeDrawable& pg,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
|
||||
|
||||
|
||||
@@ -160,15 +160,21 @@ class OSG_EXPORT StateSet : public Object
|
||||
/** Set this StateSet to contain specified attribute and override flag.*/
|
||||
void setAttribute(StateAttribute *attribute, StateAttribute::OverrideValue value=StateAttribute::OFF);
|
||||
|
||||
template<class T> void setAttribute(const ref_ptr<T>& attribute, StateAttribute::OverrideValue value=StateAttribute::OFF) { setAttribute(attribute.get(), value); }
|
||||
|
||||
/** Set this StateSet to contain specified attribute and set the associated GLMode's to specified value.*/
|
||||
void setAttributeAndModes(StateAttribute *attribute, StateAttribute::GLModeValue value=StateAttribute::ON);
|
||||
|
||||
template<class T> void setAttributeAndModes(const ref_ptr<T>& attribute, StateAttribute::GLModeValue value=StateAttribute::ON) { setAttribute(attribute.get(), value); }
|
||||
|
||||
/** remove attribute of specified type from StateSet.*/
|
||||
void removeAttribute(StateAttribute::Type type, unsigned int member=0);
|
||||
|
||||
/** remove attribute from StateSet.*/
|
||||
void removeAttribute(StateAttribute *attribute);
|
||||
|
||||
template<class T> void removeAttribute(const ref_ptr<T>& attribute) { removeAttribute(attribute.get()); }
|
||||
|
||||
/** Get specified StateAttribute for specified type.
|
||||
* Returns NULL if no type is contained within StateSet.*/
|
||||
StateAttribute* getAttribute(StateAttribute::Type type, unsigned int member = 0);
|
||||
@@ -226,15 +232,22 @@ class OSG_EXPORT StateSet : public Object
|
||||
|
||||
/** Set this StateSet to contain specified attribute and override flag.*/
|
||||
void setTextureAttribute(unsigned int unit,StateAttribute *attribute, StateAttribute::OverrideValue value=StateAttribute::OFF);
|
||||
|
||||
template<class T> void setTextureAttribute(unsigned int unit, const ref_ptr<T>& attribute, StateAttribute::OverrideValue value=StateAttribute::OFF) { setTextureAttribute( unit, attribute.get(), value); }
|
||||
|
||||
/** Set this StateSet to contain specified attribute and set the associated GLMode's to specified value.*/
|
||||
void setTextureAttributeAndModes(unsigned int unit,StateAttribute *attribute, StateAttribute::GLModeValue value=StateAttribute::ON);
|
||||
|
||||
template<class T> void setTextureAttributeAndModes(unsigned int unit, const ref_ptr<T>& attribute, StateAttribute::OverrideValue value=StateAttribute::OFF) { setTextureAttributeAndModes( unit, attribute.get(), value); }
|
||||
|
||||
/** remove texture attribute of specified type from StateSet.*/
|
||||
void removeTextureAttribute(unsigned int unit, StateAttribute::Type type);
|
||||
|
||||
/** remove texture attribute from StateSet.*/
|
||||
void removeTextureAttribute(unsigned int unit, StateAttribute *attribute);
|
||||
|
||||
template<class T> void removeTextureAttribute(unsigned int unit, const ref_ptr<T>& attribute) { removeTextureAttribute(unit, attribute.get()); }
|
||||
|
||||
/** Get specified Texture related StateAttribute for specified type.
|
||||
* Returns NULL if no type is contained within StateSet.*/
|
||||
StateAttribute* getTextureAttribute(unsigned int unit,StateAttribute::Type type);
|
||||
@@ -278,12 +291,16 @@ class OSG_EXPORT StateSet : public Object
|
||||
/** Set this StateSet to contain specified uniform and override flag.*/
|
||||
void addUniform(Uniform* uniform, StateAttribute::OverrideValue value=StateAttribute::ON);
|
||||
|
||||
template<class T> void addUniform(const ref_ptr<T>& uniform, StateAttribute::OverrideValue value=StateAttribute::ON) { addUniform( uniform.get(), value); }
|
||||
|
||||
/** remove uniform of specified name from StateSet.*/
|
||||
void removeUniform(const std::string& name);
|
||||
|
||||
/** remove Uniform from StateSet.*/
|
||||
void removeUniform(Uniform* uniform);
|
||||
|
||||
template<class T> void removeUniform(const ref_ptr<T>& uniform) { removeUniform(uniform.get()); }
|
||||
|
||||
/** Get Uniform for specified name.
|
||||
* Returns NULL if no matching Uniform is contained within StateSet.*/
|
||||
Uniform* getUniform(const std::string& name);
|
||||
@@ -427,6 +444,8 @@ class OSG_EXPORT StateSet : public Object
|
||||
/** Set the Update Callback which allows users to attach customize the updating of an object during the update traversal.*/
|
||||
void setUpdateCallback(Callback* ac);
|
||||
|
||||
template<class T> void setUpdateCallback(const ref_ptr<T>& ac) { setUpdateCallback(ac.get()); }
|
||||
|
||||
/** Get the non const Update Callback.*/
|
||||
Callback* getUpdateCallback() { return _updateCallback.get(); }
|
||||
|
||||
@@ -447,6 +466,8 @@ class OSG_EXPORT StateSet : public Object
|
||||
/** Set the Event Callback which allows users to attach customize the updating of an object during the event traversal.*/
|
||||
void setEventCallback(Callback* ac);
|
||||
|
||||
template<class T> void setEventCallback(const ref_ptr<T>& ec) { setEventCallback(ec.get()); }
|
||||
|
||||
/** Get the non const Event Callback.*/
|
||||
Callback* getEventCallback() { return _eventCallback.get(); }
|
||||
|
||||
|
||||
@@ -45,6 +45,9 @@ class OSG_EXPORT Switch : public Group
|
||||
|
||||
bool getNewChildDefaultValue() const { return _newChildDefaultValue; }
|
||||
|
||||
using osg::Group::addChild;
|
||||
using osg::Group::insertChild;
|
||||
|
||||
virtual bool addChild( Node *child );
|
||||
|
||||
virtual bool addChild( Node *child, bool value );
|
||||
|
||||
@@ -740,6 +740,8 @@ class OSG_EXPORT Texture : public osg::StateAttribute
|
||||
/** Sets the texture image for the specified face. */
|
||||
virtual void setImage(unsigned int face, Image* image) = 0;
|
||||
|
||||
template<class T> void setImage(unsigned int face, const ref_ptr<T>& image) { setImage(face, image.get()); }
|
||||
|
||||
/** Gets the texture image for the specified face. */
|
||||
virtual Image* getImage(unsigned int face) = 0;
|
||||
|
||||
@@ -753,6 +755,8 @@ class OSG_EXPORT Texture : public osg::StateAttribute
|
||||
/** Set the PBuffer graphics context to read from when using PBuffers for RenderToTexture.*/
|
||||
void setReadPBuffer(GraphicsContext* context) { _readPBuffer = context; }
|
||||
|
||||
template<class T> void setReadPBuffer(const ref_ptr<T>& context) { setReadPBuffer(context.get()); }
|
||||
|
||||
/** Get the PBuffer graphics context to read from when using PBuffers for RenderToTexture.*/
|
||||
GraphicsContext* getReadPBuffer() { return _readPBuffer.get(); }
|
||||
|
||||
|
||||
@@ -36,6 +36,13 @@ class OSG_EXPORT Texture1D : public Texture
|
||||
|
||||
Texture1D(Image* image);
|
||||
|
||||
template<class T> Texture1D(const osg::ref_ptr<T>& image):
|
||||
_textureWidth(0),
|
||||
_numMipmapLevels(0)
|
||||
{
|
||||
setImage(image.get());
|
||||
}
|
||||
|
||||
/** Copy constructor using CopyOp to manage deep vs shallow copy. */
|
||||
Texture1D(const Texture1D& text,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
|
||||
|
||||
@@ -49,6 +56,8 @@ class OSG_EXPORT Texture1D : public Texture
|
||||
/** Sets the texture image. */
|
||||
void setImage(Image* image);
|
||||
|
||||
template<class T> void setImage(const ref_ptr<T>& image) { setImage(image.get()); }
|
||||
|
||||
/** Gets the texture image. */
|
||||
Image* getImage() { return _image.get(); }
|
||||
|
||||
|
||||
@@ -30,6 +30,15 @@ class OSG_EXPORT Texture2D : public Texture
|
||||
|
||||
Texture2D(Image* image);
|
||||
|
||||
template<class T> Texture2D(const osg::ref_ptr<T>& image):
|
||||
_textureWidth(0),
|
||||
_textureHeight(0),
|
||||
_numMipmapLevels(0)
|
||||
{
|
||||
setUseHardwareMipMapGeneration(true);
|
||||
setImage(image.get());
|
||||
}
|
||||
|
||||
/** Copy constructor using CopyOp to manage deep vs shallow copy. */
|
||||
Texture2D(const Texture2D& text,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
|
||||
|
||||
@@ -43,6 +52,8 @@ class OSG_EXPORT Texture2D : public Texture
|
||||
/** Sets the texture image. */
|
||||
void setImage(Image* image);
|
||||
|
||||
template<class T> void setImage(const ref_ptr<T>& image) { setImage(image.get()); }
|
||||
|
||||
/** Gets the texture image. */
|
||||
Image* getImage() { return _image.get(); }
|
||||
|
||||
@@ -59,6 +70,8 @@ class OSG_EXPORT Texture2D : public Texture
|
||||
/** Sets the texture image, ignoring face. */
|
||||
virtual void setImage(unsigned int, Image* image) { setImage(image); }
|
||||
|
||||
template<class T> void setImage(unsigned int, const ref_ptr<T>& image) { setImage(image.get()); }
|
||||
|
||||
/** Gets the texture image, ignoring face. */
|
||||
virtual Image* getImage(unsigned int) { return _image.get(); }
|
||||
|
||||
|
||||
@@ -48,6 +48,8 @@ class OSG_EXPORT Texture2DArray : public Texture
|
||||
/** Set the texture image for specified layer. */
|
||||
virtual void setImage(unsigned int layer, Image* image);
|
||||
|
||||
template<class T> void setImage(unsigned int layer, const ref_ptr<T>& image) { setImage(layer, image.get()); }
|
||||
|
||||
/** Get the texture image for specified layer. */
|
||||
virtual Image* getImage(unsigned int layer);
|
||||
|
||||
|
||||
@@ -63,6 +63,7 @@ class OSG_EXPORT Texture2DMultisample : public Texture
|
||||
|
||||
// unnecessary for Texture2DMultisample
|
||||
virtual void setImage(unsigned int /*face*/, Image* /*image*/) {}
|
||||
|
||||
virtual Image* getImage(unsigned int /*face*/) { return NULL; }
|
||||
virtual const Image* getImage(unsigned int /*face*/) const { return NULL; }
|
||||
virtual unsigned int getNumImages() const {return 0; }
|
||||
|
||||
@@ -30,6 +30,16 @@ class OSG_EXPORT Texture3D : public Texture
|
||||
|
||||
Texture3D(Image* image);
|
||||
|
||||
|
||||
template<class T> Texture3D(const osg::ref_ptr<T>& image):
|
||||
_textureWidth(0),
|
||||
_textureHeight(0),
|
||||
_textureDepth(0),
|
||||
_numMipmapLevels(0)
|
||||
{
|
||||
setImage(image.get());
|
||||
}
|
||||
|
||||
/** Copy constructor using CopyOp to manage deep vs shallow copy. */
|
||||
Texture3D(const Texture3D& text,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
|
||||
|
||||
@@ -43,6 +53,8 @@ class OSG_EXPORT Texture3D : public Texture
|
||||
/** Sets the texture image. */
|
||||
void setImage(Image* image);
|
||||
|
||||
template<class T> void setImage(const ref_ptr<T>& image) { setImage(image.get()); }
|
||||
|
||||
/** Gets the texture image. */
|
||||
Image* getImage() { return _image.get(); }
|
||||
|
||||
|
||||
@@ -49,6 +49,8 @@ class OSG_EXPORT TextureCubeMap : public Texture
|
||||
/** Set the texture image for specified face. */
|
||||
virtual void setImage(unsigned int face, Image* image);
|
||||
|
||||
template<class T> void setImage(unsigned int face, const ref_ptr<T>& image) { setImage(face, image.get()); }
|
||||
|
||||
/** Get the texture image for specified face. */
|
||||
virtual Image* getImage(unsigned int face);
|
||||
|
||||
|
||||
@@ -36,6 +36,19 @@ class OSG_EXPORT TextureRectangle : public Texture
|
||||
|
||||
TextureRectangle(Image* image);
|
||||
|
||||
template<class T> TextureRectangle(const osg::ref_ptr<T>& image):
|
||||
_textureWidth(0),
|
||||
_textureHeight(0)
|
||||
{
|
||||
setWrap(WRAP_S, CLAMP);
|
||||
setWrap(WRAP_T, CLAMP);
|
||||
|
||||
setFilter(MIN_FILTER, LINEAR);
|
||||
setFilter(MAG_FILTER, LINEAR);
|
||||
|
||||
setImage(image.get());
|
||||
}
|
||||
|
||||
/** Copy constructor using CopyOp to manage deep vs shallow copy. */
|
||||
TextureRectangle(const TextureRectangle& text,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
|
||||
|
||||
@@ -49,6 +62,8 @@ class OSG_EXPORT TextureRectangle : public Texture
|
||||
/** Set the texture image. */
|
||||
void setImage(Image* image);
|
||||
|
||||
template<class T> void setImage(const ref_ptr<T>& image) { setImage(image.get()); }
|
||||
|
||||
/** Get the texture image. */
|
||||
Image* getImage() { return _image.get(); }
|
||||
|
||||
|
||||
@@ -47,6 +47,8 @@ class OSG_EXPORT UserDataContainer : public osg::Object
|
||||
*/
|
||||
virtual void setUserData(Referenced* obj) = 0;
|
||||
|
||||
using osg::Object::setUserData;
|
||||
|
||||
/** Get user data.*/
|
||||
virtual Referenced* getUserData() = 0;
|
||||
|
||||
@@ -56,6 +58,8 @@ class OSG_EXPORT UserDataContainer : public osg::Object
|
||||
/** Add user data object. Returns the index position of object added. */
|
||||
virtual unsigned int addUserObject(Object* obj) = 0;
|
||||
|
||||
template<class T> unsigned int addUserObject(const osg::ref_ptr<T>& obj) { return addUserObject(obj.get()); }
|
||||
|
||||
/** Add element to list of user data objects.*/
|
||||
virtual void setUserObject(unsigned int i, Object* obj) = 0;
|
||||
|
||||
@@ -127,6 +131,9 @@ class OSG_EXPORT DefaultUserDataContainer : public osg::UserDataContainer
|
||||
*/
|
||||
virtual void setUserData(Referenced* obj);
|
||||
|
||||
using osg::Object::setUserData;
|
||||
using osg::UserDataContainer::addUserObject;
|
||||
|
||||
/** Get user data.*/
|
||||
virtual Referenced* getUserData();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user