Skip to content

Commit

Permalink
Merge pull request #276 from longhuan2018/fix-empty-geometry
Browse files Browse the repository at this point in the history
修复空地物导致bbox计算错误
  • Loading branch information
fanvanzh authored Nov 17, 2023
2 parents a7c3000 + a844287 commit dd39111
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/osgb23dtile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ class InfoVisitor : public osg::NodeVisitor
}

void apply(osg::Geometry& geometry){
if (geometry.getVertexArray() == nullptr || geometry.getVertexArray()->getDataSize() == 0U || geometry.getNumPrimitiveSets() == 0U)
return;

geometry_array.push_back(&geometry);
if (GeoTransform::pOgrCT)
{
Expand Down Expand Up @@ -199,7 +202,7 @@ class InfoVisitor : public osg::NodeVisitor
double get_geometric_error(TileBox& bbox){
if (bbox.max.empty() || bbox.min.empty())
{
LOG_E("bbox is empty!");
//LOG_E("bbox is empty!");
return 0;
}

Expand Down Expand Up @@ -706,8 +709,11 @@ write_element_array_primitive(osg::Geometry* g, osg::PrimitiveSet* ps, OsgBuildS
}
write_vec3_array(vertexArr, osgState, point_max, point_min);
// merge mesh bbox
expand_bbox3d(osgState->point_max, osgState->point_min, point_max);
expand_bbox3d(osgState->point_max, osgState->point_min, point_min);
if (point_min.x() <= point_max.x() && point_min.y() <= point_max.y() && point_min.z() <= point_max.z())
{
expand_bbox3d(osgState->point_max, osgState->point_min, point_max);
expand_bbox3d(osgState->point_max, osgState->point_min, point_min);
}
}
// normal
osg::Vec3Array* normalArr = (osg::Vec3Array*)g->getNormalArray();
Expand Down

0 comments on commit dd39111

Please sign in to comment.