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