mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 16:41:02 +02:00
Limit collision injectors count to 3
This commit is contained in:
parent
854bf82631
commit
4e8b61dea0
2 changed files with 14 additions and 1 deletions
|
@ -337,7 +337,17 @@ void AvatarManager::handleCollisionEvents(const CollisionEvents& collisionEvents
|
||||||
// but most avatars are roughly the same size, so let's not be so fancy yet.
|
// but most avatars are roughly the same size, so let's not be so fancy yet.
|
||||||
const float AVATAR_STRETCH_FACTOR = 1.0f;
|
const float AVATAR_STRETCH_FACTOR = 1.0f;
|
||||||
|
|
||||||
AudioInjector::playSound(collisionSound, energyFactorOfFull, AVATAR_STRETCH_FACTOR, myAvatar->getPosition());
|
|
||||||
|
_collisionInjectors.remove_if([](QPointer<AudioInjector>& injector) {
|
||||||
|
return !injector || injector->isFinished();
|
||||||
|
});
|
||||||
|
|
||||||
|
static const int MAX_INJECTOR_COUNT = 3;
|
||||||
|
if (_collisionInjectors.size() < MAX_INJECTOR_COUNT) {
|
||||||
|
auto injector = AudioInjector::playSound(collisionSound, energyFactorOfFull, AVATAR_STRETCH_FACTOR,
|
||||||
|
myAvatar->getPosition());
|
||||||
|
_collisionInjectors.emplace_back(injector);
|
||||||
|
}
|
||||||
myAvatar->collisionWithEntity(collision);
|
myAvatar->collisionWithEntity(collision);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include "AvatarMotionState.h"
|
#include "AvatarMotionState.h"
|
||||||
|
|
||||||
class MyAvatar;
|
class MyAvatar;
|
||||||
|
class AudioInjector;
|
||||||
|
|
||||||
class AvatarManager : public AvatarHashMap {
|
class AvatarManager : public AvatarHashMap {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -94,6 +95,8 @@ private:
|
||||||
|
|
||||||
bool _shouldShowReceiveStats = false;
|
bool _shouldShowReceiveStats = false;
|
||||||
|
|
||||||
|
std::list<QPointer<AudioInjector>> _collisionInjectors;
|
||||||
|
|
||||||
SetOfAvatarMotionStates _motionStatesThatMightUpdate;
|
SetOfAvatarMotionStates _motionStatesThatMightUpdate;
|
||||||
SetOfMotionStates _motionStatesToAddToPhysics;
|
SetOfMotionStates _motionStatesToAddToPhysics;
|
||||||
VectorOfMotionStates _motionStatesToRemoveFromPhysics;
|
VectorOfMotionStates _motionStatesToRemoveFromPhysics;
|
||||||
|
|
Loading…
Reference in a new issue