fix a memory leak in newcloud.cxx

This commit is contained in:
Tim Moore
2009-11-26 16:30:46 +01:00
parent ddd72b2b37
commit 5abc6c995f
3 changed files with 6 additions and 6 deletions

View File

@@ -121,7 +121,7 @@ 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)
{

View File

@@ -69,7 +69,8 @@ class CloudShaderGeometry : public osg::Drawable
META_Object(flightgear, CloudShaderGeometry);
struct CloudSprite {
CloudSprite(SGVec3f& p, int tx, int ty, float w, float h, float s, float ch) :
CloudSprite(const SGVec3f& p, int tx, int ty, float w, float h,
float s, float ch) :
position(p), texture_index_x(tx), texture_index_y(ty), width(w), height(h), shade(s), cloud_height(ch)
{ }
@@ -106,7 +107,8 @@ class CloudShaderGeometry : public osg::Drawable
_geometry = geometry;
}
void addSprite(SGVec3f& p, int tx, int ty, float w, float h, float s, float cull, float cloud_height);
void addSprite(const SGVec3f& p, int tx, int ty, float w, float h,
float s, float cull, float cloud_height);
osg::ref_ptr<osg::Drawable> _geometry;

View File

@@ -222,8 +222,6 @@ osg::ref_ptr<EffectGeode> SGNewCloud::genCloud() {
z = height * cos(elev) * 0.5f;
}
SGVec3f *pos = new SGVec3f(x, y, z);
// Determine the height and width as scaling factors on the minimum size (used to create the quad)
float sprite_width = 1.0f + sg_random() * (max_sprite_width - min_sprite_width) / min_sprite_width;
float sprite_height = 1.0f + sg_random() * (max_sprite_height - min_sprite_height) / min_sprite_height;
@@ -241,7 +239,7 @@ osg::ref_ptr<EffectGeode> SGNewCloud::genCloud() {
int index_y = (int) floor(sg_random() * num_textures_y);
if (index_y == num_textures_y) { index_y--; }
sg->addSprite(*pos,
sg->addSprite(SGVec3f(x, y, z),
index_x,
index_y,
sprite_width,