]> git.mxchange.org Git - simgear.git/blobdiff - simgear/scene/sky/CloudShaderGeometry.cxx
Fixes for headless mode.
[simgear.git] / simgear / scene / sky / CloudShaderGeometry.cxx
old mode 100755 (executable)
new mode 100644 (file)
index 24056eb..b2ac925
@@ -40,7 +40,7 @@ struct SpriteComp
     bool operator() (const CloudShaderGeometry::SortData::SortItem& lhs,
                      const CloudShaderGeometry::SortData::SortItem& rhs) const
     {
-        return lhs.depth < rhs.depth;
+        return lhs.depth > rhs.depth;
     }
 };
 }
@@ -108,34 +108,41 @@ void CloudShaderGeometry::drawImplementation(RenderInfo& renderInfo) const
         itr != end;
         ++itr) {
         const CloudSprite& t = _cloudsprites[itr->idx];
-        GLfloat ua1[3] = { (GLfloat)t.texture_index_x/varieties_x,
-                           (GLfloat)t.texture_index_y/varieties_y,
-                           t.width };
-        GLfloat ua2[3] = { (GLfloat)t.height,
-                           t.shade,
-                           (GLfloat) t.cloud_height };
+        GLfloat ua1[3] = { (GLfloat) t.texture_index_x/varieties_x,
+                           (GLfloat) t.texture_index_y/varieties_y,
+                           (GLfloat) t.width };
+        GLfloat ua2[3] = { (GLfloat) t.height,
+                                      (GLfloat) shade_factor,
+                           (GLfloat) cloud_height };
+        GLfloat ua3[3] = { (GLfloat) bottom_factor,
+                           (GLfloat) middle_factor,
+                           (GLfloat) top_factor };
+                           
         extensions->glVertexAttrib3fv(USR_ATTR_1, ua1 );
         extensions->glVertexAttrib3fv(USR_ATTR_2, ua2 );
-        glColor4f(t.position.x(), t.position.y(), t.position.z(), 1.0);
+        extensions->glVertexAttrib3fv(USR_ATTR_3, ua3 );
+        glColor4f(t.position.x(), t.position.y(), t.position.z(), zscale);
         _geometry->draw(renderInfo);
     }
 }
 
 void CloudShaderGeometry::addSprite(const SGVec3f& p, int tx, int ty,
-                                    float w, float h,
-                                    float s, float cull, float cloud_height)
+                                    float w, float h, float cull)
 {
     // Only add the sprite if it is further than the cull distance to all other sprites
+    // except for the center sprite.   
     for (CloudShaderGeometry::CloudSpriteList::iterator iter = _cloudsprites.begin();
          iter != _cloudsprites.end();
          ++iter) 
     {
-        if (distSqr(iter->position, p) < cull) {
+        if ((iter != _cloudsprites.begin()) &&
+           (distSqr(iter->position, p) < cull)) {
             // Too close - cull it
             return;
         }
     }
-    _cloudsprites.push_back(CloudSprite(p, tx, ty, w, h, s, cloud_height));
+    
+    _cloudsprites.push_back(CloudSprite(p, tx, ty, w, h));
 }
 
 bool CloudShaderGeometry_readLocalData(Object& obj, Input& fr)
@@ -163,13 +170,13 @@ bool CloudShaderGeometry_readLocalData(Object& obj, Input& fr)
         while (!fr.eof() && fr[0].getNoNestedBrackets() > entry) {
             SGVec3f v;
             int tx, ty;
-            float w, h, s, ch;
+            float w, h;
             if (fr[0].getFloat(v.x()) && fr[1].getFloat(v.y())
                 && fr[2].getFloat(v.z()) && fr[3].getInt(tx) && fr[4].getInt(ty) &&  
-                fr[5].getFloat(w) && fr[6].getFloat(h)&& fr[7].getFloat(s) && fr[8].getFloat(ch)) {
+                fr[5].getFloat(w) && fr[6].getFloat(h)) {
                     fr += 5;
                     //SGVec3f* v = new SGVec3f(v.x(), v.y(), v.z());
-                    geom._cloudsprites.push_back(CloudShaderGeometry::CloudSprite(v, tx, ty, w, h,s,ch));
+                    geom._cloudsprites.push_back(CloudShaderGeometry::CloudSprite(v, tx, ty, w, h));
             } else {
                 ++fr;
             }
@@ -194,8 +201,7 @@ bool CloudShaderGeometry_writeLocalData(const Object& obj, Output& fw)
              fw.indent() << itr->position.x() << " " << itr->position.y() << " " 
                      << itr->position.z() << " " << itr->texture_index_x << " "
                      << itr->texture_index_y << " "  << itr->width << " " 
-                     << itr->height << " " << itr->shade 
-                     << itr->cloud_height << " "<< std::endl;
+                     << itr->height << " " << std::endl;
     }
     fw.moveOut();
     fw.indent() << "}" << std::endl;