Small code reorganization, mostly removing unneeded code
This commit is contained in:
@@ -42,8 +42,6 @@ SGSampleGroup::SGSampleGroup () :
|
||||
_tied_to_listener(false),
|
||||
_velocity(SGVec3d::zeros()),
|
||||
_orientation(SGQuatd::zeros()),
|
||||
_position(SGVec3d::zeros()),
|
||||
_pos_offs(SGVec3d::zeros()),
|
||||
_position_geod(SGGeod())
|
||||
{
|
||||
_samples.clear();
|
||||
@@ -58,8 +56,6 @@ SGSampleGroup::SGSampleGroup ( SGSoundMgr *smgr, const string &refname ) :
|
||||
_tied_to_listener(false),
|
||||
_velocity(SGVec3d::zeros()),
|
||||
_orientation(SGQuatd::zeros()),
|
||||
_position(SGVec3d::zeros()),
|
||||
_pos_offs(SGVec3d::zeros()),
|
||||
_position_geod(SGGeod())
|
||||
{
|
||||
_smgr->add(this, refname);
|
||||
@@ -344,19 +340,6 @@ void SGSampleGroup::update_pos_and_orientation() {
|
||||
SGVec3d position = SGVec3d::fromGeod( _position_geod );
|
||||
SGVec3d pos_offs = SGVec3d::fromGeod( _smgr->get_position_geod() );
|
||||
|
||||
if (_position != position || _pos_offs != pos_offs) {
|
||||
_position = position;
|
||||
_pos_offs = pos_offs;
|
||||
|
||||
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;
|
||||
sample->set_position( _position );
|
||||
sample->set_position_offset( _pos_offs );
|
||||
}
|
||||
}
|
||||
|
||||
// The rotation rotating from the earth centerd frame to
|
||||
// the horizontal local frame
|
||||
SGQuatd hlOr = SGQuatd::fromLonLat(_position_geod);
|
||||
@@ -373,6 +356,7 @@ void SGSampleGroup::update_pos_and_orientation() {
|
||||
sample_map_iterator sample_end = _samples.end();
|
||||
for ( ; sample_current != sample_end; ++sample_current ) {
|
||||
SGSoundSample *sample = sample_current->second;
|
||||
sample->set_position( position - pos_offs );
|
||||
sample->set_orientation( _orientation );
|
||||
sample->set_rotation( sc2body );
|
||||
}
|
||||
|
||||
@@ -226,9 +226,6 @@ private:
|
||||
|
||||
SGVec3f _velocity;
|
||||
SGQuatd _orientation;
|
||||
SGVec3d _position;
|
||||
SGVec3d _pos_offs;
|
||||
|
||||
SGGeod _position_geod;
|
||||
|
||||
sample_map _samples;
|
||||
|
||||
@@ -51,7 +51,6 @@ SGSoundSample::SGSoundSample() :
|
||||
_rotation(SGQuatd::zeros()),
|
||||
_orivec(SGVec3f::zeros()),
|
||||
_base_pos(SGVec3d::zeros()),
|
||||
_base_offs(SGVec3d::zeros()),
|
||||
_refname(random_string()),
|
||||
_data(NULL),
|
||||
_format(AL_FORMAT_MONO8),
|
||||
@@ -87,7 +86,6 @@ SGSoundSample::SGSoundSample( const char *path, const char *file ) :
|
||||
_rotation(SGQuatd::zeros()),
|
||||
_orivec(SGVec3f::zeros()),
|
||||
_base_pos(SGVec3d::zeros()),
|
||||
_base_offs(SGVec3d::zeros()),
|
||||
_refname(file),
|
||||
_data(NULL),
|
||||
_format(AL_FORMAT_MONO8),
|
||||
@@ -129,7 +127,6 @@ SGSoundSample::SGSoundSample( const unsigned char** data,
|
||||
_rotation(SGQuatd::zeros()),
|
||||
_orivec(SGVec3f::zeros()),
|
||||
_base_pos(SGVec3d::zeros()),
|
||||
_base_offs(SGVec3d::zeros()),
|
||||
_refname(random_string()),
|
||||
_format(format),
|
||||
_size(len),
|
||||
@@ -166,7 +163,6 @@ SGSoundSample::SGSoundSample( void** data, int len, int freq, int format ) :
|
||||
_rotation(SGQuatd::zeros()),
|
||||
_orivec(SGVec3f::zeros()),
|
||||
_base_pos(SGVec3d::zeros()),
|
||||
_base_offs(SGVec3d::zeros()),
|
||||
_refname(random_string()),
|
||||
_format(format),
|
||||
_size(len),
|
||||
@@ -201,7 +197,7 @@ SGSoundSample::~SGSoundSample() {
|
||||
|
||||
void SGSoundSample::update_pos_and_orientation() {
|
||||
|
||||
_absolute_pos = _base_pos - _base_offs;
|
||||
_absolute_pos = _base_pos;
|
||||
if ( _relative_pos[0] || _relative_pos[1] || _relative_pos[2] ) {
|
||||
_absolute_pos += _rotation.backTransform(_relative_pos);
|
||||
}
|
||||
|
||||
@@ -322,14 +322,6 @@ public:
|
||||
_base_pos = pos; _changed = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the base position offset in Cartesian coordinates
|
||||
* @param offs offset in Cartesian coordinates
|
||||
*/
|
||||
inline void set_position_offset( const SGVec3d& offs ) {
|
||||
_base_offs = offs; _changed = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the absolute position of this sound.
|
||||
* This is in the same coordinate system as OpenGL; y=up, z=back, x=right.
|
||||
@@ -472,7 +464,6 @@ private:
|
||||
SGQuatd _rotation; // rotation vector for relative offsets
|
||||
SGVec3f _orivec; // orientation vector for OpenAL
|
||||
SGVec3d _base_pos; // base position
|
||||
SGVec3d _base_offs; // base offset position
|
||||
|
||||
std::string _refname; // name or file path
|
||||
unsigned char* _data;
|
||||
|
||||
Reference in New Issue
Block a user