]> git.mxchange.org Git - simgear.git/blobdiff - simgear/scene/tgdb/pt_lights.cxx
Remove using std:: from the metar header, remove HTTP support, add very basic unit...
[simgear.git] / simgear / scene / tgdb / pt_lights.cxx
index e15b7beaae44367220cd3a26124bb80453998ab7..74c696eda2d4768221b8472b27f44faefecefb93 100644 (file)
@@ -194,7 +194,7 @@ Effect* getLightEffect(float size, const Vec3& attenuation,
     point->setDistanceAttenuation(attenuation);
     attenuationPass->setAttributeAndModes(point);
     Pass *spritePass = clone(basicPass, CopyOp::SHALLOW_COPY);
-    spritePass->setTextureAttributeAndModes(0, pointSprite,
+    spritePass->setTextureAttributeAndModes(0, pointSprite.get(),
                                             osg::StateAttribute::ON);
     Texture2D* texture = gen_standard_light_sprite();
     spritePass->setTextureAttribute(0, texture);
@@ -204,21 +204,26 @@ Effect* getLightEffect(float size, const Vec3& attenuation,
     Pass *combinedPass = clone(spritePass, CopyOp::SHALLOW_COPY);
     combinedPass->setAttributeAndModes(point);
     Effect* effect = new Effect;
-    std::vector<std::string> combinedExtensions;
-    combinedExtensions.push_back("GL_ARB_point_sprite");
-    combinedExtensions.push_back("GL_ARB_point_parameters");
-    Technique* combinedTniq = new Technique;
-    combinedTniq->passes.push_back(combinedPass);
-    combinedTniq->setGLExtensionsPred(2.0, combinedExtensions);
-    effect->techniques.push_back(combinedTniq);
-    std::vector<std::string> spriteExtensions;
-    spriteExtensions.push_back(combinedExtensions.front());
-    Technique* spriteTniq = new Technique;
-    spriteTniq->passes.push_back(spritePass);
-    spriteTniq->setGLExtensionsPred(2.0, spriteExtensions);
-    effect->techniques.push_back(spriteTniq);
     std::vector<std::string> parameterExtensions;
-    parameterExtensions.push_back(combinedExtensions.back());
+
+    if (SGSceneFeatures::instance()->getEnablePointSpriteLights())
+    {
+        std::vector<std::string> combinedExtensions;
+        combinedExtensions.push_back("GL_ARB_point_sprite");
+        combinedExtensions.push_back("GL_ARB_point_parameters");
+        Technique* combinedTniq = new Technique;
+        combinedTniq->passes.push_back(combinedPass);
+        combinedTniq->setGLExtensionsPred(2.0, combinedExtensions);
+        effect->techniques.push_back(combinedTniq);
+        std::vector<std::string> spriteExtensions;
+        spriteExtensions.push_back(combinedExtensions.front());
+        Technique* spriteTniq = new Technique;
+        spriteTniq->passes.push_back(spritePass);
+        spriteTniq->setGLExtensionsPred(2.0, spriteExtensions);
+        effect->techniques.push_back(spriteTniq);
+        parameterExtensions.push_back(combinedExtensions.back());
+    }
+
     Technique* parameterTniq = new Technique;
     parameterTniq->passes.push_back(attenuationPass);
     parameterTniq->setGLExtensionsPred(1.4, parameterExtensions);
@@ -237,8 +242,8 @@ SGLightFactory::getLightDrawable(const SGLightBin::Light& light)
   osg::Vec3Array* vertices = new osg::Vec3Array;
   osg::Vec4Array* colors = new osg::Vec4Array;
 
-  vertices->push_back(light.position.osg());
-  colors->push_back(light.color.osg());
+  vertices->push_back(toOsg(light.position));
+  colors->push_back(toOsg(light.color));
   
   osg::Geometry* geometry = new osg::Geometry;
   geometry->setVertexArray(vertices);
@@ -270,12 +275,12 @@ SGLightFactory::getLightDrawable(const SGDirectionalLightBin::Light& light)
   SGVec3f perp1 = perpendicular(normal);
   SGVec3f perp2 = cross(normal, perp1);
   SGVec3f position = light.position;
-  vertices->push_back(position.osg());
-  vertices->push_back((position + perp1).osg());
-  vertices->push_back((position + perp2).osg());
-  colors->push_back(visibleColor.osg());
-  colors->push_back(invisibleColor.osg());
-  colors->push_back(invisibleColor.osg());
+  vertices->push_back(toOsg(position));
+  vertices->push_back(toOsg(position + perp1));
+  vertices->push_back(toOsg(position + perp2));
+  colors->push_back(toOsg(visibleColor));
+  colors->push_back(toOsg(invisibleColor));
+  colors->push_back(toOsg(invisibleColor));
   
   osg::Geometry* geometry = new osg::Geometry;
   geometry->setVertexArray(vertices);
@@ -307,10 +312,10 @@ SGLightFactory::getLights(const SGLightBin& lights, unsigned inc, float alphaOff
   osg::Vec4Array* colors = new osg::Vec4Array;
 
   for (unsigned i = 0; i < lights.getNumLights(); i += inc) {
-    vertices->push_back(lights.getLight(i).position.osg());
+    vertices->push_back(toOsg(lights.getLight(i).position));
     SGVec4f color = lights.getLight(i).color;
     color[3] = SGMiscf::max(0, SGMiscf::min(1, color[3] + alphaOff));
-    colors->push_back(color.osg());
+    colors->push_back(toOsg(color));
   }
   
   osg::Geometry* geometry = new osg::Geometry;
@@ -358,12 +363,12 @@ SGLightFactory::getLights(const SGDirectionalLightBin& lights)
     SGVec3f perp1 = perpendicular(normal);
     SGVec3f perp2 = cross(normal, perp1);
     SGVec3f position = lights.getLight(i).position;
-    vertices->push_back(position.osg());
-    vertices->push_back((position + perp1).osg());
-    vertices->push_back((position + perp2).osg());
-    colors->push_back(visibleColor.osg());
-    colors->push_back(invisibleColor.osg());
-    colors->push_back(invisibleColor.osg());
+    vertices->push_back(toOsg(position));
+    vertices->push_back(toOsg(position + perp1));
+    vertices->push_back(toOsg(position + perp2));
+    colors->push_back(toOsg(visibleColor));
+    colors->push_back(toOsg(invisibleColor));
+    colors->push_back(toOsg(invisibleColor));
   }
   
   osg::Geometry* geometry = new osg::Geometry;