Merge pull request #267 from ShFil119/audio12

cAudioManager::UpdateReflections
This commit is contained in:
erorcun 2019-11-05 15:06:07 +03:00 committed by GitHub
commit e30fc9322a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 89 additions and 18 deletions

View File

@ -9289,11 +9289,75 @@ cAudioManager::UpdateGasPedalAudio(CAutomobile *automobile)
automobile->m_fGasPedalAudio = newGasPedalAudio;
}
WRAPPER
void
cAudioManager::UpdateReflections()
{
EAXJMP(0x57B470);
const CVector &camPos = TheCamera.GetPosition();
CColPoint colpoint;
CEntity *ent;
if(m_nTimeOfRecentCrime & 7) {
if(((uint8)m_nTimeOfRecentCrime + 1) & 7) {
if(((uint8)m_nTimeOfRecentCrime + 2) & 7) {
if(((uint8)m_nTimeOfRecentCrime + 3) & 7) {
if(!(((uint8)m_nTimeOfRecentCrime + 4) & 7)) {
m_avecReflectionsPos[4] = camPos;
m_avecReflectionsPos[4].z += 50.f;
if(CWorld::ProcessVerticalLine(
camPos, m_avecReflectionsPos[4].z, colpoint,
ent, true, false, false, false, true, false,
false)) {
m_afReflectionsDistances[4] =
colpoint.point.z - camPos.z;
} else {
m_afReflectionsDistances[4] = 50.0f;
}
}
} else {
m_avecReflectionsPos[3] = camPos;
m_avecReflectionsPos[3].x += 50.f;
if(CWorld::ProcessLineOfSight(
camPos, m_avecReflectionsPos[3], colpoint, ent, true,
false, false, true, false, true, true)) {
m_afReflectionsDistances[3] =
Distance(camPos, colpoint.point);
} else {
m_afReflectionsDistances[3] = 50.0f;
}
}
} else {
m_avecReflectionsPos[2] = camPos;
m_avecReflectionsPos[2].x -= 50.f;
if(CWorld::ProcessLineOfSight(camPos, m_avecReflectionsPos[2],
colpoint, ent, true, false, false,
true, false, true, true)) {
m_afReflectionsDistances[2] =
Distance(camPos, colpoint.point);
} else {
m_afReflectionsDistances[2] = 50.0f;
}
}
} else {
m_avecReflectionsPos[1] = camPos;
m_avecReflectionsPos[1].y -= 50.f;
if(CWorld::ProcessLineOfSight(camPos, m_avecReflectionsPos[1], colpoint,
ent, true, false, false, true, false, true,
true)) {
m_afReflectionsDistances[1] = Distance(camPos, colpoint.point);
} else {
m_afReflectionsDistances[1] = 50.0f;
}
}
} else {
m_avecReflectionsPos[0] = camPos;
m_avecReflectionsPos[0].y += 50.f;
if(CWorld::ProcessLineOfSight(camPos, m_avecReflectionsPos[0], colpoint, ent, true,
false, false, true, false, true, true)) {
m_afReflectionsDistances[0] = Distance(camPos, colpoint.point);
} else {
m_afReflectionsDistances[0] = 50.0f;
}
}
}
bool
@ -9570,6 +9634,7 @@ InjectHook(0x57FCC0, &cAudioManager::SetupSuspectLastSeenReport, PATCH_JUMP);
InjectHook(0x57A150, &cAudioManager::Terminate, PATCH_JUMP);
InjectHook(0x57AC60, &cAudioManager::TranslateEntity, PATCH_JUMP);
InjectHook(0x56AC80, &cAudioManager::UpdateGasPedalAudio, PATCH_JUMP);
InjectHook(0x57B470, &cAudioManager::UpdateReflections, PATCH_JUMP);
InjectHook(0x56C600, &cAudioManager::UsesReverseWarning, PATCH_JUMP);
InjectHook(0x56C3C0, &cAudioManager::UsesSiren, PATCH_JUMP);
InjectHook(0x56C3F0, &cAudioManager::UsesSirenSwitching, PATCH_JUMP);

View File

@ -689,7 +689,7 @@ public:
void TranslateEntity(CVector *v1, CVector *v2) const;
void UpdateGasPedalAudio(CAutomobile *automobile);
void UpdateReflections(); // todo
void UpdateReflections();
bool UsesReverseWarning(int32 model) const;
bool UsesSiren(int32 model) const;
bool UsesSirenSwitching(int32 model) const;

View File

@ -78,21 +78,6 @@ public:
bool IsZero(void) { return x == 0.0f && y == 0.0f && z == 0.0f; }
};
inline float
DotProduct(const CVector &v1, const CVector &v2)
{
return v1.x*v2.x + v1.y*v2.y + v1.z*v2.z;
}
inline CVector
CrossProduct(const CVector &v1, const CVector &v2)
{
return CVector(
v1.y*v2.z - v1.z*v2.y,
v1.z*v2.x - v1.x*v2.z,
v1.x*v2.y - v1.y*v2.x);
}
inline CVector operator+(const CVector &left, const CVector &right)
{
return CVector(left.x + right.x, left.y + right.y, left.z + right.z);
@ -117,3 +102,24 @@ inline CVector operator/(const CVector &left, float right)
{
return CVector(left.x / right, left.y / right, left.z / right);
}
inline float
DotProduct(const CVector &v1, const CVector &v2)
{
return v1.x*v2.x + v1.y*v2.y + v1.z*v2.z;
}
inline CVector
CrossProduct(const CVector &v1, const CVector &v2)
{
return CVector(
v1.y*v2.z - v1.z*v2.y,
v1.z*v2.x - v1.x*v2.z,
v1.x*v2.y - v1.y*v2.x);
}
inline float
Distance(const CVector &v1, const CVector &v2)
{
return (v2 - v1).Magnitude();
}