Mathias Frhlich:
Incorporating the shared ptr code: - All scenegraph references from SimGear - SGMaterial which already had a reference counter uses now that common infrastructure. - SGMatModel is now counted. - SGSoundSample from SimGear - And the corresponding change for the sound samples in flightgear which fixes a latent crash if FGBeacon would evern be deleted.
This commit is contained in:
parent
e8c4b0d57c
commit
c2c0e19305
@ -26,6 +26,8 @@
|
||||
|
||||
#include <plib/sg.h>
|
||||
#include <simgear/constants.h>
|
||||
#include <simgear/structure/SGReferenced.hxx>
|
||||
#include <simgear/structure/SGSharedPtr.hxx>
|
||||
#include <simgear/math/sg_random.h>
|
||||
#include <simgear/math/sg_geodesy.hxx>
|
||||
#include <simgear/math/point3d.hxx>
|
||||
@ -655,7 +657,7 @@ void SGEnviro::drawLightning(void) {
|
||||
double ax = 0.0, ay = 0.0;
|
||||
ax = cos(course) * dist;
|
||||
ay = sin(course) * dist;
|
||||
SGSoundSample *snd = soundMgr->find("thunder");
|
||||
SGSharedPtr<SGSoundSample> snd = soundMgr->find("thunder");
|
||||
if( snd ) {
|
||||
ALfloat pos[3]={ax, ay, -sgEnviro.last_alt };
|
||||
snd->set_source_pos(pos);
|
||||
|
@ -74,10 +74,6 @@ SGMaterial::SGMaterial( ssgSimpleState *s )
|
||||
|
||||
SGMaterial::~SGMaterial (void)
|
||||
{
|
||||
for (unsigned int i = 0; i < object_groups.size(); i++) {
|
||||
delete object_groups[i];
|
||||
object_groups[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -182,7 +178,6 @@ SGMaterial::init ()
|
||||
wrapv = true;
|
||||
mipmap = true;
|
||||
light_coverage = 0.0;
|
||||
refcount = 0;
|
||||
shininess = 1.0;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
ambient[i] = (i < 3) ? 0.2 : 1.0;
|
||||
@ -238,7 +233,6 @@ SGMaterial::build_ssg_state( bool defer_tex_load )
|
||||
for (unsigned int i = 0; i < _status.size(); i++)
|
||||
{
|
||||
ssgSimpleState *state = new ssgSimpleState();
|
||||
state->ref();
|
||||
|
||||
// Set up the textured state
|
||||
state->setShadeModel( shade_model );
|
||||
@ -279,9 +273,7 @@ SGMaterial::build_ssg_state( bool defer_tex_load )
|
||||
|
||||
void SGMaterial::set_ssg_state( ssgSimpleState *s )
|
||||
{
|
||||
_internal_state st( s, "", true );
|
||||
st.state->ref();
|
||||
_status.push_back( st );
|
||||
_status.push_back( _internal_state( s, "", true ) );
|
||||
}
|
||||
|
||||
// end of mat.cxx
|
||||
|
@ -39,6 +39,8 @@
|
||||
#include <plib/ssg.h>
|
||||
|
||||
#include <simgear/props/props.hxx>
|
||||
#include <simgear/structure/ssgSharedPtr.hxx>
|
||||
#include <simgear/structure/SGSharedPtr.hxx>
|
||||
|
||||
#include "matmodel.hxx"
|
||||
|
||||
@ -55,7 +57,7 @@ SG_USING_STD(vector);
|
||||
* defined in the $FG_ROOT/materials.xml file, and can be changed
|
||||
* at runtime.
|
||||
*/
|
||||
class SGMaterial {
|
||||
class SGMaterial : public SGReferenced {
|
||||
|
||||
public:
|
||||
|
||||
@ -161,29 +163,6 @@ public:
|
||||
return object_groups[index];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Increment the reference count for this material.
|
||||
*
|
||||
* A material with 0 references may be deleted by the
|
||||
* material library.
|
||||
*/
|
||||
virtual inline void ref () { refcount++; }
|
||||
|
||||
|
||||
/**
|
||||
* Decrement the reference count for this material.
|
||||
*/
|
||||
virtual inline void deRef () { refcount--; }
|
||||
|
||||
|
||||
/**
|
||||
* Get the reference count for this material.
|
||||
*
|
||||
* @return The number of references (0 if none).
|
||||
*/
|
||||
virtual inline int getRef () const { return refcount; }
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
@ -201,7 +180,7 @@ protected:
|
||||
struct _internal_state {
|
||||
_internal_state( ssgSimpleState *s, const string &t, bool l )
|
||||
: state(s), texture_path(t), texture_loaded(l) {}
|
||||
ssgSimpleState *state;
|
||||
ssgSharedPtr<ssgSimpleState> state;
|
||||
string texture_path;
|
||||
bool texture_loaded;
|
||||
};
|
||||
@ -235,12 +214,7 @@ private:
|
||||
sgVec4 ambient, diffuse, specular, emission;
|
||||
double shininess;
|
||||
|
||||
vector<SGMatModelGroup *> object_groups;
|
||||
|
||||
// ref count so we can properly delete if we have multiple
|
||||
// pointers to this record
|
||||
int refcount;
|
||||
|
||||
vector<SGSharedPtr<SGMatModelGroup> > object_groups;
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
@ -192,12 +192,11 @@ bool SGMaterialLib::load( const string &fg_root, const string& mpath, const char
|
||||
for (int i = 0; i < nMaterials; i++) {
|
||||
const SGPropertyNode * node = materials.getChild(i);
|
||||
if (!strcmp(node->getName(), "material")) {
|
||||
SGMaterial *m = new SGMaterial( fg_root, node, season );
|
||||
SGSharedPtr<SGMaterial> m = new SGMaterial( fg_root, node, season );
|
||||
|
||||
vector<SGPropertyNode_ptr>names = node->getChildren("name");
|
||||
for ( unsigned int j = 0; j < names.size(); j++ ) {
|
||||
string name = names[j]->getStringValue();
|
||||
m->ref();
|
||||
// cerr << "Material " << name << endl;
|
||||
matlib[name] = m;
|
||||
SG_LOG( SG_TERRAIN, SG_INFO, " Loading material "
|
||||
@ -211,7 +210,6 @@ bool SGMaterialLib::load( const string &fg_root, const string& mpath, const char
|
||||
|
||||
// hard coded ground light state
|
||||
ssgSimpleState *gnd_lights = new ssgSimpleState;
|
||||
gnd_lights->ref();
|
||||
gnd_lights->disable( GL_TEXTURE_2D );
|
||||
gnd_lights->enable( GL_CULL_FACE );
|
||||
gnd_lights->enable( GL_COLOR_MATERIAL );
|
||||
@ -228,7 +226,6 @@ bool SGMaterialLib::load( const string &fg_root, const string& mpath, const char
|
||||
// hard coded runway white light state
|
||||
tex_name = gen_standard_dir_light_map( 235, 235, 195, 255 );
|
||||
ssgSimpleState *rwy_white_lights = new ssgSimpleState();
|
||||
rwy_white_lights->ref();
|
||||
rwy_white_lights->disable( GL_LIGHTING );
|
||||
rwy_white_lights->enable ( GL_CULL_FACE ) ;
|
||||
rwy_white_lights->enable( GL_TEXTURE_2D );
|
||||
@ -249,7 +246,6 @@ bool SGMaterialLib::load( const string &fg_root, const string& mpath, const char
|
||||
// hard coded runway medium intensity white light state
|
||||
tex_name = gen_standard_dir_light_map( 235, 235, 195, 205 );
|
||||
ssgSimpleState *rwy_white_medium_lights = new ssgSimpleState();
|
||||
rwy_white_medium_lights->ref();
|
||||
rwy_white_medium_lights->disable( GL_LIGHTING );
|
||||
rwy_white_medium_lights->enable ( GL_CULL_FACE ) ;
|
||||
rwy_white_medium_lights->enable( GL_TEXTURE_2D );
|
||||
@ -267,7 +263,6 @@ bool SGMaterialLib::load( const string &fg_root, const string& mpath, const char
|
||||
// hard coded runway low intensity white light state
|
||||
tex_name = gen_standard_dir_light_map( 235, 235, 195, 155 );
|
||||
ssgSimpleState *rwy_white_low_lights = new ssgSimpleState();
|
||||
rwy_white_low_lights->ref();
|
||||
rwy_white_low_lights->disable( GL_LIGHTING );
|
||||
rwy_white_low_lights->enable ( GL_CULL_FACE ) ;
|
||||
rwy_white_low_lights->enable( GL_TEXTURE_2D );
|
||||
@ -285,7 +280,6 @@ bool SGMaterialLib::load( const string &fg_root, const string& mpath, const char
|
||||
// hard coded runway yellow light state
|
||||
tex_name = gen_standard_dir_light_map( 235, 215, 20, 255 );
|
||||
ssgSimpleState *rwy_yellow_lights = new ssgSimpleState();
|
||||
rwy_yellow_lights->ref();
|
||||
rwy_yellow_lights->disable( GL_LIGHTING );
|
||||
rwy_yellow_lights->enable ( GL_CULL_FACE ) ;
|
||||
rwy_yellow_lights->enable( GL_TEXTURE_2D );
|
||||
@ -302,7 +296,6 @@ bool SGMaterialLib::load( const string &fg_root, const string& mpath, const char
|
||||
// hard coded runway medium intensity yellow light state
|
||||
tex_name = gen_standard_dir_light_map( 235, 215, 20, 205 );
|
||||
ssgSimpleState *rwy_yellow_medium_lights = new ssgSimpleState();
|
||||
rwy_yellow_medium_lights->ref();
|
||||
rwy_yellow_medium_lights->disable( GL_LIGHTING );
|
||||
rwy_yellow_medium_lights->enable ( GL_CULL_FACE ) ;
|
||||
rwy_yellow_medium_lights->enable( GL_TEXTURE_2D );
|
||||
@ -320,7 +313,6 @@ bool SGMaterialLib::load( const string &fg_root, const string& mpath, const char
|
||||
// hard coded runway low intensity yellow light state
|
||||
tex_name = gen_standard_dir_light_map( 235, 215, 20, 155 );
|
||||
ssgSimpleState *rwy_yellow_low_lights = new ssgSimpleState();
|
||||
rwy_yellow_low_lights->ref();
|
||||
rwy_yellow_low_lights->disable( GL_LIGHTING );
|
||||
rwy_yellow_low_lights->enable ( GL_CULL_FACE ) ;
|
||||
rwy_yellow_low_lights->enable( GL_TEXTURE_2D );
|
||||
@ -338,7 +330,6 @@ bool SGMaterialLib::load( const string &fg_root, const string& mpath, const char
|
||||
// hard coded runway red light state
|
||||
tex_name = gen_standard_dir_light_map( 235, 90, 90, 255 );
|
||||
ssgSimpleState *rwy_red_lights = new ssgSimpleState();
|
||||
rwy_red_lights->ref();
|
||||
rwy_red_lights->disable( GL_LIGHTING );
|
||||
rwy_red_lights->enable ( GL_CULL_FACE ) ;
|
||||
rwy_red_lights->enable( GL_TEXTURE_2D );
|
||||
@ -356,7 +347,6 @@ bool SGMaterialLib::load( const string &fg_root, const string& mpath, const char
|
||||
// hard coded medium intensity runway red light state
|
||||
tex_name = gen_standard_dir_light_map( 235, 90, 90, 205 );
|
||||
ssgSimpleState *rwy_red_medium_lights = new ssgSimpleState();
|
||||
rwy_red_medium_lights->ref();
|
||||
rwy_red_medium_lights->disable( GL_LIGHTING );
|
||||
rwy_red_medium_lights->enable ( GL_CULL_FACE ) ;
|
||||
rwy_red_medium_lights->enable( GL_TEXTURE_2D );
|
||||
@ -374,7 +364,6 @@ bool SGMaterialLib::load( const string &fg_root, const string& mpath, const char
|
||||
// hard coded low intensity runway red light state
|
||||
tex_name = gen_standard_dir_light_map( 235, 90, 90, 155 );
|
||||
ssgSimpleState *rwy_red_low_lights = new ssgSimpleState();
|
||||
rwy_red_low_lights->ref();
|
||||
rwy_red_low_lights->disable( GL_LIGHTING );
|
||||
rwy_red_low_lights->enable ( GL_CULL_FACE ) ;
|
||||
rwy_red_low_lights->enable( GL_TEXTURE_2D );
|
||||
@ -392,7 +381,6 @@ bool SGMaterialLib::load( const string &fg_root, const string& mpath, const char
|
||||
// hard coded runway green light state
|
||||
tex_name = gen_standard_dir_light_map( 20, 235, 20, 255 );
|
||||
ssgSimpleState *rwy_green_lights = new ssgSimpleState();
|
||||
rwy_green_lights->ref();
|
||||
rwy_green_lights->disable( GL_LIGHTING );
|
||||
rwy_green_lights->enable ( GL_CULL_FACE ) ;
|
||||
rwy_green_lights->enable( GL_TEXTURE_2D );
|
||||
@ -410,7 +398,6 @@ bool SGMaterialLib::load( const string &fg_root, const string& mpath, const char
|
||||
// hard coded medium intensity runway green light state
|
||||
tex_name = gen_standard_dir_light_map( 20, 235, 20, 205 );
|
||||
ssgSimpleState *rwy_green_medium_lights = new ssgSimpleState();
|
||||
rwy_green_medium_lights->ref();
|
||||
rwy_green_medium_lights->disable( GL_LIGHTING );
|
||||
rwy_green_medium_lights->enable ( GL_CULL_FACE ) ;
|
||||
rwy_green_medium_lights->enable( GL_TEXTURE_2D );
|
||||
@ -428,7 +415,6 @@ bool SGMaterialLib::load( const string &fg_root, const string& mpath, const char
|
||||
// hard coded low intensity runway green light state
|
||||
tex_name = gen_standard_dir_light_map( 20, 235, 20, 155 );
|
||||
ssgSimpleState *rwy_green_low_lights = new ssgSimpleState();
|
||||
rwy_green_low_lights->ref();
|
||||
rwy_green_low_lights->disable( GL_LIGHTING );
|
||||
rwy_green_low_lights->enable ( GL_CULL_FACE ) ;
|
||||
rwy_green_low_lights->enable( GL_TEXTURE_2D );
|
||||
@ -448,7 +434,6 @@ bool SGMaterialLib::load( const string &fg_root, const string& mpath, const char
|
||||
// hard coded low intensity taxiway blue light state
|
||||
tex_name = gen_taxiway_dir_light_map( 90, 90, 235, 205 );
|
||||
ssgSimpleState *taxiway_blue_low_lights = new ssgSimpleState();
|
||||
taxiway_blue_low_lights->ref();
|
||||
taxiway_blue_low_lights->disable( GL_LIGHTING );
|
||||
taxiway_blue_low_lights->enable ( GL_CULL_FACE ) ;
|
||||
taxiway_blue_low_lights->enable( GL_TEXTURE_2D );
|
||||
@ -466,7 +451,6 @@ bool SGMaterialLib::load( const string &fg_root, const string& mpath, const char
|
||||
// hard coded runway vasi light state
|
||||
tex_name = gen_standard_dir_light_map( 235, 235, 195, 255 );
|
||||
ssgSimpleState *rwy_vasi_lights = new ssgSimpleState();
|
||||
rwy_vasi_lights->ref();
|
||||
rwy_vasi_lights->disable( GL_LIGHTING );
|
||||
rwy_vasi_lights->enable ( GL_CULL_FACE ) ;
|
||||
rwy_vasi_lights->enable( GL_TEXTURE_2D );
|
||||
@ -515,13 +499,11 @@ bool SGMaterialLib::add_item ( const string &mat_name, const string &full_path )
|
||||
// Load a library of material properties
|
||||
bool SGMaterialLib::add_item ( const string &mat_name, ssgSimpleState *state )
|
||||
{
|
||||
SGMaterial *m = new SGMaterial( state );
|
||||
matlib[mat_name] = new SGMaterial( state );
|
||||
|
||||
SG_LOG( SG_TERRAIN, SG_INFO, " Loading material given a premade "
|
||||
<< "ssgSimpleState = " << mat_name );
|
||||
|
||||
matlib[mat_name] = m;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -541,14 +523,6 @@ SGMaterial *SGMaterialLib::find( const string& material ) {
|
||||
|
||||
// Destructor
|
||||
SGMaterialLib::~SGMaterialLib ( void ) {
|
||||
// Free up all the material entries first
|
||||
for ( material_map_iterator it = begin(); it != end(); it++ ) {
|
||||
SGMaterial *slot = it->second;
|
||||
slot->deRef();
|
||||
if ( slot->getRef() <= 0 ) {
|
||||
delete slot;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -31,6 +31,8 @@
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
#include <simgear/structure/SGSharedPtr.hxx>
|
||||
|
||||
#include STL_STRING // Standard C++ string library
|
||||
#include <map> // STL associative "array"
|
||||
#include <vector> // STL "array"
|
||||
@ -52,7 +54,7 @@ class SGMaterialLib {
|
||||
private:
|
||||
|
||||
// associative array of materials
|
||||
typedef map < string, SGMaterial *, less<string> > material_map;
|
||||
typedef map < string, SGSharedPtr<SGMaterial>, less<string> > material_map;
|
||||
typedef material_map::iterator material_map_iterator;
|
||||
typedef material_map::const_iterator const_material_map_iterator;
|
||||
|
||||
|
@ -108,12 +108,6 @@ SGMatModel::SGMatModel (const SGPropertyNode * node, double range_m)
|
||||
|
||||
SGMatModel::~SGMatModel ()
|
||||
{
|
||||
for (unsigned int i = 0; i < _models.size(); i++) {
|
||||
if (_models[i] != 0) {
|
||||
ssgDeRefDelete(_models[i]);
|
||||
_models[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
@ -160,7 +154,6 @@ SGMatModel::load_models ( SGModelLib *modellib,
|
||||
// there).
|
||||
float ranges[] = {0, _range_m};
|
||||
ssgRangeSelector * lod = new ssgRangeSelector;
|
||||
lod->ref();
|
||||
lod->setRanges(ranges, 2);
|
||||
if (_heading_type == HEADING_BILLBOARD) {
|
||||
// if the model is a billboard, it is likely :
|
||||
@ -246,10 +239,6 @@ SGMatModelGroup::SGMatModelGroup (SGPropertyNode * node)
|
||||
|
||||
SGMatModelGroup::~SGMatModelGroup ()
|
||||
{
|
||||
for (unsigned int i = 0; i < _objects.size(); i++) {
|
||||
delete _objects[i];
|
||||
_objects[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
double
|
||||
|
@ -35,6 +35,9 @@
|
||||
#include <plib/sg.h>
|
||||
#include <plib/ssg.h>
|
||||
|
||||
#include <simgear/structure/SGReferenced.hxx>
|
||||
#include <simgear/structure/SGSharedPtr.hxx>
|
||||
#include <simgear/structure/ssgSharedPtr.hxx>
|
||||
#include <simgear/props/props.hxx>
|
||||
|
||||
SG_USING_STD(string);
|
||||
@ -53,7 +56,7 @@ class SGModelLib;
|
||||
* different shapes of trees), but they are considered equivalent
|
||||
* and interchangeable.
|
||||
*/
|
||||
class SGMatModel {
|
||||
class SGMatModel : public SGReferenced {
|
||||
|
||||
public:
|
||||
|
||||
@ -116,14 +119,14 @@ public:
|
||||
*/
|
||||
HeadingType get_heading_type () const;
|
||||
|
||||
virtual ~SGMatModel ();
|
||||
|
||||
protected:
|
||||
|
||||
friend class SGMatModelGroup;
|
||||
|
||||
SGMatModel (const SGPropertyNode * node, double range_m);
|
||||
|
||||
virtual ~SGMatModel ();
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
@ -138,7 +141,7 @@ private:
|
||||
double sim_time_sec );
|
||||
|
||||
vector<string> _paths;
|
||||
mutable vector<ssgEntity *> _models;
|
||||
mutable vector<ssgSharedPtr<ssgEntity> > _models;
|
||||
mutable bool _models_loaded;
|
||||
double _coverage_m2;
|
||||
double _range_m;
|
||||
@ -154,7 +157,7 @@ private:
|
||||
* Each SGMaterial instance keeps a (possibly-empty) list of
|
||||
* object groups for placing randomly on the scenery.
|
||||
*/
|
||||
class SGMatModelGroup {
|
||||
class SGMatModelGroup : public SGReferenced {
|
||||
|
||||
public:
|
||||
|
||||
@ -194,7 +197,7 @@ protected:
|
||||
private:
|
||||
|
||||
double _range_m;
|
||||
vector<SGMatModel *> _objects;
|
||||
vector<SGSharedPtr<SGMatModel> > _objects;
|
||||
|
||||
};
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
#include <simgear/math/point3d.hxx>
|
||||
#include <simgear/props/props.hxx>
|
||||
#include <simgear/structure/ssgSharedPtr.hxx>
|
||||
|
||||
|
||||
// Don't pull in the headers, since we don't need them here.
|
||||
@ -91,8 +92,8 @@ private:
|
||||
double _pitch_deg;
|
||||
double _heading_deg;
|
||||
|
||||
ssgSelector * _selector;
|
||||
ssgPlacementTransform * _position;
|
||||
ssgSharedPtr<ssgSelector> _selector;
|
||||
ssgSharedPtr<ssgPlacementTransform> _position;
|
||||
|
||||
// Location
|
||||
SGLocation * _location;
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include <simgear/misc/sg_path.hxx>
|
||||
#include <simgear/screen/extensions.hxx>
|
||||
#include <simgear/screen/texture.hxx>
|
||||
#include <simgear/structure/ssgSharedPtr.hxx>
|
||||
|
||||
#include "newcloud.hxx"
|
||||
#include "cloudfield.hxx"
|
||||
@ -49,12 +50,12 @@
|
||||
#endif
|
||||
|
||||
|
||||
static ssgStateSelector *layer_states[SGCloudLayer::SG_MAX_CLOUD_COVERAGES];
|
||||
static ssgSharedPtr<ssgStateSelector> layer_states[SGCloudLayer::SG_MAX_CLOUD_COVERAGES];
|
||||
static bool state_initialized = false;
|
||||
static bool bump_mapping = false;
|
||||
static GLint nb_texture_unit = 0;
|
||||
static ssgTexture *normal_map[SGCloudLayer::SG_MAX_CLOUD_COVERAGES][2] = { 0 };
|
||||
static ssgTexture *color_map[SGCloudLayer::SG_MAX_CLOUD_COVERAGES][2] = { 0 };
|
||||
static ssgSharedPtr<ssgTexture> normal_map[SGCloudLayer::SG_MAX_CLOUD_COVERAGES][2];
|
||||
static ssgSharedPtr<ssgTexture> color_map[SGCloudLayer::SG_MAX_CLOUD_COVERAGES][2];
|
||||
static GLuint normalization_cube_map;
|
||||
|
||||
static glActiveTextureProc glActiveTexturePtr = 0;
|
||||
@ -345,56 +346,44 @@ SGCloudLayer::rebuild()
|
||||
cloud_path.set(texture_path.str());
|
||||
cloud_path.append("overcast.rgb");
|
||||
color_map[ SG_CLOUD_OVERCAST ][ 0 ] = new ssgTexture( cloud_path.str().c_str() );
|
||||
color_map[ SG_CLOUD_OVERCAST ][ 0 ]->ref();
|
||||
cloud_path.set(texture_path.str());
|
||||
cloud_path.append("overcast_n.rgb");
|
||||
normal_map[ SG_CLOUD_OVERCAST ][ 0 ] = new ssgTexture( cloud_path.str().c_str() );
|
||||
normal_map[ SG_CLOUD_OVERCAST ][ 0 ]->ref();
|
||||
|
||||
cloud_path.set(texture_path.str());
|
||||
cloud_path.append("overcast_top.rgb");
|
||||
color_map[ SG_CLOUD_OVERCAST ][ 1 ] = new ssgTexture( cloud_path.str().c_str() );
|
||||
color_map[ SG_CLOUD_OVERCAST ][ 1 ]->ref();
|
||||
cloud_path.set(texture_path.str());
|
||||
cloud_path.append("overcast_top_n.rgb");
|
||||
normal_map[ SG_CLOUD_OVERCAST ][ 1 ] = new ssgTexture( cloud_path.str().c_str() );
|
||||
normal_map[ SG_CLOUD_OVERCAST ][ 1 ]->ref();
|
||||
|
||||
cloud_path.set(texture_path.str());
|
||||
cloud_path.append("broken.rgba");
|
||||
color_map[ SG_CLOUD_BROKEN ][ 0 ] = new ssgTexture( cloud_path.str().c_str() );
|
||||
color_map[ SG_CLOUD_BROKEN ][ 0 ]->ref();
|
||||
cloud_path.set(texture_path.str());
|
||||
cloud_path.append("broken_n.rgb");
|
||||
normal_map[ SG_CLOUD_BROKEN ][ 0 ] = new ssgTexture( cloud_path.str().c_str() );
|
||||
normal_map[ SG_CLOUD_BROKEN ][ 0 ]->ref();
|
||||
|
||||
cloud_path.set(texture_path.str());
|
||||
cloud_path.append("scattered.rgba");
|
||||
color_map[ SG_CLOUD_SCATTERED ][ 0 ] = new ssgTexture( cloud_path.str().c_str() );
|
||||
color_map[ SG_CLOUD_SCATTERED ][ 0 ]->ref();
|
||||
cloud_path.set(texture_path.str());
|
||||
cloud_path.append("scattered_n.rgb");
|
||||
normal_map[ SG_CLOUD_SCATTERED ][ 0 ] = new ssgTexture( cloud_path.str().c_str() );
|
||||
normal_map[ SG_CLOUD_SCATTERED ][ 0 ]->ref();
|
||||
|
||||
cloud_path.set(texture_path.str());
|
||||
cloud_path.append("few.rgba");
|
||||
color_map[ SG_CLOUD_FEW ][ 0 ] = new ssgTexture( cloud_path.str().c_str() );
|
||||
color_map[ SG_CLOUD_FEW ][ 0 ]->ref();
|
||||
cloud_path.set(texture_path.str());
|
||||
cloud_path.append("few_n.rgb");
|
||||
normal_map[ SG_CLOUD_FEW ][ 0 ] = new ssgTexture( cloud_path.str().c_str() );
|
||||
normal_map[ SG_CLOUD_FEW ][ 0 ]->ref();
|
||||
|
||||
cloud_path.set(texture_path.str());
|
||||
cloud_path.append("cirrus.rgba");
|
||||
color_map[ SG_CLOUD_CIRRUS ][ 0 ] = new ssgTexture( cloud_path.str().c_str() );
|
||||
color_map[ SG_CLOUD_CIRRUS ][ 0 ]->ref();
|
||||
cloud_path.set(texture_path.str());
|
||||
cloud_path.append("cirrus_n.rgb");
|
||||
normal_map[ SG_CLOUD_CIRRUS ][ 0 ] = new ssgTexture( cloud_path.str().c_str() );
|
||||
normal_map[ SG_CLOUD_CIRRUS ][ 0 ]->ref();
|
||||
|
||||
glGenTextures( 1, &normalization_cube_map );
|
||||
glBindTexture( GL_TEXTURE_CUBE_MAP_ARB, normalization_cube_map );
|
||||
@ -410,7 +399,6 @@ SGCloudLayer::rebuild()
|
||||
ssgSimpleState *state;
|
||||
|
||||
state_sel = new ssgStateSelector( 2 );
|
||||
state_sel->ref();
|
||||
cloud_path.set(texture_path.str());
|
||||
cloud_path.append("overcast.rgb");
|
||||
state_sel->setStep( 0, sgCloudMakeState(cloud_path.str()) );
|
||||
@ -420,7 +408,6 @@ SGCloudLayer::rebuild()
|
||||
layer_states[SG_CLOUD_OVERCAST] = state_sel;
|
||||
|
||||
state_sel = new ssgStateSelector( 2 );
|
||||
state_sel->ref();
|
||||
cloud_path.set(texture_path.str());
|
||||
cloud_path.append("broken.rgba");
|
||||
state = sgCloudMakeState(cloud_path.str());
|
||||
@ -429,7 +416,6 @@ SGCloudLayer::rebuild()
|
||||
layer_states[SG_CLOUD_BROKEN] = state_sel;
|
||||
|
||||
state_sel = new ssgStateSelector( 2 );
|
||||
state_sel->ref();
|
||||
cloud_path.set(texture_path.str());
|
||||
cloud_path.append("scattered.rgba");
|
||||
state = sgCloudMakeState(cloud_path.str());
|
||||
@ -438,7 +424,6 @@ SGCloudLayer::rebuild()
|
||||
layer_states[SG_CLOUD_SCATTERED] = state_sel;
|
||||
|
||||
state_sel = new ssgStateSelector( 2 );
|
||||
state_sel->ref();
|
||||
cloud_path.set(texture_path.str());
|
||||
cloud_path.append("few.rgba");
|
||||
state = sgCloudMakeState(cloud_path.str());
|
||||
@ -447,7 +432,6 @@ SGCloudLayer::rebuild()
|
||||
layer_states[SG_CLOUD_FEW] = state_sel;
|
||||
|
||||
state_sel = new ssgStateSelector( 2 );
|
||||
state_sel->ref();
|
||||
cloud_path.set(texture_path.str());
|
||||
cloud_path.append("cirrus.rgba");
|
||||
state = sgCloudMakeState(cloud_path.str());
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include <plib/ssg.h>
|
||||
#include <simgear/math/sg_random.h>
|
||||
#include <simgear/misc/sg_path.hxx>
|
||||
#include <simgear/structure/ssgSharedPtr.hxx>
|
||||
|
||||
#include STL_ALGORITHM
|
||||
#include SG_GLU_H
|
||||
@ -41,7 +42,7 @@
|
||||
/*
|
||||
*/
|
||||
|
||||
static ssgTexture *cloudTextures[SGNewCloud::CLTexture_max];
|
||||
static ssgSharedPtr<ssgTexture> cloudTextures[SGNewCloud::CLTexture_max];
|
||||
|
||||
|
||||
bool SGNewCloud::useAnisotropic = true;
|
||||
@ -129,12 +130,10 @@ void SGNewCloud::loadTextures(const string &tex_path) {
|
||||
cloud_path.set(tex_path);
|
||||
cloud_path.append("cl_cumulus.rgb");
|
||||
cloudTextures[ CLTexture_cumulus ] = new ssgTexture( cloud_path.str().c_str(), false, false, false );
|
||||
cloudTextures[ CLTexture_cumulus ]->ref();
|
||||
|
||||
cloud_path.set(tex_path);
|
||||
cloud_path.append("cl_stratus.rgb");
|
||||
cloudTextures[ CLTexture_stratus ] = new ssgTexture( cloud_path.str().c_str(), false, false, false );
|
||||
cloudTextures[ CLTexture_stratus ]->ref();
|
||||
|
||||
}
|
||||
|
||||
|
@ -37,6 +37,8 @@
|
||||
#include STL_STRING
|
||||
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
#include <simgear/structure/SGReferenced.hxx>
|
||||
#include <simgear/structure/SGSharedPtr.hxx>
|
||||
|
||||
#include <plib/sg.h>
|
||||
|
||||
@ -56,7 +58,7 @@ SG_USING_STD(string);
|
||||
* manages everything we need to know for an individual sound sample
|
||||
*/
|
||||
|
||||
class SGSoundSample {
|
||||
class SGSoundSample : public SGReferenced {
|
||||
|
||||
private:
|
||||
|
||||
|
@ -141,15 +141,6 @@ SGSoundMgr::~SGSoundMgr() {
|
||||
if (context)
|
||||
alcDestroyContext( context );
|
||||
#endif
|
||||
//
|
||||
// Remove the samples from the sample manager.
|
||||
//
|
||||
sample_map_iterator sample_current = samples.begin();
|
||||
sample_map_iterator sample_end = samples.end();
|
||||
for ( ; sample_current != sample_end; ++sample_current ) {
|
||||
SGSoundSample *sample = sample_current->second;
|
||||
delete sample;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -158,12 +149,6 @@ void SGSoundMgr::init() {
|
||||
//
|
||||
// Remove the samples from the sample manager.
|
||||
//
|
||||
sample_map_iterator sample_current = samples.begin();
|
||||
sample_map_iterator sample_end = samples.end();
|
||||
for ( ; sample_current != sample_end; ++sample_current ) {
|
||||
SGSoundSample *sample = sample_current->second;
|
||||
delete sample;
|
||||
}
|
||||
samples.clear();
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ SG_USING_STD(map);
|
||||
SG_USING_STD(string);
|
||||
|
||||
|
||||
typedef map < string, SGSoundSample * > sample_map;
|
||||
typedef map < string, SGSharedPtr<SGSoundSample> > sample_map;
|
||||
typedef sample_map::iterator sample_map_iterator;
|
||||
typedef sample_map::const_iterator const_sample_map_iterator;
|
||||
|
||||
|
@ -65,7 +65,6 @@ static const struct {
|
||||
SGXmlSound::SGXmlSound()
|
||||
: _sample(NULL),
|
||||
_condition(NULL),
|
||||
_property(NULL),
|
||||
_active(false),
|
||||
_name(""),
|
||||
_mode(SGXmlSound::ONCE),
|
||||
@ -80,12 +79,10 @@ SGXmlSound::~SGXmlSound()
|
||||
{
|
||||
_sample->stop();
|
||||
|
||||
delete _property;
|
||||
delete _condition;
|
||||
|
||||
_volume.clear();
|
||||
_pitch.clear();
|
||||
delete _sample;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -120,7 +120,7 @@ protected:
|
||||
|
||||
// SGXmlSound properties
|
||||
typedef struct {
|
||||
SGPropertyNode * prop;
|
||||
SGPropertyNode_ptr prop;
|
||||
double (*fn)(double);
|
||||
double *intern;
|
||||
double factor;
|
||||
@ -133,10 +133,10 @@ protected:
|
||||
private:
|
||||
|
||||
SGSoundMgr * _mgr;
|
||||
SGSoundSample * _sample;
|
||||
SGSharedPtr<SGSoundSample> _sample;
|
||||
|
||||
SGCondition * _condition;
|
||||
SGPropertyNode * _property;
|
||||
SGPropertyNode_ptr _property;
|
||||
|
||||
bool _active;
|
||||
string _name;
|
||||
|
Loading…
Reference in New Issue
Block a user