Added new getMember() method and TypeMemberPair into StateAttribute and
support for the unsigned int member to be paired with types in osg::StateSet so that lights, clipplanes and other attributes that have a type group but then need to differentiate within that group via a member uint.
This commit is contained in:
@@ -41,7 +41,7 @@ class SG_EXPORT ClipPlane : public StateAttribute
|
||||
_clipPlaneNum=cp._clipPlaneNum;
|
||||
}
|
||||
|
||||
META_StateAttribute(osg, ClipPlane, (Type)(CLIPPLANE+_clipPlaneNum));
|
||||
META_StateAttribute(osg, ClipPlane, CLIPPLANE);
|
||||
|
||||
/** Return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs. */
|
||||
virtual int compare(const StateAttribute& sa) const
|
||||
@@ -60,6 +60,8 @@ class SG_EXPORT ClipPlane : public StateAttribute
|
||||
return 0; // Passed all the above comparison macros, so must be equal.
|
||||
}
|
||||
|
||||
virtual unsigned int getMember() { return _clipPlaneNum; }
|
||||
|
||||
virtual bool getModeUsage(ModeUsage& usage) const
|
||||
{
|
||||
usage.usesMode((GLMode)(GL_CLIP_PLANE0+_clipPlaneNum));
|
||||
|
||||
@@ -42,7 +42,7 @@ class SG_EXPORT Light : public StateAttribute
|
||||
_spot_exponent(light._spot_exponent),
|
||||
_spot_cutoff(light._spot_cutoff) {}
|
||||
|
||||
META_StateAttribute(osg, Light, (Type)(LIGHT_0+_lightnum));
|
||||
META_StateAttribute(osg, Light, LIGHT);
|
||||
|
||||
/** Return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs. */
|
||||
virtual int compare(const StateAttribute& sa) const
|
||||
@@ -67,11 +67,15 @@ class SG_EXPORT Light : public StateAttribute
|
||||
return 0; // passed all the above comparison macro's, must be equal.
|
||||
}
|
||||
|
||||
virtual unsigned int getMember() { return _lightnum; }
|
||||
|
||||
virtual bool getModeUsage(ModeUsage& usage) const
|
||||
{
|
||||
usage.usesMode(GL_LIGHT0+_lightnum);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** Set which OpenGL light to operate on. */
|
||||
void setLightNum(int num) { _lightnum = num; }
|
||||
|
||||
@@ -202,20 +202,20 @@ class SG_EXPORT State : public Referenced
|
||||
|
||||
inline void setGlobalDefaultAttribute(const StateAttribute* attribute)
|
||||
{
|
||||
AttributeStack& as = _attributeMap[attribute->getType()];
|
||||
AttributeStack& as = _attributeMap[attribute->getTypeMemberPair()];
|
||||
as.global_default_attribute = attribute;
|
||||
}
|
||||
|
||||
inline const StateAttribute* getGlobalDefaultAttribute(StateAttribute::Type type)
|
||||
inline const StateAttribute* getGlobalDefaultAttribute(StateAttribute::Type type, unsigned int member=0)
|
||||
{
|
||||
AttributeStack& as = _attributeMap[type];
|
||||
AttributeStack& as = _attributeMap[StateAttribute::TypeMemberPair(type,member)];
|
||||
return as.global_default_attribute.get();
|
||||
}
|
||||
|
||||
/** Apply an attribute if required. */
|
||||
inline bool applyAttribute(const StateAttribute* attribute)
|
||||
{
|
||||
AttributeStack& as = _attributeMap[attribute->getType()];
|
||||
AttributeStack& as = _attributeMap[attribute->getTypeMemberPair()];
|
||||
as.changed = true;
|
||||
return applyAttribute(attribute,as);
|
||||
}
|
||||
@@ -223,14 +223,14 @@ class SG_EXPORT State : public Referenced
|
||||
inline void setGlobalDefaultTextureAttribute(unsigned int unit, const StateAttribute* attribute)
|
||||
{
|
||||
AttributeMap& attributeMap = getOrCreateTextureAttributeMap(unit);
|
||||
AttributeStack& as = attributeMap[attribute->getType()];
|
||||
AttributeStack& as = attributeMap[attribute->getTypeMemberPair()];
|
||||
as.global_default_attribute = attribute;
|
||||
}
|
||||
|
||||
inline const StateAttribute* getGlobalDefaultTextureAttribute(unsigned int unit, StateAttribute::Type type)
|
||||
inline const StateAttribute* getGlobalDefaultTextureAttribute(unsigned int unit, StateAttribute::Type type, unsigned int member = 0)
|
||||
{
|
||||
AttributeMap& attributeMap = getOrCreateTextureAttributeMap(unit);
|
||||
AttributeStack& as = attributeMap[type];
|
||||
AttributeStack& as = attributeMap[StateAttribute::TypeMemberPair(type,member)];
|
||||
return as.global_default_attribute.get();
|
||||
}
|
||||
|
||||
@@ -240,7 +240,7 @@ class SG_EXPORT State : public Referenced
|
||||
if (setActiveTextureUnit(unit))
|
||||
{
|
||||
AttributeMap& attributeMap = getOrCreateTextureAttributeMap(unit);
|
||||
AttributeStack& as = attributeMap[attribute->getType()];
|
||||
AttributeStack& as = attributeMap[attribute->getTypeMemberPair()];
|
||||
as.changed = true;
|
||||
return applyAttribute(attribute,as);
|
||||
}
|
||||
@@ -265,13 +265,13 @@ class SG_EXPORT State : public Referenced
|
||||
* then use the have_applied(attribute) method as this will cause the osg::State to
|
||||
* track the current state more accurately and enable lazy state updating such
|
||||
* that only changed state will be applied.*/
|
||||
void haveAppliedAttribute(StateAttribute::Type type);
|
||||
void haveAppliedAttribute(StateAttribute::Type type, unsigned int member=0);
|
||||
|
||||
/** Get whether the current specified mode is enabled (true) or disabled (false).*/
|
||||
bool getLastAppliedMode(StateAttribute::GLMode mode) const;
|
||||
|
||||
/** Get the current specified attribute, return NULL if one has not yet been applied.*/
|
||||
const StateAttribute* getLastAppliedAttribute(StateAttribute::Type type) const;
|
||||
const StateAttribute* getLastAppliedAttribute(StateAttribute::Type type, unsigned int member=0) const;
|
||||
|
||||
/** texture Mode has been set externally, update state to reflect this setting.*/
|
||||
void haveAppliedTextureMode(unsigned int unit, StateAttribute::GLMode mode,StateAttribute::GLModeValue value);
|
||||
@@ -290,13 +290,13 @@ class SG_EXPORT State : public Referenced
|
||||
* then use the have_applied(attribute) method as this will the osg::State to
|
||||
* track the current state more accurately and enable lazy state updating such
|
||||
* that only changed state will be applied.*/
|
||||
void haveAppliedTextureAttribute(unsigned int unit, StateAttribute::Type type);
|
||||
void haveAppliedTextureAttribute(unsigned int unit, StateAttribute::Type type, unsigned int member=0);
|
||||
|
||||
/** Get whether the current specified texture mode is enabled (true) or disabled (false).*/
|
||||
bool getLastAppliedTextureMode(unsigned int unit, StateAttribute::GLMode mode) const;
|
||||
|
||||
/** Get the current specified texture attribute, return NULL if one has not yet been applied.*/
|
||||
const StateAttribute* getLastAppliedTextureAttribute(unsigned int unit, StateAttribute::Type type) const;
|
||||
const StateAttribute* getLastAppliedTextureAttribute(unsigned int unit, StateAttribute::Type type, unsigned int member=0) const;
|
||||
|
||||
|
||||
/** Dirty the modes previously applied in osg::State.*/
|
||||
@@ -788,22 +788,22 @@ class SG_EXPORT State : public Referenced
|
||||
}
|
||||
|
||||
|
||||
typedef std::map<StateAttribute::GLMode,ModeStack> ModeMap;
|
||||
typedef std::vector<ModeMap> TextureModeMapList;
|
||||
typedef std::map<StateAttribute::GLMode,ModeStack> ModeMap;
|
||||
typedef std::vector<ModeMap> TextureModeMapList;
|
||||
|
||||
typedef std::map<StateAttribute::Type,AttributeStack> AttributeMap;
|
||||
typedef std::vector<AttributeMap> TextureAttributeMapList;
|
||||
typedef std::map<StateAttribute::TypeMemberPair,AttributeStack> AttributeMap;
|
||||
typedef std::vector<AttributeMap> TextureAttributeMapList;
|
||||
|
||||
typedef std::vector<const StateSet*> StateSetStack;
|
||||
typedef std::vector<ref_ptr<const Matrix> > MatrixStack;
|
||||
typedef std::vector<const StateSet*> StateSetStack;
|
||||
typedef std::vector<ref_ptr<const Matrix> > MatrixStack;
|
||||
|
||||
ModeMap _modeMap;
|
||||
AttributeMap _attributeMap;
|
||||
ModeMap _modeMap;
|
||||
AttributeMap _attributeMap;
|
||||
|
||||
TextureModeMapList _textureModeMapList;
|
||||
TextureAttributeMapList _textureAttributeMapList;
|
||||
TextureModeMapList _textureModeMapList;
|
||||
TextureAttributeMapList _textureAttributeMapList;
|
||||
|
||||
StateSetStack _drawStateStack;
|
||||
StateSetStack _drawStateStack;
|
||||
|
||||
struct EnabledArrayPair
|
||||
{
|
||||
@@ -860,9 +860,9 @@ class SG_EXPORT State : public Referenced
|
||||
void haveAppliedMode(ModeMap& modeMap,StateAttribute::GLMode mode,StateAttribute::GLModeValue value);
|
||||
void haveAppliedMode(ModeMap& modeMap,StateAttribute::GLMode mode);
|
||||
void haveAppliedAttribute(AttributeMap& attributeMap,const StateAttribute* attribute);
|
||||
void haveAppliedAttribute(AttributeMap& attributeMap,StateAttribute::Type type);
|
||||
void haveAppliedAttribute(AttributeMap& attributeMap,StateAttribute::Type type, unsigned int member);
|
||||
bool getLastAppliedMode(const ModeMap& modeMap,StateAttribute::GLMode mode) const;
|
||||
const StateAttribute* getLastAppliedAttribute(const AttributeMap& attributeMap,StateAttribute::Type type) const;
|
||||
const StateAttribute* getLastAppliedAttribute(const AttributeMap& attributeMap,StateAttribute::Type type, unsigned int member) const;
|
||||
|
||||
|
||||
mutable bool _isSecondaryColorSupportResolved;
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <osg/GL>
|
||||
|
||||
#include <typeinfo>
|
||||
#include <utility>
|
||||
|
||||
namespace osg {
|
||||
|
||||
@@ -128,14 +129,6 @@ class SG_EXPORT StateAttribute : public Object
|
||||
FRONTFACE,
|
||||
|
||||
LIGHT,
|
||||
LIGHT_0 =LIGHT,
|
||||
LIGHT_1,
|
||||
LIGHT_2,
|
||||
LIGHT_3,
|
||||
LIGHT_4,
|
||||
LIGHT_5,
|
||||
LIGHT_6,
|
||||
LIGHT_7,
|
||||
|
||||
POINT,
|
||||
LINEWIDTH,
|
||||
@@ -156,12 +149,6 @@ class SG_EXPORT StateAttribute : public Object
|
||||
|
||||
|
||||
CLIPPLANE,
|
||||
CLIPPLANE_0 =CLIPPLANE,
|
||||
CLIPPLANE_1,
|
||||
CLIPPLANE_2,
|
||||
CLIPPLANE_3,
|
||||
CLIPPLANE_4,
|
||||
CLIPPLANE_5,
|
||||
|
||||
COLORMATRIX,
|
||||
|
||||
@@ -178,6 +165,26 @@ class SG_EXPORT StateAttribute : public Object
|
||||
VALIDATOR,
|
||||
VIEWMATRIXEXTRACTOR,
|
||||
};
|
||||
|
||||
/** Simple pairing between an attribute type and the member within that attribute type group.*/
|
||||
typedef std::pair<Type,unsigned int> TypeMemberPair;
|
||||
|
||||
/*
|
||||
struct TypeMember
|
||||
{
|
||||
inline TypeMember(Type type, unsigned int member=0):
|
||||
_type(type),
|
||||
_member(member) {}
|
||||
|
||||
inline bool operator < (const TypeMember& tm) const
|
||||
{
|
||||
return (_type<tm._type) ? true : ( (tm._type<_type) ? false : (_member<tm._member) );
|
||||
}
|
||||
|
||||
Type _type;
|
||||
unsigned int _member;
|
||||
};
|
||||
*/
|
||||
|
||||
|
||||
StateAttribute() { setDataVariance(STATIC); }
|
||||
@@ -194,22 +201,28 @@ class SG_EXPORT StateAttribute : public Object
|
||||
Must be defined by derived classes.*/
|
||||
virtual Object* clone(const CopyOp&) const = 0;
|
||||
|
||||
/** return true if this and obj are of the same kind of object.*/
|
||||
/** Return true if this and obj are of the same kind of object.*/
|
||||
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const StateAttribute*>(obj)!=NULL; }
|
||||
|
||||
/** return the name of the attribute's library.*/
|
||||
/** Return the name of the attribute's library.*/
|
||||
virtual const char* libraryName() const { return "osg"; }
|
||||
|
||||
/** return the name of the attribute's class type.*/
|
||||
/** Return the name of the attribute's class type.*/
|
||||
virtual const char* className() const { return "StateAttribute"; }
|
||||
|
||||
/** return the Type identifier of the attribute's class type.*/
|
||||
/** Return the Type identifier of the attribute's class type.*/
|
||||
virtual Type getType() const = 0;
|
||||
|
||||
/** return true if StateAttribute is a type which controls texturing and needs to be issued w.r.t to specific texture unit.*/
|
||||
/** Return the member identifier within the attribute's class type. Used for light number/clip plane number etc.*/
|
||||
virtual unsigned int getMember() const { return 0; }
|
||||
|
||||
/** Return the TypeMemberPair that uniquely identifies this type member.*/
|
||||
inline TypeMemberPair getTypeMemberPair() const { return TypeMemberPair(getType(),getMember()); }
|
||||
|
||||
/** Return true if StateAttribute is a type which controls texturing and needs to be issued w.r.t to specific texture unit.*/
|
||||
virtual bool isTextureAttribute() const { return false; }
|
||||
|
||||
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
||||
/** Return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
||||
virtual int compare(const StateAttribute& sa) const = 0;
|
||||
|
||||
bool operator < (const StateAttribute& rhs) const { return compare(rhs)<0; }
|
||||
@@ -223,7 +236,7 @@ class SG_EXPORT StateAttribute : public Object
|
||||
virtual void usesTextureMode(GLMode mode) = 0;
|
||||
};
|
||||
|
||||
/** return the modes associated with this StateAttribute.*/
|
||||
/** Return the modes associated with this StateAttribute.*/
|
||||
virtual bool getModeUsage(ModeUsage&) const
|
||||
{
|
||||
// default to no GLMode's associated with use of the StateAttribute.
|
||||
|
||||
@@ -101,12 +101,14 @@ class SG_EXPORT StateSet : public Object
|
||||
|
||||
|
||||
/** Simple pairing between an attribute and its override flag.*/
|
||||
typedef std::pair<ref_ptr<StateAttribute>,StateAttribute::OverrideValue> RefAttributePair;
|
||||
/** a container to map StateAttribyte::Types to their respective RefAttributePair.*/
|
||||
typedef std::map<StateAttribute::Type,RefAttributePair> AttributeList;
|
||||
typedef std::pair<ref_ptr<StateAttribute>,StateAttribute::OverrideValue> RefAttributePair;
|
||||
|
||||
/** a container to map <StateAttribyte::Types,Member> to their respective RefAttributePair.*/
|
||||
typedef std::map<StateAttribute::TypeMemberPair,RefAttributePair> AttributeList;
|
||||
|
||||
/** Set this StateSet to contain specified attribute and override flag.*/
|
||||
void setAttribute(StateAttribute *attribute, StateAttribute::OverrideValue value=StateAttribute::OFF);
|
||||
|
||||
/** 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);
|
||||
|
||||
@@ -116,22 +118,22 @@ class SG_EXPORT StateSet : public Object
|
||||
void setAttributeToInherit(StateAttribute::Type type) { removeAttribute(type); }
|
||||
#endif
|
||||
/** remove attribute of specified type from StateSet.*/
|
||||
void removeAttribute(StateAttribute::Type type);
|
||||
void removeAttribute(StateAttribute::Type type, unsigned int member=0);
|
||||
|
||||
/** remove attribute from StateSet.*/
|
||||
void removeAttribute(StateAttribute *attribute);
|
||||
|
||||
/** Get specified StateAttribute for specified type.
|
||||
* Returns NULL if no type is contained within StateSet.*/
|
||||
StateAttribute* getAttribute(StateAttribute::Type type);
|
||||
StateAttribute* getAttribute(StateAttribute::Type type, unsigned int member = 0);
|
||||
|
||||
/** Get specified const StateAttribute for specified type.
|
||||
* Returns NULL if no type is contained within const StateSet.*/
|
||||
const StateAttribute* getAttribute(StateAttribute::Type type) const;
|
||||
const StateAttribute* getAttribute(StateAttribute::Type type, unsigned int member = 0) const;
|
||||
|
||||
/** Get specified RefAttributePair for specified type.
|
||||
* Returns NULL if no type is contained within StateSet.*/
|
||||
const RefAttributePair* getAttributePair(StateAttribute::Type type) const;
|
||||
const RefAttributePair* getAttributePair(StateAttribute::Type type, unsigned int member = 0) const;
|
||||
|
||||
/** return the list of all StateAttributes contained in this StateSet.*/
|
||||
inline AttributeList& getAttributeList() { return _attributeList; }
|
||||
@@ -292,9 +294,9 @@ class SG_EXPORT StateSet : public Object
|
||||
|
||||
void setAttribute(AttributeList& attributeList,StateAttribute *attribute, const StateAttribute::OverrideValue value=StateAttribute::OFF);
|
||||
|
||||
StateAttribute* getAttribute(AttributeList& attributeList,const StateAttribute::Type type);
|
||||
const StateAttribute* getAttribute(const AttributeList& attributeList,const StateAttribute::Type type) const;
|
||||
const RefAttributePair* getAttributePair(const AttributeList& attributeList,const StateAttribute::Type type) const;
|
||||
StateAttribute* getAttribute(AttributeList& attributeList,const StateAttribute::Type type, unsigned int member);
|
||||
const StateAttribute* getAttribute(const AttributeList& attributeList,const StateAttribute::Type type, unsigned int member) const;
|
||||
const RefAttributePair* getAttributePair(const AttributeList& attributeList,const StateAttribute::Type type, unsigned int member) const;
|
||||
|
||||
int _renderingHint;
|
||||
|
||||
|
||||
@@ -313,9 +313,9 @@ void State::haveAppliedAttribute(const StateAttribute* attribute)
|
||||
haveAppliedAttribute(_attributeMap,attribute);
|
||||
}
|
||||
|
||||
void State::haveAppliedAttribute(StateAttribute::Type type)
|
||||
void State::haveAppliedAttribute(StateAttribute::Type type, unsigned int member)
|
||||
{
|
||||
haveAppliedAttribute(_attributeMap,type);
|
||||
haveAppliedAttribute(_attributeMap,type,member);
|
||||
}
|
||||
|
||||
bool State::getLastAppliedMode(StateAttribute::GLMode mode) const
|
||||
@@ -323,9 +323,9 @@ bool State::getLastAppliedMode(StateAttribute::GLMode mode) const
|
||||
return getLastAppliedMode(_modeMap,mode);
|
||||
}
|
||||
|
||||
const StateAttribute* State::getLastAppliedAttribute(StateAttribute::Type type) const
|
||||
const StateAttribute* State::getLastAppliedAttribute(StateAttribute::Type type, unsigned int member) const
|
||||
{
|
||||
return getLastAppliedAttribute(_attributeMap,type);
|
||||
return getLastAppliedAttribute(_attributeMap,type,member);
|
||||
}
|
||||
|
||||
|
||||
@@ -344,9 +344,9 @@ void State::haveAppliedTextureAttribute(unsigned int unit,const StateAttribute*
|
||||
haveAppliedAttribute(getOrCreateTextureAttributeMap(unit),attribute);
|
||||
}
|
||||
|
||||
void State::haveAppliedTextureAttribute(unsigned int unit,StateAttribute::Type type)
|
||||
void State::haveAppliedTextureAttribute(unsigned int unit,StateAttribute::Type type, unsigned int member)
|
||||
{
|
||||
haveAppliedAttribute(getOrCreateTextureAttributeMap(unit),type);
|
||||
haveAppliedAttribute(getOrCreateTextureAttributeMap(unit),type,member);
|
||||
}
|
||||
|
||||
bool State::getLastAppliedTextureMode(unsigned int unit,StateAttribute::GLMode mode) const
|
||||
@@ -355,10 +355,10 @@ bool State::getLastAppliedTextureMode(unsigned int unit,StateAttribute::GLMode m
|
||||
return getLastAppliedMode(_textureModeMapList[unit],mode);
|
||||
}
|
||||
|
||||
const StateAttribute* State::getLastAppliedTextureAttribute(unsigned int unit,StateAttribute::Type type) const
|
||||
const StateAttribute* State::getLastAppliedTextureAttribute(unsigned int unit,StateAttribute::Type type, unsigned int member) const
|
||||
{
|
||||
if (unit>=_textureAttributeMapList.size()) return false;
|
||||
return getLastAppliedAttribute(_textureAttributeMapList[unit],type);
|
||||
return getLastAppliedAttribute(_textureAttributeMapList[unit],type,member);
|
||||
}
|
||||
|
||||
|
||||
@@ -390,7 +390,7 @@ void State::haveAppliedAttribute(AttributeMap& attributeMap,const StateAttribute
|
||||
{
|
||||
if (attribute)
|
||||
{
|
||||
AttributeStack& as = attributeMap[attribute->getType()];
|
||||
AttributeStack& as = attributeMap[attribute->getTypeMemberPair()];
|
||||
|
||||
as.last_applied_attribute = attribute;
|
||||
|
||||
@@ -399,10 +399,10 @@ void State::haveAppliedAttribute(AttributeMap& attributeMap,const StateAttribute
|
||||
}
|
||||
}
|
||||
|
||||
void State::haveAppliedAttribute(AttributeMap& attributeMap,StateAttribute::Type type)
|
||||
void State::haveAppliedAttribute(AttributeMap& attributeMap,StateAttribute::Type type, unsigned int member)
|
||||
{
|
||||
|
||||
AttributeMap::iterator itr = attributeMap.find(type);
|
||||
AttributeMap::iterator itr = attributeMap.find(StateAttribute::TypeMemberPair(type,member));
|
||||
if (itr!=attributeMap.end())
|
||||
{
|
||||
AttributeStack& as = itr->second;
|
||||
@@ -427,9 +427,9 @@ bool State::getLastAppliedMode(const ModeMap& modeMap,StateAttribute::GLMode mod
|
||||
}
|
||||
}
|
||||
|
||||
const StateAttribute* State::getLastAppliedAttribute(const AttributeMap& attributeMap,StateAttribute::Type type) const
|
||||
const StateAttribute* State::getLastAppliedAttribute(const AttributeMap& attributeMap,StateAttribute::Type type, unsigned int member) const
|
||||
{
|
||||
AttributeMap::const_iterator itr = attributeMap.find(type);
|
||||
AttributeMap::const_iterator itr = attributeMap.find(StateAttribute::TypeMemberPair(type,member));
|
||||
if (itr!=attributeMap.end())
|
||||
{
|
||||
const AttributeStack& as = itr->second;
|
||||
|
||||
@@ -85,10 +85,10 @@ StateSet::StateSet(const StateSet& rhs,const CopyOp& copyop):Object(rhs,copyop)
|
||||
itr!=rhs._attributeList.end();
|
||||
++itr)
|
||||
{
|
||||
StateAttribute::Type type = itr->first;
|
||||
const StateAttribute::TypeMemberPair& typemember = itr->first;
|
||||
const RefAttributePair& rap = itr->second;
|
||||
StateAttribute* attr = copyop(rap.first.get());
|
||||
if (attr) _attributeList[type]=RefAttributePair(attr,rap.second);
|
||||
if (attr) _attributeList[typemember]=RefAttributePair(attr,rap.second);
|
||||
}
|
||||
|
||||
// copy texture related modes.
|
||||
@@ -107,10 +107,10 @@ StateSet::StateSet(const StateSet& rhs,const CopyOp& copyop):Object(rhs,copyop)
|
||||
itr!=rhs_attributeList.end();
|
||||
++itr)
|
||||
{
|
||||
StateAttribute::Type type = itr->first;
|
||||
const StateAttribute::TypeMemberPair& typemember = itr->first;
|
||||
const RefAttributePair& rap = itr->second;
|
||||
StateAttribute* attr = copyop(rap.first.get());
|
||||
if (attr) lhs_attributeList[type]=RefAttributePair(attr,rap.second);
|
||||
if (attr) lhs_attributeList[typemember]=RefAttributePair(attr,rap.second);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -592,9 +592,9 @@ void StateSet::setAttributeAndModes(StateAttribute *attribute, StateAttribute::G
|
||||
}
|
||||
}
|
||||
|
||||
void StateSet::removeAttribute(StateAttribute::Type type)
|
||||
void StateSet::removeAttribute(StateAttribute::Type type, unsigned int member)
|
||||
{
|
||||
AttributeList::iterator itr = _attributeList.find(type);
|
||||
AttributeList::iterator itr = _attributeList.find(StateAttribute::TypeMemberPair(type,member));
|
||||
if (itr!=_attributeList.end())
|
||||
{
|
||||
setAssociatedModes(itr->second.first.get(),StateAttribute::INHERIT);
|
||||
@@ -606,7 +606,7 @@ void StateSet::removeAttribute(StateAttribute* attribute)
|
||||
{
|
||||
if (!attribute) return;
|
||||
|
||||
AttributeList::iterator itr = _attributeList.find(attribute->getType());
|
||||
AttributeList::iterator itr = _attributeList.find(attribute->getTypeMemberPair());
|
||||
if (itr!=_attributeList.end())
|
||||
{
|
||||
if (itr->second.first != attribute) return;
|
||||
@@ -616,19 +616,19 @@ void StateSet::removeAttribute(StateAttribute* attribute)
|
||||
}
|
||||
}
|
||||
|
||||
StateAttribute* StateSet::getAttribute(StateAttribute::Type type)
|
||||
StateAttribute* StateSet::getAttribute(StateAttribute::Type type, unsigned int member)
|
||||
{
|
||||
return getAttribute(_attributeList,type);
|
||||
return getAttribute(_attributeList,type,member);
|
||||
}
|
||||
|
||||
const StateAttribute* StateSet::getAttribute(StateAttribute::Type type) const
|
||||
const StateAttribute* StateSet::getAttribute(StateAttribute::Type type, unsigned int member) const
|
||||
{
|
||||
return getAttribute(_attributeList,type);
|
||||
return getAttribute(_attributeList,type,member);
|
||||
}
|
||||
|
||||
const StateSet::RefAttributePair* StateSet::getAttributePair(StateAttribute::Type type) const
|
||||
const StateSet::RefAttributePair* StateSet::getAttributePair(StateAttribute::Type type, unsigned int member) const
|
||||
{
|
||||
return getAttributePair(_attributeList,type);
|
||||
return getAttributePair(_attributeList,type,member);
|
||||
}
|
||||
|
||||
void StateSet::setTextureMode(unsigned int unit,StateAttribute::GLMode mode, StateAttribute::GLModeValue value)
|
||||
@@ -733,7 +733,7 @@ void StateSet::removeTextureAttribute(unsigned int unit,StateAttribute::Type typ
|
||||
{
|
||||
if (unit>=_textureAttributeList.size()) return;
|
||||
AttributeList& attributeList = _textureAttributeList[unit];
|
||||
AttributeList::iterator itr = attributeList.find(type);
|
||||
AttributeList::iterator itr = attributeList.find(StateAttribute::TypeMemberPair(type,0));
|
||||
if (itr!=attributeList.end())
|
||||
{
|
||||
if (unit<_textureModeList.size())
|
||||
@@ -748,21 +748,21 @@ void StateSet::removeTextureAttribute(unsigned int unit,StateAttribute::Type typ
|
||||
StateAttribute* StateSet::getTextureAttribute(unsigned int unit,StateAttribute::Type type)
|
||||
{
|
||||
if (unit>=_textureAttributeList.size()) return 0;
|
||||
return getAttribute(_textureAttributeList[unit],type);
|
||||
return getAttribute(_textureAttributeList[unit],type,0);
|
||||
}
|
||||
|
||||
|
||||
const StateAttribute* StateSet::getTextureAttribute(unsigned int unit,StateAttribute::Type type) const
|
||||
{
|
||||
if (unit>=_textureAttributeList.size()) return 0;
|
||||
return getAttribute(_textureAttributeList[unit],type);
|
||||
return getAttribute(_textureAttributeList[unit],type,0);
|
||||
}
|
||||
|
||||
|
||||
const StateSet::RefAttributePair* StateSet::getTextureAttributePair(unsigned int unit,StateAttribute::Type type) const
|
||||
{
|
||||
if (unit>=_textureAttributeList.size()) return 0;
|
||||
return getAttributePair(_textureAttributeList[unit],type);
|
||||
return getAttributePair(_textureAttributeList[unit],type,0);
|
||||
}
|
||||
|
||||
|
||||
@@ -921,14 +921,14 @@ void StateSet::setAttribute(AttributeList& attributeList,StateAttribute *attribu
|
||||
{
|
||||
if (attribute)
|
||||
{
|
||||
attributeList[attribute->getType()] = RefAttributePair(attribute,value&(StateAttribute::OVERRIDE|StateAttribute::PROTECTED));
|
||||
attributeList[attribute->getTypeMemberPair()] = RefAttributePair(attribute,value&(StateAttribute::OVERRIDE|StateAttribute::PROTECTED));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
StateAttribute* StateSet::getAttribute(AttributeList& attributeList,StateAttribute::Type type)
|
||||
StateAttribute* StateSet::getAttribute(AttributeList& attributeList,StateAttribute::Type type, unsigned int member)
|
||||
{
|
||||
AttributeList::iterator itr = attributeList.find(type);
|
||||
AttributeList::iterator itr = attributeList.find(StateAttribute::TypeMemberPair(type,member));
|
||||
if (itr!=attributeList.end())
|
||||
{
|
||||
return itr->second.first.get();
|
||||
@@ -937,9 +937,9 @@ StateAttribute* StateSet::getAttribute(AttributeList& attributeList,StateAttribu
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const StateAttribute* StateSet::getAttribute(const AttributeList& attributeList,StateAttribute::Type type) const
|
||||
const StateAttribute* StateSet::getAttribute(const AttributeList& attributeList,StateAttribute::Type type, unsigned int member) const
|
||||
{
|
||||
AttributeList::const_iterator itr = attributeList.find(type);
|
||||
AttributeList::const_iterator itr = attributeList.find(StateAttribute::TypeMemberPair(type,member));
|
||||
if (itr!=attributeList.end())
|
||||
{
|
||||
return itr->second.first.get();
|
||||
@@ -948,9 +948,9 @@ const StateAttribute* StateSet::getAttribute(const AttributeList& attributeList,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const StateSet::RefAttributePair* StateSet::getAttributePair(const AttributeList& attributeList,StateAttribute::Type type) const
|
||||
const StateSet::RefAttributePair* StateSet::getAttributePair(const AttributeList& attributeList,StateAttribute::Type type, unsigned int member) const
|
||||
{
|
||||
AttributeList::const_iterator itr = attributeList.find(type);
|
||||
AttributeList::const_iterator itr = attributeList.find(StateAttribute::TypeMemberPair(type,member));
|
||||
if (itr!=attributeList.end())
|
||||
{
|
||||
return &(itr->second);
|
||||
|
||||
Reference in New Issue
Block a user