WS30 - Move expensive conversion to loading thread

This commit is contained in:
Stuart Buchanan
2021-03-04 21:00:12 +00:00
parent ce197ea828
commit c147c5eb55
3 changed files with 10 additions and 16 deletions

View File

@@ -28,6 +28,8 @@
#include <simgear/debug/logstream.hxx>
#include <simgear/io/iostreams/sgstream.hxx>
#include <simgear/math/SGGeod.hxx>
#include <simgear/scene/util/OsgMath.hxx>
#include "LineFeatureBin.hxx"
@@ -72,7 +74,7 @@ LineFeatureBin::LineFeatureBin(const SGPath& absoluteFileName, const std::string
float w = 0.0f;
int attributes = 0;
float a=0, b=0, c=0, d=0;
std::list<SGGeod> nodes;
std::list<osg::Vec3d> nodes;
in >> w >> attributes >> a >> b >> c >> d;
@@ -89,8 +91,9 @@ LineFeatureBin::LineFeatureBin(const SGPath& absoluteFileName, const std::string
break;
}
const SGGeod node = SGGeod::fromDeg(lon, lat);
nodes.push_back(node);
SGVec3d tmp;
SGGeodesy::SGGeodToCart(SGGeod::fromDeg(lon, lat), tmp);
nodes.push_back(toOsg(tmp));
}
if (nodes.size() > 1) {

View File

@@ -30,7 +30,6 @@
#include <osg/Matrix>
#include <simgear/misc/sg_path.hxx>
#include <simgear/math/SGGeod.hxx>
namespace simgear
{
@@ -42,14 +41,14 @@ public:
~LineFeatureBin() = default;
struct LineFeature {
const std::list<SGGeod> _nodes;
const std::list<osg::Vec3d> _nodes;
const float _width;
const int _attributes;
const float _a;
const float _b;
const float _c;
const float _d;
LineFeature(const std::list<SGGeod> nodes, const float w, const int attributes, const float a, const float b, const float c, const float d) :
LineFeature(const std::list<osg::Vec3d> nodes, const float w, const int attributes, const float a, const float b, const float c, const float d) :
_nodes(nodes), _width(w), _attributes(attributes), _a(a), _b(b), _c(c), _d(d)
{
}

View File

@@ -1861,15 +1861,11 @@ void VPBTechnique::generateLineFeature(BufferData& buffer, Locator* masterLocato
return;
}
SGVec3d tmp;
osg::Vec3d ma, mb;
std::list<osg::Vec3d> roadPoints;
auto road_iter = road._nodes.begin();
// This is expensive.
SGGeodesy::SGGeodToCart(SGGeod(*road_iter), tmp);
ma = toOsg(tmp) - modelCenter;
ma = *road_iter - modelCenter;
osg::Vec3d intersect = getMeshIntersection(buffer, masterLocator, ma);
@@ -1879,10 +1875,7 @@ void VPBTechnique::generateLineFeature(BufferData& buffer, Locator* masterLocato
road_iter++;
for (; road_iter != road._nodes.end(); road_iter++) {
// This is expensive.
SGGeodesy::SGGeodToCart(SGGeod(*road_iter), tmp);
mb = toOsg(tmp) - modelCenter;
mb = *road_iter - modelCenter;
intersect = getMeshIntersection(buffer, masterLocator, mb);
if (intersect != mb) roadPoints.push_back(intersect);
@@ -1960,7 +1953,6 @@ void VPBTechnique::generateLineFeature(BufferData& buffer, Locator* masterLocato
// Find the intersection of a given SGGeod with the terrain mesh
osg::Vec3d VPBTechnique::getMeshIntersection(BufferData& buffer, Locator* masterLocator, osg::Vec3d pt)
{
SGVec3d tmp;
osg::Vec3d local, origin, top;
// Get a vertical line segment.