mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 09:24:00 +02:00
fixes per review
This commit is contained in:
parent
2a207f4a30
commit
984332e638
2 changed files with 7 additions and 4 deletions
|
@ -620,13 +620,15 @@ void Audio::addProceduralSounds(int16_t* inputBuffer,
|
|||
const float COLLISION_SOUND_CUTOFF_LEVEL = 0.01f;
|
||||
const float COLLISION_SOUND_MAX_VOLUME = 1000.f;
|
||||
const float UP_MAJOR_FIFTH = powf(1.5f, 4.0f);
|
||||
const float DOWN_TWO_OCTAVES = 4.f;
|
||||
const float DOWN_FOUR_OCTAVES = 16.f;
|
||||
float t;
|
||||
if (_collisionSoundMagnitude > COLLISION_SOUND_CUTOFF_LEVEL) {
|
||||
for (int i = 0; i < numSamples; i++) {
|
||||
t = (float) _proceduralEffectSample + (float) i;
|
||||
sample = sinf(t * _collisionSoundFrequency) +
|
||||
sinf(t * _collisionSoundFrequency / 4.f) +
|
||||
sinf(t * _collisionSoundFrequency / 16.f * UP_MAJOR_FIFTH);
|
||||
sinf(t * _collisionSoundFrequency / DOWN_TWO_OCTAVES) +
|
||||
sinf(t * _collisionSoundFrequency / DOWN_FOUR_OCTAVES * UP_MAJOR_FIFTH);
|
||||
sample *= _collisionSoundMagnitude * COLLISION_SOUND_MAX_VOLUME;
|
||||
inputBuffer[i] += sample;
|
||||
outputLeft[i] += sample;
|
||||
|
@ -638,7 +640,7 @@ void Audio::addProceduralSounds(int16_t* inputBuffer,
|
|||
}
|
||||
|
||||
//
|
||||
// Starts a collision sound. magnitude is 0-1, with 1 the loudest possible sound.
|
||||
// Starts a collision sound. magnitude is 0-1, with 1 the loudest possible sound.
|
||||
//
|
||||
void Audio::startCollisionSound(float magnitude, float frequency, float noise, float duration) {
|
||||
_collisionSoundMagnitude = magnitude;
|
||||
|
|
|
@ -881,12 +881,13 @@ void Avatar::updateCollisionWithEnvironment(float deltaTime) {
|
|||
const float ENVIRONMENT_SURFACE_ELASTICITY = 1.0f;
|
||||
const float ENVIRONMENT_SURFACE_DAMPING = 0.01;
|
||||
const float ENVIRONMENT_COLLISION_FREQUENCY = 0.05f;
|
||||
const float VISIBLE_GROUND_COLLISION_VELOCITY = 0.2f;
|
||||
glm::vec3 penetration;
|
||||
if (Application::getInstance()->getEnvironment()->findCapsulePenetration(
|
||||
_position - up * (_pelvisFloatingHeight - radius),
|
||||
_position + up * (_height - _pelvisFloatingHeight - radius), radius, penetration)) {
|
||||
float velocityTowardCollision = glm::dot(_velocity, glm::normalize(penetration));
|
||||
if (velocityTowardCollision > 0.2) {
|
||||
if (velocityTowardCollision > VISIBLE_GROUND_COLLISION_VELOCITY) {
|
||||
Application::getInstance()->setGroundPlaneImpact(1.0f);
|
||||
}
|
||||
updateCollisionSound(penetration, deltaTime, ENVIRONMENT_COLLISION_FREQUENCY);
|
||||
|
|
Loading…
Reference in a new issue