OpenSceneGraph/include/osg/GeoSet

708 lines
28 KiB
Plaintext
Raw Normal View History

2002-07-17 04:07:32 +08:00
//C++ header - Open Scene Graph - Copyright (C) 1998-2002 Robert Osfield
//Distributed under the terms of the GNU Library General Public License (LGPL)
//as published by the Free Software Foundation.
2001-01-11 00:32:10 +08:00
#ifndef OSG_GEOSET
#define OSG_GEOSET 1
2002-04-14 06:19:29 +08:00
#include <osg/Drawable>
2001-01-11 00:32:10 +08:00
#include <osg/Vec2>
#include <osg/Vec3>
#include <osg/Vec4>
2001-01-11 00:32:10 +08:00
namespace osg {
// forward declare so that we don't need to include the header.
class Geometry;
/** Note, osg::GeoSet is now deprecated, please use osg::Geometry instead.
osg::GeoSet will be kept through to the beta release for
backwards compatability only.
Encapsulates OpenGL drawing primitives, geometry and
2001-01-11 00:32:10 +08:00
optional binding of normal, color and texture coordinates. Used
for representing the visible objects in the scene. State attributes
for a GeoSet are maintained in StateSet which the GeoSet maintains
a referenced counted pointer to. Both GeoSet's and StateSet's can
2001-01-11 00:32:10 +08:00
be shared for optimal memory usage and graphics performance.
*/
class SG_EXPORT GeoSet : public Drawable
2001-01-11 00:32:10 +08:00
{
public:
2001-01-11 00:32:10 +08:00
enum PrimitiveType {
NO_TYPE,
POINTS,
LINES,
LINE_STRIP,
FLAT_LINE_STRIP,
LINE_LOOP,
TRIANGLES,
TRIANGLE_STRIP,
FLAT_TRIANGLE_STRIP,
TRIANGLE_FAN,
FLAT_TRIANGLE_FAN,
QUADS,
QUAD_STRIP,
POLYGON
};
enum BindingType {
BIND_OFF,
BIND_OVERALL,
BIND_PERPRIM,
BIND_PERVERTEX,
BIND_DEFAULT
};
enum InterleaveArrayType {
IA_OFF,
IA_V2F,
IA_V3F,
IA_C4UB_V2F,
IA_C4UB_V3F,
IA_C3F_V3F,
IA_N3F_V3F,
IA_C4F_N3F_V3F,
IA_T2F_V3F,
IA_T4F_V4F,
IA_T2F_C4UB_V3F,
IA_T2F_C3F_V3F,
IA_T2F_N3F_V3F,
IA_T2F_C4F_N3F_V3F,
IA_T4F_C4F_N3F_V4F
};
struct IndexPointer
{
mutable uint _size;
bool _is_ushort;
union
{
GLushort* _ushort;
GLuint* _uint;
} _ptr;
IndexPointer() { _size=0;_is_ushort=true;_ptr._ushort = (GLushort*)0; }
inline bool operator == (const IndexPointer& ip) const
{
return _size == ip._size &&
_is_ushort == ip._is_ushort &&
_ptr._ushort == ip._ptr._ushort;
}
inline bool valid() const
{
return _ptr._ushort != (GLushort*)0;
}
inline bool null() const
{
return _ptr._ushort == (GLushort*)0;
}
inline void setToNull()
{
_size = 0;
_is_ushort = true;
_ptr._ushort = (GLushort*)0;
}
inline void set(uint size,GLushort* data)
{
_size = size;
_is_ushort = true;
_ptr._ushort = data;
}
void set(uint size,GLuint* data)
{
_size = size;
_is_ushort = false;
_ptr._uint = data;
}
inline uint maxIndex() const
{
uint max = 0;
if (_is_ushort)
{
for(uint ai = 0; ai < _size; ai++ )
if( _ptr._ushort[ai] > max ) max = _ptr._ushort[ai];
}
else
{
for(uint ai = 0; ai < _size; ai++ )
if( _ptr._uint[ai] > max ) max = _ptr._uint[ai];
}
return max;
}
inline GLint operator [] (const GLuint pos) const
{
if (_is_ushort) return _ptr._ushort[pos];
else return _ptr._uint[pos];
}
};
2001-01-11 00:32:10 +08:00
GeoSet();
/** Copy constructor using CopyOp to manage deep vs shallow copy.*/
GeoSet(const GeoSet& geoset,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
virtual Object* cloneType() const { return osgNew GeoSet(); }
virtual Object* clone(const CopyOp& copyop) const { return osgNew GeoSet(*this,copyop); }
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const GeoSet*>(obj)!=NULL; }
virtual const char* libraryName() const { return "osg"; }
virtual const char* className() const { return "GeoSet"; }
2001-01-11 00:32:10 +08:00
// data access methods.
inline void setNumPrims( int n ) { _numprims = n; _numcoords=0;}
inline int getNumPrims() const { return _numprims; }
2001-01-11 00:32:10 +08:00
void setPrimType( PrimitiveType type );
inline PrimitiveType getPrimType() const { return _primtype; }
2001-01-11 00:32:10 +08:00
inline void setPrimLengths( int *lens ) { _primLengths = lens; }
inline int *getPrimLengths() { return _primLengths; }
inline int *getPrimLengths() const { return _primLengths; }
2001-01-11 00:32:10 +08:00
void computeNumVerts() const;
2001-01-11 00:32:10 +08:00
/** get the number of coords required by the defined primitives. */
inline int getNumCoords() const
{ if( _numcoords == 0 ) computeNumVerts(); return _numcoords; }
2001-01-11 00:32:10 +08:00
/** get a pointer to Vec3 coord array. */
inline Vec3* getCoords() { return _coords; }
/** get a const pointer to Vec3 coord array. */
inline const Vec3* getCoords() const { return _coords; }
2001-01-11 00:32:10 +08:00
/** get the number of indices required by the defined primitives. */
inline int getNumCoordIndices() const { return _cindex._size; }
2001-01-11 00:32:10 +08:00
/** get the coord index array. */
inline IndexPointer& getCoordIndices() { return _cindex; }
/** get the const coord index array. */
inline const IndexPointer& getCoordIndices() const { return _cindex; }
2001-01-11 00:32:10 +08:00
/** set the coords (i.e the geometry) of the geoset.*/
void setCoords( Vec3 *cp );
/** set the coords (i.e the geometry) and ushort indices of the geoset.
To reduce memory footprint and bandwidth for small datasets it is
recommended the ushort indices are used instead of unit indices.*/
void setCoords( Vec3 *cp, GLushort *ci );
/** set the coords (i.e the geometry) and uint indices of the geoset.
Unless your data set exceeds 65536 indices prefer ushort indices
over uint indices, only use this unit indices version if necessary.*/
void setCoords( Vec3 *cp, GLuint *ci );
/** set the coords (i.e the geometry) and indices of the geoset.*/
void setCoords( Vec3 *cp, IndexPointer& ip );
2001-01-11 00:32:10 +08:00
/** get the number of normals required by the defined primitives and normals binding.*/
inline int getNumNormals() const { return _numnormals; }
2001-01-11 00:32:10 +08:00
/** get a pointer to Vec3 normal array. */
inline Vec3* getNormals() { return _normals; }
/** get a const pointer to Vec3 normal array. */
inline const Vec3* getNormals() const { return _normals; }
2001-01-11 00:32:10 +08:00
/** get the number of normal indices required by the defined primitives and normals binding.*/
inline int getNumNormalIndices() const { return _nindex._size; }
2001-01-11 00:32:10 +08:00
/** get the normal index array. */
inline IndexPointer& getNormalIndices() { return _nindex; }
/** get the const normal index array. */
inline const IndexPointer& getNormalIndices() const { return _nindex; }
2001-01-11 00:32:10 +08:00
/** set the normals of the geoset.*/
void setNormals( Vec3 *np );
/** set the normals and normal indices of the geoset.*/
void setNormals( Vec3 *np, GLushort *ni );
/** set the normals and normal indices of the geoset.*/
void setNormals( Vec3 *np, GLuint *ni );
/** set the normals and normal indices of the geoset.*/
void setNormals( Vec3 *np, IndexPointer& ip );
2001-01-11 00:32:10 +08:00
/** set the normals binding to the vertices/primitives/overall.*/
void setNormalBinding( BindingType binding );
inline BindingType getNormalBinding() const { return _normal_binding; }
2001-01-11 00:32:10 +08:00
/** get the number of colors required by the defined primitives and color binding.*/
inline int getNumColors() const { return _numcolors; }
2001-01-11 00:32:10 +08:00
/** get a pointer to Vec4 color array. */
inline Vec4* getColors() { return _colors; }
/** get a pointer to Vec4 color array. */
inline const Vec4* getColors() const { return _colors; }
2001-01-11 00:32:10 +08:00
/** get the number of colors indices required by the defined primitives and color binding.*/
inline int getNumColorIndices() const { return _colindex._size; }
2001-01-11 00:32:10 +08:00
/** get the color index array. */
inline IndexPointer& getColorIndices() { return _colindex; }
/** get the const color index array. */
inline const IndexPointer& getColorIndices() const { return _colindex; }
2001-01-11 00:32:10 +08:00
/** set the colors of the geoset.*/
void setColors( Vec4 *cp );
/** set the colors and color indices of the geoset.*/
void setColors( Vec4 *cp, GLushort *li );
/** set the colors and color indices of the geoset.*/
void setColors( Vec4 *cp, GLuint *li );
2001-01-11 00:32:10 +08:00
/** set the colors and color indices of the geoset.*/
void setColors( Vec4 *cp, IndexPointer& ip );
2001-01-11 00:32:10 +08:00
/** set the color binding to the vertices/primitives/overall.*/
void setColorBinding( BindingType binding );
inline BindingType getColorBinding() const { return _color_binding; }
2001-01-11 00:32:10 +08:00
/** get the number of texture coords required by the defined primitives and textures binding.*/
inline int getNumTextureCoords() const { return _numtcoords; }
2001-01-11 00:32:10 +08:00
/** get a pointer to Vec4 color array. */
inline Vec2* getTextureCoords() { return _tcoords; }
/** get a pointer to Vec4 color array. */
inline const Vec2* getTextureCoords() const { return _tcoords; }
2001-01-11 00:32:10 +08:00
/** get the number of texture coord indices required by the defined primitives and texture binding.*/
inline int getNumTextureIndices() const { return _tindex._size; }
/** get the texture index array. */
inline IndexPointer& getTextureIndices() { return _tindex; }
2001-01-11 00:32:10 +08:00
/** get the texture index array. */
inline const IndexPointer& getTextureIndices() const { return _tindex; }
2001-01-11 00:32:10 +08:00
/** set the texture coords of the geoset.*/
void setTextureCoords( Vec2 *tc );
/** set the texture coords and texture coord indices of the geoset.*/
void setTextureCoords( Vec2 *tc, GLushort *ti );
/** set the texture coords and texture coord indices of the geoset.*/
void setTextureCoords( Vec2 *tc, GLuint *ti );
/** set the texture coords and texture indices of the geoset.*/
void setTextureCoords( Vec2 *tc, IndexPointer& ip );
2001-01-11 00:32:10 +08:00
/** set the texture coord binding to the vertices/primitives/overall.*/
void setTextureBinding( BindingType binding );
inline BindingType getTextureBinding() const { return _texture_binding; }
2001-01-11 00:32:10 +08:00
/** get the number of texture coords required by the defined primitives and textures binding.*/
inline int getNumInterleavedCoords() const { return _numcoords; }
/** get a pointer to interleaved float array. */
inline void* getInterleavedArray() { return _iarray; }
/** get a const pointer to interleaved float array. */
inline const void* getInterleavedArray() const { return _iarray; }
/** get the number of texture coord indices required by the defined primitives and texture binding.*/
inline int getNumInterleavedIndices() const { return _iaindex._size; }
/** get the texture index array. */
inline IndexPointer& getInterleavedIndices() { return _iaindex; }
/** get the interleaved index array. */
inline const IndexPointer& getInterleavedIndices() const { return _iaindex; }
/** get the interleaved array storage format. */
inline InterleaveArrayType getInterleavedFormat() const { return _iaformat; }
/** set the interleaved arrays of the geoset.*/
void setInterleavedArray( InterleaveArrayType format, float *ia );
void setInterleavedArray( InterleaveArrayType format, float *ia, GLushort *iai );
void setInterleavedArray( InterleaveArrayType format, float *ia, GLuint *iai );
void setInterleavedArray( InterleaveArrayType format, float *ia, IndexPointer& iai );
2001-01-11 00:32:10 +08:00
/** draw geoset directly ignoring an OpenGL display list which could be attached.
* This is the internal draw method which does the drawing itself,
* and is the method to override when deriving from GeoSet for user-drawn objects.
*/
virtual void drawImplementation(State& state) const;
2001-01-11 00:32:10 +08:00
bool check() const;
2001-01-11 00:32:10 +08:00
/** function object which is used to handling the clean up of attribute arrays
* associated with GeoSet's. A default is provided which assumes that all
* momory attached to the GeoSet is owned by this GeoSet and can be deleted
* using delete []. If this is not the cause derive your own AttributeDeleteFunctor
* a specify your own memory deletion operation.*/
struct AttributeDeleteFunctor : public osg::Referenced
{
// see GeoSet.cpp for implemention.
virtual void operator() (GeoSet* gset);
};
/** set an alternative AttributeDeleteFunction to handle attribute arrays attached to this Geoset.*/
void setAttributeDeleteFunctor(AttributeDeleteFunctor* adf) { _adf = adf; }
/** get the current AttributeDeleteFunction to handle attribute arrays attached to this Geoset.*/
AttributeDeleteFunctor* getAttributeDeleteFunctor() { return _adf.get(); }
/** get the current AttributeDeleteFunction to handle attribute arrays attached to this Geoset.*/
const AttributeDeleteFunctor* getAttributeDeleteFunctor() const { return _adf.get(); }
/** return true, osg::GeoSet does support accept(AttributeFunctor&).*/
virtual bool supports(AttributeFunctor&) const { return true; }
/** accept an AttributeFunctor and call its methods to tell it about the interal attributes that this Drawable has.*/
virtual void accept(AttributeFunctor& af);
/** return true, osg::GeoSet does support accept(ConstAttributeFunctor&).*/
virtual bool supports(ConstAttributeFunctor&) const { return true; }
/** accept an ConstAttributeFunctor and call its methods to tell it about the interal attributes that this Drawable has.*/
virtual void accept(ConstAttributeFunctor& af) const;
/** return true, osg::GeoSet does support accept(PrimitiveFunctor&) .*/
virtual bool supports(PrimitiveFunctor&) const { return true; }
/** accept a PrimtiveFunctor and call its methods to tell it about the interal primtives that this Drawable has.*/
virtual void accept(PrimitiveFunctor& pf) const;
/** convinience function for converting GeoSet's to equivilant Geometry nodes.*/
Geometry* convertToGeometry();
2001-01-11 00:32:10 +08:00
protected:
GeoSet& operator = (const GeoSet&) { return *this;}
virtual ~GeoSet();
virtual bool computeBound() const;
ref_ptr<AttributeDeleteFunctor> _adf;
2001-01-11 00:32:10 +08:00
int _numprims;
PrimitiveType _primtype;
int _needprimlen;
unsigned int _oglprimtype;
int *_primLengths;
mutable unsigned char _primlength;
2001-01-11 00:32:10 +08:00
unsigned char _flat_shaded_skip;
mutable int _numcoords;
Vec3 *_coords;
mutable IndexPointer _cindex;
2001-01-11 00:32:10 +08:00
BindingType _normal_binding;
mutable int _numnormals;
Vec3 *_normals;
IndexPointer _nindex;
2001-01-11 00:32:10 +08:00
BindingType _color_binding;
mutable int _numcolors;
Vec4 *_colors;
IndexPointer _colindex;
2001-01-11 00:32:10 +08:00
BindingType _texture_binding;
mutable int _numtcoords;
Vec2 *_tcoords;
IndexPointer _tindex;
2001-01-11 00:32:10 +08:00
void *_iarray;
IndexPointer _iaindex;
InterleaveArrayType _iaformat;
unsigned int _ogliaformat;
2001-01-11 00:32:10 +08:00
int _fast_path;
2001-01-11 00:32:10 +08:00
void set_fast_path( void );
void draw_fast_path( State& state ) const;
void draw_alternate_path( State& state ) const;
2001-01-11 00:32:10 +08:00
};
/** Template function for iterating through a GeoSet operating on triangles
with templated functor. Function automatically decomposes quads and polygons
into sub triangles which are passed onto functor.*/
template<class T>
void for_each_triangle(GeoSet& gset,T& op)
{
switch(gset.getPrimType())
{
case(GeoSet::TRIANGLE_STRIP):
case(GeoSet::FLAT_TRIANGLE_STRIP):
{
if (gset.getCoordIndices().valid())
2001-01-11 00:32:10 +08:00
{
if (gset.getCoordIndices()._is_ushort)
2001-01-11 00:32:10 +08:00
{
GLushort* iptr = gset.getCoordIndices()._ptr._ushort;
Vec3* vptr = gset.getCoords();
const int numPrim = gset.getNumPrims();
for(int i=0; i<numPrim; ++i )
2001-01-11 00:32:10 +08:00
{
const int primLength = gset.getPrimLengths()[i];
GLushort* iend = iptr+primLength;
for(int j = 2; j < primLength; j++ )
{
if( !(j%2) )
op(vptr[*(iptr)],vptr[*(iptr+1)],vptr[*(iptr+2)]);
else
op(vptr[*(iptr)],vptr[*(iptr+2)],vptr[*(iptr+1)]);
++iptr;
}
iptr=iend;
}
}
else
{
GLuint* iptr = gset.getCoordIndices()._ptr._uint;
Vec3* vptr = gset.getCoords();
const int numPrim = gset.getNumPrims();
for(int i=0; i<numPrim; ++i )
{
const int primLength = gset.getPrimLengths()[i];
GLuint* iend = iptr+primLength;
for(int j = 2; j < primLength; j++ )
{
if( !(j%2) )
op(vptr[*(iptr)],vptr[*(iptr+1)],vptr[*(iptr+2)]);
else
op(vptr[*(iptr)],vptr[*(iptr+2)],vptr[*(iptr+1)]);
++iptr;
}
iptr=iend;
2001-01-11 00:32:10 +08:00
}
}
}
else
{
Vec3* vptr = gset.getCoords();
const int numPrim = gset.getNumPrims();
for(int i=0; i<numPrim; ++i )
{
const int primLength = gset.getPrimLengths()[i];
Vec3* vend = vptr+primLength;
for(int j = 2; j < primLength; j++ )
{
if( !(j%2) )
op(*(vptr),*(vptr+1),*(vptr+2));
else
op(*(vptr),*(vptr+2),*(vptr+1));
2001-01-11 00:32:10 +08:00
++vptr;
}
vptr=vend;
}
}
}
break;
case(GeoSet::TRIANGLES):
{
if (gset.getCoordIndices().valid())
2001-01-11 00:32:10 +08:00
{
if (gset.getCoordIndices()._is_ushort)
2001-01-11 00:32:10 +08:00
{
GLushort* iptr = gset.getCoordIndices()._ptr._ushort;
Vec3* vptr = gset.getCoords();
const int numPrim = gset.getNumPrims();
for(int i=0; i<numPrim; ++i )
{
op(vptr[*(iptr)],vptr[*(iptr+1)],vptr[*(iptr+2)]);
iptr+=3;
}
}
else
{
GLuint* iptr = gset.getCoordIndices()._ptr._uint;
Vec3* vptr = gset.getCoords();
const int numPrim = gset.getNumPrims();
for(int i=0; i<numPrim; ++i )
{
op(vptr[*(iptr)],vptr[*(iptr+1)],vptr[*(iptr+2)]);
iptr+=3;
}
2001-01-11 00:32:10 +08:00
}
}
else
{
Vec3* vptr = gset.getCoords();
const int numPrim = gset.getNumPrims();
for(int i=0; i<numPrim; ++i )
{
op(*(vptr),*(vptr+1),*(vptr+2));
vptr+=3;
}
}
}
break;
case(GeoSet::QUAD_STRIP):
{
if (gset.getCoordIndices().valid())
2001-01-11 00:32:10 +08:00
{
if (gset.getCoordIndices()._is_ushort)
2001-01-11 00:32:10 +08:00
{
GLushort* iptr = gset.getCoordIndices()._ptr._ushort;
Vec3* vptr = gset.getCoords();
const int numPrim = gset.getNumPrims();
for(int i=0; i<numPrim; ++i )
2001-01-11 00:32:10 +08:00
{
const int primLength = gset.getPrimLengths()[i];
GLushort* iend = iptr+primLength;
for(int j = 3; j < primLength; j+=2 )
{
op(vptr[*(iptr)],vptr[*(iptr+1)],vptr[*(iptr+2)]);
op(vptr[*(iptr+1)],vptr[*(iptr+3)],vptr[*(iptr+2)]);
iptr+=2;
}
iptr=iend;
}
}
else
{
GLuint* iptr = gset.getCoordIndices()._ptr._uint;
Vec3* vptr = gset.getCoords();
const int numPrim = gset.getNumPrims();
for(int i=0; i<numPrim; ++i )
{
const int primLength = gset.getPrimLengths()[i];
GLuint* iend = iptr+primLength;
for(int j = 3; j < primLength; j+=2 )
{
op(vptr[*(iptr)],vptr[*(iptr+1)],vptr[*(iptr+2)]);
op(vptr[*(iptr+1)],vptr[*(iptr+3)],vptr[*(iptr+2)]);
iptr+=2;
}
iptr=iend;
2001-01-11 00:32:10 +08:00
}
}
}
else
{
Vec3* vptr = gset.getCoords();
const int numPrim = gset.getNumPrims();
for(int i=0; i<numPrim; ++i )
{
const int primLength = gset.getPrimLengths()[i];
Vec3* vend = vptr+primLength;
for(int j = 3; j < primLength; j+=2 )
{
op(*(vptr),*(vptr+1),*(vptr+2));
op(*(vptr+1),*(vptr+3),*(vptr+2));
2001-01-11 00:32:10 +08:00
vptr+=2;
}
vptr=vend;
}
}
}
break;
case(GeoSet::QUADS):
{
if (gset.getCoordIndices().valid())
2001-01-11 00:32:10 +08:00
{
if (gset.getCoordIndices()._is_ushort)
{
GLushort* iptr = gset.getCoordIndices()._ptr._ushort;
Vec3* vptr = gset.getCoords();
const int numPrim = gset.getNumPrims();
for(int i=0; i<numPrim; ++i )
{
op(vptr[*(iptr)],vptr[*(iptr+1)],vptr[*(iptr+2)]);
op(vptr[*(iptr)],vptr[*(iptr+2)],vptr[*(iptr+3)]);
iptr+=4;
}
}
else
2001-01-11 00:32:10 +08:00
{
GLuint* iptr = gset.getCoordIndices()._ptr._uint;
Vec3* vptr = gset.getCoords();
const int numPrim = gset.getNumPrims();
for(int i=0; i<numPrim; ++i )
{
op(vptr[*(iptr)],vptr[*(iptr+1)],vptr[*(iptr+2)]);
op(vptr[*(iptr)],vptr[*(iptr+2)],vptr[*(iptr+3)]);
iptr+=4;
}
2001-01-11 00:32:10 +08:00
}
}
else
{
Vec3* vptr = gset.getCoords();
const int numPrim = gset.getNumPrims();
for(int i=0; i<numPrim; ++i )
{
op(*(vptr),*(vptr+1),*(vptr+2));
op(*(vptr),*(vptr+2),*(vptr+3));
2001-01-11 00:32:10 +08:00
vptr+=4;
}
}
}
break;
case(GeoSet::FLAT_TRIANGLE_FAN):
2001-01-11 00:32:10 +08:00
case(GeoSet::TRIANGLE_FAN):
case(GeoSet::POLYGON):
{
if (gset.getCoordIndices().valid())
2001-01-11 00:32:10 +08:00
{
if (gset.getCoordIndices()._is_ushort)
2001-01-11 00:32:10 +08:00
{
GLushort* iptr = gset.getCoordIndices()._ptr._ushort;
Vec3* vptr = gset.getCoords();
const int numPrim = gset.getNumPrims();
for(int i=0; i<numPrim; ++i )
2001-01-11 00:32:10 +08:00
{
const int primLength = gset.getPrimLengths()[i];
if (primLength>0)
2001-01-11 00:32:10 +08:00
{
const Vec3& start = vptr[*(iptr)];
ushort* iend = iptr+primLength;
2001-01-11 00:32:10 +08:00
++iptr;
for(int j = 2; j < primLength; ++j )
{
op(start,vptr[*(iptr)],vptr[*(iptr+1)]);
++iptr;
}
iptr=iend;
}
}
}
else
{
GLuint* iptr = gset.getCoordIndices()._ptr._uint;
Vec3* vptr = gset.getCoords();
const int numPrim = gset.getNumPrims();
for(int i=0; i<numPrim; ++i )
{
const int primLength = gset.getPrimLengths()[i];
if (primLength>0)
{
const Vec3& start = vptr[*(iptr)];
GLuint* iend = iptr+primLength;
++iptr;
for(int j = 2; j < primLength; ++j )
{
op(start,vptr[*(iptr)],vptr[*(iptr+1)]);
++iptr;
}
iptr=iend;
2001-01-11 00:32:10 +08:00
}
}
}
}
else
{
Vec3* vptr = gset.getCoords();
const int numPrim = gset.getNumPrims();
for(int i=0; i<numPrim; ++i )
{
const int primLength = gset.getPrimLengths()[i];
if (primLength>0)
{
const Vec3& start = *vptr;
Vec3* vend = vptr+primLength;
++vptr;
for(int j = 2; j < primLength; ++j)
{
op(start,*(vptr),*(vptr+1));
++vptr;
}
vptr = vend;
}
}
}
}
break;
default:
break;
}
}
2001-01-11 00:32:10 +08:00
}
2001-01-11 00:32:10 +08:00
#endif