Added ParentList's into StateSet, Uniform and StateAttribute in preparation for

providing update and event handling.
This commit is contained in:
Robert Osfield
2005-04-24 21:04:54 +00:00
parent 4262366f62
commit 193c83cb9c
12 changed files with 345 additions and 35 deletions

View File

@@ -135,7 +135,7 @@ class OSG_EXPORT Drawable : public Object
/** Set the StateSet attached to the Drawable.
Previously attached StateSet are automatically unreferenced on
assignment of a new drawstate.*/
inline void setStateSet(StateSet *state) { _stateset = state; }
void setStateSet(StateSet* stateset);
/** Get the attached StateSet.*/
inline StateSet* getStateSet() { return _stateset.get();}

View File

@@ -221,7 +221,7 @@ class OSG_EXPORT Node : public Object
/** Set the node's StateSet.*/
inline void setStateSet(osg::StateSet* dstate) { _stateset = dstate; }
void setStateSet(osg::StateSet* stateset);
/** return the node's StateSet, if one does not already exist create it
* set the node and return the newly created StateSet. This ensures

View File

@@ -20,6 +20,7 @@
#include <typeinfo>
#include <utility>
#include <vector>
// define for the GL_EXT_secondary_color extension, GL_COLOR_SUM is OpenGL
// mode to be used to enable and disable the second color.
@@ -231,7 +232,28 @@ class OSG_EXPORT StateAttribute : public Object
bool operator < (const StateAttribute& rhs) const { return compare(rhs)<0; }
bool operator == (const StateAttribute& rhs) const { return compare(rhs)==0; }
bool operator != (const StateAttribute& rhs) const { return compare(rhs)!=0; }
/** A vector of osg::StateSet pointers which is used to store the parent(s) of this StateAttribute.*/
typedef std::vector<StateSet*> ParentList;
/** Get the parent list of this StateAttribute. */
inline const ParentList& getParents() const { return _parents; }
inline StateSet* getParent(unsigned int i) { return _parents[i]; }
/**
* Get a single const parent of this StateAttribute.
* @param i index of the parent to get.
* @return the parent i.
*/
inline const StateSet* getParent(unsigned int i) const { return _parents[i]; }
/**
* Get the number of parents of this StateAttribute.
* @return the number of parents of this StateAttribute.
*/
inline unsigned int getNumParents() const { return _parents.size(); }
struct ModeUsage
{
@@ -299,6 +321,12 @@ class OSG_EXPORT StateAttribute : public Object
virtual ~StateAttribute() {}
void addParent(osg::StateSet* object);
void removeParent(osg::StateSet* object);
ParentList _parents;
friend class osg::StateSet;
ref_ptr<Callback> _updateCallback;
ref_ptr<Callback> _eventCallback;
};

View File

@@ -66,6 +66,32 @@ class OSG_EXPORT StateSet : public Object
bool operator == (const StateSet& rhs) const { return compare(rhs)==0; }
bool operator != (const StateSet& rhs) const { return compare(rhs)!=0; }
/** A vector of osg::Object pointers which is used to store the parent(s) of this Stateset, the parents could be osg::Node or osg::Drawable.*/
typedef std::vector<Object*> ParentList;
/** Get the parent list of this StateSet. */
inline const ParentList& getParents() const { return _parents; }
/** Get the a copy of parent list of node. A copy is returned to
* prevent modification of the parent list.*/
inline ParentList getParents() { return _parents; }
inline Object* getParent(unsigned int i) { return _parents[i]; }
/**
* Get a single const parent of this StateSet.
* @param i index of the parent to get.
* @return the parent i.
*/
inline const Object* getParent(unsigned int i) const { return _parents[i]; }
/**
* Get the number of parents of this StateSet.
* @return the number of parents of this StateSet.
*/
inline unsigned int getNumParents() const { return _parents.size(); }
/** Set all the modes to on or off so that it defines a
complete state, typically used for a default global state.*/
void setGlobalDefaults();
@@ -410,6 +436,13 @@ class OSG_EXPORT StateSet : public Object
StateSet& operator = (const StateSet&) { return *this; }
void addParent(osg::Object* object);
void removeParent(osg::Object* object);
ParentList _parents;
friend class osg::Node;
friend class osg::Drawable;
ModeList _modeList;
AttributeList _attributeList;

View File

@@ -25,6 +25,7 @@
#include <osg/GL>
#include <string>
#include <vector>
#ifndef GL_VERSION_2_0 //[
#define GL_VERSION_2_0 1
@@ -159,6 +160,9 @@ class OSG_EXPORT Uniform : public Object
META_Object(osg, Uniform);
bool setType( Type t );
bool setName( const std::string& name );
@@ -202,6 +206,32 @@ class OSG_EXPORT Uniform : public Object
void copyData( const Uniform& rhs );
/** A vector of osg::StateSet pointers which is used to store the parent(s) of this Uniform, the parents could be osg::Node or osg::Drawable.*/
typedef std::vector<StateSet*> ParentList;
/** Get the parent list of this Uniform. */
inline const ParentList& getParents() const { return _parents; }
/** Get the a copy of parent list of node. A copy is returned to
* prevent modification of the parent list.*/
inline ParentList getParents() { return _parents; }
inline StateSet* getParent(unsigned int i) { return _parents[i]; }
/**
* Get a single const parent of this Uniform.
* @param i index of the parent to get.
* @return the parent i.
*/
inline const StateSet* getParent(unsigned int i) const { return _parents[i]; }
/**
* Get the number of parents of this Uniform.
* @return the number of parents of this Uniform.
*/
inline unsigned int getNumParents() const { return _parents.size(); }
/** value assignment */
bool set( float f );
bool set( int i );
@@ -280,6 +310,12 @@ class OSG_EXPORT Uniform : public Object
bool isCompatibleType( Type t ) const;
void addParent(osg::StateSet* object);
void removeParent(osg::StateSet* object);
ParentList _parents;
friend class osg::StateSet;
std::string _name;
Type _type;
union {