SSE2: Workaround alignment issue related to std::pair

--HG--
branch : sse2
hg/feature/sse2
kaetemi 11 years ago
parent 00b8ad4c91
commit d3847e10cc

@ -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<NL3D::CCluster*, CClusterSoundStatus> 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,

@ -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

@ -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;
}

@ -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;
}

@ -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;
}

@ -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);

Loading…
Cancel
Save