Runtime VBO option in BTG loading.
This commit is contained in:
parent
481f7e3bfa
commit
d4030e72e4
@ -315,7 +315,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
osg::Geometry* buildGeometry(const TriangleVector& triangles) const
|
||||
osg::Geometry* buildGeometry(const TriangleVector& triangles, bool useVBOs) const
|
||||
{
|
||||
// Do not build anything if there is nothing in here ...
|
||||
if (empty() || triangles.empty())
|
||||
@ -330,6 +330,10 @@ public:
|
||||
colors->push_back(osg::Vec4(1, 1, 1, 1));
|
||||
|
||||
osg::Geometry* geometry = new osg::Geometry;
|
||||
geometry->setUseDisplayList(false);
|
||||
if (useVBOs)
|
||||
geometry->setUseVertexBufferObjects(true);
|
||||
|
||||
geometry->setDataVariance(osg::Object::STATIC);
|
||||
geometry->setVertexArray(vertices);
|
||||
geometry->setNormalArray(normals);
|
||||
@ -373,8 +377,8 @@ public:
|
||||
return geometry;
|
||||
}
|
||||
|
||||
osg::Geometry* buildGeometry() const
|
||||
{ return buildGeometry(getTriangles()); }
|
||||
osg::Geometry* buildGeometry(bool useVBOs) const
|
||||
{ return buildGeometry(getTriangles(), useVBOs); }
|
||||
|
||||
int getTextureIndex() const
|
||||
{
|
||||
|
@ -95,7 +95,7 @@ public:
|
||||
SGDirectionalLightListBin reilLights;
|
||||
SGMatModelBin randomModels;
|
||||
SGBuildingBinList randomBuildings;
|
||||
|
||||
|
||||
static SGVec4f
|
||||
getMaterialLightColor(const SGMaterial* material)
|
||||
{
|
||||
@ -387,7 +387,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
osg::Node* getSurfaceGeometry(SGMaterialLib* matlib) const
|
||||
osg::Node* getSurfaceGeometry(SGMaterialLib* matlib, bool useVBOs) const
|
||||
{
|
||||
if (materialTriangleMap.empty())
|
||||
return 0;
|
||||
@ -397,7 +397,7 @@ public:
|
||||
//osg::Geode* geode = new osg::Geode;
|
||||
SGMaterialTriangleMap::const_iterator i;
|
||||
for (i = materialTriangleMap.begin(); i != materialTriangleMap.end(); ++i) {
|
||||
osg::Geometry* geometry = i->second.buildGeometry();
|
||||
osg::Geometry* geometry = i->second.buildGeometry(useVBOs);
|
||||
SGMaterial *mat = 0;
|
||||
if (matlib)
|
||||
mat = matlib->findCached(i->first);
|
||||
@ -1187,6 +1187,8 @@ SGLoadBTG(const std::string& path, const simgear::SGReaderWriterOptions* options
|
||||
matlib = options->getMaterialLib();
|
||||
}
|
||||
|
||||
bool useVBOs = (options->getPluginStringData("SimGear::USE_VBOS") == "ON");
|
||||
|
||||
SGVec3d center = tile.get_gbs_center();
|
||||
SGGeod geodPos = SGGeod::fromCart(center);
|
||||
SGQuatd hlOr = SGQuatd::fromLonLat(geodPos)*SGQuatd::fromEulerDeg(0, 0, 180);
|
||||
@ -1212,7 +1214,7 @@ SGLoadBTG(const std::string& path, const simgear::SGReaderWriterOptions* options
|
||||
osg::Group* terrainGroup = new osg::Group;
|
||||
terrainGroup->setName("BTGTerrainGroup");
|
||||
|
||||
osg::Node* node = tileGeometryBin->getSurfaceGeometry(matlib);
|
||||
osg::Node* node = tileGeometryBin->getSurfaceGeometry(matlib, useVBOs);
|
||||
if (node)
|
||||
terrainGroup->addChild(node);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user