From: Tim Moore Date: Thu, 26 Nov 2009 15:30:46 +0000 (+0100) Subject: fix a memory leak in newcloud.cxx X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=5abc6c995fc0e0b56f84b59813a9adcf76d9658a;p=simgear.git fix a memory leak in newcloud.cxx --- diff --git a/simgear/scene/sky/CloudShaderGeometry.cxx b/simgear/scene/sky/CloudShaderGeometry.cxx index 49244faf..24056ebc 100755 --- a/simgear/scene/sky/CloudShaderGeometry.cxx +++ b/simgear/scene/sky/CloudShaderGeometry.cxx @@ -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) { diff --git a/simgear/scene/sky/CloudShaderGeometry.hxx b/simgear/scene/sky/CloudShaderGeometry.hxx index 8a9c31c5..cd00da8d 100755 --- a/simgear/scene/sky/CloudShaderGeometry.hxx +++ b/simgear/scene/sky/CloudShaderGeometry.hxx @@ -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 _geometry; diff --git a/simgear/scene/sky/newcloud.cxx b/simgear/scene/sky/newcloud.cxx index d4219210..1518b133 100644 --- a/simgear/scene/sky/newcloud.cxx +++ b/simgear/scene/sky/newcloud.cxx @@ -222,8 +222,6 @@ osg::ref_ptr 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 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,