X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fscene%2Fsky%2FCloudShaderGeometry.cxx;h=229710db32ba4fa96dad76aa3ec4bf0a59c5820d;hb=11479cd8c386d8bf7e1fee7bed60ab4abefc5fad;hp=9acc3f309bad30545609901531bf10f880158264;hpb=7151c3fac153fdeb12f4b4f1fd16d55ac6c89107;p=simgear.git diff --git a/simgear/scene/sky/CloudShaderGeometry.cxx b/simgear/scene/sky/CloudShaderGeometry.cxx index 9acc3f30..229710db 100755 --- a/simgear/scene/sky/CloudShaderGeometry.cxx +++ b/simgear/scene/sky/CloudShaderGeometry.cxx @@ -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; } }; } @@ -58,7 +58,7 @@ void CloudShaderGeometry::drawImplementation(RenderInfo& renderInfo) const if (!sortData.spriteIdx) sortData.spriteIdx = new SortData::SortItemList; if (sortData.spriteIdx->size() < _cloudsprites.size()) { - for (int i = sortData.spriteIdx->size(); i < _cloudsprites.size(); ++i) + for (unsigned i = sortData.spriteIdx->size(); i < (unsigned)_cloudsprites.size(); ++i) sortData.spriteIdx->push_back(SortData::SortItem(i, 0.0f)); sortData.frameSorted = frameNumber - (sortData.skip_limit + 1); } @@ -74,7 +74,7 @@ void CloudShaderGeometry::drawImplementation(RenderInfo& renderInfo) const itr != end; ++itr) { Vec4f projPos - = Vec4f(_cloudsprites[itr->idx].position.osg(), 1.0f) * mvp; + = Vec4f(toOsg(_cloudsprites[itr->idx].position), 1.0f) * mvp; itr->depth = projPos.z() / projPos.w(); } // Already sorted? @@ -108,11 +108,11 @@ 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 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) t.shade, (GLfloat) t.cloud_height }; extensions->glVertexAttrib3fv(USR_ATTR_1, ua1 ); extensions->glVertexAttrib3fv(USR_ATTR_2, ua2 ); @@ -121,20 +121,23 @@ void CloudShaderGeometry::drawImplementation(RenderInfo& renderInfo) const } } -void CloudShaderGeometry::addSprite(SGVec3f& p, int tx, int ty, +void CloudShaderGeometry::addSprite(const SGVec3f& p, int tx, int ty, float w, float h, float s, float cull, float cloud_height) { // 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)); }