Added Vec3Array arrange pointer to avoid dynamic cast

This commit is contained in:
Robert Osfield 2008-07-01 13:56:02 +00:00
parent c6ba70e3ad
commit 82ed445a31

View File

@ -122,6 +122,8 @@ class KDTree : public osg::Shape
AxisStack _axisStack;
KDNodeList _kdNodes;
KDLeafList _kdLeaves;
osg::ref_ptr<osg::Vec3Array> _vertices;
Indices _vertexIndices;
};
@ -248,7 +250,7 @@ KDTree* KDTreeBuilder::createKDTree(osg::Geometry* geometry)
osg::ref_ptr<KDTree> kdTree = new KDTree;
kdTree->_geometry = geometry;
kdTree->_bb = kdTree->_geometry->getBound();
kdTree->_vertices = vertices;
unsigned int estimatedSize = (unsigned int)(float(vertices->size())/float(_targetNumVerticesPerLeaf)*1.5);
@ -372,7 +374,7 @@ int KDTreeBuilder::divide(KDTree& kdTree, osg::BoundingBox& bb, int nodeIndex, u
{
KDLeaf& leaf = kdTree.getLeaf(nodeIndex);
osg::Vec3Array* vertices = dynamic_cast<osg::Vec3Array*>(kdTree._geometry->getVertexArray());
osg::Vec3Array* vertices = kdTree._vertices.get();
//osg::notify(osg::NOTICE)<<" divide leaf->_vertexIndices.size()="<<leaf->_vertexIndices.size()<<std::endl;