MCPcopy Create free account
hub / github.com/StrongPC123/Far-Cry-1-Source-Full / SetPosition

Method SetPosition

CrySoundSystem/Sound.cpp:778–849  ·  view source on GitHub ↗

/////////////////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

776
777//////////////////////////////////////////////////////////////////////
778void CSound::SetPosition(const Vec3d &pos)
779{
780
781 m_position=pos;
782 m_RealPos=m_position;
783
784 if (!(m_nFlags & FLAG_SOUND_3D))
785 return;
786
787 /*
788 if (m_pSSys->m_pCVarDebugSound->GetIVal()==1)
789 {
790 m_pSSys->m_pILog->Log("Sound %s, pos+%f,%f,%f",m_strName.c_str(),m_position.x,m_position.y,m_position.z);
791 }
792 */
793
794 float fPos[3];
795
796 fPos[0]=m_position.x;
797 fPos[1]=m_position.z;
798 fPos[2]=m_position.y;
799
800 if ((m_pSSys->m_fDirAttCone>0.0f) && (m_pSSys->m_fDirAttCone<1.0f))
801 {
802 Vec3d DirToPlayer=m_position-m_pSSys->m_DirAttPos;
803 DirToPlayer.Normalize();
804 float fScale=((1.0f-(DirToPlayer*m_pSSys->m_DirAttDir))/(1.0f-m_pSSys->m_fDirAttCone));
805 if ((fScale>0.0f) && (fScale<=1.0f)) // inside cone
806 {
807 if ((1.0f-fScale)>m_pSSys->m_fDirAttMaxScale)
808 m_pSSys->m_fDirAttMaxScale=1.0f-fScale;
809 m_RealPos=m_position*fScale+(m_pSSys->m_DirAttPos+(m_pSSys->m_DirAttDir*0.1f))*(1.0f-fScale);
810 fPos[0]=m_RealPos.x;
811 fPos[1]=m_RealPos.z;
812 fPos[2]=m_RealPos.y;
813 //TRACE("Sound-Proj: %s, %1.3f, %1.3f, %1.3f, (%5.3f, %5.3f, %5.3f)", m_strName.c_str(), fScale, DirToPlayer*m_pSSys->m_DirAttDir, m_pSSys->m_fDirAttCone, m_RealPos.x, m_RealPos.y, m_RealPos.z);
814 }
815 }
816
817 if (m_pSSys->m_pCVarDopplerEnable->GetIVal() && (m_nFlags & FLAG_SOUND_DOPPLER))
818 {
819 Vec3d vVel=(pos-m_position);
820 float fTimeDelta=m_pSSys->m_pISystem->GetITimer()->GetFrameTime();
821
822 vVel=vVel*(m_pSSys->m_pCVarDopplerEnable->GetFVal()/fTimeDelta);
823
824 float fVel[3];
825 fVel[0]=vVel.x;
826 fVel[1]=vVel.z;
827 fVel[2]=vVel.y;
828
829 GUARD_HEAP;
830 CS_3D_SetAttributes(m_nChannel, fPos, fVel);
831 }
832 else
833 {
834 GUARD_HEAP;
835 //m_pSSys->m_pILog->LogToConsole("Setting sound pos for channel %d",m_nChannel);

Callers 8

ApplySoundKeyMethod · 0.45
SetSoundPositionMethod · 0.45
PlaySoundMethod · 0.45
UpdateSoundsMethod · 0.45
PlayDialogMethod · 0.45
UpdateLipSyncMethod · 0.45
SetPosMethod · 0.45
PlaySoundMethod · 0.45

Calls 7

GetIValMethod · 0.80
GetITimerMethod · 0.80
GetFValMethod · 0.80
GetI3DEngineMethod · 0.80
NormalizeMethod · 0.45
GetFrameTimeMethod · 0.45
GetVisAreaFromPosMethod · 0.45

Tested by

no test coverage detected