diff --git a/include/osg/Drawable b/include/osg/Drawable index e7bff0823..99f5d463f 100644 --- a/include/osg/Drawable +++ b/include/osg/Drawable @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -75,7 +76,9 @@ class SG_EXPORT Drawable : public Object void dirtyDisplayList(); - + /** Dirty the bounding box, forcing a computeBound() on the next call + * to getBound(). Should be called in the internal geometry of the Drawable + * is modified.*/ inline void dirtyBound() { _bbox_computed = false; } /** get bounding box of geoset. @@ -124,7 +127,9 @@ class SG_EXPORT Drawable : public Object virtual bool getStats(Statistics&) { return false; } - enum AttributeBitMask + typedef uint AttributeBitMask; + + enum AttributeBitMaskValues { COORDS = 0x1, NORMALS = 0x2, @@ -138,14 +143,20 @@ class SG_EXPORT Drawable : public Object struct AttributeUpdateFunctor { - virtual bool apply(AttributeBitMask abm,Vec2* begin,Vec2* end) { return false; } - virtual bool apply(AttributeBitMask abm,Vec3* begin,Vec3* end) { return false; } - virtual bool apply(AttributeBitMask abm,Vec4* begin,Vec4* end) { return false; } + inline bool apply(AttributeBitMask abm,Vec2& vec) { return apply(abm,&vec,(&vec)+1); } + inline bool apply(AttributeBitMask abm,Vec3& vec) { return apply(abm,&vec,(&vec)+1); } + inline bool apply(AttributeBitMask abm,Vec4& vec) { return apply(abm,&vec,(&vec)+1); } + + virtual bool apply(AttributeBitMask,Vec2*,Vec2*) { return false; } + virtual bool apply(AttributeBitMask,Vec3*,Vec3*) { return false; } + virtual bool apply(AttributeBitMask,Vec4*,Vec4*) { return false; } }; - virtual bool suppportsAttributeUpdate(AttributeBitMask) { return false; } + /** return the attributes supported by applyAttrbuteUpdate() as an AttributeBitMask.*/ + virtual AttributeBitMask suppportsAttributeUpdate() const { return (AttributeBitMask)0; } - virtual bool applyAttributeUpdate(AttributeBitMask,AttributeUpdateFunctor&) { return false; } + /** return the attributes successully applied in applyAttributeUpdate.*/ + virtual AttributeBitMask applyAttributeUpdate(AttributeBitMask,AttributeUpdateFunctor&) { return (AttributeBitMask)0; } protected: diff --git a/include/osg/GeoSet b/include/osg/GeoSet index 5a5d18b65..0b0b91f23 100644 --- a/include/osg/GeoSet +++ b/include/osg/GeoSet @@ -288,6 +288,14 @@ class SG_EXPORT GeoSet : public Drawable const bool check() const; + + /** return the attributes supported by applyAttrbuteUpdate() as an AttributeBitMask.*/ + virtual AttributeBitMask suppportsAttributeUpdate() const; + + /** return the attributes successully applied in applyAttributeUpdate.*/ + virtual AttributeBitMask applyAttributeUpdate(AttributeBitMask abm,AttributeUpdateFunctor& auf); + + protected: GeoSet(const GeoSet&):Drawable() {} diff --git a/include/osg/Vec2 b/include/osg/Vec2 index bfbd5c796..adf1c9638 100644 --- a/include/osg/Vec2 +++ b/include/osg/Vec2 @@ -32,9 +32,11 @@ class Vec2 float _v[2]; - const bool operator == (const Vec2& v) const { return _v[0]==v._v[0] && _v[1]==v._v[1]; } + inline const bool operator == (const Vec2& v) const { return _v[0]==v._v[0] && _v[1]==v._v[1]; } - const bool operator < (const Vec2& v) const + inline const bool operator != (const Vec2& v) const { return _v[0]!=v._v[0] || _v[1]!=v._v[1]; } + + inline const bool operator < (const Vec2& v) const { if (_v[0]v._v[0]) return false; diff --git a/include/osg/Vec3 b/include/osg/Vec3 index bdb7032a2..c08f053ce 100644 --- a/include/osg/Vec3 +++ b/include/osg/Vec3 @@ -33,6 +33,8 @@ class Vec3 inline const bool operator == (const Vec3& v) const { return _v[0]==v._v[0] && _v[1]==v._v[1] && _v[2]==v._v[2]; } + inline const bool operator != (const Vec3& v) const { return _v[0]!=v._v[0] || _v[1]!=v._v[1] || _v[2]!=v._v[2]; } + inline const bool operator < (const Vec3& v) const { if (_v[0]