Fix quad tree node child bounding box dimensions

pull/2192/head
bzzt 6 years ago committed by Capostrophic
parent 172cb74763
commit b2000b7642

@ -171,20 +171,21 @@ public:
QuadTreeNode* addChild(QuadTreeNode* parent, ChildDirection direction, float size)
{
float halfSize = size/2.f;
osg::Vec2f center;
switch (direction)
{
case SW:
center = parent->getCenter() + osg::Vec2f(-size/2.f,-size/2.f);
center = parent->getCenter() + osg::Vec2f(-halfSize,-halfSize);
break;
case SE:
center = parent->getCenter() + osg::Vec2f(size/2.f, -size/2.f);
center = parent->getCenter() + osg::Vec2f(halfSize, -halfSize);
break;
case NW:
center = parent->getCenter() + osg::Vec2f(-size/2.f, size/2.f);
center = parent->getCenter() + osg::Vec2f(-halfSize, halfSize);
break;
case NE:
center = parent->getCenter() + osg::Vec2f(size/2.f, size/2.f);
center = parent->getCenter() + osg::Vec2f(halfSize, halfSize);
break;
default:
break;
@ -206,8 +207,8 @@ public:
mStorage->getMinMaxHeights(size, center, minZ, maxZ);
float cellWorldSize = mStorage->getCellWorldSize();
osg::BoundingBox boundingBox(osg::Vec3f((center.x()-size)*cellWorldSize, (center.y()-size)*cellWorldSize, minZ),
osg::Vec3f((center.x()+size)*cellWorldSize, (center.y()+size)*cellWorldSize, maxZ));
osg::BoundingBox boundingBox(osg::Vec3f((center.x()-halfSize)*cellWorldSize, (center.y()-halfSize)*cellWorldSize, minZ),
osg::Vec3f((center.x()+halfSize)*cellWorldSize, (center.y()+halfSize)*cellWorldSize, maxZ));
node->setBoundingBox(boundingBox);
return node;

Loading…
Cancel
Save