From 0eacd8161a1361e371e3c881d55634c53a7d9d84 Mon Sep 17 00:00:00 2001 From: Andreas Ekstrand Date: Wed, 10 Jan 2018 11:07:46 +0000 Subject: [PATCH] Small fix in the osgjs plugin. Since osgjs uses pixel area for PIXEL_SIZE_ON_SCREEN PagedLOD ranges instead of a diameter, it's a more correct approximation to square the ranges in this case. --- src/osgPlugins/osgjs/WriteVisitor.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/osgPlugins/osgjs/WriteVisitor.cpp b/src/osgPlugins/osgjs/WriteVisitor.cpp index e062f8bde..955359f30 100644 --- a/src/osgPlugins/osgjs/WriteVisitor.cpp +++ b/src/osgPlugins/osgjs/WriteVisitor.cpp @@ -871,7 +871,15 @@ JSONObject* WriteVisitor::createJSONPagedLOD(osg::PagedLOD *plod) ss << "Range "; ss << i; std::string str = ss.str(); - rangeObject->getMaps()[str] = new JSONVec2Array(osg::Vec2(plod->getRangeList()[i].first, plod->getRangeList()[i].second)); + + osg::Vec2 range(plod->getRangeList()[i].first, plod->getRangeList()[i].second); + + // Since OSGJS uses pixel area, use square range + if (plod->getRangeMode() == osg::LOD::PIXEL_SIZE_ON_SCREEN) { + range.set(pow(range.x(), 2.0f), pow(range.y(), 2.0f)); + } + + rangeObject->getMaps()[str] = new JSONVec2Array(range); } jsonPlod->getMaps()["RangeList"] = rangeObject; // File List