Changed the naming and calling convention of the new Drawable::AttributeFunctor
and have updated GeoSet to use mutable values for the _numverts etc, allowing osg::GeoSet::computeNumVerts() to be a const operation. osg::GeoSet::getNumVerts is now a const once more, so avoiding compilation problems. Also chaned the new osgconv orientation code to use a Drawable::AttributeFunctor so it can work on other Drawables other than just GeoSets.
This commit is contained in:
@@ -141,22 +141,30 @@ class SG_EXPORT Drawable : public Object
|
||||
TEXTURE_COORDS_3 = 0x64
|
||||
};
|
||||
|
||||
struct AttributeUpdateFunctor
|
||||
class AttributeFunctor
|
||||
{
|
||||
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); }
|
||||
|
||||
public:
|
||||
|
||||
AttributeFunctor(AttributeBitMask abm):_abm(abm) {}
|
||||
virtual ~AttributeFunctor() {}
|
||||
|
||||
void setAttributeBitMask(AttributeBitMask abm) { _abm=abm; }
|
||||
AttributeBitMask getAttributeBitMask() const { return _abm; }
|
||||
|
||||
virtual bool apply(AttributeBitMask,Vec2*,Vec2*) { return false; }
|
||||
virtual bool apply(AttributeBitMask,Vec3*,Vec3*) { return false; }
|
||||
virtual bool apply(AttributeBitMask,Vec4*,Vec4*) { return false; }
|
||||
|
||||
protected:
|
||||
|
||||
AttributeBitMask _abm;
|
||||
};
|
||||
|
||||
/** return the attributes supported by applyAttrbuteUpdate() as an AttributeBitMask.*/
|
||||
virtual AttributeBitMask suppportsAttributeUpdate() const { return (AttributeBitMask)0; }
|
||||
/** return the attributes supported by applyAttrbuteOperation() as an AttributeBitMask.*/
|
||||
virtual AttributeBitMask suppportsAttributeOperation() const { return (AttributeBitMask)0; }
|
||||
|
||||
/** return the attributes successully applied in applyAttributeUpdate.*/
|
||||
virtual AttributeBitMask applyAttributeUpdate(AttributeBitMask,AttributeUpdateFunctor&) { return (AttributeBitMask)0; }
|
||||
virtual AttributeBitMask applyAttributeOperation(AttributeFunctor&) { return 0; }
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
@@ -70,7 +70,7 @@ class SG_EXPORT GeoSet : public Drawable
|
||||
struct IndexPointer
|
||||
{
|
||||
|
||||
uint _size;
|
||||
mutable uint _size;
|
||||
bool _is_ushort;
|
||||
union
|
||||
{
|
||||
@@ -160,11 +160,11 @@ class SG_EXPORT GeoSet : public Drawable
|
||||
inline int *getPrimLengths() { return _primLengths; }
|
||||
inline const int *getPrimLengths() const { return _primLengths; }
|
||||
|
||||
void computeNumVerts();
|
||||
void computeNumVerts() const;
|
||||
|
||||
/** get the number of coords required by the defined primitives. */
|
||||
// inline const int getNumCoords() const
|
||||
inline const int getNumCoords()
|
||||
inline const int getNumCoords() const
|
||||
{ if( _numcoords == 0 ) computeNumVerts(); return _numcoords; }
|
||||
/** get a pointer to Vec3 coord array. */
|
||||
inline Vec3* getCoords() { return _coords; }
|
||||
@@ -292,10 +292,10 @@ class SG_EXPORT GeoSet : public Drawable
|
||||
|
||||
|
||||
/** return the attributes supported by applyAttrbuteUpdate() as an AttributeBitMask.*/
|
||||
virtual AttributeBitMask suppportsAttributeUpdate() const;
|
||||
virtual AttributeBitMask suppportsAttributeOperation() const;
|
||||
|
||||
/** return the attributes successully applied in applyAttributeUpdate.*/
|
||||
virtual AttributeBitMask applyAttributeUpdate(AttributeBitMask abm,AttributeUpdateFunctor& auf);
|
||||
virtual AttributeBitMask applyAttributeOperation(AttributeFunctor& auf);
|
||||
|
||||
|
||||
protected:
|
||||
@@ -312,25 +312,25 @@ class SG_EXPORT GeoSet : public Drawable
|
||||
int _needprimlen;
|
||||
unsigned int _oglprimtype;
|
||||
int *_primLengths;
|
||||
unsigned char _primlength;
|
||||
mutable unsigned char _primlength;
|
||||
unsigned char _flat_shaded_skip;
|
||||
|
||||
int _numcoords;
|
||||
mutable int _numcoords;
|
||||
Vec3 *_coords;
|
||||
IndexPointer _cindex;
|
||||
|
||||
BindingType _normal_binding;
|
||||
int _numnormals;
|
||||
mutable int _numnormals;
|
||||
Vec3 *_normals;
|
||||
IndexPointer _nindex;
|
||||
|
||||
BindingType _color_binding;
|
||||
int _numcolors;
|
||||
mutable int _numcolors;
|
||||
Vec4 *_colors;
|
||||
IndexPointer _colindex;
|
||||
|
||||
BindingType _texture_binding;
|
||||
int _numtcoords;
|
||||
mutable int _numtcoords;
|
||||
Vec2 *_tcoords;
|
||||
IndexPointer _tindex;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user