mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 20:56:52 +02:00
slaps sound only on impact with velocity
This commit is contained in:
parent
d68a551940
commit
09e5b8ea4a
1 changed files with 11 additions and 3 deletions
|
@ -362,6 +362,7 @@ void Hand::updateCollisions() {
|
||||||
// Check for palm collisions
|
// Check for palm collisions
|
||||||
glm::vec3 myPalmPosition = palm.getPosition();
|
glm::vec3 myPalmPosition = palm.getPosition();
|
||||||
float palmCollisionDistance = 0.1f;
|
float palmCollisionDistance = 0.1f;
|
||||||
|
bool wasColliding = palm.getIsCollidingWithPalm();
|
||||||
palm.setIsCollidingWithPalm(false);
|
palm.setIsCollidingWithPalm(false);
|
||||||
// If 'Play Slaps' is enabled, look for palm-to-palm collisions and make sound
|
// If 'Play Slaps' is enabled, look for palm-to-palm collisions and make sound
|
||||||
for (int j = 0; j < otherAvatar->getHand().getNumPalms(); j++) {
|
for (int j = 0; j < otherAvatar->getHand().getNumPalms(); j++) {
|
||||||
|
@ -372,14 +373,21 @@ void Hand::updateCollisions() {
|
||||||
glm::vec3 otherPalmPosition = otherPalm.getPosition();
|
glm::vec3 otherPalmPosition = otherPalm.getPosition();
|
||||||
if (glm::length(otherPalmPosition - myPalmPosition) < palmCollisionDistance) {
|
if (glm::length(otherPalmPosition - myPalmPosition) < palmCollisionDistance) {
|
||||||
palm.setIsCollidingWithPalm(true);
|
palm.setIsCollidingWithPalm(true);
|
||||||
|
if (!wasColliding) {
|
||||||
const float PALM_COLLIDE_VOLUME = 1.f;
|
const float PALM_COLLIDE_VOLUME = 1.f;
|
||||||
const float PALM_COLLIDE_FREQUENCY = 150.f;
|
const float PALM_COLLIDE_FREQUENCY = 1000.f;
|
||||||
const float PALM_COLLIDE_DURATION_MAX = 2.f;
|
const float PALM_COLLIDE_DURATION_MAX = 0.75f;
|
||||||
const float PALM_COLLIDE_DECAY_PER_SAMPLE = 0.005f;
|
const float PALM_COLLIDE_DECAY_PER_SAMPLE = 0.01f;
|
||||||
Application::getInstance()->getAudio()->startDrumSound(PALM_COLLIDE_VOLUME,
|
Application::getInstance()->getAudio()->startDrumSound(PALM_COLLIDE_VOLUME,
|
||||||
PALM_COLLIDE_FREQUENCY,
|
PALM_COLLIDE_FREQUENCY,
|
||||||
PALM_COLLIDE_DURATION_MAX,
|
PALM_COLLIDE_DURATION_MAX,
|
||||||
PALM_COLLIDE_DECAY_PER_SAMPLE);
|
PALM_COLLIDE_DECAY_PER_SAMPLE);
|
||||||
|
// If the other person's palm is in motion, move mine downward to show I was hit
|
||||||
|
const float MIN_VELOCITY_FOR_SLAP = 0.05f;
|
||||||
|
if (glm::length(otherPalm.getVelocity()) > MIN_VELOCITY_FOR_SLAP) {
|
||||||
|
// add slapback here
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue