From d3847e10ccb132ba2738462a58dc2ef1f6610d8d Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 13 Jun 2014 05:36:43 +0200 Subject: [PATCH] SSE2: Workaround alignment issue related to std::pair --HG-- branch : sse2 --- code/nel/include/nel/sound/clustered_sound.h | 16 +++++++--------- code/nel/src/sound/audio_mixer_user.cpp | 2 +- code/nel/src/sound/clustered_sound.cpp | 9 ++++----- code/nel/src/sound/simple_source.cpp | 2 +- code/nel/src/sound/stream_source.cpp | 2 +- code/ryzom/client/src/sound_manager.cpp | 2 +- 6 files changed, 15 insertions(+), 18 deletions(-) diff --git a/code/nel/include/nel/sound/clustered_sound.h b/code/nel/include/nel/sound/clustered_sound.h index d9d2c47f2..da7cdb12f 100644 --- a/code/nel/include/nel/sound/clustered_sound.h +++ b/code/nel/include/nel/sound/clustered_sound.h @@ -50,7 +50,6 @@ class CClusteredSound { public: /// This structure contain data about sound status in a cluster - NL_ALIGN_SSE2(16) struct CClusterSoundStatus { /// The relative gain of sound in the cluster @@ -60,11 +59,11 @@ public: /// The ratio distance/max earing distance float DistFactor; /// The sound virtual position (in fact Dist * Direction) - NLMISC::CVector Position; + NLMISC::CVectorPacked Position; /// The blending factor between real sound pos and virtual pos (1 mean virtual pos, 0 mean real pos). float PosAlpha; /// The direction vector for the virtual sound source. - NLMISC::CVector Direction; + NLMISC::CVectorPacked Direction; /// The occlusion att. sint32 Occlusion; /// The occlusion LF factor (see EAX spec) @@ -79,7 +78,6 @@ public: typedef std::map TClusterStatusMap; /// This structure is used when we traverse the cluster/portal graph. - NL_ALIGN_SSE2(16) struct CSoundTravContext { /// The current gain. @@ -99,18 +97,18 @@ public: /// A blending factor to compute virtual source position. float Alpha; /// The direction vector from listener to the first portal/cluster - NLMISC::CVector Direction1; + NLMISC::CVectorPacked Direction1; /// The direction vector from the first portal/cluster to the second one. - NLMISC::CVector Direction2; + NLMISC::CVectorPacked Direction2; /// The current blended direction used to place vitual source. - NLMISC::CVector Direction; + NLMISC::CVectorPacked Direction; /// The previously traversed cluster. Used to stop back traversal. NL3D::CCluster *PreviousCluster; /// The previous sound propagation vector - NLMISC::CVector PreviousVector; + NLMISC::CVectorPacked PreviousVector; /// The last pseudo listener position - NLMISC::CVector ListenerPos; + NLMISC::CVectorPacked ListenerPos; /// Constructor. Init all default value. CSoundTravContext(const NLMISC::CVector &listenerPos, diff --git a/code/nel/src/sound/audio_mixer_user.cpp b/code/nel/src/sound/audio_mixer_user.cpp index 3a75433f4..4807581f0 100644 --- a/code/nel/src/sound/audio_mixer_user.cpp +++ b/code/nel/src/sound/audio_mixer_user.cpp @@ -1705,7 +1705,7 @@ void CAudioMixerUser::update() { // there is some data here, update the virtual position of the sound. float dist = (css->Position - source->getPos()).norm(); - CVector vpos(_ListenPosition + css->Direction * (css->Dist + dist)); + CVector vpos(_ListenPosition + CVector(css->Direction) * (css->Dist + dist)); // _Tracks[i]->DrvSource->setPos(source->getPos() * (1-css->PosAlpha) + css->Position*(css->PosAlpha)); _Tracks[i]->getPhysicalSource()->setPos(source->getPos() * (1-css->PosAlpha) + vpos*(css->PosAlpha)); // update the relative gain diff --git a/code/nel/src/sound/clustered_sound.cpp b/code/nel/src/sound/clustered_sound.cpp index 0ccfd0d59..8dbc12264 100644 --- a/code/nel/src/sound/clustered_sound.cpp +++ b/code/nel/src/sound/clustered_sound.cpp @@ -263,7 +263,7 @@ void CClusteredSound::update(const CVector &listenerPos, const CVector &/* view { // this one is better ! cs.Distance = css.Dist; - cs.Source->setPos(listenerPos + css.Direction * css.Dist + CVector(0,0,2)); + cs.Source->setPos(listenerPos + CVector(css.Direction) * css.Dist + CVector(0,0,2)); if (css.DistFactor < 1.0f) cs.Source->setRelativeGain(css.Gain * (1.0f - (css.DistFactor*css.DistFactor*css.DistFactor*css.DistFactor))); else @@ -289,7 +289,7 @@ void CClusteredSound::update(const CVector &listenerPos, const CVector &/* view cs.Source = CAudioMixerUser::instance()->createSource(soundName, false, NULL, NULL, cluster); if (cs.Source != 0) { - cs.Source->setPos(listenerPos + css.Direction * css.Dist + CVector(0,0,2)); + cs.Source->setPos(listenerPos + CVector(css.Direction) * css.Dist + CVector(0,0,2)); if (css.DistFactor < 1.0f) cs.Source->setRelativeGain(css.Gain * (1.0f - (css.DistFactor*css.DistFactor/**css.DistFactor*css.DistFactor*/))); else @@ -867,7 +867,7 @@ bool CClusteredSound::addAudibleCluster(CCluster *cluster, CClusterSoundStatus & { TClusterStatusMap::iterator it(_AudibleClusters.find(cluster)); nlassert(soundStatus.Dist < _MaxEarDistance); - nlassert(soundStatus.Direction.norm() <= 1.01f); + nlassert(CVector(soundStatus.Direction).norm() <= 1.01f); if (it != _AudibleClusters.end()) { @@ -881,8 +881,7 @@ bool CClusteredSound::addAudibleCluster(CCluster *cluster, CClusterSoundStatus & } else { - //_AudibleClusters.insert(make_pair(cluster, soundStatus)); - _AudibleClusters[cluster] = soundStatus; + _AudibleClusters.insert(make_pair(cluster, soundStatus)); return true; } diff --git a/code/nel/src/sound/simple_source.cpp b/code/nel/src/sound/simple_source.cpp index 2c9dda86c..0bf4eba8d 100644 --- a/code/nel/src/sound/simple_source.cpp +++ b/code/nel/src/sound/simple_source.cpp @@ -109,7 +109,7 @@ CVector CSimpleSource::getVirtualPos() const { // there is some data here, update the virtual position of the sound. float dist = (css->Position - getPos()).norm(); - CVector vpos(CAudioMixerUser::instance()->getListenPosVector() + css->Direction * (css->Dist + dist)); + CVector vpos(CAudioMixerUser::instance()->getListenPosVector() + CVector(css->Direction) * (css->Dist + dist)); vpos = _Position * (1-css->PosAlpha) + vpos*(css->PosAlpha); return vpos; } diff --git a/code/nel/src/sound/stream_source.cpp b/code/nel/src/sound/stream_source.cpp index 9bd48ff25..ece500cd0 100644 --- a/code/nel/src/sound/stream_source.cpp +++ b/code/nel/src/sound/stream_source.cpp @@ -134,7 +134,7 @@ CVector CStreamSource::getVirtualPos() const { // there is some data here, update the virtual position of the sound. float dist = (css->Position - getPos()).norm(); - CVector vpos(CAudioMixerUser::instance()->getListenPosVector() + css->Direction * (css->Dist + dist)); + CVector vpos(CAudioMixerUser::instance()->getListenPosVector() + CVector(css->Direction) * (css->Dist + dist)); vpos = _Position * (1-css->PosAlpha) + vpos*(css->PosAlpha); return vpos; } diff --git a/code/ryzom/client/src/sound_manager.cpp b/code/ryzom/client/src/sound_manager.cpp index f87c6cdee..7c5589432 100644 --- a/code/ryzom/client/src/sound_manager.cpp +++ b/code/ryzom/client/src/sound_manager.cpp @@ -343,7 +343,7 @@ void CSoundManager::drawSounds(float camHeight) const CClusteredSound::CClusterSoundStatus &css = first->second; if (css.Direction != CVector::Null) { - CVector dest = pos+css.Direction*css.Dist; + CVector dest = pos+CVector(css.Direction)*css.Dist; NL3D::CDRU::drawLine(pos, dest, CRGBA(0,255,255,255), *idriver); NL3D::CDRU::drawLine(dest+CVector(0.5f,0.5f,0), dest+CVector(-0.5f,-0.5f,0), CRGBA(0, 255,255,255), *idriver);