]> git.mxchange.org Git - simgear.git/commitdiff
VBO switch also controls random-buildings.
authorJames Turner <zakalawe@mac.com>
Wed, 5 Mar 2014 10:20:48 +0000 (10:20 +0000)
committerJames Turner <zakalawe@mac.com>
Wed, 5 Mar 2014 10:20:48 +0000 (10:20 +0000)
simgear/scene/tgdb/SGBuildingBin.cxx
simgear/scene/tgdb/SGBuildingBin.hxx
simgear/scene/tgdb/obj.cxx

index 30fc34a9438416a71e415ad6d8cb02263983e81f..bafb9c3838bbd5d1adfe2c344b5136c695f40fbf 100644 (file)
@@ -108,7 +108,7 @@ BuildingBoundingBoxCallback::computeBound(const Drawable& drawable) const
 }
 
   // Set up the building set based on the material definitions
-  SGBuildingBin::SGBuildingBin(const SGMaterial *mat) {
+  SGBuildingBin::SGBuildingBin(const SGMaterial *mat, bool useVBOs) {
 
     material_name = new std::string(mat->get_names()[0]);
     SG_LOG(SG_TERRAIN, SG_DEBUG, "Building material " << material_name);
@@ -161,7 +161,11 @@ BuildingBoundingBoxCallback::computeBound(const Drawable& drawable) const
       sharedGeometry->setFogCoordBinding(osg::Geometry::BIND_PER_VERTEX);
       sharedGeometry->setComputeBoundingBoxCallback(new BuildingBoundingBoxCallback);
       sharedGeometry->setUseDisplayList(false);
-
+      sharedGeometry->setDataVariance(osg::Object::STATIC);
+      if (useVBOs) {
+          sharedGeometry->setUseVertexBufferObjects(true);
+      }
+      
       for (unsigned int j = 0; j < BUILDING_SET_SIZE; j++) {
         float width;
         float depth;
index 890dff988eaa1a12b06e2d5bc343df906820147a..f64599dbee8c8d9cd784ac9b117425216fa7af2c 100644 (file)
@@ -168,7 +168,7 @@ private:
 
 public:
 
-  SGBuildingBin(const SGMaterial *mat);
+  SGBuildingBin(const SGMaterial *mat, bool useVBOs);
 
   ~SGBuildingBin() {
     smallBuildings.clear();
index 82b97e9b1b2192f7c564ec76dd78704c07b447b1..8885e405a81cd0ee7147879fd2adb949343e8e47 100644 (file)
@@ -480,7 +480,8 @@ public:
     SGMaterialLib* matlib,
     float building_density,
     bool use_random_objects,
-    bool use_random_buildings)
+    bool use_random_buildings,
+    bool useVBOs)
   {
     SGMaterialTriangleMap::iterator i;
 
@@ -508,7 +509,7 @@ public:
       SGBuildingBin* bin = NULL;
 
       if (building_coverage > 0) {
-        bin = new SGBuildingBin(mat);
+        bin = new SGBuildingBin(mat, useVBOs);
         randomBuildings.push_back(bin);
       }
 
@@ -1121,7 +1122,8 @@ public:
       bool use_random_buildings = false;
       float vegetation_density = 1.0f;
       float building_density = 1.0f;
-
+      bool useVBOs = false;
+      
       osg::ref_ptr<osg::Group> randomObjects;
       osg::ref_ptr<osg::Group> forestNode;
       osg::ref_ptr<osg::Group> buildingNode;
@@ -1146,6 +1148,8 @@ public:
                 = propertyNode->getFloatValue("/sim/rendering/building-density",
                                               building_density);
         }
+        
+        useVBOs = (_options->getPluginStringData("SimGear::USE_VBOS") == "ON");
       }
 
 
@@ -1154,7 +1158,8 @@ public:
         _tileGeometryBin->computeRandomObjectsAndBuildings(matlib,
                                                          building_density,
                                                          use_random_objects,
-                                                         use_random_buildings);
+                                                         use_random_buildings,
+                                                         useVBOs);
       }