Added osg::State::getCurrentMode and osg::State::getCurrentAttribute().
Aded osg::clampAbove(..) and osg::clampBelow() template functions to include/osg/Math.
This commit is contained in:
parent
a57eae47f6
commit
b8d8a8be27
@ -73,6 +73,12 @@ const double PI_4 = 0.78539816339744830962;
|
||||
template<typename T>
|
||||
inline T clampTo(T v,T minimum,T maximum) { return v<minimum?minimum:v>maximum?maximum:v; }
|
||||
|
||||
template<typename T>
|
||||
inline T clampAbove(T v,T minimum) { return v<minimum?minimum:v; }
|
||||
|
||||
template<typename T>
|
||||
inline T clampBelow(T v,T maximum) { return v>maximum?maximum:v; }
|
||||
|
||||
template<typename T>
|
||||
inline T sign(T v) { return v<0?-1:1; }
|
||||
|
||||
|
@ -53,20 +53,6 @@ class SG_EXPORT State : public Referenced
|
||||
/** reset the state object to an empty stack.*/
|
||||
void reset();
|
||||
|
||||
|
||||
/** apply an OpenGL mode if required. */
|
||||
inline const bool applyMode(const StateAttribute::GLMode mode,const bool enabled)
|
||||
{
|
||||
return applyMode(mode,enabled,_modeMap[mode]);
|
||||
}
|
||||
|
||||
|
||||
/** apply an attribute if required. */
|
||||
inline const bool applyAttribute(const StateAttribute* attribute)
|
||||
{
|
||||
return applyAttribute(attribute,_attributeMap[attribute->getType()]);
|
||||
}
|
||||
|
||||
inline void applyProjectionMatrix(const osg::Matrix* matrix)
|
||||
{
|
||||
if (_projection!=matrix)
|
||||
@ -117,23 +103,39 @@ class SG_EXPORT State : public Referenced
|
||||
ClippingVolume getClippingVolume() const;
|
||||
|
||||
|
||||
/** apply stateset.*/
|
||||
|
||||
/** Apply stateset.*/
|
||||
void apply(const StateSet* dstate);
|
||||
|
||||
/** apply the state.*/
|
||||
/** Apply the state.*/
|
||||
void apply();
|
||||
|
||||
|
||||
/** Apply an OpenGL mode if required. */
|
||||
inline const bool applyMode(const StateAttribute::GLMode mode,const bool enabled)
|
||||
{
|
||||
return applyMode(mode,enabled,_modeMap[mode]);
|
||||
}
|
||||
|
||||
|
||||
/** Apply an attribute if required. */
|
||||
inline const bool applyAttribute(const StateAttribute* attribute)
|
||||
{
|
||||
return applyAttribute(attribute,_attributeMap[attribute->getType()]);
|
||||
}
|
||||
|
||||
|
||||
/** mode has been set externally, update state to reflect this setting.*/
|
||||
/** Mode has been set externally, update state to reflect this setting.*/
|
||||
void haveAppliedMode(const StateAttribute::GLMode mode,const StateAttribute::GLModeValue value);
|
||||
|
||||
/** mode has been set externally, therefore dirty the associated mode in osg::State
|
||||
/** Mode has been set externally, therefore dirty the associated mode in osg::State
|
||||
* so it is applied on next call to osg::State::apply(..)*/
|
||||
void haveAppliedMode(const StateAttribute::GLMode mode);
|
||||
|
||||
/** attribute has been applied externally, update state to reflect this setting.*/
|
||||
/** Attribute has been applied externally, update state to reflect this setting.*/
|
||||
void haveAppliedAttribute(const StateAttribute* attribute);
|
||||
|
||||
/** attribute has been applied externally,
|
||||
/** Attribute has been applied externally,
|
||||
* and therefore this attribute type has been dirtied
|
||||
* and will need to be re-appplied on next osg::State.apply(..).
|
||||
* note, if you have an osg::StateAttribute which you have applied externally
|
||||
@ -142,6 +144,12 @@ class SG_EXPORT State : public Referenced
|
||||
* that only changed state will be applied.*/
|
||||
void haveAppliedAttribute(const StateAttribute::Type type);
|
||||
|
||||
/** Get whether the current specified mode is enabled (true) or disabled (false).*/
|
||||
const bool getCurrentMode(const StateAttribute::GLMode mode) const;
|
||||
|
||||
/** Get the current specified attribute, return NULL is one has not yet been applied.*/
|
||||
const StateAttribute* getCurrentAttribute(const StateAttribute::Type type) const;
|
||||
|
||||
|
||||
/** Set the current OpenGL context uniqueID.
|
||||
Note, it is the application developers responsibility to
|
||||
|
@ -563,7 +563,6 @@ void State::haveAppliedAttribute(const StateAttribute::Type type)
|
||||
if (itr!=_attributeMap.end())
|
||||
{
|
||||
AttributeStack& as = itr->second;
|
||||
|
||||
as.last_applied_attribute = 0L;
|
||||
|
||||
// will need to update this attribute on next apply so set it to changed.
|
||||
@ -571,6 +570,35 @@ void State::haveAppliedAttribute(const StateAttribute::Type type)
|
||||
}
|
||||
}
|
||||
|
||||
const bool State::getCurrentMode(const StateAttribute::GLMode mode) const
|
||||
{
|
||||
ModeMap::const_iterator itr = _modeMap.find(mode);
|
||||
if (itr!=_modeMap.end())
|
||||
{
|
||||
const ModeStack& ms = itr->second;
|
||||
return ms.last_applied_value;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
const StateAttribute* State::getCurrentAttribute(const StateAttribute::Type type) const
|
||||
{
|
||||
AttributeMap::const_iterator itr = _attributeMap.find(type);
|
||||
if (itr!=_attributeMap.end())
|
||||
{
|
||||
const AttributeStack& as = itr->second;
|
||||
return as.last_applied_attribute;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ClippingVolume State::getClippingVolume() const
|
||||
{
|
||||
ClippingVolume cv;
|
||||
|
Loading…
Reference in New Issue
Block a user