mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-04 00:44:12 +02:00
turn down collision sounds
This commit is contained in:
parent
ba2c98a3eb
commit
bc1ac6b455
4 changed files with 13 additions and 14 deletions
|
@ -196,7 +196,6 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
|
|||
_isTouchPressed(false),
|
||||
_yawFromTouch(0.0f),
|
||||
_pitchFromTouch(0.0f),
|
||||
_groundPlaneImpact(0.0f),
|
||||
_mousePressed(false),
|
||||
_isHoverVoxel(false),
|
||||
_isHoverVoxelSounding(false),
|
||||
|
@ -2789,8 +2788,12 @@ void Application::displayOverlay() {
|
|||
glDisable(GL_DEPTH_TEST);
|
||||
glDisable(GL_LIGHTING);
|
||||
|
||||
// Display a single screen-size quad to
|
||||
renderCollisionOverlay(_glWidget->width(), _glWidget->height(), _audio.getCollisionSoundMagnitude());
|
||||
// Display a single screen-size quad to create an alpha blended 'collision' flash
|
||||
float collisionSoundMagnitude = _audio.getCollisionSoundMagnitude();
|
||||
const float VISIBLE_COLLISION_SOUND_MAGNITUDE = 0.5f;
|
||||
if (collisionSoundMagnitude > VISIBLE_COLLISION_SOUND_MAGNITUDE) {
|
||||
renderCollisionOverlay(_glWidget->width(), _glWidget->height(), _audio.getCollisionSoundMagnitude());
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
_audio.render(_glWidget->width(), _glWidget->height());
|
||||
|
|
|
@ -109,8 +109,6 @@ public slots:
|
|||
|
||||
void sendAvatarFaceVideoMessage(int frameCount, const QByteArray& data);
|
||||
|
||||
void setGroundPlaneImpact(float groundPlaneImpact) { _groundPlaneImpact = groundPlaneImpact; }
|
||||
|
||||
|
||||
private slots:
|
||||
|
||||
|
@ -371,8 +369,6 @@ private:
|
|||
float _yawFromTouch;
|
||||
float _pitchFromTouch;
|
||||
|
||||
float _groundPlaneImpact;
|
||||
|
||||
VoxelDetail _mouseVoxelDragging;
|
||||
glm::vec3 _voxelThrust;
|
||||
bool _mousePressed; // true if mouse has been pressed (clear when finished)
|
||||
|
|
|
@ -339,6 +339,7 @@ void renderCollisionOverlay(int width, int height, float magnitude) {
|
|||
}
|
||||
|
||||
void renderGroundPlaneGrid(float size, float impact) {
|
||||
float IMPACT_SOUND_MAGNITUDE_FOR_RECOLOR = 0.3f;
|
||||
glLineWidth(2.0);
|
||||
glm::vec4 impactColor(1, 0, 0, 1);
|
||||
glm::vec3 lineColor(0.4, 0.5, 0.3);
|
||||
|
@ -355,7 +356,12 @@ void renderGroundPlaneGrid(float size, float impact) {
|
|||
}
|
||||
|
||||
// Draw the floor, colored for recent impact
|
||||
glm::vec4 floorColor = impact * impactColor + (1.f - impact) * surfaceColor;
|
||||
glm::vec4 floorColor;
|
||||
if (impact > IMPACT_SOUND_MAGNITUDE_FOR_RECOLOR) {
|
||||
floorColor = impact * impactColor + (1.f - impact) * surfaceColor;
|
||||
} else {
|
||||
floorColor = surfaceColor;
|
||||
}
|
||||
glColor4fv(&floorColor.x);
|
||||
glBegin(GL_QUADS);
|
||||
glVertex3f(0, 0, 0);
|
||||
|
|
|
@ -892,21 +892,15 @@ void Avatar::updateCollisionWithSphere(glm::vec3 position, float radius, float d
|
|||
}
|
||||
|
||||
void Avatar::updateCollisionWithEnvironment(float deltaTime) {
|
||||
|
||||
glm::vec3 up = getBodyUpDirection();
|
||||
float radius = _height * 0.125f;
|
||||
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 > VISIBLE_GROUND_COLLISION_VELOCITY) {
|
||||
Application::getInstance()->setGroundPlaneImpact(1.0f);
|
||||
}
|
||||
_lastCollisionPosition = _position;
|
||||
updateCollisionSound(penetration, deltaTime, ENVIRONMENT_COLLISION_FREQUENCY);
|
||||
applyHardCollision(penetration, ENVIRONMENT_SURFACE_ELASTICITY, ENVIRONMENT_SURFACE_DAMPING);
|
||||
|
|
Loading…
Reference in a new issue