From d0f4e9018c6f21048c74cc37006ea1fe3a1b7fb6 Mon Sep 17 00:00:00 2001 From: Stuart Buchanan Date: Wed, 12 May 2021 21:36:11 +0100 Subject: [PATCH] WS30: Fix regression of lakes Fix regression that stopped lakes from being generated. --- simgear/scene/tgdb/VPBTechnique.cxx | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/simgear/scene/tgdb/VPBTechnique.cxx b/simgear/scene/tgdb/VPBTechnique.cxx index d7a442be..61d559de 100644 --- a/simgear/scene/tgdb/VPBTechnique.cxx +++ b/simgear/scene/tgdb/VPBTechnique.cxx @@ -176,9 +176,11 @@ void VPBTechnique::init(int dirtyMask, bool assumeMultiThreaded) else { generateGeometry(*buffer, masterLocator, centerModel); + applyColorLayers(*buffer, masterLocator); applyTrees(*buffer, masterLocator); applyLineFeatures(*buffer, masterLocator); + applyAreaFeatures(*buffer, masterLocator); applyCoastline(*buffer, masterLocator); } @@ -1848,6 +1850,8 @@ void VPBTechnique::applyAreaFeatures(BufferData& buffer, Locator* masterLocator) if (v->size() == 0) continue; c->push_back(osg::Vec4(1.0,1.0,1.0,1.0)); + geometry->dirtyBound(); + EffectGeode* geode = new EffectGeode; geode->addDrawable(geometry); @@ -1881,6 +1885,7 @@ void VPBTechnique::generateAreaFeature(BufferData& buffer, Locator* masterLocato // Build up the tesselator while also determining the correct elevation for the feature. double elev = 0; unsigned int elev_count = 0; + osg::Vec3d last_pt; auto area_iter = area._nodes.begin(); osg::Vec3d pt = *area_iter - modelCenter; @@ -1892,12 +1897,21 @@ void VPBTechnique::generateAreaFeature(BufferData& buffer, Locator* masterLocato for (; area_iter != area._nodes.end(); area_iter++) { pt = *area_iter - modelCenter; + + // Ignore small segments - we really don't need resolution less than 10m + if ((pt - last_pt).length2() < 100.0) continue; + ma = getMeshIntersection(buffer, masterLocator, pt, up); if (ma !=pt) { elev += up*ma; elev_count++; } - tessellator->addVertex(new osg::Vec3f(*area_iter - modelCenter)); + + // To handle the case where the feature overlaps the edge of this particular mesh, + // we always add vertices, even if they don't intersect the edge of the mesh. + tessellator->addVertex(new osg::Vec3f(pt)); + + last_pt = pt; } tessellator->endContour();