Updates NEWS file for 0.9.0 release.

Added default computeBound() implementation to osg::Drawable which uses
a PrimtiveFunctor to compute the bounding box in a generic way, that
will work for all Drawable subclasses that implement the accept(PrimitiveFunctor&).
This commit is contained in:
Robert Osfield
2002-07-18 22:35:54 +00:00
parent e492b79da5
commit 3cba9a52ef
9 changed files with 173 additions and 55 deletions

View File

@@ -227,3 +227,77 @@ void Drawable::setAppCallback(AppCallback* ac)
}
}
}
struct ComputeBound : public Drawable::PrimitiveFunctor
{
ComputeBound():_vertices(0) {}
virtual void setVertexArray(unsigned int,Vec3* vertices) { _vertices = vertices; }
virtual void drawArrays(GLenum,GLint first,GLsizei count)
{
if (_vertices)
{
osg::Vec3* vert = _vertices+first;
for(;count>0;--count,++vert)
{
_bb.expandBy(*vert);
}
}
}
virtual void drawElements(GLenum,GLsizei count,GLubyte* indices)
{
if (_vertices)
{
for(;count>0;--count,++indices)
{
_bb.expandBy(_vertices[*indices]);
}
}
}
virtual void drawElements(GLenum,GLsizei count,GLushort* indices)
{
if (_vertices)
{
for(;count>0;--count,++indices)
{
_bb.expandBy(_vertices[*indices]);
}
}
}
virtual void drawElements(GLenum,GLsizei count,GLuint* indices)
{
if (_vertices)
{
for(;count>0;--count,++indices)
{
_bb.expandBy(_vertices[*indices]);
}
}
}
virtual void begin(GLenum) {}
virtual void vertex(const Vec3& vert) { _bb.expandBy(vert); }
virtual void vertex(float x,float y,float z) { _bb.expandBy(x,y,z); }
virtual void end() {}
Vec3* _vertices;
BoundingBox _bb;
};
const bool Drawable::computeBound() const
{
ComputeBound cb;
Drawable* non_const_this = const_cast<Drawable*>(this);
non_const_this->accept(cb);
_bbox = cb._bb;
_bbox_computed = true;
return true;
}